SDK 2.0 inittab entries not found booting from /dev/mmcblk0p2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDK 2.0 inittab entries not found booting from /dev/mmcblk0p2

Jump to solution
6,247 Views
pro-supportengi
NXP Employee
NXP Employee

Experiencing failure to read inittab file on kernel boot rootfs from /dev/mmcblk0p2

When using the following bootargs, inittab tab entries are not found.  Reproducible on two different boards. Was able to boot rootfs successfully from /dev/mmcblk0p2 on SDK 0.5.

Bootargs to reproduce the failure:

This boots successfully:

setenv bootargs "console=ttyS0,115200 root=/dev/ram0 rw rootdelay=5
earlycon=uart8250,0x21c0500,115200"

This fails to boot:
setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootdelay=5 earlycon=uart8250,0x21c0500,115200"

Get the following output on the serial console on failure. The content of both filesystems are identical.

[    2.372835] fsl_generic:
FSL DPAA Generic Ethernet driver

[    2.373027] hctosys: unable to open rtc device (rtc0)
[    2.373139] fdt: not creating '/sys/firmware/fdt': CRC
check failed

[   2.403534] usb usb6-port1: over-current condition
[    2.408271] Waiting 5 sec before mounting root device...
[    2.426819] mmc0: new high speed SDXC card at address
aaaa

[    2.432439] mmcblk0: mmc0:aaaa SL64G 59.4 GiB
[    2.443559]  mmcblk0: p1 p2 p3 p4 < p5 p6 >
[    7.420969] RAMDISK: gzip image found at block 0
[    8.663559] VFS: Mounted root (ext2 filesystem) on device
1:0.

Bad inittab entry at line 5
can't open /dev/si: No such file or directory
can't open /dev/~~: No such file or directory
can't open /dev/l0: No such file or directory
can't open /dev/l1: No such file or directory
can't open /dev/l2: No such file or directory
can't open /dev/l3: No such file or directory
can't open /dev/l4: No such file or directory
can't open /dev/l5: No such file or directory
can't open /dev/l6: No such file or directory
can't open /dev/z6: No such file or directory
can't open /dev/S0: No such file or directory
can't open /dev/AMA0: No such file or directory
can't open /dev/z6: No such file or directory
can't open /dev/S0: No such file or directory
can't open /dev/AMA0: No such file or directory
can't open /dev/z6: No such file or directory
can't open /dev/S0: No such file or directory
can't open /dev/AMA0: No such file or directory
can't open /dev/z6: No such file or directory
can't open /dev/S0: No such file or directory
can't open /dev/AMA0: No such file or directory


Procedure to boot from SD:

$ cd ~/QorIQ-SDK-V2.0-20160527-yocto

$ ./install

$ ./sources/meta-freescale/scripts/host-prepare.sh

$ . ./fsl-setup-env -m ls1043ardb

$ bitbake fsl-image-core

$ bitbake fsl-image-kernelitb

$ sudo fdisk /dev/mmcblk0

Create a Fat32 partition ornpartition 1 and the default ext2 for partition 2.  Place kernel.itb on partition 1 and the rootfs on partition 2. Sectors are all aligned and work SD boot works fine on v0.5 SDK. For 64GB SD partition 1 start block 8192 and end block 1056863. Partition 2 1056864 and end block 124735487 (end of disk).

$ sudo dd if=/tmp/deploy/images/ls1043ardb/u-boot-sdcard.bin of=/dev/mmcblk0 seek=8 bs=512

$ sudo dd if=tmp/deploy/images/ls1043ardb/fsl_fman_ucode_t2080_r1.1_106_4_18.bin of=/dev/mmcblk0 seek=2080 bs=512

$ sudo mkfs.vfat /dev/mmcblk0p1

$ sudo mkfs.ext2 /dev/mmcblk0p2

mount mmcblk0p1 and copy the kernel.itb

$ sudo cp -L tmp/deploy/ls1043ardb/kernel-fsl-ls1043a-rdb.itb /mnt/mmcblk0p1/kernel.itb

