public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* UBIFS failure on SheevaPlug Basic
@ 2012-11-09  9:35 Dimax
  2012-11-09 11:20 ` Andreas Bießmann
  0 siblings, 1 reply; 5+ messages in thread
From: Dimax @ 2012-11-09  9:35 UTC (permalink / raw)
  To: linux-mtd@lists.infradead.org

1. Problem Description
---------------------------------
1.1 Setup
I have a SheevaPlug running Debian. System is installed on nand Flash.
Installation process is following:
- First I boot up with USB stick and Debian installer images on it
- Get Debian Installed and running on USB stick
- Run the commands below to get it moved to Flash:

ubiformat /dev/mtd2 -s 512
ubiattach /dev/ubi_ctrl -m 2
ubimkvol /dev/ubi0 -N rootfs -m

mount -t ubifs ubi0:rootfs /mnt
mkdir /tmp/rootfs
mount -o bind / /tmp/rootfs/

cp -a /tmp/rootfs/* /mnt/
cp -a /boot /mnt/

- Make required changes in u-boot configuration and system starts to work.

1.2 Failure
Everything is all right until I get power surge
After that system fails with:

Marvell>> boot

UBI: mtd1 is detached from ubi0
Creating 1 MTD partitions on "nand0":
0x000000500000-0x000020000000 : "mtd=2"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=2"
UBI: MTD device size:            507 MiB
UBI: number of good PEBs:        4055
UBI: number of bad PEBs:         1
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     1
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 4055
UBI: number of PEBs reserved for bad PEB handling: 40
UBI: max/mean erase counter: 1/0
UBIFS: recovery needed
Error reading superblock on volume 'ubi:rootfs'!
UBIFS not mounted, use ubifs mount to mount volume first!
UBIFS not mounted, use ubifs mount to mount volume first!
Wrong Image Format for bootm command
ERROR: can't get kernel image!

1.3 Recovery
If I run again from the USB stick and mount Flash partition Debian
kernel manage to recover it:

root@debian:~# mount -t ubifs ubi0:rootfs /mnt
[  306.205029] UBIFS: recovery needed
[  309.341987] UBIFS: recovery completed
[  309.345705] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  309.351738] UBIFS: file system size:   515192832 bytes (503118 KiB,
491 MiB, 3993 LEBs)
[  309.359789] UBIFS: journal size:       25804800 bytes (25200 KiB,
24 MiB, 200 LEBs)
[  309.367495] UBIFS: media format:       w4/r0 (latest is w4/r0)
[  309.373352] UBIFS: default compressor: lzo
[  309.377479] UBIFS: reserved for root:  4952683 bytes (4836 KiB)

2. Fixing
======
2.1. My first direction is to update u-boot with latest patches. There
is a chance it will let u-boot be able to mount broken partition.
There is another thread here where I work on it "Latest SheevaPlug u-boot"

2.2.
My second plan is to separate rootfs partition into two partitions.
One would be read only and will keep all static data. The second
partition will be RW and will contain changing data.
Actually all I need is to
1. Arrange let's say /flash_rw partiotion
2. Make rootfs partition read only
3. Fix u-boot settings
And here I'm not sure how to do all this.

2.3. u-boot
I assume I should start with changing partitioning in u-boot:
Currently I have
mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)

How to split rootfs into two partitions?

============
Do you think such approach will help to survive power surges?
What should be next steps?

Thanks a lot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UBIFS failure on SheevaPlug Basic
  2012-11-09  9:35 UBIFS failure on SheevaPlug Basic Dimax
@ 2012-11-09 11:20 ` Andreas Bießmann
  2012-11-09 11:41   ` Dimax
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Bießmann @ 2012-11-09 11:20 UTC (permalink / raw)
  To: Dimax; +Cc: linux-mtd@lists.infradead.org

Dear Dimax,

On 09.11.2012 10:35, Dimax wrote:
> 1. Problem Description
> ---------------------------------

<snip>

> 1.2 Failure
> Everything is all right until I get power surge
> After that system fails with:
> 
> Marvell>> boot
> 
> UBI: mtd1 is detached from ubi0
> Creating 1 MTD partitions on "nand0":
> 0x000000500000-0x000020000000 : "mtd=2"
> UBI: attaching mtd1 to ubi0
> UBI: physical eraseblock size:   131072 bytes (128 KiB)
> UBI: logical eraseblock size:    129024 bytes
> UBI: smallest flash I/O unit:    2048
> UBI: sub-page size:              512
> UBI: VID header offset:          512 (aligned 512)
> UBI: data offset:                2048
> UBI: attached mtd1 to ubi0
> UBI: MTD device name:            "mtd=2"
> UBI: MTD device size:            507 MiB
> UBI: number of good PEBs:        4055
> UBI: number of bad PEBs:         1
> UBI: max. allowed volumes:       128
> UBI: wear-leveling threshold:    4096
> UBI: number of internal volumes: 1
> UBI: number of user volumes:     1
> UBI: available PEBs:             0
> UBI: total number of reserved PEBs: 4055
> UBI: number of PEBs reserved for bad PEB handling: 40
> UBI: max/mean erase counter: 1/0
> UBIFS: recovery needed
> Error reading superblock on volume 'ubi:rootfs'!
> UBIFS not mounted, use ubifs mount to mount volume first!
> UBIFS not mounted, use ubifs mount to mount volume first!
> Wrong Image Format for bootm command
> ERROR: can't get kernel image!
> 

we discussed that already:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/145526
And a possible solution exists here:
http://patchwork.ozlabs.org/patch/195174/

> 1.3 Recovery
> If I run again from the USB stick and mount Flash partition Debian
> kernel manage to recover it:
> 
> root@debian:~# mount -t ubifs ubi0:rootfs /mnt
> [  306.205029] UBIFS: recovery needed
> [  309.341987] UBIFS: recovery completed
> [  309.345705] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
> [  309.351738] UBIFS: file system size:   515192832 bytes (503118 KiB,
> 491 MiB, 3993 LEBs)
> [  309.359789] UBIFS: journal size:       25804800 bytes (25200 KiB,
> 24 MiB, 200 LEBs)
> [  309.367495] UBIFS: media format:       w4/r0 (latest is w4/r0)
> [  309.373352] UBIFS: default compressor: lzo
> [  309.377479] UBIFS: reserved for root:  4952683 bytes (4836 KiB)
> 
> 2. Fixing
> ======
> 2.1. My first direction is to update u-boot with latest patches. There
> is a chance it will let u-boot be able to mount broken partition.
> There is another thread here where I work on it "Latest SheevaPlug u-boot"
> 
> 2.2.
> My second plan is to separate rootfs partition into two partitions.
> One would be read only and will keep all static data. The second
> partition will be RW and will contain changing data.
> Actually all I need is to
> 1. Arrange let's say /flash_rw partiotion
> 2. Make rootfs partition read only

No, just use a /boot ro. All you need is kernel and initrd which should
be located in /boot. You can use a raw mtd for that too to avoid that
ubifs fails (as I understood is your fear).
Another alternative is to have two logical ubifs in a physical ubi
section. One of them is ro, the other rw mounted.

> 3. Fix u-boot settings
> And here I'm not sure how to do all this.

Just provide a correct cmdline so that the kernel knows about your
special nand organization. u-boot also want to know that to load the
kernel from appropriate position. Read about the mtdpart parameter in
u-boot, that should be sufficient for your needs.

> 2.3. u-boot
> I assume I should start with changing partitioning in u-boot:
> Currently I have
> mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
---------------------------------^----------------------------^

you will waste some space here! BTW did you think about your block size?

> How to split rootfs into two partitions?

You could handle it on a directory basis, just mount /boot from another fs.

Best regards

Andreas Bießmann

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UBIFS failure on SheevaPlug Basic
  2012-11-09 11:20 ` Andreas Bießmann
