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.

CC2538-OTA-Image-A.icf for CC2538SF23

Other Parts Discussed in Thread: CC2538, Z-STACK

Dear Support:

my project used CC2538SF23 not CC2538SF53, do you have a updated CC2538-OTA-Image-A.icf for CC2538SF23 for me.

by the way, if I want to do the OTA process, whether the 256K flash is enough for me? or should use 512K flash of CC2538SF53 like zstack demo software?

BR,

  • Hi,

    We do not have a linker file for this particular part, but you may start with the provided linker file as a base and modify it to fit the flash size of the smaller part.

    Depending on which device type and which stack you are using, 256k flash may or may not be enough. For instance, a ZHA 1.2.2a end device requires about 85k flash on the CC2538, so 256k would be sufficient for OTA. However, a Z3.0 coordinator requires over 130k flash, so 256k flash would not be sufficient for OTA.
  • Hello Jason,

    thank you for your reply.

    Because as coordinator, we don't need update through OTA, we used SCI to update coordinator firmware. so it is not an issue for us.

    and as device,  we should use OTA to update the device firmware through coordinator.

    according to your description, maybe 256k is sufficient for my project both device and coordinator.

    and if I have modified the icf file, what other .c files in the zstack should be modified? Is it a huge work?

    BR,

  • The size I used for end device was the baseline Z-Stack 1.2.2a SampleLight with all MT interfaces removed. Your application size will vary depending on what you are doing, so you will want to make sure your application does not exceed more than half the size of the available flash.

    The only changes you should need to make if you decide to use the 256k part are to the icf file and the target device configuration in IAR.
  • We just used ADC module to get temperature and send the AD value to coordinator, it is very simple function, we just need very lower current consuming used power saving function.
    So I think 128K is enough.
    and about the changing, I have a question like in hal_board_cfg.h:
    // Flash is constructed of 128 pages of 2 KB.
    #define HAL_FLASH_PAGE_SIZE 2048


    #define HAL_IMG_A_BEG FLASH_BASE
    #define HAL_IMG_B_BEG (FLASH_BASE + 0x0003E000)

    #if defined HAL_IMG_AREA
    #define HAL_NVIC_OSET 512
    #if (HAL_IMG_AREA == 0)
    #define HAL_NVIC_ADDR (HAL_IMG_A_BEG + HAL_NVIC_OSET)
    #elif (HAL_IMG_AREA == 1)
    #define HAL_NVIC_ADDR (HAL_IMG_B_BEG + HAL_NVIC_OSET)
    #else
    #error HAL_IMG_AREA is invalid.
    #endif
    #else
    #define HAL_NVIC_ADDR FLASH_BASE
    #endif

    #define HAL_NV_PAGE_END 254

    #define HAL_OTA_LEDGER_PAGE 248
    #define HAL_OTA_LEDGER_PAGE_ADDR (FLASH_BASE + (HAL_OTA_LEDGER_PAGE * HAL_FLASH_PAGE_SIZE))

    the address must overflow of 256K like upper setting in hal_board_cfg.h, any modificaiton here?
  • Dear Jason, the icf in attached is updated and the hal_board_cfg.h is updated, too.

    please help me to check whether it is ok or not.

    My project is used OTA.bin combined samplesw(enddevice-OTAClient-ImageA-withBootloader), and the CC2538-OTA-Image-A.icf is modified like below:

    //*****************************************************************************
    //
    // Linker configuration file for CC2538 configured to build Image-A.
    //
    // Copyright (c) 2012-2013 Texas Instruments Incorporated.  All rights reserved.
    //
    //*****************************************************************************

    //
    // Define a memory region that covers the entire 4 GB addressible space of the
    // processor.
    //
    define memory mem with size = 4G;

    //
    // Define a region for the on-chip program code space - the OTA post-processing tool will pad the
    // first 492 bytes with OTA headers and dummy bytes. The CRC calculation starts with the preamble.

    define region FLASH = mem:[from 0x002001EC to 0x0021DFFF];

    //
    // Define a region for the OTA CRC structure.
    //
    define region CRC = mem:[from 0x002001EC to 0x002001F3];

    //
    // Define a region for the OTA Preamble structure.
    //
    define region PREAMBLE = mem:[from 0x002001F4 to 0x002001FF];

    //
    // Define a region for the NVIC table that is 512-byte aligned.
    //
    define region INTVEC = mem:[from 0x00200200 to 0x002003FF];

    //
    // Define a region for the on-chip non-volatile (NV) memory.
    //   "HAL_NV_PAGE_CNT" pages of on-chip flash memory (originally 6 pages) are
    //   designated for Z-Stack NV items to be stored outside program code space.
    //   The size of this region MUST MATCH the size defined by "HAL_NV_PAGE_CNT"
    //   in the file: hal_board_cfg.h
    //
    define region NV_MEM = mem:[from 0x0023C800 to 0x0023F7FF];

    //
    // Define regions for on-chip factory Commissioning Parameters.
    //   One page of on-chip flash memory (originally page 255) is designated
    //   for various parameters to be "commissioned" outside program code space.
    //
    // Key-Establishment "Implicit Certificate 283"
    define region CP_IMPC_283 = mem:[from 0x0023FED4 to 0x0023FF1F];
    //
    // Key-Establishment "Certificate Authority Public Key 283"
    define region CP_CAPK_283 = mem:[from 0x0023FF20 to 0x0023FF47];
    //
    // Key-Establishment "Device Private Key 283"
    define region CP_DEPK_283 = mem:[from 0x0023FF48 to 0x0023FF6B];
    //
    // Key-Establishment "Implicit Certificate"
    define region CP_IMPC = mem:[from 0x0023FF6C to 0x0023FF9B];
    //
    // Key-Establishment "Certificate Authority Public Key"
    define region CP_CAPK = mem:[from 0x0023FF9C to 0x0023FFB3];
    //
    // Key-Establishment "Device Private Key"
    define region CP_DEPK = mem:[from 0x0023FFB4 to 0x0023FFCB];
    //
    // Device's unique 64-bit IEEE address
    define region CP_IEEE = mem:[from 0x0023FFCC to 0x0023FFD3];


    //
    // Define a region for Customer Configuration Area in flash.
    define region FLASH_CCA = mem:[from 0x0023FFD4 to 0x0023FFDF];

    //
    // Define the region for Lock Bits in flash.
    define region FLASH_LCK = mem:[from 0x0023FFE0 to 0x0023FFFF];

    //
    // Define the region for Image Boot Manager (IBM) Ledger Page.
    define region LEDGER_PAGE = mem:[from 0x0023C000 to 0x0023C7FF];

    //
    // Define the region for Image Boot Manager (IBM)
    define region BOOTLOADER_PAGE = mem:[from 0x0023F800 to 0x0023FD00];

    //
    // Define a region for the on-chip SRAM.
    //
    define region SRAM = mem:[from 0x20004000 to 0x20007FFF];

    //
    // Define a block for the heap.  The size should be set to something other
    // than zero if things in the C library that require the heap are used.
    //
    define block HEAP with alignment = 8, size = 0x00000100 { };

    //
    // Indicate that the read/write values should be initialized by copying from
    // flash.
    //
    initialize by copy { readwrite };

    //
    // Indicate that the noinit values should be left alone.  This includes the
    // stack, which if initialized will destroy the return address from the
    // initialization code, causing the processor to branch to zero and fault.
    //
    do not initialize { section .noinit };

    //
    // Place the OTA CRC structure.
    //
    place at start of CRC { readonly section .crc };

    //
    // Place the OTA Preamble structure.
    //
    place at start of PREAMBLE { readonly section .preamble };

    //
    // Place the interrupt vectors.
    //
    place at start of INTVEC { readonly section .intvec };

    //
    // Place the cca area at the end of flash.
    //
    place at start of FLASH_CCA { readonly section .cca };

    //
    // Place the commissioning parameter items.
    //
    place at start of CP_IEEE { readonly section IEEE_ADDRESS_SPACE };
    place at start of CP_DEPK { readonly section DEV_PRIVATE_KEY_ADDRESS_SPACE };
    place at start of CP_CAPK { readonly section CA_PUBLIC_KEY_ADDRESS_SPACE };
    place at start of CP_IMPC { readonly section IMPLICIT_CERTIFICATE_ADDRESS_SPACE };
    place at start of CP_DEPK_283 { readonly section PRIV_KEY_283_ADDRESS_SPACE };
    place at start of CP_CAPK_283 { readonly section CA_PUB_KEY_283_ADDRESS_SPACE };
    place at start of CP_IMPC_283 { readonly section IMPL_CERT_283_ADDRESS_SPACE };

    //
    // Place the remainder of the read-only items into flash.
    //
    place in FLASH { readonly };

    //
    // Place the RAM vector table at the start of SRAM.
    //
    place at start of SRAM { section VTABLE };

    //
    // Place all read/write items into SRAM.
    //
    place in SRAM { readwrite, block HEAP };

    //
    // Place the ledger page, if it's defined
    //
    place at start of LEDGER_PAGE { section .ledger };
    do not initialize { section .ledger };

    //
    // Place the bootloader page, if it's defined startup_ewarm
    //
    place at start of BOOTLOADER_PAGE { section .bootloader };

    but it firmware can't go into main function, can you help me to check what will be the problem?

    Thank you.

  • the hal_board_cfg.h is modified like below:

    /* ------------------------------------------------------------------------------------------------
     *                              Multiple Image Management
     * ------------------------------------------------------------------------------------------------
     */

    /* The download-to and run-in-place areas must begin on an even page boundary.
     * The NVIC Vector Table must be placed on a 512-byte boundary.
     * Currently the OTA headers are pre-pended to the image and downloaded to flash in-place, but
     * changing this strategy in the future will not affect the function of the image boot manager.
     * The image areas do not have to be equal in size, but either image must always be able to find
     * the other. Changes to these constants require corresponding changes in the linker config file(s).
     */
    #define HAL_IMG_A_BEG             FLASH_BASE
    #ifdef  CC2538SF53     
        #define HAL_IMG_B_BEG            (FLASH_BASE + 0x0003E000)
    #else     
        #define HAL_IMG_B_BEG            (FLASH_BASE + 0x0001E000)
    #endif
    #if defined HAL_IMG_AREA
    #define HAL_NVIC_OSET             512
    #if    (HAL_IMG_AREA == 0)
    #define HAL_NVIC_ADDR            (HAL_IMG_A_BEG + HAL_NVIC_OSET)
    #elif  (HAL_IMG_AREA == 1)
    #define HAL_NVIC_ADDR            (HAL_IMG_B_BEG + HAL_NVIC_OSET)
    #else
    #error  HAL_IMG_AREA is invalid.
    #endif
    #else
    #define HAL_NVIC_ADDR             FLASH_BASE
    #endif

    #ifdef  CC2538SF53      
      #define HAL_NV_PAGE_END           254
    #else
      #define HAL_NV_PAGE_END           126     
    #endif
         
    #ifdef  CC2538SF53      
      #define HAL_OTA_LEDGER_PAGE       248
    #else
      #define HAL_OTA_LEDGER_PAGE       120 
    #endif
         
    #define HAL_OTA_LEDGER_PAGE_ADDR  (FLASH_BASE + (HAL_OTA_LEDGER_PAGE * HAL_FLASH_PAGE_SIZE))

    /* ------------------------------------------------------------------------------------------------
     *                         OSAL NV implemented by internal flash pages.
     * ------------------------------------------------------------------------------------------------
     */

    // Flash consists of 256 pages of 2 KB.
    #define HAL_FLASH_PAGE_SIZE       2048
    #define HAL_FLASH_WORD_SIZE       4

    // Z-Stack uses flash pages for NV
    #define HAL_NV_PAGE_CNT           6
    #define HAL_NV_PAGE_BEG           (HAL_NV_PAGE_END-HAL_NV_PAGE_CNT+1)
    #define HAL_NV_START_ADDR         ((FLASH_BASE) + (HAL_NV_PAGE_BEG * HAL_FLASH_PAGE_SIZE))

    // Factory commmissioning location is now placed in the Lock Bits page.  The
    // certificates are stored at the locations defined below.
    // NOTE: these addresses MUST match those defined in the associated linker
    // control file (.icf)
    // NOTE: Commissioning items are aligned and padded to HAL_FLASH_WORD_SIZE

    // 74-byte Implicit Certificate (for binary 283 Key Establishment)
    #ifdef  CC2538SF53      
      #define HAL_FLASH_IMPLICIT_CERT_283_ADDR  ( 0x0027FED4 )
    #else
      #define HAL_FLASH_IMPLICIT_CERT_283_ADDR  ( 0x0023FED4 ) 
    #endif     
    #define HAL_FLASH_IMPLICIT_CERT_283_SIZE  ( 74 + 2 ) // 2-bytes of pad

    // 37-byte CA Public Key (for binary 283 Key Establishment)
    #ifdef  CC2538SF53 
      #define HAL_FLASH_CA_PUBLIC_KEY_283_ADDR  ( 0x0027FF20 )
    #else
      #define HAL_FLASH_CA_PUBLIC_KEY_283_ADDR  ( 0x0023FF20 ) 
    #endif
    #define HAL_FLASH_CA_PUBLIC_KEY_283_SIZE  ( 37 + 3 )  // 3-bytes of pad

    // 36-byte Device Private Key (for binary 283 Key Establishment)
    #ifdef  CC2538SF53     
        #define HAL_FLASH_DEV_PRIVATE_KEY_283_ADDR  ( 0x0027FF48 )
    #else
        #define HAL_FLASH_DEV_PRIVATE_KEY_283_ADDR  ( 0x0023FF48 ) 
    #endif     
    #define HAL_FLASH_DEV_PRIVATE_KEY_283_SIZE  ( 36 )

    // 48-byte Implicit Certificate (for Key Establishment)
    #ifdef  CC2538SF53     
        #define HAL_FLASH_IMPLICIT_CERT_ADDR  ( 0x0027FF6C )
    #else
         #define HAL_FLASH_IMPLICIT_CERT_ADDR  ( 0x0023FF6C )
    #endif     
    #define HAL_FLASH_IMPLICIT_CERT_SIZE  ( 48 )

    // 22-byte CA Public Key (for Key Establishment)
    #ifdef  CC2538SF53     
        #define HAL_FLASH_CA_PUBLIC_KEY_ADDR  ( 0x0027FF9C )
    #else
          #define HAL_FLASH_CA_PUBLIC_KEY_ADDR  ( 0x0023FF9C )
    #endif     
    #define HAL_FLASH_CA_PUBLIC_KEY_SIZE  ( 22 + 2 )  // 2-bytes of pad

    // 21-byte Device Private Key (for Key Establishment)
    #ifdef  CC2538SF53     
        #define HAL_FLASH_DEV_PRIVATE_KEY_ADDR  ( 0x0027FFB4 )
    #else
         #define HAL_FLASH_DEV_PRIVATE_KEY_ADDR  ( 0x0023FFB4 ) 
    #endif     
    #define HAL_FLASH_DEV_PRIVATE_KEY_SIZE  ( 21 + 3 )  // 3-bytes of pad

    // 8-byte IEEE address (unique for each device)
    #define HAL_FLASH_IEEE_ADDR  ( 0x0023FFCC )
    #define HAL_FLASH_IEEE_SIZE  ( 8 )  // Re-defining Z_EXTADDR_LEN here

    // Location of SoC factory IEEE address (Information Page)
    #define HAL_INFO_ADDR  0x00280000
    #define HAL_INFO_IEEE_OFST  0x028
    #define HAL_INFO_IEEE_ADDR  (HAL_INFO_ADDR + HAL_INFO_IEEE_OFST)

  • Dear Jason,

    now I have solved the issue, except change the icf and hal_board_cfg.h files, I also modified the FLASH_START_ADDR from 0x0027F800 to 0x0023F800 in startup_ewarm.c.

    Thank you for your reply.

    BR,

  • Hi Wulin,

    Glad to hear it worked for you.