Project

General

Profile

Linux Boot Parameter and NAND Partition

Added by Okan Çalış over 6 years ago

Hi,

I have a general question about Linux on MityDsp, which might help me solve the problem I consulted you about before.

On my MityDsp, the NAND flash is partitioned as follows:

device nand0 <nand>, # parts = 3
#: name size offset mask_flags
0: userfs 0x00e00000 0x00000000 0
1: rootfs 0x08000000 0x00e00000 0
2: unused 0x17200000 0x08e00000 0

I flashed a JFFS2 onto the rootfs partition and it has been working properly ever since. What confuses me is the boot parameters:

bootargs=mem=96M console=ttyS1,115200n8 mtdparts=nand:14M(userfs),128M(rootfs),-(unused) root=/dev/mtdblock0 rw noatime rootfstype=jffs2 ip=none

Given root=/dev/mtdblock0, how does the kernel know the root file system is on the rootfs partition? Shouldn't it look for the file system in the userfs partition and throw an error? Oddly, when I set the parameter as root=/dev/mtdblock1, it does throw an error and fails to boot.

I thought the mtdblockX parameter was about the flash partition on which the root file system is installed; is that wrong? I've read the kernel documentation as well as init/do_mounts.c, but couldn't find that detail.

Thanks in advance,
Okan


Replies (7)

RE: Linux Boot Parameter and NAND Partition - Added by Jonathan Cormier over 6 years ago

Okan Çalış wrote:

Hi,

I have a general question about Linux on MityDsp, which might help me solve the problem I consulted you about before.

On my MityDsp, the NAND flash is partitioned as follows:

Where did you print out this partition table?

device nand0 <nand>, # parts = 3
#: name size offset mask_flags
0: userfs 0x00e00000 0x00000000 0
1: rootfs 0x08000000 0x00e00000 0
2: unused 0x17200000 0x08e00000 0

I flashed a JFFS2 onto the rootfs partition and it has been working properly ever since. What confuses me is the boot parameters:

[...]

Given root=/dev/mtdblock0, how does the kernel know the root file system is on the rootfs partition? Shouldn't it look for the file system in the userfs partition and throw an error? Oddly, when I set the parameter as root=/dev/mtdblock1, it does throw an error and fails to boot.

Yes I agree with you. Given that parition table, I would expect you to have to use mtdblock1.

Can you run cat /proc/mtd in linux and post the results. I suspect your partition table isn't set to what you think.

root@mityomapl138:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 08000000 00020000 "rootfs" 
mtd1: 08000000 00020000 "homefs" 
mtd2: 00010000 00010000 "ubl" 
mtd3: 00080000 00010000 "u-boot" 
mtd4: 00010000 00010000 "u-boot-env" 
mtd5: 00010000 00010000 "periph-config" 
mtd6: 00050000 00010000 "reserved" 
mtd7: 00300000 00010000 "kernel" 
mtd8: 00200000 00010000 "fpga" 
mtd9: 00200000 00010000 "spare" 

RE: Linux Boot Parameter and NAND Partition - Added by Okan Çalış over 6 years ago

Where did you print out this partition table?

From the mtdparts command of the U-Boot. It is also consistent with environment variable of the same name.

Can you run cat /proc/mtd in linux and post the results.

As you suspected, the MTD partitions listed by Linux don't match those in U-Boot, even though I pass them as kernel boot parameters.

bootargs=mem=96M console=ttyS1,115200n8 mtdparts=nand:14M(userfs),128M(rootfs),-(unused) root=/dev/mtdblock0 rw noatime rootfstype=jffs2 ip=none
root@mityomapl138:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 08000000 00020000 "rootfs" 
mtd1: 18000000 00020000 "homefs" 
mtd2: 00010000 00010000 "ubl" 
mtd3: 00080000 00010000 "u-boot" 
mtd4: 00010000 00010000 "u-boot-env" 
mtd5: 00010000 00010000 "periph-config" 
mtd6: 00050000 00010000 "reserved" 
mtd7: 00300000 00010000 "kernel" 
mtd8: 00200000 00010000 "fpga" 
mtd9: 00200000 00010000 "spare"

The kernel I'm booting is the one provided in the MDK. In the kernel config, I can see MTD_CMDLINE_PARTS (Command line partition table parsing) is enabled, so I don't get why Linux lists the partitions that way.

RE: Linux Boot Parameter and NAND Partition - Added by Jonathan Cormier over 6 years ago

You can manually update the nand partition tables by changing the file arch/arm/mach-davinci/board-mityomapl138.c and look for mityomapl138_nandflash_partition.

RE: Linux Boot Parameter and NAND Partition - Added by Okan Çalış over 6 years ago

I know I can do that. (You suggested doing so when we realized, the kernel on the custom board listed the MTD partitions differently than configured in U-Boot. It's the same problem, but still, MityDsp can boot to Linux, while the custom board can't.)

This still doesn't explain how Linux on MityDsp can mount the file system in MTD partition 1, although the boot parameter tells it to mount mtdblock0.

Also, once I start using a JFFS2, everything I scp from my host PC is stored in the file system, and not in another flash partition, right?

RE: Linux Boot Parameter and NAND Partition - Added by Okan Çalış over 6 years ago

Also, when I issue a "cat /proc/mtd" with NFS, it prints only the SPI partitions starting from mtd0; it doesn't print rootfs and homefs.

RE: Linux Boot Parameter and NAND Partition - Added by Jonathan Cormier over 6 years ago

Okan Çalış wrote:

I know I can do that. (You suggested doing so when we realized, the kernel on the custom board listed the MTD partitions differently than configured in U-Boot. It's the same problem, but still, MityDsp can boot to Linux, while the custom board can't.)

Your custom board and kernel have an ECC misconfiguration.

This still doesn't explain how Linux on MityDsp can mount the file system in MTD partition 1, although the boot parameter tells it to mount mtdblock0.

I'm not following you.

Also, once I start using a JFFS2, everything I scp from my host PC is stored in the file system, and not in another flash partition, right?

Correct.

Also, when I issue a "cat /proc/mtd" with NFS, it prints only the SPI partitions starting from mtd0; it doesn't print rootfs and homefs.

I would guess this would mean that you are booting a different kernel in this case.

RE: Linux Boot Parameter and NAND Partition - Added by Okan Çalış over 6 years ago

Hi,

I solved this problem by writing the JFFS2 image to the NAND partition via the MTD Utilities in Linux, instead of U-Boot. Now, I can boot up Linux properly with the file system.

Thanks for your help.

    (1-7/7)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)