Load the initramfs.cpio file directly to RAM for iMX8MP platform

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Load the initramfs.cpio file directly to RAM for iMX8MP platform

4,248件の閲覧回数
msivanesancq
Contributor I

Hi,

I am trying to load the OS image directly to RAM and run it in iMX8MP process.

According to this https://community.nxp.com/t5/i-MX-Processors/RAM-Test-using-UUU/td-p/1720256 it seems this cannot be doable.

Are there any alternative way for me to achieve my goal which is download the initramfs into RAM and run it lively? 

Thank you

ラベル(1)
0 件の賞賛
返信
14 返答(返信)

4,146件の閲覧回数
msivanesancq
Contributor I

Hi Zhiming,

Thank you for the comprehensive answer.

I am trying to run custom binary after loading the initramfs. Is it mandatory to the mount rootfs after doing this initramfs? 

May I know what you are doing in the step ?

FBK: ucp  _rootfs.tar.zst t:-

Thank you

Mayuran

 

0 件の賞賛
返信

4,200件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

The following uuu demo is an example of how to download the kernel using initramfs, you can refer to it.

uuu_version 1.2.39

# Please Replace below items with actually file names
# @_flash.bin			| boot loader
# @_Image			| kernel image, arm64 is Image, arm32 it is zImage
# @_board.dtb			| board dtb file
# @_initramfs.cpio.gz.uboot	| mfgtool init ramfs
# @_rootfs.tar.zst		| rootfs
# @_uTee.tar			| optee image, put dummy _uTee.tar file here if platform is not MX6/MX7*

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

# This command will be run when ROM support stream mode
# i.MX8QXP, i.MX8QM
SDPS: boot -f _flash.bin

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
# }

# use uboot burn bootloader to eMMC
# becaue difference chip, offset is difference
# you can use kernel to do that for specific boards
FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: flash bootloader _flash.bin

FB: ucmd if env exists emmc_ack; then ; else setenv emmc_ack 0; fi;

FB: ucmd setenv emmc_cmd mmc partconf ${emmc_dev} ${emmc_ack} 1 0
FB: ucmd if test "${emmc_skip_fb}" != "yes"; then run emmc_cmd; fi
FB: ucmd setenv emmc_cmd mmc bootbus ${emmc_dev} 2 0 1;
FB: ucmd if test "${emmc_skip_fb}" != "yes"; then run emmc_cmd; fi

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f _Image
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f _board.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f _initramfs.cpio.gz.uboot
#FB: ucmd setenv bootargs console=${console},${baudrate} earlycon=${earlycon},${baudrate}
FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}

# get mmc dev number from kernel command line
# Wait for emmc
FBK: ucmd while [ ! -e /dev/mmcblk*boot0 ]; do sleep 1; echo "wait for /dev/mmcblk*boot* appear"; done;

