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.

MCU-PLUS-SDK-AM273X: Fail to boot APP if using freeRTOS in SBL

Other Parts Discussed in Thread: MCU-PLUS-SDK-AM273X
  • Part Number: MCU-PLUS-SDK-AM273X

Hi,

My customer modified the SBL to support freeRTOS, but failed to boot APP. Do you have any idea on this problem?

I am trying to reproduce the problem. Can we still use below way to debug freeRTOS SBL in CCS?

(2) [FAQ] MCU-PLUS-SDK-AM243X: How to debug sbl_qspi (for am263 and am273) or sbl_ospi (for am243) or an application which is booted via OSPI/QSPI boot ? - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

Thanks,

Chris

  • Hi ,

    My customer modified the SBL to support freeRTOS, but failed to boot APP. Do you have any idea on this problem?

    The bootloader files are not built for freertos driver libraries. SBL is not supported OOB with RTOS.

    Can we still use below way to debug freeRTOS SBL in CCS?

    Yes, this can be used for the same.

    Best Regards,
    Aakash

  • Aakash,

    The bootloader files are not built for freertos driver libraries.

    My understand on the function flow of SBL is to read app image on flash and copy it to ram. Change interrupt vector table and then reset the core to restart from APP.

    What's the difference with these functions to implement on noOS or freeRTOS?

    Thanks, 

     Chris

  • Hi ,

    We neither support nor have we tested the flow with FreeRTOS. Its too early to predict any problems. But what API are you facing the problem or is failing for you ?

    Best Regards,
    Aakash

  • Aakash,

    I did more test these days. Pls find more detail info below.

    1. I modified the freertos empty demo in mcu_plus_sdk_am273x_08_04_00_17 to support SBL feature. Pls find my test project below.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/empty_5F00_am273x_2D00_evm_5F00_r5fss0_2D00_0_5F00_freertos_5F00_ti_2D00_arm_2D00_clang.7z

    Due to fail to boot the APP with above SBL and easy to debug, I disabled the DMA feature in QSPI in above project. 

    2. With above SBL, if the APP is big, such as mmw demo in mmwave mcu plus sdk. The code will run abnormal during the flash reading of 2nd big section of mss code of APP.

    3. If I use small APP like hello example, the flash read work ok. But the code will hang in semaphore pend in DebugP_log after flash read.

     SemaphoreP_pend(&gDebugLogLockObj, SystemP_WAIT_FOREVER);

    Would you pls help to check what I may miss in this SBL with freeRTOS?

    Thanks,

    Chris

  • Hi ,

    Thanks for these details. Let me work through this and get more information. ETA : 02/27/2023

    Best Regards,
    Aakash

  • Askash,

    Any update?

    Thanks,

    Chris

  • HI Chris Meng

    Please expect a delay in response as we are still working on this. The expert is Out of Office and will get back to you shortly.

    Regards

    Sri Vidya

  • Hi ,

    We are working on a Flash Example with FreeRTOS to predict if there are any issues with the same or not.

    Best Regards,
    Aakash

  • Our product is about to be produced, but the function of freertos boot jumping to app is still blocked. Please help to raise the priority of this problem and help to put it into position. Thank you very much.

  • Aakash,

    This issue has opened for long time. Would you pls help to give an estimated feedback date?

    Thanks,

    Chris

  • Hi ,

    Let me work on this on highest priority. I expect to close this before 10th March.

    Best Regards,
    Aakash

  • Hi ,

    A few clarifications are required here -

    What is the memory map of the applications in the device ? Is it like this ?

    I tried this and it worked for me (on AM263x). Can you share your memory map so I can try the same on AM273x-EVM as well ?

    Best Regards,
    Aakash

  • I tried this and it worked for me (on AM263x).

    Did you use the sbl with freertos I shared and hello word project?

    Can you share your memory map so I can try the same on AM273x-EVM as well ?

    Do you mean the map of sbl with freertos?

    Thanks,

    Chris

  • Aakash,

    Below is map info of mmw demo.

    R5f:

    dsp:

    APP image file:
    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/am273x_5F00_mmw_5F00_demoTDM.appimage

    Thanks,

    Chris

  • Hi ,

    Did you use the sbl with freertos I shared and hello word project?

    Yes. I also had to disable the eDMA. I will discuss this internally though.

    Do you mean the map of sbl with freertos?

    No. In fact I would like to know what is location for Application in memory and also the SBL QSPI which I will assume to be at the start of MSS_L2 of 200KB (at max). 

    Best Regards,
    Aakash

  • I also had to disable the eDMA.

    There is an issue on qspi driver for EDMA and it is fixed in 8.5 release.

    No. In fact I would like to know what is location for Application in memory and also the SBL QSPI which I will assume to be at the start of MSS_L2 of 200KB (at max).

    sbl with freertos project uses the cmd file from defulat noOS sbl. The map file is similar.

    For APP, I think the map file provides the info you need. Pls let me know if you need other info.

    Thanks,

    Chris

  • Hi ,

    I think now I am clear of what you are attempting. I will try this experimentation on my end but I would like to know why are you integrating OS in your bootloader ?

    BR,
    Aakash 

  • Aakash,

    Customer need to add ethernet support in SBL. 

    Thanks,

    Chris

  • Hi ,

    The LwIP support is available for no-rtos as well in release 08.05. I think it might be much better option rather then working your bootloader code to Free-RTOS. Bootloader is suppose to be a startup code which will boot the main application but OS (in embedded systems) is suppose to be an never ending loop.

    Are you sure customer is okay with this path ?

    Best Regards,
    Aakash

  • Aakash,

    Customer also met issue with bare Matel LWIP driver in SBL.

    Pls kindly help on this sbl with freeRTOS case. I think this is also helpful for other customers who need to use freertos in SBL later.

    Thanks,

    Chris

  • AaKash,

    Please inform us of the progress as soon as possible. 

    Thanks.

  • Hi /,

    We have a working example with SBL QSPI with FreeRTOS - https://tidrive.ext.ti.com/u/4Z_8S9Qf_FXzn_xG/43231052-04f1-40d7-8d39-dddc93e40714?l

    Please try the same and let me know if you need any more help.

    Best Regards,
    Aakash

  • Thanks.We will verify as soon as possible. We want to know why freertos sbl failed to boot before. Is it related to the image size of sbl or app?

  • Hi ,

    Although I could not root cause the problem in the application shared. The primary reason that comes in my mind is basic initialization of OS requires stable RTI clock which was not available during the boot or before the PLL config and this might be causing failures.

    Best Regards,
    Aakash

  • Project file cannot be used directly, prompt meta-data cannot be interpreted.I compared the difference with the original sbl project. The link in the project you provided is nortos.am273x.r5f.ti-arm-clang.release.lib(shown in .cproject).Whether the project is provided incorrectly?Thanks.

  • Hi ,

    I have updated the link for project that builds with CCS - https://tidrive.ext.ti.com/u/r1mKD5rZiha9WYoC/dc5e3029-8bf7-4c2c-a5fe-c537ce49f201?l

    Hope it helps,

    Aakash

  • Can you base on mcu_ plus_ sdk_ am273x_ 08_ 04_ 00_ 17 solve the problem that freertos sbl can't boot apps? Our board is currently in 08_05_00_24 There are still problems with network functions.Thanks.

  • Hi ,

    You can simply change the mcu_plus_sdk to 08_ 04_ 00_17 in CCS. Is there any other issues with the SBL application on 08_ 04_ 00_17 ?

    Best Regards,
    Aakash

  • I tried in 08_ 04_ 00_17, only two letters of St were printed and then hung up. Can you test tried in 08_ 04_ 00_17? thanks.

  • Aakash,

    Pls find current debug status below.

    1. freertos sbl +hello world project: hello world still hangs.

    I can see sbl output on serial port, but no hello world print. Then I connected R5F and loaded hello world symbol.

    2. Then I reset cpu in CCS and run again. Then I can see "Hello World" in serial terminal. 

    It seems the hello world app image is copied to ram correctly. 

    Would you pls help again?

    Thanks,

    Chris 

  • Hi Chris,

    I found two issues with the SDK with FreeRTOS added.

    First issue: UART_flushTxFifo() is called after the image is loaded.

    UART_flushTxFifo() calls TaskP_yield() when the UART FIFO isn't empty but there hasn't been a timeout.

    TaskP_yield() calls SVC, which causes an SVC exception.

    The FreeRTOS SVC exception handler would normally invoke the FreeRTOS scheduler. However, the application has already been loaded, so the application SVC handler is invoked instead. The SVC handler is an infinite loop and the code hangs.

    Second issue: interrupts are active just before the call to Bootloader_runSelfCpu()

    The RTI timer (OS tick) IRQ & EDMA IRQ are active.

    This causes call to IRQ handler to be called through VIM/VIC interface.

    The IRQ handler includes an SVC call, which causes an SVC exception.

    The SVC exception handler is the application SVC handler, so the code hangs.

    There are probably more elegant solutions to this, but for now I did the following:

    1. comment out UART_flushTxFifo()
    2. disable and clear enabled IRQs & globally disable IRQs before call to R5F reset.

    This seems to work.

    I've attached my CCS project below. I built the code for AM273x and used MCU+SDK 08.05. I tested the code on an AM273x EVM Rev C.

    Regards,
    Frank

    sbl_qspi_am273x-evm_r5fss0-0_freertos_ti-arm-clang.zip

  • I tried the project you gave, but there is only “Starting QSPI Bootloader...".

    I wonder if there is a difference between our 0805 sdk.

    I have provided the syscfg for our board. Can I recompile the tiimage image based on this syscfg and provide it? I will try again.

    /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --device "AM273x" --package "ZCE" --part "Default" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM273x.evmAM273x@08.05.00"
     * @versions {"tool":"1.14.0+2667"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const flash       = scripting.addModule("/board/flash/flash", {}, false);
    const flash1      = flash.addInstance();
    const bootloader  = scripting.addModule("/drivers/bootloader/bootloader", {}, false);
    const bootloader1 = bootloader.addInstance();
    const edma        = scripting.addModule("/drivers/edma/edma", {}, false);
    const edma1       = edma.addInstance();
    const hsmclient   = scripting.addModule("/drivers/hsmclient/hsmclient", {}, false);
    const hsmclient1  = hsmclient.addInstance();
    const clock       = scripting.addModule("/kernel/dpl/clock");
    const debug_log   = scripting.addModule("/kernel/dpl/debug_log");
    const mpu_armv7   = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
    const mpu_armv71  = mpu_armv7.addInstance();
    const mpu_armv72  = mpu_armv7.addInstance();
    const mpu_armv73  = mpu_armv7.addInstance();
    const mpu_armv74  = mpu_armv7.addInstance();
    const mpu_armv75  = mpu_armv7.addInstance();
    const mpu_armv76  = mpu_armv7.addInstance();
    const mpu_armv77  = mpu_armv7.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    bootloader1.$name          = "CONFIG_BOOTLOADER0";
    bootloader1.appImageOffset = "0x000A0000";
    
    flash1.$name                  = "CONFIG_FLASH0";
    bootloader1.flashDriver       = flash1;
    flash1.device                 = "CUSTOM_FLASH";
    flash1.fname                  = "XM25QH64C";
    flash1.flashManfId            = "0x20";
    flash1.peripheralDriver.$name = "CONFIG_QSPI0";
    
    hsmclient1.$name = "CONFIG_HSMCLIENT0";
    
    debug_log.enableUartLog               = true;
    debug_log.enableCssLog                = false;
    debug_log.uartLog.$name               = "CONFIG_UART0";
    debug_log.uartLog.intrEnable          = "DISABLE";
    debug_log.uartLog.MSS_UART.$assign    = "MSS_UARTA";
    debug_log.uartLog.MSS_UART.RX.$assign = "ball.U3";
    debug_log.uartLog.MSS_UART.TX.$assign = "ball.W2";
    
    debug_log.uartLog.edmaConfig       = edma1;
    edma1.$name                        = "CONFIG_EDMA0";
    flash1.peripheralDriver.edmaConfig = edma1;
    edma1.instance                     = "EDMA_MSS_A";
    edma1.edmaRmDmaCh[0].resourceType  = scripting.forceWrite("ownDmaCh");
    edma1.edmaRmDmaCh[0].$name         = "CONFIG_EDMA_RM0";
    edma1.edmaRmQdmaCh[0].$name        = "CONFIG_EDMA_RM1";
    edma1.edmaRmTcc[0].$name           = "CONFIG_EDMA_RM2";
    edma1.edmaRmParam[0].$name         = "CONFIG_EDMA_RM3";
    edma1.edmaRmReservedDmaCh[0].$name = "CONFIG_EDMA_RM4";
    
    mpu_armv71.$name        = "CONFIG_MPU_REGION0";
    mpu_armv71.attributes   = "Device";
    mpu_armv71.allowExecute = false;
    
    mpu_armv72.$name = "CONFIG_MPU_REGION1";
    mpu_armv72.size  = 15;
    
    mpu_armv73.$name    = "CONFIG_MPU_REGION2";
    mpu_armv73.baseAddr = 0x80000;
    mpu_armv73.size     = 15;
    
    mpu_armv74.$name    = "CONFIG_MPU_REGION3";
    mpu_armv74.baseAddr = 0x10200000;
    mpu_armv74.size     = 20;
    
    mpu_armv75.$name        = "CONFIG_MPU_REGION4";
    mpu_armv75.baseAddr     = 0x102E0000;
    mpu_armv75.size         = 16;
    mpu_armv75.attributes   = "NonCached";
    mpu_armv75.allowExecute = false;
    
    mpu_armv76.$name    = "CONFIG_MPU_REGION5";
    mpu_armv76.baseAddr = 0xC3000000;
    mpu_armv76.size     = 14;
    
    mpu_armv77.$name    = "CONFIG_MPU_REGION6";
    mpu_armv77.size     = 14;
    mpu_armv77.baseAddr = 0xC3800000;
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    flash1.peripheralDriver.MSS_QSPI["0"].$suggestSolution = "ball.C2";
    flash1.peripheralDriver.MSS_QSPI["1"].$suggestSolution = "ball.D2";
    flash1.peripheralDriver.MSS_QSPI["2"].$suggestSolution = "ball.D1";
    flash1.peripheralDriver.MSS_QSPI["3"].$suggestSolution = "ball.E2";
    flash1.peripheralDriver.MSS_QSPI.$suggestSolution      = "MSS_QSPI0";
    flash1.peripheralDriver.MSS_QSPI.CLK.$suggestSolution  = "ball.E1";
    flash1.peripheralDriver.MSS_QSPI.CS.$suggestSolution   = "ball.F2";
  • Hi Gmsy,

    I'm using the installed SDK 08.05. I haven't made any modifications to it.

    Can I recompile the tiimage image based on this syscfg and provide it?

    I don't understand. Are you asking me to recompile?

    Regards,
    Frank

  • Hi Gmsy,

    I get this UART log:

    Starting QSPI Bootloader ...
    [BOOTLOADER_PROFILE] Boot Media       : NOR SPI FLASH
    [BOOTLOADER_PROFILE] Boot Media Clock : 80.000 MHz
    [BOOTLOADER_PROFILE] Boot Image Size  : 64 KB
    [BOOTLOADER_PROFILE] Cores present    :
    r5f0-0
    [BOOTLOADER PROFILE] System_init                      :        160us
    [BOOTLOADER PROFILE] Drivers_open                     :         32us
    [BOOTLOADER PROFILE] Board_driversOpen                :       2558us
    [BOOTLOADER PROFILE] CPU load                         :      58193us
    [BOOTLOADER_PROFILE] SBL Total Time Taken             :      60946us

    Image loading done, switching to application ...
    Hello World!

    Here I'm using the SBL-FreeRTOS project I shared above. For the application, I'm using the FreeRTOS version of the hello world project: https://software-dl.ti.com/mcu-plus-sdk/esd/AM273X/08_05_00_24/exports/docs/api_guide_am273x/EXAMPLES_HELLO_WORLD.html

    I've attached the project below.

    Regards,
    Frank

    hello_world_am273x-evm_r5fss0-0_freertos_ti-arm-clang.zip

  • Frank and Aakash,

    Thanks a lot for your kindly help! Now I can boot freertos sbl (8.05) + hello world app well.

    For 8.04, I changed uart to polling mode as Aakash suggested and it also works well.

    Best Regards,

    Chris

  • Frank,

    Customer added ethernet open in the freeRTOS sbl and then failed to boot the app again. Below is my suggestion for current issue. Would you pls kindly check and give your comment?

    1. save mss vector table to variable and not copy to memory during Bootloader_loadCpu(bootHandle, &bootImageInfo.cpuInfo[CSL_CORE_ID_R5FSS0_0]);

    2, after mss image read from flash to memory, do driver close.

    3. disable HWI.

    4. copy mss vector table to memory

    5. reset mss core

    Thanks,

    Chris

  • Hi Chris,

    I'm reassigning this to Aakash since he our boot expert.

    Regards,
    Frank

  • Hi Chris,

    1. save mss vector table to variable and not copy to memory during Bootloader_loadCpu(bootHandle, &bootImageInfo.cpuInfo[CSL_CORE_ID_R5FSS0_0]);

    Are you copying all the sections of the software ?

    4. copy mss vector table to memory

    As this is MSS, the address is suppose to be 0x0.

    The flow looks good to me. What is the failure point for you here ?

    Best Regards,
    Aakash