@ 2012-11-09 11:41   ` Dimax
  2012-11-09 12:32     ` Andreas Bießmann
  0 siblings, 1 reply; 5+ messages in thread
From: Dimax @ 2012-11-09 11:41 UTC (permalink / raw)
  To: Andreas Bießmann; +Cc: linux-mtd@lists.infradead.org

HI Andreas,
Thanks for your help. I'm not so advanced in Linux knowledge and will
ask for deeper explanations. Or more exactly I understand what you
mean but do not know how to do it.
Please see below

On Fri, Nov 9, 2012 at 1:20 PM, Andreas Bießmann
<biessmann@corscience.de> wrote:
> Dear Dimax,
>
> On 09.11.2012 10:35, Dimax wrote:
>> 1. Problem Description
>> ---------------------------------
>
> <snip>
>
>> Error reading superblock on volume 'ubi:rootfs'!
>> UBIFS not mounted, use ubifs mount to mount volume first!
>> UBIFS not mounted, use ubifs mount to mount volume first!
>> Wrong Image Format for bootm command
>> ERROR: can't get kernel image!
>>
>
> we discussed that already:
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/145526
> And a possible solution exists here:
> http://patchwork.ozlabs.org/patch/195174/
>

This is what I'm trying to do. I'm working now on building an u-boot
image with suggested patch.