# serach emmc device number, if your platform have more than two emmc chip, please echo dev number >/tmp/mmcdev 
FBK: ucmd dev=`ls /dev/mmcblk*boot*`; dev=($dev); dev=${dev[0]}; dev=${dev#/dev/mmcblk}; dev=${dev%boot*}; echo $dev > /tmp/mmcdev;

# dd to clear the possible MBR
FBK: ucmd mmc=`cat /tmp/mmcdev`; dd if=/dev/zero of=/dev/mmcblk${mmc} bs=512 count=1
# create partition
FBK: ucmd mmc=`cat /tmp/mmcdev`; PARTSTR=$'10M,500M,0c\n600M,,83\n'; echo "$PARTSTR" | sfdisk --force /dev/mmcblk${mmc}

FBK: ucmd mmc=`cat /tmp/mmcdev`; dd if=/dev/zero of=/dev/mmcblk${mmc} bs=1k seek=4096 count=1
FBK: ucmd sync
# you can enable below command to write boot partition. but offset is difference at difference platform
#FBK: ucmd mmc=`cat /tmp/mmcdev`; echo 0 > /sys/block/mmcblk${mmc}boot0/force_ro
#FBK: ucp  _flash.bin t:/tmp
#FBK: ucmd mmc=`cat /tmp/mmcdev`; dd if=/tmp/_flash.bin of=/dev/mmc${mmc}boot0 bs=1K seek=32
#FBK: ucmd mmc=`cat /tmp/mmcdev`; echo 1 > /sys/block/mmcblk${mmc}boot0/force_ro
FBK: ucmd mmc=`cat /tmp/mmcdev`; while [ ! -e /dev/mmcblk${mmc}p1 ]; do sleep 1; done
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkfs.vfat /dev/mmcblk${mmc}p1
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkdir -p /mnt/fat
FBK: ucmd mmc=`cat /tmp/mmcdev`; mount -t vfat /dev/mmcblk${mmc}p1 /mnt/fat
FBK: ucp  _Image t:/mnt/fat
FBK: ucp  _board.dtb t:/mnt/fat
FBK: ucp  _uTee.tar t:/tmp/op.tar
FBK: ucmd tar --no-same-owner -xf /tmp/op.tar -C /mnt/fat
FBK: ucmd umount /mnt/fat
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkfs.ext3 -F -E nodiscard /dev/mmcblk${mmc}p2
FBK: ucmd mkdir -p /mnt/ext3
FBK: ucmd mmc=`cat /tmp/mmcdev`; mount /dev/mmcblk${mmc}p2 /mnt/ext3
FBK: acmd export EXTRACT_UNSAFE_SYMLINKS=1; tar --zstd --warning=no-timestamp -x -C /mnt/ext3
FBK: ucp  _rootfs.tar.zst t:-
FBK: Sync
FBK: ucmd umount /mnt/ext3
FBK: DONE



Best Regards,
Zhiming

0 件の賞賛
返信

4,143件の閲覧回数
msivanesancq
Contributor I

Hi Zhiming,

Thank you for the comprehensive answer.

I am trying to run custom binary after loading the initramfs. Is it mandatory to the mount rootfs after doing this initramfs? 

May I know what you are doing in the step ?

FBK: ucp  _rootfs.tar.zst t:-

Thank you

Mayuran

0 件の賞賛
返信

4,139件の閲覧回数
msivanesancq
Contributor I

Basically,

1. I have custom meta layer to install binaries in /usr/bin folder.

2. I added this in the PACKAGE_INSTALL of sources/poky/meta/recipes-core/images/core-image-minimal-initramfs.bb

3. Once I build using  bitbake core-image-minimal-initramfs I flashed it with UUU command(emmc_all).

4. Then I booted the device using FB: ucmd boot and realized that the binaries are missing.

Am I missing any steps here?

Thank you

Mayuran

0 件の賞賛
返信

4,104件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

You may need use ucp to transfer your binary to ramfs.

Best Regards,
Zhiming

0 件の賞賛
返信

4,016件の閲覧回数
msivanesancq
Contributor I

Hi Zhiming

Thank you for the reply.

We executed all of the command that you were suggested in the iMX8MP dev board and we see device boots but not prompting for user login. Thus we think that rootfs is not loaded and mounted by the device. Please see the attachment for the kernel console output.

It would be helpful if you can advice us on which steps are need to be corrected.

Thank you

Mayuran

0 件の賞賛
返信

3,916件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

From the log, it seem that you want to transfer files after image boot. Please refer the uuu script. You may need to wait emmc device.

FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}

# get mmc dev number from kernel command line
# Wait for emmc
FBK: ucmd while [ ! -e /dev/mmcblk*boot0 ]; do sleep 1; echo "wait for /dev/mmcblk*boot* appear"; done;



Best Regards,
Zhiming

0 件の賞賛
返信

3,854件の閲覧回数
msivanesancq
Contributor I

Hello Zhiming,

We havn't modified the script you shared other than replacing the file names of boot, rootfs etc.

We did not remove any of the wait procedures. I hope that while loop with sleep will do this waiting process.

