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.

am335x spiboot trouble

Other Parts Discussed in Thread: AM3358

hardware am3358

uboot:uboot201.01.01-psp06.00.00.00(sdk6.0)

1. accroding to the am335x uboot user's gudie.pdf ,i use the build command
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm O=am335x_evm am335x_evm_spiboot
to generate MLO , MLO.byteswap and u-boot.img, i copy all this file into sd card.
i set the sysboot[4:0]=10111(mmc0 spi0 uart0 usb0)

then i insert sd card into my board and powerup,when uboot is work, i use the command
to copy MLO.byteswap and u-boot.img to spi flash.

sf probe 0
sf erase 0 +e0000
mmc rescan
fatload mmc 0 0x82000000 MLO.byteswap
sf write 0x82000000 0 0x20000
fatload mmc 0 0x82000000 u-boot.img
sf write 0x82000000 0x80000 0x60000

now i power down my board and extract sdcard,and then i power up again, the board
can boot from spi,however, there seems to be 2 question:

1. when i moidfy the environment variables such as
setenv serverip 192.168.135.220

saveenv

then the terminal shows


-Boot# setenv serverip 192.168.135.220
U-Boot# saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...U-Boot#

when i repower up my board and use printenv command, i find the new environment variables
can't be saved

2.if i boor fromm sd,the ethernet is ok ,however when i boot from spi ,the the ethernet is
link up but i can't read or write file to nand by ftp?


why i encounter this trouble ,pls help me ,thanks?

  • You should find and check what saveenv does in your u-boot code. From what you post it seems that it only erases but does not write the changes to SPI.

  • Can some SW engineers help me?

  • I will bring this to the attention of the SW experts.

  • Hi,

    What I can to add is to see the following links:
    http://processors.wiki.ti.com/index.php?title=Update_U-Boot_Environment_Variables_stored_in_SPI_Flash_from_Linux
    http://downloads.ti.com/sitara_linux/esd/AM335xSDK/06_00_00_00/exports/sitara-linuxsdk-sdg-06.00.00.00.pdf

    BR
    Ivan

  • Hi,

    Are you sure that this offset in line is correct:
    fatload mmc 0 0x82000000 u-boot.img
    sf write 0x82000000 0x80000 0x60000
    I mean 0x80000 offset. See in the doc:
    #fatload mmc 0 ${loadaddr} u-boot.img
    # sf write ${loadaddr} 0x20000 ${filesize}

    BR
    Ivan


  • Hi, Ivan Matrakov

    1. my spi flash is ST M25P32,the first question has been solved by modifing the codes as belows:

    # define CONFIG_ENV_OFFSET (896 << 10) /* default: 892 << 10 */
    # define CONFIG_ENV_SECT_SIZE (64 << 10) /* default:4 << 10 */
    #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x80000 /* i don't change this*/

    this is because in the function spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len) of spi_flash.c

    if (offset % erase_size || len % erase_size) {
    debug("SF: Erase offset/length not multiple of erase size\n");
    return -1;
    }

    the offset is (896 << 10) ,the erase_size is (64 << 10) and the len is (64 << 10),so it will not execute the
    codes in the {}. and then it work.

    now i can modify the environment variables and save them in spi flash,i also can boot from spi flash.


    2. the second question makes me puzzled. the uboot command i use is as belows:

    sf probe 0
    sf erase 0 +e0000
    mmc rescan
    fatload mmc 0 0x82000000 MLO.byteswap
    sf write 0x82000000 0 0x20000
    fatload mmc 0 0x82000000 u-boot.img
    sf write 0x82000000 0x80000 0x60000

    so because #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x80000 then the offset is 0x80000.
    however the ture size of MLO.byteswap is 100549bytes(0x188c5) and the ture size of
    u-boot.img is 364376bytes(0x58f58).maybe i should use

    sf write 0x82000000 0 0x188c5 and sf write 0x82000000 0x80000 0x58f58

    does it work? i will try tomorrow and contact to you later.

  • Hi

    I hope this will work. Exactly this I mean in a previous post.

    BR
    Ivan

  • sorry , i  am disturbed by some other things, now i have solved this problem .the trobule is because  the boundary is not aligned when visiting the spi flash.