>> 1.3 Recovery
>>
>> 2. Fixing
>> ======
>> 2. Make rootfs partition read only
>
> No, just use a /boot ro. All you need is kernel and initrd which should
> be located in /boot. You can use a raw mtd for that too to avoid that
> ubifs fails (as I understood is your fear).

Please explain how to get initrd in /boot ?
And what is a row mtd ?

> Another alternative is to have two logical ubifs in a physical ubi
> section. One of them is ro, the other rw mounted.
>
How can I arrange it?

>> 3. Fix u-boot settings
>> And here I'm not sure how to do all this.
>
> Just provide a correct cmdline so that the kernel knows about your
> special nand organization. u-boot also want to know that to load the
> kernel from appropriate position. Read about the mtdpart parameter in
> u-boot, that should be sufficient for your needs.
>
OK
Will do it

>> 2.3. u-boot
>> I assume I should start with changing partitioning in u-boot:
>> Currently I have
>> mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
> ---------------------------------^----------------------------^
>
> you will waste some space here! BTW did you think about your block size?
>
Where exactly?
I actually do not understand why should I have uImage partition as
uImage is located now under /boot in rootfs partition as far as I
understand. But this is what I took from other discussion thread.

>> How to split rootfs into two partitions?
>
> You could handle it on a directory basis, just mount /boot from another fs.
>

How can I do it?

