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.

AWRL1432: Secondary Boot Loader cannot be executed in a task in freeRTOS.

Part Number: AWRL1432
Other Parts Discussed in Thread: UNIFLASH

Tool/software:

Also, SBL cannot be executed in a task in freeRTOS? Because I couldn't use it when testing.

Main code as follows

/*
* Copyright (C) 2024 Texas Instruments Incorporated
*
* All rights reserved not granted herein.
* Limited License.  
*
* Texas Instruments Incorporated grants a world-wide, royalty-free, 
* non-exclusive license under copyrights and patents it now or hereafter 
* owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
* this software subject to the terms herein.  With respect to the foregoing patent 
* license, such license is granted  solely to the extent that any such patent is necessary 
* to Utilize the software alone.  The patent license shall not apply to any combinations which 
* include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  
* No hardware patent is licensed hereunder.
*
* Redistributions must preserve existing copyright notices and reproduce this license (including the 
* above copyright notice and the disclaimer and (if applicable) source code license limitations below) 
* in the documentation and/or other materials provided with the distribution
*
* Redistribution and use in binary form, without modification, are permitted provided that the following
* conditions are met:
*
*	* No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any 
*     software provided in binary form.
*	* any redistribution and use are licensed by TI for use only with TI Devices.
*	* Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
*
* If software source code is provided to you, modification and redistribution of the source code are permitted 
* provided that the following conditions are met:
*
*   * any redistribution and use of the source code, including any resulting derivative works, are licensed by 
*     TI for use only with TI Devices.
*   * any redistribution and use of any object code compiled from the source code and any resulting derivative 
*     works, are licensed by TI for use only with TI Devices.
*
* Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or 
* promote products derived from this software without specific prior written permission.
*
* DISCLAIMER.
*
* THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
* IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdlib.h>
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_board_config.h"
#include "FreeRTOS.h"
#include "task.h"

#define MAIN_TASK_PRI  (configMAX_PRIORITIES-1)

#define MAIN_TASK_SIZE (1024U/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));

StaticTask_t gMainTaskObj;
TaskHandle_t gMainTask;

void sbl_main(void *args);

void freertos_main(void *args)
{
    sbl_main(NULL);

    vTaskDelete(NULL);
}


int main()
{
    /* init SOC specific modules */
    System_init();
    Board_init();

    /* This task is created at highest priority, it should create more tasks and then delete itself */
    gMainTask = xTaskCreateStatic( freertos_main,   /* Pointer to the function that implements the task. */
                                  "freertos_main", /* Text name for the task.  This is to facilitate debugging only. */
                                  MAIN_TASK_SIZE,  /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                  NULL,            /* We are not using the task parameter. */
                                  MAIN_TASK_PRI,   /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                  gMainTaskStack,  /* pointer to stack base */
                                  &gMainTaskObj ); /* pointer to statically allocated task object memory */
    configASSERT(gMainTask != NULL);

    /* Start the scheduler to start the tasks executing. */
    vTaskStartScheduler();

    /* The following line should never be reached because vTaskStartScheduler()
    will only return if there was not enough FreeRTOS heap memory available to
    create the Idle and (if configured) Timer tasks.  Heap management, and
    techniques for trapping heap exhaustion, are described in the book text. */
    DebugP_assertNoLog(0);

    return 0;
}

  • Hi Johnny,

    Thank you for reaching out. I would love to help but first need some information so that I can narrow in on what might be going on. Please let me know the answer to the following questions.

    • Which SDK are you using?
    • What failure are you seeing?
      • i.e. a hard fault somewhere, jumping to the wrong address, etc.
      • Is there any error code that you are receiving?
      • Is it failing before SBL main, after, during?

    Please answer above to the best of your knowledge. 

    Best,

    Vignesh K.

  • I refer to "radar_toolbox_2_30_00_12\source\ti\examples\Automotive_HandsFree_Access\Hands_Free_Access\Kick_to_Open" and "MMWAVE_L_SDK_05_05_03_00\examples\drivers\boot\sbl" example code.

    And add SBL function to Kick_to_Open project.

    The application image(any image) has been pre-burned in Partition 2, and the log will be displayed in the terminal when it is turned on.

    If the following main code is executed in the main task, it will not switch to Partition 2 for booting, and no log will be displayed in the terminal.

    /*
    * Copyright (C) 2024 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    * Limited License.  
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, 
    * non-exclusive license under copyrights and patents it now or hereafter 
    * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
    * this software subject to the terms herein.  With respect to the foregoing patent 
    * license, such license is granted  solely to the extent that any such patent is necessary 
    * to Utilize the software alone.  The patent license shall not apply to any combinations which 
    * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license (including the 
    * above copyright notice and the disclaimer and (if applicable) source code license limitations below) 
    * in the documentation and/or other materials provided with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided that the following
    * conditions are met:
    *
    *	* No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any 
    *     software provided in binary form.
    *	* any redistribution and use are licensed by TI for use only with TI Devices.
    *	* Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the source code are permitted 
    * provided that the following conditions are met:
    *
    *   * any redistribution and use of the source code, including any resulting derivative works, are licensed by 
    *     TI for use only with TI Devices.
    *   * any redistribution and use of any object code compiled from the source code and any resulting derivative 
    *     works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or 
    * promote products derived from this software without specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
    * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
    * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
    * POSSIBILITY OF SUCH DAMAGE.
    */
    
    #include <stdlib.h>
    #include <kernel/dpl/DebugP.h>
    #include "ti_drivers_config.h"
    #include "ti_board_config.h"
    #include "FreeRTOS.h"
    #include "task.h"
    
    #define MAIN_TASK_PRI  (configMAX_PRIORITIES-1)
    
    #define MAIN_TASK_SIZE (1024U/sizeof(configSTACK_DEPTH_TYPE))
    StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));
    
    StaticTask_t gMainTaskObj;
    TaskHandle_t gMainTask;
    
    //void gesture_recognition(void *args);
    void sbl_main(void *args);
    
    void freertos_main(void *args)
    {
        //gesture_recognition(NULL);
        sbl_main(NULL);
    
        vTaskDelete(NULL);
    }
    
    
    int main()
    {
        /* init SOC specific modules */
        System_init();
        Board_init();
    #if 0
        sbl_main(NULL);
    #else
        /* This task is created at highest priority, it should create more tasks and then delete itself */
        gMainTask = xTaskCreateStatic( freertos_main,   /* Pointer to the function that implements the task. */
                                      "freertos_main", /* Text name for the task.  This is to facilitate debugging only. */
                                      MAIN_TASK_SIZE,  /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                      NULL,            /* We are not using the task parameter. */
                                      MAIN_TASK_PRI,   /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                      gMainTaskStack,  /* pointer to stack base */
                                      &gMainTaskObj ); /* pointer to statically allocated task object memory */
        configASSERT(gMainTask != NULL);
    
        /* Start the scheduler to start the tasks executing. */
        vTaskStartScheduler();
    
        /* The following line should never be reached because vTaskStartScheduler()
        will only return if there was not enough FreeRTOS heap memory available to
        create the Idle and (if configured) Timer tasks.  Heap management, and
        techniques for trapping heap exhaustion, are described in the book text. */
        DebugP_assertNoLog(0);
    #endif
        return 0;
    }
    

    /**************************************************************************
     *************************** Function Definitions *************************
     **************************************************************************/
    void sbl_main(void *args)
    {
        /* Open drivers for peripherals*/
        Drivers_open();
        Board_driversOpen();
    
        int32_t retVal = MINUS_ONE;
    
        /* Configuring EDMA for Sending data to CRC engine */
        sbl_configureEdmaCrc();
    
        retVal = bootload_qspi(((uint32_t)M_META_SBL + (uint32_t)(0x80000U)));
        if (retVal == 0)
        {
            Board_driversClose();
            Drivers_close();
            Board_deinit();
            System_deinit();
            sbl_switchtoapp();
            while(1)
            {}
        }
    }

    bootload_qspi() cannot be executed in main task? Why?

  • I currently have no other ideas to solve this problem, do you have any other suggestions? Thanks!

  • Do you have any other suggestions or other approaches? Thanks!

  • Hey Johnny,

    Thank you for your patience. Could you try your example following the steps outlined here

    Do I understand correctly that you are using CCS to implement this? I think it may be easier to use UNIFLASH and just flash the device with all the correct images at once instead.

    I will get back to you on why the bootload_qspi function may not be working. I have to look further into this.

    Best,

    Vignesh K.

  • The current problem is as shown in the figure below. Setting "#if 1" works normally, but setting "#if 0" does not work?

    The secondary boot loader cannot be executed in a freeRTOS task?

  • Hi Johnny, 

    Thanks for your response. I am trying to understand your issue better and I want to know why you want to use FreeRTOS for this SBL image. Is there a reason you want FreeRTOS support for the SBL? Why did you remove the download portion of the sbl_main? 

    We don't support a FreeRTOS SBL, the reason for this is that there is a lot of overhead that needs to be de-initialized and re-initialized when switching over from the SBL example to be FreeRTOS compatible which ends up being difficult to implement. 

    Please try using the SBL as is, outlined here.

    Best,

    Vignesh K.

  • This is the question at the beginning of the title."Secondary Boot Loader cannot be executed in a task in freeRTOS."

  • Hi Johnny,

    We understand your interest in using FreeRTOS with our SBL example. However, as previously communicated, we do not officially support a FreeRTOS implementation for the secondary bootloader. We kindly suggest using the SBL noRTOS example as is. While we cannot provide direct support for integrating FreeRTOS with the SBL example, our team would be happy to assist you with any other inquiries or issues related to our officially supported configurations and examples. Please feel free to open a new thread or contact us if you have any further questions, otherwise I will be closing out this thread.

    Best,

    Vignesh K.