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.

AM437x SK - how to boot from SPI Flash

Hi guys,

I'm using AM437x SK. I'm able to boot (Linux system created with Yotco; 2 partitions: 1st - FAT with MLO, u-boot.img, ..; 2nd EXT with roofs, kernel, ...) from SD Card. And now I would like to boot it from onboard QSPI-NOR flash. 

I ran into U-Boot 2015.07 (from SD Card) and wanted to use these commands (from http://processors.wiki.ti.com/index.php/AMSDK_u-boot_User's_Guide ) to load MLO, u-boot.img to QSPI Flash.

U-Boot # mmc rescan
U-Boot # sf probe 0
U-Boot # sf erase 0 +80000
U-Boot # fatload mmc 0 ${loadaddr} MLO.byteswap
U-Boot # sf write ${loadaddr} 0 ${filesize}
U-Boot # fatload mmc 0 ${loadaddr} u-boot.img
U-Boot # sf write ${loadaddr} 0x20000 ${filesize}

I succesfully loaded it into the SPI flash and then I rebooted the board (without SD card). Nothing happened. Am I doing it right way? Am I missing some configuration? (Is there any tutorial, wiki how to boot from (AM437x SK) SPI flash I didn't find?)

U-Boot# printenv
arch=arm
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=am43xx
board_name=AM43__SK
board_rev=1.1A
board_serial=11144P420878
bootcmd=run findfdt; run envboot;run mmcboot;run usbboot;run nandboot;
bootdelay=1
bootdir=/boot
bootenvfile=uEnv.txt
bootfile=zImage
bootm_size=0x10000000
bootpart=0:2
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
console=ttyO0,115200n8
cpu=armv7
dfu_alt_info_emmc=MLO raw 0x100 0x100 mmcpart 0;u-boot.img raw 0x300 0x1000 mmcpart 0
dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;spl-os-args fat 0 1;spl-os-image fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1
dfu_alt_info_qspi=u-boot.bin raw 0x0 0x080000;u-boot.backup raw 0x080000 0x080000;u-boot-spl-os raw 0x100000 0x010000;u-boot-env raw 0x110000 0x010000;u-boot-env.backup raw 0x120000 0x010000;kernel raw 0x130000 0x800000
dfu_alt_info_ram=kernel ram 0x80200000 0x4000000;fdt ram 0x80f80000 0x80000;ramdisk ram 0x81000000 0x4000000
dfu_bufsiz=0x10000
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;else if run loadbootenv; then echo Loaded env from ${bootenvfile};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;fi;fi;
eth1addr=c4:be:84:cc:b9:7b
ethact=cpsw
ethaddr=c4:be:84:cc:b9:79
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtfile=undefined
findfdt=if test $board_name = AM43EPOS; then setenv fdtfile am43x-epos-evm.dtb; fi; if test $board_name = AM43__GP; then setenv fdtfile am437x-gp-evm.dtb; fi; if test $board_name = AM43__SK; then setenv fdtfile am437x-sk-evm.dtb; fi; if test $board_name = AM43_IDK; then setenv fdtfile am437x-idk-evm.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree; fi;
finduuid=part uuid mmc 0:2 uuid
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
kernel_addr_r=0x82000000
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load ${devtype} ${devnum} ${rdaddr} ramdisk.gz
mmcboot=mmc dev ${mmcdev}; setenv devnum ${mmcdev}; setenv devtype mmc; if mmc rescan; then echo SD/MMC found on device ${devnum};if run loadimage; then run loadfdt; echo Booting from mmc${mmcdev} ...; run args_mmc; bootz ${loadaddr} - ${fdtaddr}; fi;fi;
mmcdev=0
mmcrootfstype=ext4 rootwait
mtdids=nand0=nand.0
mtdparts=mtdparts=nand.0:256k(NAND.SPL),256k(NAND.SPL.backup1),256k(NAND.SPL.backup2),256k(NAND.SPL.backup3),512k(NAND.u-boot-spl-os),1m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup1),7m(NAND.kernel),-(NAND.file-system)
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}
nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,4096
nandrootfstype=ubifs rootwait=1
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; dhcp; run netloadimage; run netloadfdt; run netargs; bootz ${loadaddr} - ${fdtaddr}
netloadfdt=tftp ${fdtaddr} ${fdtfile}
netloadimage=tftp ${loadaddr} ${bootfile}
nfsopts=nolock
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramdisk_addr_r=0x88080000
ramroot=/dev/ram0 rw
ramrootfstype=ext2
rdaddr=0x88080000
rootpath=/export/rootfs
soc=am33xx
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial
usbargs=setenv bootargs console=${console} ${optargs} root=${usbroot} rootfstype=${usbrootfstype}
usbboot=setenv devnum ${usbdev}; setenv devtype usb; usb start ${usbdev}; if usb dev ${usbdev}; then if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run loadfdt; echo Booting from usb ${usbdev}...; run usbargs;bootz ${loadaddr} - ${fdtaddr}; fi;fi
usbdev=0
usbnet_devaddr=c4:be:84:cc:b9:7b
usbroot=/dev/sda2 rw
usbrootfstype=ext4 rootwait
vendor=ti
ver=U-Boot 2015.07 (Dec 17 2015 - 06:53:08 +0100)

  • Hi,

    Check this wiki: processors.wiki.ti.com/.../Linux_Core_U-Boot_User's_Guide You should also check your SYSBOOT settings.
  • Hi,

    as I wrote, I have  AM437x SK (Starter Kit). SYSBOOT options are hard-defined. As I can read from schematic sprr202.pdf (naming is confusing for me - AM437X_LCD_DATAx/SYSBOOTx) - SYSBOOT[4:0] is set to 11000b -> 1) MMC0, 2) USB_MS, 3) USB_CL, 4) QSPI.

    So I followed your wiki:

    U-Boot # mmc rescan
    U-Boot # fatload mmc 0 ${loadaddr} u-boot.bin
    U-Boot # sf probe 0
    U-Boot # sf erase 0x0 0x100000
    U-Boot # sf write ${loadaddr} 0x0 ${filesize}

    Instead of u-boot.bin I used u-boot.img. Everything was written to SPI Flash. (Don't I need MLO? It's because of XIP?)

    I don't fully understand next commands:

    U-Boot # sf probe 0
    U-Boot # sf read ${loadaddr} 0x1a0000 0x800000
    U-Boot # sf read ${fdtaddr} 0x100000 0x80000
    U-Boot # setenv bootargs console=${console} spi-ti-qspi.enable_qspi=1 root=/dev/mtdblock6 rootfstype=jffs2
    U-Boot # bootz ${loadaddr} - ${fdtaddr}

    So I tried to reboot the board (without SD Card or USB connected). No success.

    Do you have some hint for me? Thx.

    Btw in chapter "Boot Modes supported" in this wiki AM437x StarterKit QSPI Boot mode is not supported? Is it possible to use QSPI for booting on SK?

  • For some reason I can't get to the wiki. What I have done:

    make am43xx_evm_config

    make

    Copy MLO and u-boot.img to the SD Card.

    make distclean

    make am43xx_evm_qspiboot_config

    make

    Copy u-boot.bin to the SD Card. Boot the SD Card and flash u-boot.bin to the QSPI.

    Steve K.

  • Hi Steve,

    thank you for quick response!

    I already have SD Card with MLO and u-boot.img able to run u-boot on AM437x SK board.

    As I wrote, I'm using Yocto Poky (Fido). So I searched Yocto build (work) for u-boot.bin. I found something, so I tried to load it to QSPI Flash (see *1). Didn't worked for me.

    Then I cloned git://git.denx.de/u-boot.git, later on git://git.ti.com/ti-u-boot/ti-u-boot.git and tried to build it with poky toolchain (arm-poky-linux-gnueabi-...). Both compilations ended with error:

    make CROSS_COMPILE=arm-poky-linux-gnueabi- am43xx_evm_qspiboot_config
    make CROSS_COMPILE=arm-poky-linux-gnueabi-
    ...
      CC      examples/standalone/hello_world.o
      LD      examples/standalone/hello_world
    arm-poky-linux-gnueabi-ld.bfd: cannot find -lgcc
    make[2]: *** [examples/standalone/hello_world] Error 1
    make[1]: *** [examples/standalone] Error 2
    make: *** [examples] Error 2
    ...

    Then I tried to compile u-boot (git://git.ti.com/ti-u-boot/ti-u-boot.git) using Linaro toolchain (4.9) and I have bee succesfull (got u-boot.bin)

    -rw-rw-r--   1 user user  327528 Jan 28 13:21 u-boot.bin

    I copied this bin file to SD Card FAT partition. Run uboot from SD Card (MLO, u-boot.img) and tried to load u-boot.bin to QSPI Flash (I'm using serial console as terminal) as is described in "Writing to QSPI from U-Boot" step in wiki.

    (*1)

    U-Boot 2015.07 (Dec 17 2015 - 06:53:08 +0100)
    
    I2C:   ready
    DRAM:  1 GiB
    PMIC:  TPS65218
    NAND:  0 MiB
    MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
    reading uboot.env
    
    ** Unable to read "uboot.env" from mmc0:1 **
    Using default environment
    
    Net:   <ethaddr> not set. Validating first E-fuse MAC
    cpsw, usb_ether
    Hit any key to stop autoboot:  0
    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 ${loadaddr} u-boot.bin
    reading u-boot.bin
    327528 bytes read in 20 ms (15.6 MiB/s)
    U-Boot# sf probe 0
    SF: Detected MX25L51235F with page size 256 Bytes, erase size 64 KiB, total 64 MiB, mapped at 30000000
    U-Boot# sf erase 0x0 0x100000
    SF: 1048576 bytes @ 0x0 Erased: OK
    U-Boot# sf write ${loadaddr} 0x0 ${filesize}
    device 0 offset 0x0, size 0x4ff68
    SF: 327528 bytes @ 0x0 Written: OK
    U-Boot#

    Then I removed the SD Card, rebooted the board and I was expecting that it will boot from QSPI Flash. But no response on serial console. Do you have any idea what could be wrong?

    I hope that u-boot.bin in QSPI Flash doesn't need SPL (MLO) regards to XIP feature? (EDIT: here is answer https://e2e.ti.com/support/arm/sitara_arm/f/791/t/392796

    I'm not sure that I understand the second step "Booting from QSPI" step in wiki. These commands should I use in u-boot run from QSPI Flash, right? (but before this step I need to load kernel image to ${loadaddr}? dtb file ${fdtaddr}?)

    U-Boot # sf probe 0
    U-Boot # sf read ${loadaddr} 0x1a0000 0x800000
    U-Boot # sf read ${fdtaddr} 0x100000 0x80000
    U-Boot # setenv bootargs console=${console} spi-ti-qspi.enable_qspi=1 root=/dev/mtdblock6 rootfstype=jffs2
    U-Boot # bootz ${loadaddr} - ${fdtaddr}

    Thanks for your help!

    Ondra

  • Also I found this unanswered post https://e2e.ti.com/support/arm/sitara_arm/f/791/p/448893/1613676

    HOWEVER, the pure QSPI bootmode from ROM code does not seem to work. It does not seem to execute XIP from the QSPI NOR, even though the above proves that the code is flashed correctly. Is there something I am missing?? The SDCARD is removed, the QSPI flashed and then just power up, it should fall eventually into 0x30000000 and start executing, but I never see that. 

  • There was a bug in u-boot that is fixed in SDK 02.00.01.07. I just booted QSPI using u-boot from that SDK.

    Steve K.

  • Hi Steve,

    I downloaded latest SDK -  ti-processor-sdk-linux-am437x-evm-02.00.01.07-Linux-x86-Install.bin and installed it. In ti-processor-sdk-linux-am437x-evm-02.00.01.07/board-support/prebuilt-images/ folder is no u-boot.bin file? Which one have you used? Can you also send me commands for loading u-boot to QSPI Flash? I can't get it run..

    Thanks, Ondrej

  • You have to create u-boot.bin. Go into the u-boot source directory and type in

    make am43xx_evm_qspiboot_config

    make

    Then copy u-boot.bin to the SD card. You need MLO and u-boot.img from the pre-built to boot from the SD card and flash the u-boot.bin. Use the 'sf' commands to flash it.

    Steve K.

  • Hi,

    so I 'm able to run u-boot from QSPI Flash now (thanks Steve ;) ). I also wanted to try load and boot kernel from QSPI Flash.

    In posts above I mentioned this wiki with these steps:

    U-Boot # sf probe 0
    U-Boot # sf read ${loadaddr} 0x1a0000 0x800000
    U-Boot # sf read ${fdtaddr} 0x100000 0x80000
    U-Boot # setenv bootargs console=${console} spi-ti-qspi.enable_qspi=1 root=/dev/mtdblock6 rootfstype=jffs2
    U-Boot # bootz ${loadaddr} - ${fdtaddr}

    I'm missing here step(s) about writing kernel, dtb to QSPI Flash, so I did it this way

    * Load2RAM, erase, write to SPI Flash - zImage
    fatload mmc 0 ${loadaddr} zImage
    sf erase 0x1a0000 0x800000
    sf write ${loadaddr} 0x1a0000 0x800000
    * Load2RAM, erase, write to SPI Flash - DTB
    fatload mmc 0 ${fdtaddr} am437x-sk-evm.dtb
    sf erase 0x100000 0x80000
    sf write ${fdtaddr} 0x100000 0x80000

    After that I proceed steps from the wiki and bootz it. It eneded with 

    Kernel image @ 0x82000000 [ 0x000000 - 0x330750 ]
    ## Flattened Device Tree blob at 88000000
       Booting using the fdt blob at 0x88000000
       Loading Device Tree to 8fff1000, end 8ffff2c2 ... OK
    
    Starting kernel ...

    It was probably because I had no rootfs on QSPI, right? Becasue if i used this bootargs (with rootfs from SD Card)

    setenv bootargs console=${console} spi-ti-qspi.enable_qspi=1 ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}

    then I was able to start kernel and whole system.

    Can you tell me what is correct way how to load rootfs into the QSPI Flash? (Or is something else wrong?)

    Regrads, Ondra

  • I was trying it again and I realized that I can boot kernel from SPI Flash (with rootfs on SD Card) only if bootz from u-boot loaded from SD Card. (I hope that you understand me.. it's a little bit confusing..).
    1) (no SD Card inserted)->u-boot loaded from QSPI->read zImage+dtb to RAM from QSPI->set bootarg to spi-ti-qspi.enable_qspi=1 and SD Card rootfs->insert the SD Card because of rootfs->bootz->freeze on "Starting kernel ..."
    2) (SD Card inserted)->u-boot loaded from SD Card->read zImage+dtb to RAM from QSPI->set bootarg to spi-ti-qspi.enable_qspi=1 and SD Card rootfs->bootz->system is running

    Actually I'm still not able to boot entire OS from QSPI Flash.