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.

spi flash boot

I am working on a custom board based on AM335x and SDK 6.0.0.0. The board has a Macronix MX25L3206D spi flash. I have implemented this flash into u-boot and linux kernel and it seems working quite well. Below is the log.

For u-boot:

=======

U-Boot# sf probe 0:0
SF: Detected MX25L3206D with page size 64 KiB, total 4 MiB

U-Boot#

=====

For linux kernel:

============

root@am335x-evm:~# dmesg |grep -i spi
[ 1.238906] m25p80 spi1.0: mx25l3206d (4096 Kbytes)
[ 1.244305] Creating 5 MTD partitions on "spi_flash":
root@am335x-evm:~#

===========

I can read/write the spi nor flash without any problems.

I then dd the MLO and uboot.bin into /dev/mtd0 and /dev/mtd1 during SD boot and config the SYSBOOT to spi boot properly. However, I cannot see the device boot up. 

My question is: What will be the correct steps to bring the device up from spi nor flash? I also tried the MLO.byteswap and still no lucks. Thanks.

-Eric

  • Hi,

    Here are the instructions for compiling the bootloaders for SPI boot and booting from SPI: http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#SPI_2

    You need to compile the bootloaders with the am335x_evm_spiboot option.

    Do you get any serial output when you try to boot from SPI?

    Best regards,
    Miroslav

  • Miroslav,

    I see. I didn't compile the bootloader with am335x_evm_spiboot option. I didn't see the serial output. I will give this a try.

    -Eric

  • Mirolav,

    I compiled the uboot with am335x_evm_spiboot option. Copy the MLO.byteswap and u-boot.img (rename as u-boot.img.spi) into the SD card. At uboot, I performed:

    ========

    U-Boot# mmc rescan; mw.b 0x82000000 0xFF 0x20000; fatload mmc 0 0x82000000 MLO.byteswap; sf probe 0:0; sf erase 0x0 0x20000; sf write 0x82000000 0x0 0x20000
    reading MLO.byteswap
    103812 bytes read in 16 ms (6.2 MiB/s)
    SF: Detected MX25L3206D with page size 64 KiB, total 4 MiB
    SF: 131072 bytes @ 0x0 Erased: OK
    SF: 131072 bytes @ 0x0 Written: OK
    U-Boot# mmc rescan; mw.b 0x82000000 0xFF 0x40000; fatload mmc 0 0x82000000 u-boot.img.spi; sf probe 0:0; sf erase 0x20000 0x60000; sf write 0x82000000 0x20000 0x60000
    reading u-boot.img.spi
    358224 bytes read in 46 ms (7.4 MiB/s)
    SF: Detected MX25L3206D with page size 64 KiB, total 4 MiB
    SF: 393216 bytes @ 0x20000 Erased: OK
    SF: 393216 bytes @ 0x20000 Written: OK
    U-Boot#

    ==========

    As of now, it seems fine.

    Then I switched the boot select to spi boot and reboot. I still cannot see any characters from my serial port. Any idea?

    -Eric

  • Please verify the contents of your SPI flash.

    Read the first N bytes of the SPI flash into RAM from U-Boot:

    sf read 0x82000000 0 100

    Then dump that part of the memory:

    md.b 0x82000000 100

    Then hexdump the contents of the MLO (first N bytes) in your build folder and compare them to the contents of the SPI flash:

    hexdump -C -n 256 MLO

    Best regards,
    Miroslav

  • Miroslav,

    At boot:

    =====

    U-Boot# sf read 0x82000000 0 100
    SF: 256 bytes @ 0x0 Read: OK
    U-Boot# md.b 0x82000000 100
    82000000: 00 00 00 40 00 00 00 0c 00 00 00 00 00 00 00 00 ...@............
    82000010: 00 00 00 00 45 53 48 43 4e 49 54 54 00 00 53 47 ....ESHCNITT..SG
    82000020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
    82000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
    82000040: c0 c0 c0 c1 00 00 01 00 00 00 00 00 00 00 00 00 ................
    82000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    82000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    82000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    82000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    82000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    820000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    U-Boot#

    ==========

    There is no hexdump command in uboot. I boot into arago rootfs.

    ==========

    root@am335x-evm:~# mount /dev/mmcblk0p1 /mnt
    root@am335x-evm:~# hexdump -C -n 256 /mnt/MLO.byteswap
    00000000 00 00 00 40 00 00 00 0c 00 00 00 00 00 00 00 00 |...@............|
    00000010 00 00 00 00 45 53 48 43 4e 49 54 54 00 00 53 47 |....ESHCNITT..SG|
    00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
    *
    00000040 c0 c0 c0 c1 00 00 01 00 00 00 00 00 00 00 00 00 |................|
    00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    *
    00000100
    root@am335x-evm:~#

    ===========

    Any idea?

    -Eric

  • Miroslav,

    BTW, I also used a scope to measure the spi0_clk and spi0_cs0# signals. The SYSBOOT seems fine. I did saw the clock and chip select signals.

    -Eric

  • Miroslav,

    I can see characters from serial port now. It is very weird. It seems that only the MLO.byteswap generated from EZSDK will be working. I was using BBB's uboot with the kernel from EZSDK. When I hexdump and compared the MLO.byteswap file generated from the BBB's uboot and EZSDK, the are exactly the same as my previous post. However, the outputs of md5sum are not the same. Did you know the why??

    I have another question. My console port is uart3. My uboot make option was am335x_evm_uart3. When I tried the spi boot, the make option became am335x_evm_spiboot. This will force my debug port to default uart0. How can I have spiboot and uart3 as debug port at the same time? I tried am335x_evm_uart3_spiboot or am335x_evm_spiboot_uart3. Both gave me an unknown option. 

    Thanks.

    -Eric

  • Hi Eric,

    The hex dumps from the MLO files seem fine. I can't explain why the md5sums are different.

    Please try these exact commands to flash the SPI flash with the images. The offset of the u-boot.img is 0x80000 and not 0x20000:

    U-Boot# sf probe 0
    SF: Detected W25Q64 with page size 4 KiB, total 8 MiB
    U-Boot# mmc rescan
    U-Boot# sf erase 0 +80000
    U-Boot# fatload mmc 0 0x82000000 MLO.byteswap
    reading MLO.byteswap
    100965 bytes read in 15 ms (6.4 MiB/s)
    U-Boot# sf write 0x82000000 0 0x20000
    U-Boot# fatload mmc 0 0x82000000 u-boot.img.spiboot
    reading u-boot.img.spiboot
    364572 bytes read in 45 ms (7.7 MiB/s)
    U-Boot# sf write 0x82000000 0x80000 0x60000

    Then stop the board, change the sysboot switches for SPI boot and turn the board on.

    Regarding your second question, there are no am335x_evm_uart3_spiboot or am335x_evm_spiboot_uart3 make options. To view all the U-Boot make options please do the following:

    cat <u-boot_dir>/boards.cfg | grep am335x

    This will list all the options:

    am335x_evm                   arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1
    am335x_evm_nor               arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,NOR
    am335x_evm_norboot           arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,NOR,NOR_BOOT
    am335x_evm_spiboot           arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,SPI_BOOT
    am335x_evm_uart1             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL2,CONS_INDEX=2
    am335x_evm_uart2             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL3,CONS_INDEX=3
    am335x_evm_uart3             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL4,CONS_INDEX=4
    am335x_evm_uart4             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL5,CONS_INDEX=5
    am335x_evm_uart5             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL6,CONS_INDEX=6
    am335x_evm_usbspl            arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,SPL_USBETH_SUPPORT
    am335x_evm_restore_flash     arm    armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,RESTORE_FLASH
    am335x_evm_restore_flash_usbspl   arm    armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,RESTORE_FLASH,SPL_USBETH_SUPPORT
    am335x_evm_uart_usbspl       arm    armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,UART_THEN_USB_SPL,SPL_USBETH_SUPPORT
    am335x_evm_restore_flash_uart_usbspl       arm    armv7       am335x              ti             am33xx      am335x_evm:SERIAL1,CONS_INDEX=1,RESTORE_FLASH,UART_THEN_USB_SPL,SPL_USBETH_SUPPORT

    I guess you can modify the am335x_evm_spiboot option to display the serial console on UART3 port.

    Best regards,
    Miroslav