This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM62A7: Bootfs.img generation and eMMC flashing over USB

Part Number: AM62A7

Tool/software:

Hi Team

I have compiled the kernel Image and  dtb using the command below as per the documentation.

Compiling the Kernel:
make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" Image
Compiling the Kernel Modules:
make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" modules
Compiling the DTB:
make DTC_FLAGS=-@ ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" ti/k3-am62a7-sk.dtb
As per the TI documentation I just copied Image and dtb to generate the "bootfs.img" using "make_bootfs.sh" you shared.

Do we need to copy any other files to "build/parmesan/boot/" to build the "bootfs.img" using "make_bootfs.sh"?

Am I missing something for emmc flashing?
copy Image and dtb file to build directory and using below script prepared the bootfs.img 

make_bootfs.sh
#!/bin/bash
truncate -s 120M bootfs.img
dd if=/dev/null of=bootfs.img bs=1M seek=150
mkfs.ext4 -O ^metadata_csum -F bootfs.img
mkdir -p boot
sudo mount -t ext4 -o loop bootfs.img $(pwd)/boot
sudo cp -rv build/boot/* boot/
ls -l boot
sync -f boot
sudo umount -l boot
flash_bootfs.sh
#!/bin/bash

# Write boot filesystem to eMMC
# The image can be build with make_bootfs.sh
# Note: dfu-util may need to be run as root.
#
# U-Boot should be waiting for conneciton before running:
# > setenv dfu_alt_info ${dfu_alt_info_emmc}
# > dfu 0 mmc 0
sudo dfu-util -a boot -D bootfs.img

Logs after fleshing 
U-Boot SPL 2023.04 (Aug 07 2024 - 20:41:57 +0000)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
am62a_init: board_init_f done
SPL initial stack usage: 17080 bytes
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Trying to boot from MMC1
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
Starting ATF on ARM64 core...

NOTICE: BL31: v2.8(release):
NOTICE: BL31: Built : 20:34:34, Aug 7 2024
I/TC:
I/TC: OP-TEE version: Unknown_3.19 (gcc version 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))) #1 Wed Aug 7 20:34
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check optee.readthedocs.io/.../porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot

U-Boot SPL 2023.04 (Aug 07 2024 - 20:42:32 +0000)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
am62a_init: board_init_f done
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Trying to boot from MMC1
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed
am62a_init: spl_boot_device: devstat = 0x44b bootmedia = 0x9 bootindex = 0
Authentication passed


U-Boot 2023.04 (Aug 07 2024 - 20:42:32 +0000)

SoC: AM62AX SR1.0 HS-FS
Model: Texas Instruments AM62A7 SK
DRAM: 2 GiB
Core: 56 devices, 25 uclasses, devicetree: separate
MMC: mmc@fa10000: 0
Loading Environment from nowhere... OK
In: serial@2800000
Out: serial@2800000
Err: serial@2800000
Failed to probe am65_cpsw_nuss driver
Net: No ethernet found.
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0(part 0) is current device
SD/MMC found on device 0
Failed to load 'boot.scr'
Can't set block device
## Error: "main_cpsw0_qsgmii_phyinit" not defined
19909120 bytes read in 131 ms (144.9 MiB/s)
Failed to load '//dtb/ti/k3-am62a7-sk.dtb'
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
No EFI system partition
No EFI system partition
Failed to persist EFI variables
BootOrder not defined
EFI boot manager: Cannot load any image
MMC Device 1 not found
no mmc device at slot 1
starting USB...
No working controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No working controllers found
No ethernet found.
missing environment variable: pxeuuid
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
Retrieving file: pxelinux.cfg/000000
No ethernet found.
Retrieving file: pxelinux.cfg/00000
No ethernet found.
Retrieving file: pxelinux.cfg/0000
No ethernet found.
Retrieving file: pxelinux.cfg/000
No ethernet found.
Retrieving file: pxelinux.cfg/00
No ethernet found.
Retrieving file: pxelinux.cfg/0
No ethernet found.
Retrieving file: pxelinux.cfg/default-arm-k3-am62ax
No ethernet found.
Retrieving file: pxelinux.cfg/default-arm-k3
No ethernet found.
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
starting USB...
No working controllers found
No ethernet found.
No ethernet found.
  • Hi Kishan,

    Failed to load '//dtb/ti/k3-am62a7-sk.dtb'

    U-Boot is looking for the kernel devicetree file under /boot/dtb/ti/ directory. Did you copy the file k3-am62a7-sk.dtb to the correct location before creating bootfs.img?

  • Hi Bin

    Thank you for your response!

    I have copied the boot directory from the file system to my build directory

    tar -xvf tisdk-edgeai-image-am62axx-evm.tar.xz --strip-components=1 -C build/ /boot

    Used below commands to create the bootfs.img

    truncate -s 120M bootfs.img
    dd if=/dev/null of=bootfs.img bs=1M seek=150
    mkfs.ext4 -O ^metadata_csum -F bootfs.img
    mkdir -p boot
    sudo mount -t ext4 -o loop bootfs.img $(pwd)/boot
    sudo cp -rv build/boot/* boot/
    sync -f boot
    sudo umount -l boot

    using below command flashing the bootfs.img

    Device:
    > setenv dfu_alt_info ${dfu_alt_info_emmc}
    > dfu 0 mmc 0

    Host:
    sudo dfu-util -a boot -D bootfs.img

    kernel got tainted is there any other things I need to copy to boot directory or am I missing in flashing procedure?

    Tainted kernel logs:

    [ 3.542907] debugfs: Directory 'pd:182' with parent 'pm_genpd' already present!
    [ 3.551719] debugfs: Directory 'pd:182' with parent 'pm_genpd' already present!
    [ 3.559061] debugfs: Directory 'pd:182' with parent 'pm_genpd' already present!
    [ 3.574179] ALSA device list:
    [ 3.577243] No soundcards found.
    [ 3.618855] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Quota mode: none.
    [ 3.627472] VFS: Mounted root (ext4 filesystem) on device 179:1.
    [ 3.634092] devtmpfs: error mounting -2
    [ 3.638634] Freeing unused kernel memory: 1984K
    [ 3.643269] Run /sbin/init as init process
    [ 3.647565] Run /etc/init as init process
    [ 3.651685] Run /bin/init as init process
    [ 3.655773] Run /bin/sh as init process
    [ 3.659659] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for gui.
    [ 3.673804] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.1.80-ti-g2e423244f8c0 #1
    [ 3.681188] Hardware name: Texas Instruments AM62A7 SK (DT)
    [ 3.686746] Call trace:
    [ 3.689183] dump_backtrace.part.0+0xdc/0xf0
    [ 3.693457] show_stack+0x18/0x30
    [ 3.696767] dump_stack_lvl+0x68/0x84
    [ 3.700426] dump_stack+0x18/0x34
    [ 3.703735] panic+0x188/0x348
    [ 3.706783] kernel_init+0x124/0x130
    [ 3.710355] ret_from_fork+0x10/0x20
    [ 3.713925] SMP: stopping secondary CPUs
    [ 3.717844] Kernel Offset: disabled
    [ 3.721320] CPU features: 0x00000,00800084,0000420b
    [ 3.726186] Memory Limit: none
    [ 3.729235] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rs-

  • Hi Kishan,

    tar -xvf tisdk-edgeai-image-am62axx-evm.tar.xz --strip-components=1 -C build/ /boot

    Used below commands to create the bootfs.img

    truncate -s 120M bootfs.img
    dd if=/dev/null of=bootfs.img bs=1M seek=150

    If I am not wrong, are you trying to create a 120MB image file to host ~900MB eageai rootfs tarball?

  • Hi Bin

    Do I need to create 900MB of bootfs.img ?

    Only boot directory from the evm.tar.xz is enough or do we need to add anything else as well?

    tar -xvf tisdk-edgeai-image-am62axx-evm.tar.xz --strip-components=1 -C build/ /boot

  • The size of bootfs.img should be big enough to host the rootfs of your choice, depending on the application of your project.

  • Hi Bin 

    Thank you,

    is my bootfs.img creation is correct or do i need to add any other things in that?


  • Hi Kishan,

    The command sequence to create the bootfs image seems to be correct, except you should know what file size to use, which is determined by the rootfs you use for your project. For example, the Processor SDK provides the following prebuilt rootfs images:

    - tisdk-edgeai-image-am62axx-evm.tar.xz [899MB]
    - tisdk-tiny-image-am62axx-evm.tar.xz [25MB]

    Please note that these are compressed files. You would have to decompress it to see how much space is needed to host the root filesystem.

  • Hi Bin

    Thank you very much for your support,

    could you please guide me, how to flash the  tar.xz file to emmc using dfu-util so I can flash complete device?

    I am not able to find the exact steps to flash complete board over emmc using dfu-util.

    tisdk-default-image-am62xx-evm.tar.xz
  • Hi Kishan,

    Sorry, it is my bad, I didn't realize that your "flash_bootfs.sh" script only flashes to the eMMC boot partition, but not the rootfs, all our previous communication is invalid. Sorry for the confusion.

    Can you please follow the instruction linked below for flashing the eMMC?

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1127618/faq-sk-am62-how-to-flash-emmc-using-usb-dfu-on-am62x-sk-e2

  • Hi Bin,

    I am able to flash the rootfs system but if i generate bootfs.img with just Image and dtb file then i am not able to boot the device completely,

    can you please share the process to prepare the kernel image and flash method using dfu-util ?

    I am following below command to prepare the bootfs, where i copy Image and dtb file only 

    truncate -s 120M bootfs.img
    dd if=/dev/null of=bootfs.img bs=1M seek=150
    mkfs.ext4 -O ^metadata_csum -F bootfs.img
    mkdir -p boot
    sudo mount -t ext4 -o loop bootfs.img $(pwd)/boot
    sudo cp -rv build/kishan/boot/* boot/
    sync -f boot
    sudo umount -l boot

    Flash command:
    # > setenv dfu_alt_info ${dfu_alt_info_emmc}
    # > dfu 0 mmc 0
    sudo dfu-util -a boot -D bootfs.img


  • In the e2e FAQ I linked above, it has the following instruction to create an rootfs image:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    The following instructions can be used to prepare the <your_rootfs.ext4> using tisdk-base-image-am62xx-evm.tar.xz:
    $ cd <path-ti-psdk>/filesystem
    $ dd if=/dev/null of=tisdk-base.ext4 bs=1M seek=300
    $ mkfs.ext4 -F tisdk-base.ext4
    $ mkdir mnt_fs
    $ sudo mount -t ext4 tisdk-base.ext4 mnt_fs
    $ cd mnt_fs
    $ sudo tar xvf ../tisdk-base-image-am62xx-evm.tar.xz
    $ cd ..
    $ sudo umount mnt_fs
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    then you need the following command to flash the rootfs image to emmc. Please ensure you copied kernel image and dtb to the rootfs created using the instructions above.

    $ sudo dfu-util -a rootfs -D <your_rootfs.ext4>

  • Hi Bin,

    This step will flash full root file system I just want to flash the kernel and dtb.

    I had tried this and flashed the device, but it will erase the complete device.

    Is there any way we can prepare the bootfs.img and just update dtb and kernel image?

  • Hi Kishan,

    To run Linux on the AM62Ax board, Linux rootfs is needed, where do you flash the rootfs to if bootfs.img has only kernel image and its dtb?

  • Hi Bin,

    I have flashed the rootfs only, and this my question, can I flash only kernel and dtb image instead of rootfs?

    because if I debug something in platform driver every time, I need to flash complete rootfs it erases everything's on device.

    That is the reason to just flash kernel image and dtb on device.

  • Okay, now I understand the problem you are trying to resolve - just updating kernel in eMMC during software development.

    I can think of two different solutions.

    1. after initially flashed the entire Linux to eMMC and whenever you need to update the kernel image or dtb, boot your board from eMMC to Linux, then use whatever interface on your board to copy/download the individual files in Linux and write them to the corresponding locations in eMMC, then reboot your board. This is basically the same way that how to use a Linux computer.

    Whenever the updated kernel image or dtb causes your board unable to boot, you would need to use DFU to flash the entire rootfs to recover.

    -2. partition your eMMC to separate kernel image and dtb from the rootfs, so that both files are not in the rootfs. Then you can just use DFU to update the kernel image and dtb whenever you want to. You just need to modify U-Boot to load the kernel image and dtb from the new partition, but not from the rootfs.

  • Hi Bin,

    Thank you very much for your support!

    can you help to partition eMMC to separate kernel image and dtb from the rootf?

    Any reference or steps would be appreciated. 

  • Hi Kishan,

    This is not supported in the SDK, so I don't have an example to show you. But I already explained it in my previous post, you should be able follow and implement it.

  • Hi Bin,

    I have built the images using "MACHINE="am62axx-evm" bitbake -k tisdk-edgeai-image" command

    and flash the rootfs from the below location but my kernel and dtb changes are not affected while booting the board.

    build/deploy-ti/images/am62axx-evm/tisdk-edgeai-image-am62axx-evm-20240930132544.rootfs.tar.xz

    Prepare the ext4 using below commands 

    mkdir -p mnt_fs
    dd if=/dev/null of=tisdk-base.ext4 bs=1M seek=6144
    mkfs.ext4 -F tisdk-base.ext4
    sudo mount -t ext4 tisdk-base.ext4 mnt_fs
    cd mnt_fs
    sudo tar xvf ../tisdk-edgeai-image-am62axx-evm-20240930132544.rootfs.tar.xz
    cd ../
    sudo umount mnt_fs

    flashing steps:

    # U-Boot should be waiting for conneciton before running:
    # > setenv dfu_alt_info ${dfu_alt_info_emmc}
    # > dfu 0 mmc 0

    sudo dfu-util -a rootfs -D tisdk-base.ext4

    do i need to flash bootloader as explained in below command to flash my kernel and dtb ?

    • sudo dfu-util -a tiboot3.bin.raw -D <your_tiboot3.bin>
    • sudo dfu-util -a tispl.bin.raw -D <your_tispl.bin>
    • sudo dfu-util -a u-boot.img.raw -D <your_u-boot.img>

     referance : [FAQ] SK-AM62: How to flash eMMC using USB DFU on AM62x-SK E2 - Processors forum - Processors - TI E2E support forums





  • I have below configuration

    ls -lrth /dev/block/platform/*
    lrwxrwxrwx 1 root root 15 Jan 1 1970 /dev/block/platform/boot -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 15 Jan 1 1970 /dev/block/platform/rootfs -> ../../mmcblk0p2



    root@am62axx-evm:~# dmesg | grep -i 'mmc'
    [ 0.982369] mmc0: CQHCI version 5.10
    [ 1.023814] mmc0: SDHCI controller on fa10000.mmc [fa10000.mmc] using ADMA 64-bit
    [ 1.098712] mmc0: Command Queue Engine enabled
    [ 1.098730] mmc0: new HS200 MMC card at address 0001
    [ 1.099359] mmcblk0: mmc0:0001 016G01 14.5 GiB
    [ 1.102349] mmcblk0: p1 p2
    [ 1.103025] mmcblk0boot0: mmc0:0001 016G01 8.00 MiB
    [ 1.103919] mmcblk0boot1: mmc0:0001 016G01 8.00 MiB
    [ 1.104808] mmcblk0rpmb: mmc0:0001 016G01 4.00 MiB, chardev (510:0)
    [ 31.581167] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: none.
    [ 35.894032] EXT4-fs (mmcblk0p2): re-mounted. Quota mode: none.
    [ 39.259037] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Quota mode: none.

  • lrwxrwxrwx 1 root root 15 Jan 1 1970 /dev/block/platform/boot -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 15 Jan 1 1970 /dev/block/platform/rootfs -> ../../mmcblk0p2

    Good, now your eMMC UDA has two partitions.

    # > setenv dfu_alt_info ${dfu_alt_info_emmc}

    I never did this, but you need to modify $dfu_alt_info_emmc, so that

    sudo dfu-util -a rootfs -D tisdk-base.ext4

    this "rootfs" points to mmcblk0p2, instead of mmcblk0 which is the default.

    To dfu flash kernel image and dtb to mmcblk0p1, you need to add two entries to $dfu_alt_info_emmc so that both files can be written to mmcblk0p1 in FAT file format.

  • Hi Bin

    Thank you for your reply!

    I have print the env variables.


    Fullscreen
    1
    2
    3
    4
    5
    6
    dfu_alt_info_emmc=rawemmc raw 0 0x800000 mmcpart 1; boot part 0 1; rootfs part 0 2; tiboot3.bin.raw raw 0x0 0x400 mmcpart 1; tispl.bin.raw raw 0x400 0x1000 mmcpart 1; u-1
    dfu_alt_info_mmc=boot part 1 1; rootfs part 1 2; tiboot3.bin fat 1 1; tispl.bin fat 1 1; u-boot.img fat 1 1; uEnv.txt fat 1 1; sysfw.itb fat 1 1
    dfu_alt_info_nand=NAND.tiboot3 part 0 1; NAND.tispl part 0 2; NAND.tiboot3.backup part 0 3; NAND.u-boot part 0 4; NAND.u-boot-env part 0 5; NAND.u-boot-env.backup part 07
    dfu_alt_info_ospi=tiboot3.bin raw 0x0 0x080000; tispl.bin raw 0x080000 0x200000; u-boot.img raw 0x280000 0x400000; u-boot-env raw 0x680000 0x020000; sysfw.itb raw 0x6c000
    dfu_alt_info_ospi_nand=ospi_nand.tiboot3 part 1; ospi_nand.tispl part 2; ospi_nand.u-boot part 3; ospi_nand.env part 4; ospi_nand.env.backup part 5; ospi_nand.rootfs par7
    dfu_alt_info_ram=tispl.bin ram 0x80080000 0x200000; u-boot.img ram 0x81000000 0x400000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    Q1) could you please share how to update the "dfu_alt_info_emmc"?
    Q2) do i need to flash bootloader as explained in below command to flash my kernel and dtb?

    • sudo dfu-util -a tiboot3.bin.raw -D <your_tiboot3.bin>
    • sudo dfu-util -a tispl.bin.raw -D <your_tispl.bin>
    • sudo dfu-util -a u-boot.img.raw -D <your_u-boot.img>

     Referance : [FAQ] SK-AM62: How to flash eMMC using USB DFU on AM62x-SK E2 - Processors forum - Processors - TI E2E support forums

  • Hi Kishan,

    Q1) could you please share how to update the "dfu_alt_info_emmc"?

    I think you can refer to dfu_alt_info_mmc, which defines the files in FAT format.

    Q2) do i need to flash bootloader as explained in below command to flash my kernel and dtb?

    Yes, this way to flash u-boot binaries has no change. They are irrelevant to flashing kernel and dtb, which go to different partition and format.