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.

RTOS/PROCESSOR-SDK-AM437X: Bootloader and QSPI flash

Part Number: PROCESSOR-SDK-AM437X

Tool/software: TI-RTOS

My board shall boot from a SD card or QSPI flash. The sysboot pins configuration provide this information to the ROM Bootloader.

If the SD card is present, the bootloader shall load the image file from the SD card into the QSPI flash. If the SD card is not present, the MPU shall execute the software that is stored in the QSPI flash (copy it to the RAM and run it from there).

For the AM437x Starter Kit board, I already use the file \pdk_am437x_1_0_7\packages\ti\starterware\binary\bootloader\bin\am43xx-evm\gcc\bootloader_boot_mmcsd_a9host_release_ti.bin to create a SD card that copies the application image to RAM and executes it.

The document processors.wiki.ti.com/.../AM437x explains how to use CCS to load the QSPI flash.

But, how do I create a SD card that loads the application in the QSPI flash?
 
Installed items:
CCS 7.2
GCC ARM Compiler 4.9.3
processor_sdk_rtos_am437x  4.00.00.04
am437x PDK v1.0.7
bios 6.46.05.55
xdctools 3.32.02.25_core
Board: AM437x Starter Kit

regards,

Marcio

  • Do you mean that you want to program the QSPI flash without using CCS but using SD card only ? If that is the use case, it would require you to convert QSPI flash writer to SD bootable binary (similar to your SD boot MLO) which reads the boot, app and the config file to flash the QSPI flash. QSPI flashwriter is using DDR so ROM bootloader can`t load it directly into DDR so you should configure it to run from OCMC RAM and initialize DDR if data needs to copied into DDR before loading to QSPI flash.

    Alternate option is to use SD bootloader MLO and configure the QSPI flash writer as your SD card "app". The MLO with initialize the device, DDR and pinmux and load the QSPI flash writer and then read the boot, QSPI "app" and config file. Note the QSPI "app" file will need to be renamed in this case as the QSPI flash writer will be named as app when booting this from SD card.

    Either ways you will need modifications to the existing boot setup to achieve this functionality.

    Regards,
    Rahul
  • Thanks for your reply Rahul.

    My requirement match with the second option.

    So, I need to use a SD bootloader (bootloader_boot_mmcsd_a9host_release_ti.bin renamed to MLO) to load and run the QSPI flash writer (app). The QSPI flash writer must seek my application on the SD card and write it in the QSPI flash. Then, I have to remove the SD card, power-cycle the board and the primary bootloader copies the program in the flash to the DDR and run it.

    Does the primary bootloader copy the program in the flash to the DDR and run it? or Do I need something more?

    The folder c:\ti\pdk_am437x_1_0_7\packages\ti\starterware\binary\bootloader\bin\am43xx-evm\gcc\ has several images. What does bootloader_boot_qspi_a9host_release_ti.bin do?

    regards,
    Marcio.
  • Marcio,

    Just for additional clarification, I would like to re-enforce the system boot details on these devices. Using the bootloader from Processor SDK RTOS is always 2 stage boot. Primary bootloader is the ROM bootloader and secondary bootloader is the bootloader from the the SDK

    The two stages boot process in Processor SDK RTOS :

    BOOT Stage I : ROM bootloader(RBL) loads SBL into device on chip memory only.

    BOOT Stage II : Secondary bootloader loads application into DDR memory.

    Note: ROM bootloader resides on the on chip ROM and can`t be modified (Description in Initialization chapter of Technical reference manual)

    Secondary bootloader is the bootloader that we provide in the Processor SDK RTOS and is user level bootloader and can be modified/debugged.

    Answers to your question:

    Marcio Borges said:
    Does the primary bootloader copy the program in the flash to the DDR and run it? or Do I need something more?

    Primary bootloader (ROM bootloader) can only load code into on chip memory hence we need a secondary bootloader to load application in DDR. ROM bootloader on the device loads the secondary bootloader which is MLO  for SD boot) and  bootloader_boot_qspi_a9host_release_ti.bin for QSPI boot

    Marcio Borges said:
    The folder c:\ti\pdk_am437x_1_0_7\packages\ti\starterware\binary\bootloader\bin\am43xx-evm\gcc\ has several images. What does bootloader_boot_qspi_a9host_release_ti.bin do?

    This bootloader needs to reside on the QSPI flash at offset 0x000000 and the application in flash should be flashed at  0x80000. When device boots in QSPI mode, the ROM code will read the bootloader_boot_qspi_a9host_release_ti.bin from offset 0x000000 and load in into  on chip memory and pass control to this secondary bootloader. This will then setup the pinmux, PLL and DDR and then copy the application from offset 0x80000 and load into DDR memory.

    More details: processors.wiki.ti.com/.../AM437x

    Hope this provides some clarification.

  • Thanks again Rahul.

    I beleive I undestood the work involved. Just to confirm...

    In the SD card, the "MLO" file is "bootloader_boot_mmcsd_a9host_release_ti.bin".
    The "app" is a modified version of "QSPI flash writer" program.
    2 more files needed to be added to the card: "bootloader_boot_qspi_a9host_release_ti.bin" and my application, both renamed in such a way that the length of name is less than 9 characters.

    Thus, if the boot is configured to the SD card, the ROM bootloader loads and runs "MLO".
    The MLO then loads and runs the "app" on the DDR, which is the "QSPI flash writer".
    The flash writer reads the "bootloader_boot_qspi_a9host_release_ti.bin" file from the card and writes it to the flash (at offset 0x000000).
    In the same way, the flash writer reads my application from the card and writes to the flash (at offset 0x80000).

    If the boot is configured to the QSPI , the ROM bootloader loads and runs " bootloader_boot_qspi_a9host_release_ti.bin", that loads and runs my application on the DDR.

    Where can I find the "QSPI flash writer"? What does need to be changed?

    regards,
    Marcio.
  • Hi Rahul,
    Have you had a chance to look into this?
    regards,
    Marcio

  • Marcio,

    the QSPI flash writer source is available here:
    PDK_INSTALL_DIR\packages\ti\starterware\examples\qspi\flash_writer

    There prebuilt binary is available here:
    PDK_INSTALL_DIR\packages\ti\starterware\starterware\binary\qspi_app_flash_writer\bin\am43xx-evm

    and config file is provided here:
    PDK_INSTALL_DIR\packages\ti\starterware\tools\qspi

    To convert qspi flash writer to .out to bootable application you can used the following.
    <TOOLCHAIN_A8>/bin/arm-none-eabi-objcopy -O binary %APP_NAME%.out %APP_NAME%.bin
    PDK_INSTALL_DIR/packages/ti/starterware/tools/ti_image/tiimage.exe 0x80000000 NONE %APP_NAME%.bin app )

    Note when you do everything from the SD card, you need to make sure that there is no dependency on reading any file over JTAG and also since you have 2 app files, one of them needs to be renamed

    Here are the 2 apps, I am referring to :
    * app (flash writer application): bootloader source hard codes name of the app it reads from SD so you need to leave this as is.
    * app (production application image): rename this app to app_prod and in the config file. check code in flash writer from line 295 to line 350 . If you modify the name in the config, I believe no code change is required.

    Regards,
    Rahul
  • Thank you very much Rahul.

  • Hi,
    Just to let you know, the QSPI flash load and boot discussed on this thread are working very well.

    The only changes I had to make was to remove the id memory check from the bootloaders because my board does not have an id memory.

    Thanks again.