> Best regards
>
> Andreas Bießmann

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UBIFS failure on SheevaPlug Basic
  2012-11-09 11:41   ` Dimax
@ 2012-11-09 12:32     ` Andreas Bießmann
  2012-11-12  5:33       ` Dimax
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Bießmann @ 2012-11-09 12:32 UTC (permalink / raw)
  To: Dimax; +Cc: linux-mtd@lists.infradead.org

Dear Dimax,

On 09.11.2012 12:41, Dimax wrote:
> HI Andreas,
> Thanks for your help. I'm not so advanced in Linux knowledge and will
> ask for deeper explanations. 

all of us started some time ...

> Or more exactly I understand what you
> mean but do not know how to do it.
> Please see below
> 
> On Fri, Nov 9, 2012 at 1:20 PM, Andreas Bießmann
> <biessmann@corscience.de> wrote:
>> Dear Dimax,
>>
>> On 09.11.2012 10:35, Dimax wrote:
>>> 1. Problem Description
>>> ---------------------------------
>>
>> <snip>
>>
>>> Error reading superblock on volume 'ubi:rootfs'!
>>> UBIFS not mounted, use ubifs mount to mount volume first!
>>> UBIFS not mounted, use ubifs mount to mount volume first!
>>> Wrong Image Format for bootm command
>>> ERROR: can't get kernel image!
>>>
>>
>> we discussed that already:
>> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/145526
>> And a possible solution exists here:
>> http://patchwork.ozlabs.org/patch/195174/
>>
> 
> This is what I'm trying to do. I'm working now on building an u-boot
> image with suggested patch.

Ok

>>> 1.3 Recovery
>>>
>>> 2. Fixing
>>> ======
>>> 2. Make rootfs partition read only
>>
>> No, just use a /boot ro. All you need is kernel and initrd which should
>> be located in /boot. You can use a raw mtd for that too to avoid that
>> ubifs fails (as I understood is your fear).
> 
> Please explain how to get initrd in /boot ?

cp <initrd provided by debian distro> /boot
BTW: debian will install the initrd into /boot

> And what is a row mtd ?

I mean a RAW mtd section. You can access the mtd with tools from
mtd-utils to write raw data on it (without an file system). These data
can you get out of the mtd from u-boot, again without interaction with
an fs.

>> Another alternative is to have two logical ubifs in a physical ubi
>> section. One of them is ro, the other rw mounted.
>>
> How can I arrange it?

You can leave your mtdparts setting in u-boot as is and just create two
different ubifs filesystems in it. Lets call the first one <boot> and
the second one <fs>. So you will end up with these commands (not
checked, please read man page before using them):

% ubiformat -y -q /dev/mtd1
% ubiattach -p /dev/mtd1
% ubimkvol /dev/ubi0 -N boot -s 10MiB
% ubimkvol /dev/ubi0 -N fs -m
% mount -t ubifs ubi0:fs /target
% mkdir /target/boot
% mount -t ubifs ubi0:boot /target/boot
% debootstrap ...

Then configure your /etc/fstab and ensure the /boot is mounted ro
always. Just mount rw for an kernel update and then remount ro right
after the update.

>>> 3. Fix u-boot settings
>>> And here I'm not sure how to do all this.
>>
>> Just provide a correct cmdline so that the kernel knows about your
>> special nand organization. u-boot also want to know that to load the
>> kernel from appropriate position. Read about the mtdpart parameter in
>> u-boot, that should be sufficient for your needs.
>>
> OK
> Will do it
> 
>>> 2.3. u-boot
>>> I assume I should start with changing partitioning in u-boot:
>>> Currently I have
>>> mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
>> ---------------------------------^----------------------------^
>>
>> you will waste some space here! BTW did you think about your block size?
>>
> Where exactly?

Well, there is a gap of 0x60000 between u-boot and uImage section.

> I actually do not understand why should I have uImage partition as
> uImage is located now under /boot in rootfs partition as far as I
> understand. But this is what I took from other discussion thread.

Well, as mentioned above you can have a RAW mtd which could hold for
example the uImage.

>>> How to split rootfs into two partitions?
>>
>> You could handle it on a directory basis, just mount /boot from another fs.
>>
> 
> How can I do it?

Just mount /boot as another fs, as described above.

Best regards

Andreas Bießmann

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UBIFS failure on SheevaPlug Basic
  2012-11-09 12:32     ` Andreas Bießmann
