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.

AM57X: Boot sequence question

Hi, all

the AM57XX Peripheral Preferred Booting Order seems strange.

sysboot[5:0] = 0b000010, it means booting order is USB first, SD second  and EMMC third.

I wants to boot from SD and EMMC, if SD failed, it boots from EMMC, the USB is not concened.

When I test boot from SD and EMMC individual, it is ok.

When Both contain boot code, the SD is prior to EMMC.

But when I test boot from EMMC, and insert a empty SD card(the SD card contains only one FAT32 partition, and all data is 0).

It can not boot from EMMC and seems dead loop to boot from SD,  when removing SD, it boots from EMMC.

Any suggestion?

  • Please read section 33.3.7.6 of the AM572x TRM Rev. I, where eMMC/SD booting procedure is described in details. The ROM code probably recognizes your SD card as a valid boot source and stops there.
  • According to 33.3.7.6, it requires the SD card with a active(boot) FAT partition and contains a file name "MLO".

    But the SD card I used is a empty card, with a FAT partition, but no active, and no file.

    So why ROM code treats it as a valid boot source?

    According to figure 33-24, 33-29, 33-30, if no active partition or no boot file found, it will failed.

    I do a test:
    (1) Format a SD card on window, and copy valid MLO, u-boot.img file into.
    (2) But using the SD can not bootup the board(because windows formatter does not set partition as active), and also it is not turn to boot from emmc.
    (3) And goto linux, using parted cmd to toggle SD card partition to boot.
    (4) And now, the SD card can bootup the board.

    So it means that if a SD card contains a FAT partiton(even though not a active partition and no MLO), ROM code will recognizes as valid boot source, trys always and never failed?

    The judgement of valid boot source is only by FAT?

  • I have asked the factory team for additional comments. They will post here.
  • Hi, Is there any information from factory team?
  • What's happening is that once the ROM doesn't find a proper boot file, the ROM assumes the card is formatted in raw mode.  The ROM then looks for a valid TOC structure ('valid' means the first location is not 0x00000000 or 0xFFFFFFFF).  Since a formatted card has data other than 0x0 or all Fs in the first few locations (where the ROM retrieves TOC), the ROM thinks this is a valid TOC and tries to boot, and then fails.   The ROM does not move on to the next boot source because the TOC structure check passed.

    Regards,

    James

  • The judgement seems so strange.

    you mean if first location is not 0x00000000 or 0xFFFFFFFF, Never fail?

    ROM code check SD as a valid Raw mode, but formatted card should not be a valid Raw, and can not location mlo file.

    if boot failed, Why not goto next boot device?

    It means if I want boot sequence:SD first(if emmc failed, I can boot from sd to rescue emmc.) and EMMC second, and want to using EMMC as system, SD as storage. I should format SD card as a activated FAT partition, but no contains any boot file?
  • That is correct, if first location is not 0x0 or 0xFFFFFFFF, the boot will fail but not move on to the next boot device. You would have to have one of these values in each of the four consecutive locations that the ROM expects to find the raw mode image, otherwise it will assume a valid image.

    Regards,
    James
  • sysboot[5:0] = 0b000010, it means booting order is USB first, SD second  and EMMC third.

    I want boot sequence:SD first(if emmc failed, I can boot from sd to rescue emmc.) and EMMC second, and normally, want to using EMMC as system, SD as storage.

    I format a SD card as a activated FAT32 partition with no boot file.

    But the same, when SD card exists, the system can not boot up.

    How can I do for the purpose?

  • Hi,
    the main problem is that a formatted SD card will have a value other than 0x0 or 0xFFFFFFFF in the first location of the first sector. When the ROM fails to find a valid boot file in the FAT partition, it will check the card in raw mode, and this is when the boot will fail, because of the first location in the first sector.
    You would have to create a formatted card that has either 0x0 or 0xFFFFFFFF in the first location of all the sectors which are checked for redundant images in raw mode (that is, sectors (address): 0x0 (0 KiB), 0x20000 (128 KiB) 0x40000 (256 KiB), 0x60000 (384 KiB).

    Regards,
    James
  • Upon discussing this with a colleague, it is not possible to have a formatted card and change the master boot record in the first few locations of the first sector. This would corrupt the MBR.
    Thus, the only workaround i can suggest is some sort of H/W button or switch which changes the boot order depending on if you want to boot from SD or boot from eMMC.

    Regards,
    James
  • Hi jinhu, i was able to unlock this post.

    It looks like another poster has a solution for you.

    Here is the text of the post.  Please try this to see if it solves your issue

    When you use parted instead of fdisk to format your SD Card, parted puts extra data on first location, so that the ROM bootloader assumes that the card is formatted in raw mode. To exit from that situation just run sudo dd if=/dev/zero of=/dev/sdX bs=4 count=1 command to zero these data and the booting will jump to eMMC.

    Here is more detailed info:

    When you use <Processor SDK>/bin/create-sdcard.sh to create a SD card, it uses parted command to format the SD card which puts extra data on first location 0x000000:

     

    Code snippet of <Processor SDK>/bin/create-sdcard.sh

    ################################################################################

            Now making 2 partitions

    ################################################################################

    EOM
    dd if=/dev/zero of=$DRIVE bs=1024 count=1024

    SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`

    echo DISK SIZE - $SIZE bytes

    parted -s $DRIVE mklabel msdos
    parted -s $DRIVE unit cyl mkpart primary fat32 -- 0 9
    parted -s $DRIVE set 1 boot on
    parted -s $DRIVE unit cyl mkpart primary ext2 -- 9 -2

    cat << EOM



    //-----------------------------------------------------------------------------------------------------------------------------------------------

     

    sudo hexdump /dev/sdb -n 16

    0000000 b8fa 1000 d08e 00bc b8b0 0000 d88e c08e

     

    When we use fdisk to format the SD card with these commands, the first location 0x000000 is empty:

     

    sudo fdisk /dev/sdb

    Type:
    1. p - print the partition table
    2. o - create a new empty DOS partition table
    3. p - print the partition table
    4. n - add a new partition
    5. p - primary
    6. 1 - default
    7. 2048 - default
    8. 145407 - sectors
    9. t - change a partition type
    10. c - W95 FAT32 (LBA)
    11. p - print the partition table
    12. a - toggle a bootable flag
    13. p - print the partition table
    14. n - add a new partition
    15. Press 4 times Enter and take the default values
    16. p - print the partition table
    17. w - write table to disk and exit

    sudo mkfs.vfat /dev/sdb1

    sudo mkfs.ext3 /dev/sdb2

     

    sudo hexdump /dev/sdb -n 16

     

    0000000 0000 0000 0000 0000 0000 0000 0000 0000

     

    So, if you use <Processor SDK>/bin/create-sdcard.sh to create a SD card, switching to eMMC will fail.
    If you use fdisk to format the SD card, the ROM bootloader will jump to eMMC if the MLO is not found on SD card's first partition.

    You can use this command sudo dd if=/dev/zero of=/dev/sdb bs=4 count=1 to zero the extra data putted by<Processor SDK>/bin/create-sdcard.sh parted.


    Thanks,

    James