mount mmcblk0p2 and copy the rootfs

$ sudo tar xvf tmp/deploy/images/ls1043ardb/fsl-image-core-ls1043ardb.tar.gz -C /mnt/mmcblk0p2


Then boot on LS 1043ARDB target.  Uboot boots successfully, but kernel boot fails.

Labels (1)
0 Kudos
1 Solution
3,009 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello pro-supportengineer,

I suggest you use uImage+dts to boot up the system.

In SDK 2.0, uImage is not  generated by default, please use the following method to generate uImage. After run "bitbake virtual/kernel", you will get "Image" in QorIQ-SDK-V2.0-20160527-yocto/build_ls1043ardb/tmp/deploy/images/ls1043ardb folder, please copy it out to make uImage.

$ export PATH=/home/b25805/test/QorIQ-SDK-V2.0-20160527-yocto/build_ls1043ardb/tmp/sysroots/x86_64-linux/usr/bin/:$PATH

$ gzip Image

$ mkimage -A arm64 -O linux -T kernel -C gzip  -a 0x80080000 -e 0x80080000 -n linux-4.1 -d  Image.gz uImage

On the target board(I put rootfs in the first partition of SD card.)

=> tftp 0xa0000000 b25805/ls1043rdb/uImage

=> tftp 0x90000000 b25805/ls1043rdb/Image-fsl-ls1043a-rdb.dtb

=> setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p1 rw rootdelay=5 earlycon=uart8250,0x21c0500,115200"

=> bootm 0xa0000000 - 0x90000000

Please refer to the attached log.


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
9 Replies
3,009 Views
pro-supportengi
NXP Employee
NXP Employee

The SD boot was booting from rootfs packaged in the kernel.itb file loaded into NOR instead of the rootfs on the SD card.  So, the kernel when it loaded was unable to find the correct rootfs on the SD card and was unable to read the inittab file.  Solution to this was to make sure that we removed the ramdisk from the kernel.its file as mentioned above, which we needed to do regardless since we don’t want the rootfs in the kernel.itb when booting from NOR because the current NOR/IF read performance is too slow when copying the rootfs from NOR to DDR ramdisk.

To boot with the core rootfs in NOR and still booting from SD, one can do the following:

For SDK0.5:

=> setenv bootcmd “ext2load mmc 0 a0000000 kernel.itb”

=> setenv bootargs "root=/dev/mmcblk0p2 rw earlycon=uart8250,0x21c0500,115200 console=ttyS0,115200"

=> bootm a0000000

For SDK2.0:

=> ext2load mmc 0:2 a0000000 kernel.itb

=> setenv bootargs “root=/dev/mmcblk0p2 rw earlycon=uart8250,0x21c0500 console=ttyS0,115200”

=> bootm a0000000:kernel@1 - a0000000:fdt@1

Both cases are loading kernel.itb into ram,  SDK0.5 can locate kernel and fdt in ram automatically, but SDK2.0 locates kernel and fdt in ram according to address settings.

3,009 Views
cswarth
Contributor III

Thanks for this - For anyone else who would like an explanation of what is going on here, 

the answer can be found if you type "help bootm" at the uboot console.

=> bootm a0000000:kernel@1 - a0000000:fdt@1

doesn't mean you are subtracting one address from another; you're passing three arguments to `bootm`

The actual form of the bootm command is,

=> bootm <kernel> <initrd> <devicetree>

We are passing '-' for the second argument so we will boot without an initrd (the initial ramdisk)

a0000000:kernel@1 means to extract the first component from the FIT (aka ITB) image loaded at address a0000000.

Similarly a0000000:fdt@1 fetches the flattened device tree from the FIT image.

I guess by explicitly prohibiting the initrd from the FIT image, the "root=/dev/mmcblk0p2" value provided in the bootargs environment variable can actually work.

And no, you would not have known about this trick unless you ran across this posting.  The LS1046ARDB BSP documentation doesn't mention it except under "NFS Deployment".  It is not mentioned, for example, under "U-Boot Image Deployment from SD Card" even though that has a subsection titled "Using the Ext2 Partition of SD card as the Root File System"

0 Kudos
3,010 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello pro-supportengineer,

I suggest you use uImage+dts to boot up the system.

In SDK 2.0, uImage is not  generated by default, please use the following method to generate uImage. After run "bitbake virtual/kernel", you will get "Image" in QorIQ-SDK-V2.0-20160527-yocto/build_ls1043ardb/tmp/deploy/images/ls1043ardb folder, please copy it out to make uImage.

$ export PATH=/home/b25805/test/QorIQ-SDK-V2.0-20160527-yocto/build_ls1043ardb/tmp/sysroots/x86_64-linux/usr/bin/:$PATH

$ gzip Image

$ mkimage -A arm64 -O linux -T kernel -C gzip  -a 0x80080000 -e 0x80080000 -n linux-4.1 -d  Image.gz uImage

On the target board(I put rootfs in the first partition of SD card.)

=> tftp 0xa0000000 b25805/ls1043rdb/uImage

=> tftp 0x90000000 b25805/ls1043rdb/Image-fsl-ls1043a-rdb.dtb

=> setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p1 rw rootdelay=5 earlycon=uart8250,0x21c0500,115200"

=> bootm 0xa0000000 - 0x90000000

Please refer to the attached log.


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
3,009 Views
pro-supportengi
NXP Employee
NXP Employee

Hi Yiping,

This is considered a bug in ramfs for SDK 2.0 requiring the need for the uImage, correct?  Thanks

0 Kudos
3,009 Views
pro-supportengi
NXP Employee
NXP Employee

Thanks Klemen!  So, why is this workaround around needed?  What changed between SDK 0.5 and 2.0 and is booting from ram disk broken in SDK 2.0?  When will the official patch for this bug be available to download?

Oleg also discovered a workaround for removing the ramdisk for the kernel.itb file below.  But we need the recipe changes to avoid having to do the workaround.  There is likely a yocto define that prevents having to incorporate the rootfs in the kernel.itb.  Do you know what this would be?

The file to be updated is QorIQ-SDK-V2.0-20160527-yocto/sources/meta-freescale/recipes-fsl/images/fsl-image-kernelitb/kernel.its

We can create bbappend file for the QorIQ-SDK-V2.0-20160527-yocto/sources/meta-freescale/recipes-fsl/images/fsl-image-kernelitb.bb, replacing the following setting:

KERNEL_ITS ?=
"kernel.its"                                                                                                                                                                                                                 

with our own ITS file with the following sections commented out:

...............
  /*              
  ramdisk@1 {
                      
  description = "Ramdisk";
                    
  data = /incbin/("rootfs.ext2.gz");
                      
  type = "ramdisk";
                      
  arch = "arm64";
                    
  os = "linux";
                   
  compression = "none";
              
  };

  */
  .......
  /*             
  ramdisk = ramdisk@1;

  */



Now the kernel.itb is just 5MB and works just fine :smileyhappy:

0 Kudos
3,009 Views
pro-supportengi
NXP Employee
NXP Employee

Need clarification why this is required since it was working fine in SDK 0.5 simply using the kernel.itb.  If the ramfs is corrupt for SD boot, there should be a fix and a JIRA ticket opened.  Can someone open a JIRA ticket so this can be fixed by NXP appropriately?  The issue is the ramfs appears to be corrupt and a workaround isn't sufficient if it is corrupt.  It is simply using a different ramfs, not the one provided by the kernel.itb.

0 Kudos
3,009 Views
pro-supportengi
NXP Employee
NXP Employee

Also, note when boot fails the postinst scripts in bold listed below do not appear. 

What changed between 0.5v and SDK 2.0 with inittab related scripts that causes initdefault to fail causing an inability to boot from SD? It was working fine with no issues on 0.5v.  How does initdefault work and is it trying to use a bad sysvinit?

Line five in /etc/inittab where the failure occurs is "id:5:initdefault:" 

VFS: Mounted root (ext2 filesystem) on device 1:0.                         

   
VFS: Mounted root (ext2 filesystem) readonly on device 179:2.                  
Trying to move old root to /initrd ... /initrd does not exist. Ignored.        
Unmounting old root                                                            
Trying to free ramdisk memory ... failed                                       
devtmpfs: mounted                                                              
Freeing unused kernel memory: 284K (ffffffc000902000 - ffffffc000949000)       
Freeing alternatives memory: 36K (ffffffc000949000 - ffffffc000952000)         
INIT: version 2.88 booting                                                     
Starting udev                                                                  
udevd[1148]: starting version 182                                              
EXT2-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommend
random: dd urandom read with 16 bits of entropy available                      
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt.
Running postinst /etc/rpm-postinsts/100-inetutils-inetd...                     
Running postinst /etc/rpm-postinsts/101-sysvinit-inittab...                    
Running postinst /etc/rpm-postinsts/102-inetutils-ftpd...                      

update-rc.d: /etc/init.d/run-postinsts exists during rc.d purge (continuing)   
INIT: Entering runlevel: 5up links for run-postin                              
Configuring network interfaces... done.                                        
Starting OpenBSD Secure Shell server: sshd                                     
  generating ssh RSA key...                                                    
  generating ssh ECDSA key...                                                  
  generating ssh DSA key...                                                    
  generating ssh ED25519 key...                                                
done.                                                                          
Starting network benchmark server: netserver.                                  
Starting system log daemon...0                                                 
Starting kernel log daemon...0                                                 
Starting internet superserver: xinetd.                                         
                                                                               
QorIQ SDK (FSL Reference Distro) 2.0 ls1043ardb /dev/ttyS0                     
                                                                               
ls1043ardb login:

Here is the inittab:

# /etc/inittab: init(8) configuration.

# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.

id:5:initdefault:

# Boot-time system configuration/initialization script.

# This is run first except when booting in emergency (-b) mode.

si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.

~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change

# of runlevel.

#

# Runlevel 0 is halt.

# Runlevel 1 is single-user.

# Runlevels 2-5 are multi-user.

# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0

l1:1:wait:/etc/init.d/rc 1

l2:2:wait:/etc/init.d/rc 2

l3:3:wait:/etc/init.d/rc 3

l4:4:wait:/etc/init.d/rc 4

l5:5:wait:/etc/init.d/rc 5

l6:6:wait:/etc/init.d/rc 6

# Normally not reached, but fallthrough in case of emergency.

z6:6:respawn:/sbin/sulogin

S0:12345:respawn:/sbin/getty -L 115200 ttyS0

AMA0:12345:respawn:/sbin/getty -L 115200 ttyAMA0

0 Kudos
3,009 Views
kporenta
Contributor III

Hello,

as it looks it has something to do with RAMDISK found in FIT image.

Fast and ugly workaround to use rootfs from SD card:

- load FIT image

     ext2load mmc 0 a0000000 kernel.itb

- set fdt address and read ramdisk address

     fdt address a0000000

     fdt print

                ramdisk@1 {

                        description = "Ramdisk";

                        data = * 0x00000000a05286d4 [0x019a7205];

                        type = "ramdisk";

                        arch = "arm64";

                        os = "linux";

                        compression = "none";

                };

- corrupt ramdisk in ram

     mw.l a05286d4 0

- set bootargs to point rootfs to mmcblk0p1 and boot the board

     setenv bootargs "root=/dev/mmcblk0p1 rw earlycon=uart8250,0x21c0500 console=ttyS0,115200"

     bootm a0000000

As a result you can see:

     RAMDISK: Couldn't find valid RAM disk image starting at 0.

instead of:

     RAMDISK: gzip image found at block 0

This steps works for me. I hope it helps!

Klemen

0 Kudos
3,009 Views
olegnazarov
Contributor I

It appears that noinitrd boot option helps to resolve this issue.

Still we need to understand how to get rid of this initial ram disk when the SD is used for booting, to improve boot speed and memory usage.

0 Kudos