@ 2012-11-12  5:33       ` Dimax
  0 siblings, 0 replies; 5+ messages in thread
From: Dimax @ 2012-11-12  5:33 UTC (permalink / raw)
  To: Andreas Bießmann; +Cc: linux-mtd@lists.infradead.org

HI,
I have managed to build latest image and apply MALLOC patch.
After that system is fully working:

UBIFS: recovery needed
UBIFS: recovery deferred
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: mounted read-only
UBIFS: file system size:   515708928 bytes (503622 KiB, 491 MiB, 3997 LEBs)
UBIFS: journal size:       25804800 bytes (25200 KiB, 24 MiB, 200 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: LZO
UBIFS: reserved for root:  5182151 bytes (5060 KiB)
Loading file '/boot/uInitrd' to addr 0x01100000 with size 5472032
(0x00537f20)...
Done
Loading file '/boot/uImage' to addr 0x00800000 with size 1435120 (0x0015e5f0)...
Done
## Booting kernel from Legacy Image at 00800000 ...
....

If someone need u-boot image I can provide it

On Fri, Nov 9, 2012 at 2:32 PM, Andreas Bießmann
<biessmann@corscience.de> wrote:
> Dear Dimax,
>
> On 09.11.2012 12:41, Dimax wrote:
>> HI Andreas,
>> Thanks for your help. I'm not so advanced in Linux knowledge and will
>> ask for deeper explanations.
>
> all of us started some time ...
>
>> Or more exactly I understand what you
>> mean but do not know how to do it.
>> Please see below
>>
>> On Fri, Nov 9, 2012 at 1:20 PM, Andreas Bießmann
>> <biessmann@corscience.de> wrote:
>>> Dear Dimax,
>>>
>>> On 09.11.2012 10:35, Dimax wrote:
>>>> 1. Problem Description
>>>> ---------------------------------
>>>
>>> <snip>
>>>
>>>> Error reading superblock on volume 'ubi:rootfs'!
>>>> UBIFS not mounted, use ubifs mount to mount volume first!
>>>> UBIFS not mounted, use ubifs mount to mount volume first!
>>>> Wrong Image Format for bootm command
>>>> ERROR: can't get kernel image!
>>>>
>>>
>>> we discussed that already:
>>> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/145526
>>> And a possible solution exists here:
>>> http://patchwork.ozlabs.org/patch/195174/
>>>
>>
>> This is what I'm trying to do. I'm working now on building an u-boot
>> image with suggested patch.
>
> Ok
>
>>>> 1.3 Recovery
>>>>
>>>> 2. Fixing
>>>> ======
>>>> 2. Make rootfs partition read only
>>>
>>> No, just use a /boot ro. All you need is kernel and initrd which should
>>> be located in /boot. You can use a raw mtd for that too to avoid that
>>> ubifs fails (as I understood is your fear).
>>
>> Please explain how to get initrd in /boot ?
>
> cp <initrd provided by debian distro> /boot
> BTW: debian will install the initrd into /boot
>
>> And what is a row mtd ?
>
> I mean a RAW mtd section. You can access the mtd with tools from
> mtd-utils to write raw data on it (without an file system). These data
> can you get out of the mtd from u-boot, again without interaction with
> an fs.
>
>>> Another alternative is to have two logical ubifs in a physical ubi
>>> section. One of them is ro, the other rw mounted.
>>>
>> How can I arrange it?
>
> You can leave your mtdparts setting in u-boot as is and just create two
> different ubifs filesystems in it. Lets call the first one <boot> and
> the second one <fs>. So you will end up with these commands (not
> checked, please read man page before using them):
>
> % ubiformat -y -q /dev/mtd1
> % ubiattach -p /dev/mtd1
> % ubimkvol /dev/ubi0 -N boot -s 10MiB
> % ubimkvol /dev/ubi0 -N fs -m
> % mount -t ubifs ubi0:fs /target
> % mkdir /target/boot
> % mount -t ubifs ubi0:boot /target/boot
> % debootstrap ...
>
> Then configure your /etc/fstab and ensure the /boot is mounted ro
> always. Just mount rw for an kernel update and then remount ro right
> after the update.
>
>>>> 3. Fix u-boot settings
>>>> And here I'm not sure how to do all this.
>>>
>>> Just provide a correct cmdline so that the kernel knows about your
>>> special nand organization. u-boot also want to know that to load the
>>> kernel from appropriate position. Read about the mtdpart parameter in
>>> u-boot, that should be sufficient for your needs.
>>>
>> OK
>> Will do it
>>
>>>> 2.3. u-boot
>>>> I assume I should start with changing partitioning in u-boot:
>>>> Currently I have
>>>> mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
>>> ---------------------------------^----------------------------^
>>>
>>> you will waste some space here! BTW did you think about your block size?
>>>
>> Where exactly?
>
> Well, there is a gap of 0x60000 between u-boot and uImage section.
>
>> I actually do not understand why should I have uImage partition as
>> uImage is located now under /boot in rootfs partition as far as I
>> understand. But this is what I took from other discussion thread.
>
> Well, as mentioned above you can have a RAW mtd which could hold for
> example the uImage.
>
>>>> How to split rootfs into two partitions?
>>>
>>> You could handle it on a directory basis, just mount /boot from another fs.
>>>
>>
>> How can I do it?
>
> Just mount /boot as another fs, as described above.
>
> Best regards
>
> Andreas Bießmann

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-12  5:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-09  9:35 UBIFS failure on SheevaPlug Basic Dimax
2012-11-09 11:20 ` Andreas Bießmann
2012-11-09 11:41   ` Dimax
2012-11-09 12:32     ` Andreas Bießmann
2012-11-12  5:33       ` Dimax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox