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.

CC1312R: Problem jumping from custom bootloader to application

Part Number: CC1312R
Other Parts Discussed in Thread: SYSCONFIG

Hi,

I am trying to develop a custom bootloader. I am using SDK 3.40. The bootloader is based on the nvsinternal example project. I am using the default memory

map for the bootloader and am using TI-RTOS.

My application is also using TI-RTOS. The FLASH_BASE address has been changed from 0x0 to 0x12000 in my .cmd file. In the .cfg file for the TI-RTOS project

I have added:

m3Hwi.resetVectorAddress = 0x12000;

and commented out:

//var ROM = xdc.useModule('ti.sysbios.rom.ROM');

//ROM.romName = ROM.CC13X2V2;

The link map for my application looks fine. In my bootloader I added:

void (*func_ptr)(void) = 0x1cbd9;

(*func_ptr)();

When using the above jump address (address of _c_int00) it does jump there but ends up with an invalid PC exception at a different address. I also tried jumping directly to

the ResetISR address (0x12000) and it encountered an invalid state error at that address.

Is there something else I need to do in order to jump from one TI-RTOS application (bootloader) and jump to another application and re-initialize from scratch?

Victor

  • Hi Victor,

    I would highly recommend that you take a look at the BIM examples in the SDK (<SDK>/examples/nortos/CC1312R1_LAUNCHXL/bim/) on how you correctly setup and jump to the reset ISR in your application from the bootloader.

    In short, you will have to do three things:

    1. Locate the program entry (pointer to the reset ISR in the application).
    2. Reset the stack pointer.
    3. Jump to the program entry.

    This is done in the jumpToPrgEntry() function in the BIM examples.

    Also note that there is no need to disable TI-RTOS in ROM when relocating the application, as TI-RTOS ROM structures are relocatable through dispatch tables in RAM, and are no longer hardcoded in flash as with the CC13x0.

  • Hi Severin,

    Thanks for the help. I re-enabled the ROM and added the function jumpToPrgEntry() and called it with the address of the ResetISR.

    To debug I first loaded my main app and then terminated the debug session.  Then I loaded the bootloader app and ran it. Once

    bootloader jumps to the main app the debugger loses connection with the target which is probably expected. I have verified that the main app

    is not running correctly so I followed the instructions here: https://processors.wiki.ti.com/index.php/Debug_Handbook_for_CCS#Manual_launch

    to connect the debugger without loading the main app. I was hoping I could see what the main app was doing. 

    When selecting "launch selected configuration" I was able to connect to the target. The processor stopped at address 0x1000118e which

    I assume is somewhere in ROM. 

    When loading and running the main app from the debugger it works fine.  Do you have any suggestions on how to debug this?

    Victor

  • In what memory region have you placed the bootloader? Can you verify that you have a CCFG configured in the device (usually this is bundled with the bootloader), and that the CCFG correctly configures the NVIC to point to the reset vector of the bootloader (CCFG_IMAGE_VALID_CONF).

  • Hi Severin,

    The bootloader is loaded starting at address 0x0. The main application starts at 0x12000.

    Both the bootloader and the main application use the same default "startup_files/ccfg.c" which contains:

    //#####################################
    // Flash image valid
    //#####################################
    #ifndef SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID
    #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID           0x00000000                  // Flash image vector table is at address 0x00000000 (default)
    // #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID        <valid_vector_table_addr>   // Flash image vector table is at address <valid_vector_table_addr>
    // #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID        <invalid_vector_table_addr> // Flash image vector table address is invalid. ROM boot loader is called.
    #endif
    

  • Hi Severin,

    I believe I have found the issue. I had defined a flash region that included the last sector of flash. When I erased that region as part of my

    init code the ccfg was corrupted which caused everything to fail after that. My app would only run if I ran an example application first which

    restored the ccfg sector.

    I still have a couple of questions though:

    1) This implies that both the bootloader and main application use the same CCFG. Will that work correctly since the reset vector will

    always point to the one in the bootloader?

    2) Once the main application boots will my method of connecting to the target to debug work properly?  Is there a better way to do it?

    Victor

  • The device always uses the same CCFG, whether it is currently running as the bootloader or as the application. The CCFG will always be placed at the upper 88 bytes of the flash, regardless of what is running. Hence, for the application to run correctly, a valid CCFG must be placed in the upper 88 bytes of the flash.

    TI recommends to bundle the CCFG configuration with the bootloader, by allocating the upper flash page(s) for the bootloader+CCFG. This means the application can be re-programmed without affecting the CCFG, and ultimately any application image running would be using the static CCFG bundled with the bootloader.

    Are you asking about how to attach to running target in debug without doing a reset? 

  • Hi Severin,

    Things are working much better now that I have CCFG in the right location and nobody else touches it.

    Yes, I still want to be able to attach to an application that is already running that has been started by

    a bootloader so any help would be appreciated.

    Victor

  • Hi Severin,

    I'm still have issues jumping to my application.  My bootloader starts at 0x0 and the application starts at 0x12000. In the bootloader I am

    calling the function jumpToProgEntry(0x120000).

    Immediately before the jump it loads the address of _c_int00 in my main app which is 0x1c631 and then jumps to it so that part seems OK.  At that

    point I am single-stepping through the assembly and it continues to set up the stack and then appears to jump to args_main.c at address 0x1f2cc.

                      0001f2cc    00000018     rtsv7M4_T_le_v4SPD16_eabi.lib : args_main.c.obj (.text:_args_main)
                      0001f2e4    00000018                                   : snprintf.c.obj (.text:_outc)

    It then just seems to run forever stuck in the following loop:

    0001efa4:   E7FE                b          #0x1efa4

    I have verified that both the bootloader and application map ccfg to the last sector of flash.

    I have attached the link map for both my bootloader and the main application.

    cc1312_bolus_bootloader.txt

    bolus_1312_5_0_kbps.txt

  • Hi Severin,

    I have not heard back from you on this issue.  Are you still available to help with this or should I open

    another thread?

    Victor

  • Victor,

    It is wrong that both the bootloader and the applications links the CCFG section. Only the bootloader should link the CCFG section, or in other words the last flash page. The application code should not use the last flash page at all.

  • Hi Severin,

    Thanks for the response. Hope you're doing well during all this craziness!

    How do I remove ccfg from my application? The file ccfg.c is already excluded from the

    build and I commented out the ccfg line in the .cmd file but I still get a link warning:

    warning #10247-D: creating output section ".ccfg" without a SECTIONS specification

    Victor

     

  • You should remove the ccfg.c file entirely from the application project, and also remove the following line in the linker file:

        .ccfg           :   > FLASH (HIGH)

  • Hi Severin,

    Here's the steps I took:

    1) completely remove ccfg.c from the project

    2) removed the .ccfg line from the .cmd file

    3) performed a clean build

    and I still got the same warning.

    I can see the following in the .syscfg file though:

    bolus/Bolus.syscfg:var CCFG = scripting.addModule("/ti/devices/CCFG", {}, false);
    bolus/Bolus.syscfg:CCFG.enableBootloaderBackdoor = true;
    bolus/Bolus.syscfg:CCFG.dioBootloaderBackdoor = 15;
    bolus/Bolus.syscfg:CCFG.enableDCDC = false;
    bolus/Bolus.syscfg:CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0";

    Looking at sysconfig I can see that there is one device configured. I am unable to remove that device since there is

    a dependency with Power.  Viewing the Power configuration if I mouse over "Remove All" I get

    the following error:

    Unable to render selection
    TypeError: Cannot read property 'def' of undefined
        at file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:34:164936
        at Object.t.format (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:34:165804)
        at I (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:34:35614)
        at i.FormattedMsg.r.chain.words.map.t (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:50:69110)
        at Qt (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:5767)
        at Function.Ya [as map] (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:40622)
        at d (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:67296)
        at Function.Ba [as thru] (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:39837)
        at file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:25649
        at tn (file:///C:/ti/ccs930/ccs/utils/sysconfig/dist/ui.js:9:5949)
    
    

    I guess this means I am not able to get rid of .ccfg in sysconfig.  What should I do at this point?

    Victor

  • I see the problem. As long as you remove the ".ccfg" line in the linker file then the CCFG section won't be linked with the application. You will still receive the linker warning, but that is because the generated CCFG from SysConfig won't find a section to be linked against.

  • Hi Severin,

    A default .cmd file would have the following:

        .ccfg           :   > FLASH (HIGH)
    

    If I remove that, I get the following warning:

    warning #10247-D: creating output section ".ccfg" without a SECTIONS specification
    

    and the .map file has the following:

    .ccfg      0    0000dce8    00000058     
                      0000dce8    00000058     ti_devices_config.obj (.ccfg:retain)

    which is obviously the incorrect address for CCFG.

    The CCFG being linked comes from the bottom of (auto-generated) ti_devices_config.c:

    /*
     *  ======== Include Base Settings for device ========
     */
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(startup_files/ccfg.c)

    How do I configure it so that only the bootloader links the CCFG section?

  • Hi Victor,

    Simply remove the ccfg.c file from the application. As you use SysConfig, you are getting the auto generated file as you say. My suggestion is that you copy all the generated files out into the project root, exclude the .syscfg file (right click -> exclude from build) and then remove the ti_devices_config.c file from the project.

  • Hi Severin,

    I have made the following changes but it's still not working.

    1) The application no longer links the CCFG section. The bootloader does link the CCFG section and it's located at the end of flash.

    2) The application starts at address 0 and the bootloader starts at address 0x44000.

    3) The Bootloader OS project's release.cfg has the resetVec set to the starting address of the bootloader (0x44000).

    4) The application OS project's resetVec is not modified so it's at the default value which I assume is 0.

    Using assembly single-step I can see the bootloader jumping to the address of the application ResetISR. It then

    runs for a bit and ends up at "$C$L141, xdc_runtime_System_exitSpin__E:"If I download and run the application from CCS is runs fine so I know that the app is OK. It must be something happening

    with the transition. I have attached the Release.cfg files and link maps for both the bootloader and the application.

    Victor

    1234.cc1312_bolus_bootloader.txtbootloader_release.cfg4478.bolus_1312_5_0_kbps.txt3644.app_release.cfg

  • If you end up in xdc_runtime_System_exitSpin__E then I would assume you can use the ROV to see what kind of exception you are getting. Have you tried doing this?

  • Hi M-W,

    I was not able to successfully connect to the target when it is in the error state so I could not see anything in ROV.

    I'd like to take a step back in solving this issue.

    Here's what I have:

    • A bootloader loaded at address 0x44000
    • The bootloader uses an OS with a customized release.cfg that has m3Hwi.resetVectorAddress = 0x44000
    • The bootloader maintains the CCFG section which is located at the top of flash
    • An application which uses a different OS which is not customized so it uses the default m3Hwi.resetVectorAddress
    • The application is loaded at address 0x0
    • If I debug the bootloader using CCS it appears to run fine until it transfers control to the application.
    • If I debug the application using CCS it appears to run fine

    Here's my debug procedure:

    1. I download, using CCS, the application like I am going to debug it.
    2. I terminate the debug session
    3. I download, using CCS, the bootloader like I am going to debug it.
    4. I press "run"

    When I use this procedure, the bootloader runs until it jumps to the application and then it eventually hits xdc_runtime_System_exitSpin__E.

    Here are some specific questions that might help understand what is happening.

    1. Should the application be using the default value for m3Hwi.resetVectorAddress or should it be using the same as the bootloader (0x44000)?
    2. If I load the bootloader and run it I can see the expected console output (custom console which sends characters to a serial port) showing that it is running correctly.  If I terminate the debug session, disconnect and reconnect the power to the target I expect to see the same output as I would if the debugger is connected but I don't see anything. Is there something special I need to configure for a bootloader not loaded at address 0 to run without the debugger?

    Victor

  • Hi Victor,

    Is there a reason that your bootloader is using TI-RTOS? This would mean you need to run TI-RTOS from flash which would cost you quite some flash.

    The application in a bootloader situation does not share the reset vectors, it should define it's own. The bootloader should jump directly into the ResetSR located in the application reset vectors. You could potentially have an issue moving from TI-RTOS to TI-RTOS again as there is a lot of things setup behind the scene. I would at the very least try to disable interrupt prior to jumping to your application.

    You should be fine rebooting the device assuming that your CCFG section is correctly setup to tell the ROM bootloader that the valid image is located at the address of the bootloader (this step is not needed when debugging which is why it might work during debug but not after). 

  • Hi M-W,

    > Is there a reason that your bootloader is using TI-RTOS? This would mean you need to run TI-RTOS from flash which would cost you quite some flash.

    My bootloader will have some complex functionality so the RTOS-based design seemed best. In the field if an application is updated over the air and it fails then the bootloader will be responsible for downloading a new image over the air so it has similar functionality to the application. Once the device is deployed there is no way to access it for several years so the upgrade process has to be solid.

    Why would I need to run the TI-RTOS from flash? Can't I use the same one (in ROM) used by the application? I tried commenting out the

    following lines in my bootloader custom .cfg file (in the TI-RTOS project being referenced):

    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    ROM.romName = ROM.CC13X2V2;

    but the resulting image file did not change size. Is there a way to verify that the TI-RTOS used by the bootloader is properly loaded in flash?

    > I would at the very least try to disable interrupt prior to jumping to your application.

    I tried this but it did not help.

    I have attached the bootloader and application link maps, the ccfg.c used by the bootloader, and the .cfg file from the bootloader OS project.

    6746.cc1312_bolus_bootloader.txt

    bolus_1312_5_0_kbps (1).txt

    6765.ccfg.c
    /******************************************************************************
    *  Filename:       ccfg.c
    *  Revised:        $Date: 2017-11-02 11:36:28 +0100 (Thu, 02 Nov 2017) $
    *  Revision:       $Revision: 18030 $
    *
    *  Description:    Customer Configuration for:
    *                  CC13x2, CC13x4, CC26x2, CC26x4 device family (HW rev 2).
    *
    *  Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
    *
    *
    *  Redistribution and use in source and binary forms, with or without
    *  modification, are permitted provided that the following conditions
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the
    *    documentation and/or other materials provided with the distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    *  "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 THE COPYRIGHT
    *  OWNER OR CONTRIBUTORS 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.
    *
    ******************************************************************************/
    
    #ifndef __CCFC_C__
    #define __CCFC_C__
    
    #include <stdint.h>
    #include <ti/devices/DeviceFamily.h>
    #include "ti/devices/cc13x2_cc26x2/inc/hw_types.h"
    #include "ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h"
    #include "ti/devices/cc13x2_cc26x2/inc/hw_ccfg_simple_struct.h"
    
    //*****************************************************************************
    //
    // Introduction
    //
    // This file contains fields used by Boot ROM, startup code, and SW radio 
    // stacks to configure chip behavior.
    //
    // Fields are documented in more details in hw_ccfg.h and CCFG.html in 
    // DriverLib documentation (doc_overview.html -> CPU Domain Memory Map -> CCFG).
    //
    // PLEASE NOTE:
    // It is not recommended to do modifications inside the ccfg.c file.
    // This file is part of the CoreSDK release and future releases may have
    // important modifications and new fields added without notice.
    // The recommended method to modify the CCFG settings is to have a separate
    // <customer_ccfg>.c file that defines the specific CCFG values to be
    // overridden and then include the TI provided ccfg.c at the very end,
    // giving default values for non-overriden settings.
    //
    // Example:
    // #define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE  0xC5 // Enable ROM boot loader
    // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION     0x3  // LF RCOSC
    // //---- Use default values for all others ----
    // #include "<project-path>/source/ti/devices/<device>/startup_files/ccfg.c"
    // 
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // Internal settings, forcing several bit-fields to be set to a specific value.
    //
    //*****************************************************************************
    
    //#####################################
    // Force VDDR high setting (Higher output power but also higher power consumption)
    // This is also called "boost mode"
    //#####################################
    
    #ifndef CCFG_FORCE_VDDR_HH
    #define CCFG_FORCE_VDDR_HH                              0x0        // Use default VDDR trim
    // #define CCFG_FORCE_VDDR_HH                           0x1        // Force VDDR voltage to the factory HH setting (FCFG1..VDDR_TRIM_HH)
    #endif
    
    //*****************************************************************************
    //
    // Set the values of the individual bit fields.
    //
    //*****************************************************************************
    
    //#####################################
    // Alternative DC/DC settings
    //#####################################
    
    #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING    0x0    // Alternative DC/DC setting enabled
    // #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING 0x1    // Alternative DC/DC setting disabled
    #endif
    
    #if ( CCFG_FORCE_VDDR_HH )
    #define SET_CCFG_MODE_CONF_1_ALT_DCDC_VMIN                  0xC    // Special VMIN level (2.5V) when forced VDDR HH voltage
    #else
    #ifndef SET_CCFG_MODE_CONF_1_ALT_DCDC_VMIN
    #define SET_CCFG_MODE_CONF_1_ALT_DCDC_VMIN                  0x8    // 2.25V
    #endif
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN
    #define SET_CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN         0x0        // Dithering disabled
    // #define SET_CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN      0x1        // Dithering enabled
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_ALT_DCDC_IPEAK
    #define SET_CCFG_MODE_CONF_1_ALT_DCDC_IPEAK             0x0        // Peak current
    #endif
    
    //#####################################
    // XOSC override settings
    //#####################################
    
    #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR
    // #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR     0x0        // Enable override
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR        0x1        // Disable override
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_DELTA_IBIAS_INIT
    #define SET_CCFG_MODE_CONF_1_DELTA_IBIAS_INIT           0x0        // Delta = 0
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET
    #define SET_CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET         0x0        // Delta = 0
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_XOSC_MAX_START
    #define SET_CCFG_MODE_CONF_1_XOSC_MAX_START             0x10       // 1600us
    #endif
    
    //#####################################
    // Power settings
    //#####################################
    
    #ifndef SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA
    #define SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA        0xF        // Signed delta value +1 to apply to the VDDR_TRIM_SLEEP target (0xF=-1=default=no compensation)
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_DCDC_RECHARGE
    #define SET_CCFG_MODE_CONF_DCDC_RECHARGE                0x0        // Use the DC/DC during recharge in powerdown
    // #define SET_CCFG_MODE_CONF_DCDC_RECHARGE             0x1        // Do not use the DC/DC during recharge in powerdown
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_DCDC_ACTIVE
    #define SET_CCFG_MODE_CONF_DCDC_ACTIVE                  0x0        // Use the DC/DC during active mode
    // #define SET_CCFG_MODE_CONF_DCDC_ACTIVE               0x1        // Do not use the DC/DC during active mode
    #endif
    
    #if ( CCFG_FORCE_VDDR_HH )
    #define SET_CCFG_MODE_CONF_VDDS_BOD_LEVEL               0x1        // Special setting to enable forced VDDR HH voltage
    #else
    #ifndef SET_CCFG_MODE_CONF_VDDS_BOD_LEVEL
    // #define SET_CCFG_MODE_CONF_VDDS_BOD_LEVEL            0x0        // VDDS BOD level is 2.0V
    #define SET_CCFG_MODE_CONF_VDDS_BOD_LEVEL               0x1        // VDDS BOD level is 1.8V (or 1.65V for external regulator mode)
    #endif
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_VDDR_CAP
    #define SET_CCFG_MODE_CONF_VDDR_CAP                     0x3A       // Unsigned 8-bit integer representing the min. decoupling capacitance on VDDR in units of 100nF
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC
    #define SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC           0x1        // Temperature compensation on VDDR sleep trim disabled (default)
    // #define SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC        0x0        // Temperature compensation on VDDR sleep trim enabled
    #endif
    
    //#####################################
    // Clock settings
    //#####################################
    
    #ifndef SET_CCFG_MODE_CONF_SCLK_LF_OPTION
    // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION            0x0        // LF clock derived from HF clock. Note: using this configuration will block the device from entering Standby mode.
    // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION            0x1        // External LF clock
    #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION               0x2        // LF XOSC
    // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION            0x3        // LF RCOSC
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_XOSC_CAP_MOD
    // #define SET_CCFG_MODE_CONF_XOSC_CAP_MOD              0x0        // Apply cap-array delta
    #define SET_CCFG_MODE_CONF_XOSC_CAP_MOD                 0x1        // Don't apply cap-array delta 
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA
    #define SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA          0xFF       // Signed 8-bit value, directly modifying trimmed XOSC cap-array value
    #endif
    
    #ifndef SET_CCFG_EXT_LF_CLK_DIO
    #define SET_CCFG_EXT_LF_CLK_DIO                         0x01       // DIO number if using external LF clock
    #endif
    
    #ifndef SET_CCFG_EXT_LF_CLK_RTC_INCREMENT
    #define SET_CCFG_EXT_LF_CLK_RTC_INCREMENT               0x800000   // RTC increment representing the external LF clock frequency
    #endif
    
    //#####################################
    // Special HF clock source setting
    //#####################################
    #ifndef SET_CCFG_MODE_CONF_XOSC_FREQ
    // #define SET_CCFG_MODE_CONF_XOSC_FREQ                 0x0        // HF source is 48 MHz TCXO
    // #define SET_CCFG_MODE_CONF_XOSC_FREQ                 0x1        // HF source is HPOSC (BAW) (only valid for CC2652RB)
    #define SET_CCFG_MODE_CONF_XOSC_FREQ                    0x2        // HF source is a 48 MHz xtal
    // #define SET_CCFG_MODE_CONF_XOSC_FREQ                 0x3        // HF source is a 24 MHz xtal (not supported)
    #endif
    
    //#####################################
    // Bootloader settings
    //#####################################
    
    #ifndef SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE
    #define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE            0x00       // Disable ROM boot loader
    // #define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE         0xC5       // Enable ROM boot loader
    #endif
    
    #ifndef SET_CCFG_BL_CONFIG_BL_LEVEL
    // #define SET_CCFG_BL_CONFIG_BL_LEVEL                  0x0        // Active low to open boot loader backdoor
    #define SET_CCFG_BL_CONFIG_BL_LEVEL                     0x1        // Active high to open boot loader backdoor
    #endif
    
    #ifndef SET_CCFG_BL_CONFIG_BL_PIN_NUMBER
    #define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER                0xFF       // DIO number for boot loader backdoor
    #endif
    
    #ifndef SET_CCFG_BL_CONFIG_BL_ENABLE
    // #define SET_CCFG_BL_CONFIG_BL_ENABLE                 0xC5       // Enabled boot loader backdoor
    #define SET_CCFG_BL_CONFIG_BL_ENABLE                    0xFF       // Disabled boot loader backdoor
    #endif
    
    //#####################################
    // Debug access settings
    //#####################################
    
    #ifndef SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE
    #define SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE           0x00       // Disable unlocking of TI FA option.
    // #define SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE        0xC5       // Enable unlocking of TI FA option with the unlock code
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE
    // #define SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE       0x00       // Access disabled
    #define SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE          0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE
    //#define SET_CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE    0x00       // Access disabled
    #define SET_CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE      0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE
    #define SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE         0x00       // Access disabled
    //#define SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE       0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE
    #define SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE       0x00       // Access disabled
    // #define SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE    0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE
    #define SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE       0x00       // Access disabled
    // #define SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE    0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    #ifndef SET_CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE
    #define SET_CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE          0x00       // Access disabled
    // #define SET_CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE       0xC5       // Access enabled if also enabled in FCFG
    #endif
    
    //#####################################
    // Alternative IEEE 802.15.4 MAC address
    //#####################################
    #ifndef SET_CCFG_IEEE_MAC_0
    #define SET_CCFG_IEEE_MAC_0                             0xFFFFFFFF // Bits [31:0]
    #endif
    
    #ifndef SET_CCFG_IEEE_MAC_1
    #define SET_CCFG_IEEE_MAC_1                             0xFFFFFFFF // Bits [63:32]
    #endif
    
    //#####################################
    // Alternative BLE address
    //#####################################
    #ifndef SET_CCFG_IEEE_BLE_0
    #define SET_CCFG_IEEE_BLE_0                             0xFFFFFFFF // Bits [31:0]
    #endif
    
    #ifndef SET_CCFG_IEEE_BLE_1
    #define SET_CCFG_IEEE_BLE_1                             0xFFFFFFFF // Bits [63:32]
    #endif
    
    //#####################################
    // Flash erase settings
    //#####################################
    
    #ifndef SET_CCFG_ERASE_CONF_CHIP_ERASE_DIS_N
    // #define SET_CCFG_ERASE_CONF_CHIP_ERASE_DIS_N         0x0        // Any chip erase request detected during boot will be ignored
    #define SET_CCFG_ERASE_CONF_CHIP_ERASE_DIS_N            0x1        // Any chip erase request detected during boot will be performed by the boot FW
    #endif
    
    #ifndef SET_CCFG_ERASE_CONF_BANK_ERASE_DIS_N
    // #define SET_CCFG_ERASE_CONF_BANK_ERASE_DIS_N         0x0        // Disable the boot loader bank erase function
    #define SET_CCFG_ERASE_CONF_BANK_ERASE_DIS_N            0x1        // Enable the boot loader bank erase function
    #endif
    
    //#####################################
    // Flash image valid
    //#####################################
    #ifndef SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID
    #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID           0x00044000                  // Flash image vector table is at address 0x00000000 (default)
    // #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID        <valid_vector_table_addr>   // Flash image vector table is at address <valid_vector_table_addr>
    // #define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID        <invalid_vector_table_addr> // Flash image vector table address is invalid. ROM boot loader is called.
    #endif
    
    //#####################################
    // Flash sector write protection
    //#####################################
    #ifndef SET_CCFG_CCFG_PROT_31_0
    #define SET_CCFG_CCFG_PROT_31_0                         0xFFFFFFFF
    #endif
    
    #ifndef SET_CCFG_CCFG_PROT_63_32
    #define SET_CCFG_CCFG_PROT_63_32                        0xFFFFFFFF
    #endif
    
    #ifndef SET_CCFG_CCFG_PROT_95_64
    #define SET_CCFG_CCFG_PROT_95_64                        0xFFFFFFFF
    #endif
    
    #ifndef SET_CCFG_CCFG_PROT_127_96
    #define SET_CCFG_CCFG_PROT_127_96                       0xFFFFFFFF
    #endif
    
    //#####################################
    // Select between cache or GPRAM
    //#####################################
    #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM
    // #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM        0x0        // Cache is disabled and GPRAM is available at 0x11000000-0x11001FFF
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM           0x1        // Cache is enabled and GPRAM is disabled (unavailable)
    #endif
    
    //#####################################
    // TCXO settings
    //#####################################
    #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO            0x1        // Deprecated. Must be set to 0x1.
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_TCXO_TYPE
    #define SET_CCFG_MODE_CONF_1_TCXO_TYPE                  0x1        // 1 = Clipped-sine type.
    //#define SET_CCFG_MODE_CONF_1_TCXO_TYPE                0x0        // 0 = CMOS type.
    #endif
    
    #ifndef SET_CCFG_MODE_CONF_1_TCXO_MAX_START
    #define SET_CCFG_MODE_CONF_1_TCXO_MAX_START             0x7F       // Maximum TCXO startup time in units of 100us.
    #endif
    
    //*****************************************************************************
    //
    // CCFG values that should not be modified.
    //
    //*****************************************************************************
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_SIZE_OF_CCFG        0x0058
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS       (CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS_M >> CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS_S)
    
    #if ( CCFG_FORCE_VDDR_HH )
    #define SET_CCFG_MODE_CONF_VDDR_EXT_LOAD                0x0        // Special setting to enable forced VDDR HH voltage
    #else
    #define SET_CCFG_MODE_CONF_VDDR_EXT_LOAD                0x1
    #endif
    
    #define SET_CCFG_MODE_CONF_RTC_COMP                     0x1
    #define SET_CCFG_MODE_CONF_HF_COMP                      0x1
    
    #define SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP45              0xFF
    #define SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP25              0xFF
    #define SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP5               0xFF
    #define SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TM15              0xFF
    
    #define SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP125             0xFF
    #define SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP105             0xFF
    #define SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP85              0xFF
    #define SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP65              0xFF
    
    #define SET_CCFG_RTC_OFFSET_RTC_COMP_P0                 0xFFFF
    #define SET_CCFG_RTC_OFFSET_RTC_COMP_P1                 0xFF
    #define SET_CCFG_RTC_OFFSET_RTC_COMP_P2                 0xFF
    
    #define SET_CCFG_FREQ_OFFSET_HF_COMP_P0                 0xFFFF
    #define SET_CCFG_FREQ_OFFSET_HF_COMP_P1                 0xFF
    #define SET_CCFG_FREQ_OFFSET_HF_COMP_P2                 0xFF
    
    //*****************************************************************************
    //
    // Concatenate bit fields to words.
    // DO NOT EDIT!
    //
    //*****************************************************************************
    #define DEFAULT_CCFG_EXT_LF_CLK          ( \
    	 ((((uint32_t)( SET_CCFG_EXT_LF_CLK_DIO                          )) << CCFG_EXT_LF_CLK_DIO_S                          ) | ~CCFG_EXT_LF_CLK_DIO_M                          ) & \
    	 ((((uint32_t)( SET_CCFG_EXT_LF_CLK_RTC_INCREMENT                )) << CCFG_EXT_LF_CLK_RTC_INCREMENT_S                ) | ~CCFG_EXT_LF_CLK_RTC_INCREMENT_M                ) )
    
    #define DEFAULT_CCFG_MODE_CONF_1         ( \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_TCXO_TYPE                   )) << CCFG_MODE_CONF_1_TCXO_TYPE_S                   ) | ~CCFG_MODE_CONF_1_TCXO_TYPE_M                   ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_TCXO_MAX_START              )) << CCFG_MODE_CONF_1_TCXO_MAX_START_S              ) | ~CCFG_MODE_CONF_1_TCXO_MAX_START_M              ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_VMIN               )) << CCFG_MODE_CONF_1_ALT_DCDC_VMIN_S               ) | ~CCFG_MODE_CONF_1_ALT_DCDC_VMIN_M               ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN          )) << CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN_S          ) | ~CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN_M          ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_IPEAK              )) << CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_S              ) | ~CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_M              ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_DELTA_IBIAS_INIT            )) << CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S            ) | ~CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_M            ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET          )) << CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_S          ) | ~CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_M          ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_1_XOSC_MAX_START              )) << CCFG_MODE_CONF_1_XOSC_MAX_START_S              ) | ~CCFG_MODE_CONF_1_XOSC_MAX_START_M              ) )
    
    #define DEFAULT_CCFG_SIZE_AND_DIS_FLAGS  ( \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_SIZE_OF_CCFG         )) << CCFG_SIZE_AND_DIS_FLAGS_SIZE_OF_CCFG_S         ) | ~CCFG_SIZE_AND_DIS_FLAGS_SIZE_OF_CCFG_M         ) & \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS        )) << CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS_S        ) | ~CCFG_SIZE_AND_DIS_FLAGS_DISABLE_FLAGS_M        ) & \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO             )) << CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO_S             ) | ~CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO_M             ) & \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM            )) << CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM_S            ) | ~CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM_M            ) & \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING )) << CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING_S ) | ~CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING_M ) & \
    	 ((((uint32_t)( SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR         )) << CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR_S         ) | ~CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR_M         ) )
    
    #define DEFAULT_CCFG_MODE_CONF           ( \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA         )) << CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_S         ) | ~CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_M         ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_DCDC_RECHARGE                 )) << CCFG_MODE_CONF_DCDC_RECHARGE_S                 ) | ~CCFG_MODE_CONF_DCDC_RECHARGE_M                 ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_DCDC_ACTIVE                   )) << CCFG_MODE_CONF_DCDC_ACTIVE_S                   ) | ~CCFG_MODE_CONF_DCDC_ACTIVE_M                   ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_VDDR_EXT_LOAD                 )) << CCFG_MODE_CONF_VDDR_EXT_LOAD_S                 ) | ~CCFG_MODE_CONF_VDDR_EXT_LOAD_M                 ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_VDDS_BOD_LEVEL                )) << CCFG_MODE_CONF_VDDS_BOD_LEVEL_S                ) | ~CCFG_MODE_CONF_VDDS_BOD_LEVEL_M                ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_SCLK_LF_OPTION                )) << CCFG_MODE_CONF_SCLK_LF_OPTION_S                ) | ~CCFG_MODE_CONF_SCLK_LF_OPTION_M                ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC            )) << CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC_S            ) | ~CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC_M            ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_RTC_COMP                      )) << CCFG_MODE_CONF_RTC_COMP_S                      ) | ~CCFG_MODE_CONF_RTC_COMP_M                      ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_XOSC_FREQ                     )) << CCFG_MODE_CONF_XOSC_FREQ_S                     ) | ~CCFG_MODE_CONF_XOSC_FREQ_M                     ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_XOSC_CAP_MOD                  )) << CCFG_MODE_CONF_XOSC_CAP_MOD_S                  ) | ~CCFG_MODE_CONF_XOSC_CAP_MOD_M                  ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_HF_COMP                       )) << CCFG_MODE_CONF_HF_COMP_S                       ) | ~CCFG_MODE_CONF_HF_COMP_M                       ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA           )) << CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S           ) | ~CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_M           ) & \
    	 ((((uint32_t)( SET_CCFG_MODE_CONF_VDDR_CAP                      )) << CCFG_MODE_CONF_VDDR_CAP_S                      ) | ~CCFG_MODE_CONF_VDDR_CAP_M                      ) )
    
    #define DEFAULT_CCFG_VOLT_LOAD_0         ( \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP45               )) << CCFG_VOLT_LOAD_0_VDDR_EXT_TP45_S               ) | ~CCFG_VOLT_LOAD_0_VDDR_EXT_TP45_M               ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP25               )) << CCFG_VOLT_LOAD_0_VDDR_EXT_TP25_S               ) | ~CCFG_VOLT_LOAD_0_VDDR_EXT_TP25_M               ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TP5                )) << CCFG_VOLT_LOAD_0_VDDR_EXT_TP5_S                ) | ~CCFG_VOLT_LOAD_0_VDDR_EXT_TP5_M                ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_0_VDDR_EXT_TM15               )) << CCFG_VOLT_LOAD_0_VDDR_EXT_TM15_S               ) | ~CCFG_VOLT_LOAD_0_VDDR_EXT_TM15_M               ) )
    
    #define DEFAULT_CCFG_VOLT_LOAD_1         ( \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP125              )) << CCFG_VOLT_LOAD_1_VDDR_EXT_TP125_S              ) | ~CCFG_VOLT_LOAD_1_VDDR_EXT_TP125_M              ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP105              )) << CCFG_VOLT_LOAD_1_VDDR_EXT_TP105_S              ) | ~CCFG_VOLT_LOAD_1_VDDR_EXT_TP105_M              ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP85               )) << CCFG_VOLT_LOAD_1_VDDR_EXT_TP85_S               ) | ~CCFG_VOLT_LOAD_1_VDDR_EXT_TP85_M               ) & \
    	 ((((uint32_t)( SET_CCFG_VOLT_LOAD_1_VDDR_EXT_TP65               )) << CCFG_VOLT_LOAD_1_VDDR_EXT_TP65_S               ) | ~CCFG_VOLT_LOAD_1_VDDR_EXT_TP65_M               ) )
    
    #define DEFAULT_CCFG_RTC_OFFSET          ( \
    	 ((((uint32_t)( SET_CCFG_RTC_OFFSET_RTC_COMP_P0                  )) << CCFG_RTC_OFFSET_RTC_COMP_P0_S                  ) | ~CCFG_RTC_OFFSET_RTC_COMP_P0_M                  ) & \
    	 ((((uint32_t)( SET_CCFG_RTC_OFFSET_RTC_COMP_P1                  )) << CCFG_RTC_OFFSET_RTC_COMP_P1_S                  ) | ~CCFG_RTC_OFFSET_RTC_COMP_P1_M                  ) & \
    	 ((((uint32_t)( SET_CCFG_RTC_OFFSET_RTC_COMP_P2                  )) << CCFG_RTC_OFFSET_RTC_COMP_P2_S                  ) | ~CCFG_RTC_OFFSET_RTC_COMP_P2_M                  ) )
    
    #define DEFAULT_CCFG_FREQ_OFFSET         ( \
    	 ((((uint32_t)( SET_CCFG_FREQ_OFFSET_HF_COMP_P0                  )) << CCFG_FREQ_OFFSET_HF_COMP_P0_S                  ) | ~CCFG_FREQ_OFFSET_HF_COMP_P0_M                  ) & \
    	 ((((uint32_t)( SET_CCFG_FREQ_OFFSET_HF_COMP_P1                  )) << CCFG_FREQ_OFFSET_HF_COMP_P1_S                  ) | ~CCFG_FREQ_OFFSET_HF_COMP_P1_M                  ) & \
    	 ((((uint32_t)( SET_CCFG_FREQ_OFFSET_HF_COMP_P2                  )) << CCFG_FREQ_OFFSET_HF_COMP_P2_S                  ) | ~CCFG_FREQ_OFFSET_HF_COMP_P2_M                  ) )
    
    #define DEFAULT_CCFG_IEEE_MAC_0          SET_CCFG_IEEE_MAC_0
    #define DEFAULT_CCFG_IEEE_MAC_1          SET_CCFG_IEEE_MAC_1
    #define DEFAULT_CCFG_IEEE_BLE_0          SET_CCFG_IEEE_BLE_0
    #define DEFAULT_CCFG_IEEE_BLE_1          SET_CCFG_IEEE_BLE_1
    
    #define DEFAULT_CCFG_BL_CONFIG           ( \
    	 ((((uint32_t)( SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE             )) << CCFG_BL_CONFIG_BOOTLOADER_ENABLE_S             ) | ~CCFG_BL_CONFIG_BOOTLOADER_ENABLE_M             ) & \
    	 ((((uint32_t)( SET_CCFG_BL_CONFIG_BL_LEVEL                      )) << CCFG_BL_CONFIG_BL_LEVEL_S                      ) | ~CCFG_BL_CONFIG_BL_LEVEL_M                      ) & \
    	 ((((uint32_t)( SET_CCFG_BL_CONFIG_BL_PIN_NUMBER                 )) << CCFG_BL_CONFIG_BL_PIN_NUMBER_S                 ) | ~CCFG_BL_CONFIG_BL_PIN_NUMBER_M                 ) & \
    	 ((((uint32_t)( SET_CCFG_BL_CONFIG_BL_ENABLE                     )) << CCFG_BL_CONFIG_BL_ENABLE_S                     ) | ~CCFG_BL_CONFIG_BL_ENABLE_M                     ) )
    
    #define DEFAULT_CCFG_ERASE_CONF          ( \
    	 ((((uint32_t)( SET_CCFG_ERASE_CONF_CHIP_ERASE_DIS_N             )) << CCFG_ERASE_CONF_CHIP_ERASE_DIS_N_S             ) | ~CCFG_ERASE_CONF_CHIP_ERASE_DIS_N_M             ) & \
    	 ((((uint32_t)( SET_CCFG_ERASE_CONF_BANK_ERASE_DIS_N             )) << CCFG_ERASE_CONF_BANK_ERASE_DIS_N_S             ) | ~CCFG_ERASE_CONF_BANK_ERASE_DIS_N_M             ) )
    
    #define DEFAULT_CCFG_CCFG_TI_OPTIONS     ( \
    	 ((((uint32_t)( SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE            )) << CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE_S            ) | ~CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE_M            ) )
    
    #define DEFAULT_CCFG_CCFG_TAP_DAP_0      ( \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE           )) << CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE_S           ) | ~CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE_M           ) & \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE       )) << CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE_S       ) | ~CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE_M       ) & \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE          )) << CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE_S          ) | ~CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE_M          ) )
    
    #define DEFAULT_CCFG_CCFG_TAP_DAP_1      ( \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE        )) << CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE_S        ) | ~CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE_M        ) & \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE        )) << CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE_S        ) | ~CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE_M        ) & \
    	 ((((uint32_t)( SET_CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE           )) << CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE_S           ) | ~CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE_M           ) )
    
    #define DEFAULT_CCFG_IMAGE_VALID_CONF    SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID
    
    #define DEFAULT_CCFG_CCFG_PROT_31_0      SET_CCFG_CCFG_PROT_31_0  
    #define DEFAULT_CCFG_CCFG_PROT_63_32     SET_CCFG_CCFG_PROT_63_32 
    #define DEFAULT_CCFG_CCFG_PROT_95_64     SET_CCFG_CCFG_PROT_95_64 
    #define DEFAULT_CCFG_CCFG_PROT_127_96    SET_CCFG_CCFG_PROT_127_96
    
    //*****************************************************************************
    //
    // Customer Configuration Area in Lock Page
    //
    //*****************************************************************************
    #if defined(__IAR_SYSTEMS_ICC__)
    __root const ccfg_t __ccfg @ ".ccfg" =
    #elif defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(__ccfg, ".ccfg")
    #pragma RETAIN(__ccfg)
    const ccfg_t __ccfg =
    #else
    const ccfg_t __ccfg __attribute__((section(".ccfg"))) __attribute__((used)) =
    #endif
    {                                     // Mapped to address
        DEFAULT_CCFG_EXT_LF_CLK         , // 0x50003FA8 (0x50003xxx maps to last
        DEFAULT_CCFG_MODE_CONF_1        , // 0x50003FAC  sector in FLASH.
        DEFAULT_CCFG_SIZE_AND_DIS_FLAGS , // 0x50003FB0  Independent of FLASH size)
        DEFAULT_CCFG_MODE_CONF          , // 0x50003FB4
        DEFAULT_CCFG_VOLT_LOAD_0        , // 0x50003FB8 
        DEFAULT_CCFG_VOLT_LOAD_1        , // 0x50003FBC
        DEFAULT_CCFG_RTC_OFFSET         , // 0x50003FC0
        DEFAULT_CCFG_FREQ_OFFSET        , // 0x50003FC4
        DEFAULT_CCFG_IEEE_MAC_0         , // 0x50003FC8
        DEFAULT_CCFG_IEEE_MAC_1         , // 0x50003FCC
        DEFAULT_CCFG_IEEE_BLE_0         , // 0x50003FD0
        DEFAULT_CCFG_IEEE_BLE_1         , // 0x50003FD4
        DEFAULT_CCFG_BL_CONFIG          , // 0x50003FD8
        DEFAULT_CCFG_ERASE_CONF         , // 0x50003FDC
        DEFAULT_CCFG_CCFG_TI_OPTIONS    , // 0x50003FE0
        DEFAULT_CCFG_CCFG_TAP_DAP_0     , // 0x50003FE4
        DEFAULT_CCFG_CCFG_TAP_DAP_1     , // 0x50003FE8
        DEFAULT_CCFG_IMAGE_VALID_CONF   , // 0x50003FEC
        DEFAULT_CCFG_CCFG_PROT_31_0     , // 0x50003FF0
        DEFAULT_CCFG_CCFG_PROT_63_32    , // 0x50003FF4
        DEFAULT_CCFG_CCFG_PROT_95_64    , // 0x50003FF8
        DEFAULT_CCFG_CCFG_PROT_127_96   , // 0x50003FFC
    };
    
    #endif // __CCFC_C__
    

    4572.bootloader_release.cfg

  • Hi Victor,

    I think you can ignore my comment about running Ti-RTOS from flash, this is mainly an issue on the CC13x0 devices as TI-RTOS ROM require specific placements into flash.

    Based on you description above, it seems that your approach should actually be that of a dual image setup:

    A small basic bootloader + persistent fallback application + actual application image.

    This setup would also likely allow you leverage more of what is offered out of the SDK today. To give an example:

    You have a bootloader that does only a few things. It checks for two separate images, "Image A" and "Image B". If it finds both, it takes the one with the higher version number (that is at least what the TI Bootloader does, you could choose to do it however you want) and then jump into that image. This means that the bootloader do not enable any interrupts or depend on any RTOS which is ideal. It also means it would fit into one page which is convenient. 

    You then setup the device to use "Image B" as a persistent image. What I mean by this is that it is never replaced or erased. This application (that do not include any bootloader functionality) would be responsible for performing the OAD (as your requirement seems to be that it is decoupled from the actual application). "Image B" would thus be responsible for updating "Image A". Once "Image A" is in place, as long as the version number is higher (again, this assumes he TI bootloader, you could have different logic) it would jump to Image A instead of Image B. 

    When you need to perform an OAD you could simply have Image A write an invalid header value (the TI OAD applications include some meta data in flash that the bootloader uses to decide on if the image is OK or not) and reset itself. This would force the bootloader to load Image B and enter OAD mode. 

    I'm not saying you need to do it this way, but I recommend you look into it as you should be able to leverage what is already in the SDK in terms of OAD capabilities. There is actually an example for this in the SDK: 

    rfWsnNodeIntFlashOadClientPApp and rfWsnNodeIntFlashOadClientUApp

    Here P stand for persistent and for user application. The responsibilities of the first is to handle OAD and update the "U" app and then boot into that, these examples might be what you are looking for?

    As for the map files you attached above, I can't tell you what could be wrong but I can tell you that the application map file shows that you assign it the full flash, it should exclude the bootloader -> length == 44000 and not 58000.

  • Hi M-W,

    Your suggestion worked great.  Thanks for your help.

    Victor