Then may I know why the original script is failing?

Can you please precisely mention what change need to be done here to make this working?

Thank you and expecting your quick response.

Mayuran

0 件の賞賛
返信

3,843件の閲覧回数
msivanesancq
Contributor I

Additionally we see that the command execution is not happening in the kernel mode using FBK commands.

For example when we try

FBK: ucmd while [ ! -e /dev/mmcblk1boot0 ]; do sleep 1; echo "wait for /dev/mmcblk*boot* appear"; done;

and we see

run shell cmd: while [ ! -e /dev/mmcblk1boot0 ]; do sleep 1; echo "wait for /dev/mmcblk*boot* appear"; done;

also

if we run 

uuu.exe FBK: ucmd ls /dev/mmc*

we see below output

run shell cmd: ls /dev/mmc*

Which seems that the shell commands are not processed. So the uuu tool is not downloading the rootfs.

0 件の賞賛
返信

3,802件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

 

I am testing with fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.zst.u-boot from https://github.com/Freescale/meta-freescale/blob/master/classes/mfgtool-initramfs-image.bbclass and it can boot into rootfs

uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk

# This command will be run when ROM support stream mode
# i.MX8QXP, i.MX8QM
SDPS: boot -f imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk -skipspl
SDPV: jump
# }


FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: flash bootloader imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk

FB: ucmd if env exists emmc_ack; then ; else setenv emmc_ack 0; fi;

FB: ucmd setenv emmc_cmd mmc partconf ${emmc_dev} ${emmc_ack} 1 0
FB: ucmd if test "${emmc_skip_fb}" != "yes"; then run emmc_cmd; fi
FB: ucmd setenv emmc_cmd mmc bootbus ${emmc_dev} 2 0 1;
FB: ucmd if test "${emmc_skip_fb}" != "yes"; then run emmc_cmd; fi

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f Image
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f imx8mp-evk.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.zst.u-boot
FB: ucmd setenv bootargs console=${console},${baudrate} earlycon=${earlycon},${baudrate} root=/dev/ram rw
FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}
FB: DONE

 

Zhiming_Liu_0-1733883949777.png

 



Best Regards,
Zhiming

0 件の賞賛
返信

3,798件の閲覧回数
msivanesancq
Contributor I

Hi,

Few clarifications:

Are you sure that the board is alredy does not flashed with anu other kernel images? Because I have seen that rootfs will be chosen from any other derives if the are available.

To be precise which bitbake commands did you use to produce those binaries?

We use below 2:

bitbake core-image-minimal-initramfs
bitbake fsl-image-mfgtool-initramfs

0 件の賞賛
返信

3,796件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

Are you sure that the board is alredy does not flashed with anu other kernel images?

-->Of course, i don't plug in SD card, only emmc

Please use bitbake fsl-image-mfgtool-initramfs

Best Regards,
Zhiming

0 件の賞賛
返信

3,778件の閲覧回数
msivanesancq
Contributor I

Hi Zhiming,

The answer you provided is really helpful and it works.

But I would like to ask 2 more questions.

1. In the latest script you have shared, does not include any commands to download tee.tar and rootfs.tar.zst files. But in our use case, we still wanted to download our custom rootfs(ex: the rootfs of multimedia image). How can I do that?

2. After the kernel is booted I tried to issue some shell commands from uuu using FBK. But not seeing any responses in UART console or UUU command console. Instead UUU freezes.

Ex:

>uuu.exe FBK: acmd ls /dev/
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.182-0-gda3cd53

Success 0 Failure 0 Wait for Known USB Device Appear...

>uuu.exe FBK: acmd ls /dev/
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.182-0-gda3cd53

Success 0 Failure 0 Wait for Known USB Device Appear..

0 件の賞賛
返信

3,723件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

The top script is based on initramfs to download the filesystem, kernel and dtb.

Zhiming_Liu_0-1734052330909.png

 




Best Regards,
Zhiming

0 件の賞賛
返信