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: CC2538SF23 not running in flash memory

Part Number: CC2538
Other Parts Discussed in Thread: Z-STACK,

IAR Embedded Workbench IDE - Arm 8.30.1

ZStack 3.0.1 "GenericApp" example workspace 

Windows 10 w/ Fast Computer, XDS200 Debug Probe

1. The workspace compiles.

2. The MCU can be flashed through the IAR Flash Programmer. The IDE was configured to output the Intel .hex file and this file can be uploaded through SmartRF Flash Programmer 2 as well.

3. Disassembly shows that the PC is stuck somewhere in the ROM, presumably the bootloader. It runs, but never exits a preset memory range.

4. Using a .mac setup file in the IDE to move the PC to 0x200004 allows the program to execute or "blink an LED". This was verified in disassembly with the HAL performing it's loop.

5. When disconnected from the Debug Probe and operating independently the circuit board is not running in flash memory.

ZStack 3.0.1 is designed to run on an evaluation board which might have a different MCU, potentially a CC2538SF53 with 512kB flash. Maybe a mapping error preventing the bootloader from verifying the flash?

IAR support has already helped me diagnose an IDE issue (moving from CC to IAR) and I have a contact there if there needs to be further correspondence. 

  • I've looked at this forum post and believe it is somewhat similar to the issue I am encountering.

    e2e.ti.com/.../694306
  • Have you changed the Device Processor Variant in the IAR project General Options? The Z-Stack project Linker configuration file (C:\Texas Instruments\Z-Stack 3.0.1\Projects\zstack\Tools\CC2538DB) defaults to the 512 kB version and must be modified. You should also be using EWARM 8.11.1 for Z-Stack 3.0.1 as stated in the release notes.

    Edit: Definitely modify CC2538.icf

    Regards,
    Ryan

  • Thank you for the quick response.

    The version of EWARM I am using includes a Linker file for the 256kB variant. I am overriding the default Linker file with said file. The memory addresses seem to line up. See the code below.

    I will look into the version differences in EWARM. 

    //*****************************************************************************
    //
    // Linker configuration file for CC2538.
    //
    // 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.
    //
    define region FLASH = mem:[from 0x00200000 to 0x0023C7FF];
    
    //
    // 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 0x0027C800 to 0x0027F7FF];
    
    //
    // 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 0x0027FED4 to 0x0027FF1F];
    //
    // Key-Establishment "Certificate Authority Public Key 283"
    define region CP_CAPK_283 = mem:[from 0x0027FF20 to 0x0027FF47];
    //
    // Key-Establishment "Device Private Key 283"
    define region CP_DEPK_283 = mem:[from 0x0027FF48 to 0x0027FF6B];
    //
    // Key-Establishment "Implicit Certificate"
    define region CP_IMPC = mem:[from 0x0027FF6C to 0x0027FF9B];
    //
    // Key-Establishment "Certificate Authority Public Key"
    define region CP_CAPK = mem:[from 0x0027FF9C to 0x0027FFB3];
    //
    // Key-Establishment "Device Private Key"
    define region CP_DEPK = mem:[from 0x0027FFB4 to 0x0027FFCB];
    //
    // Device's unique 64-bit IEEE address
    define region CP_IEEE = mem:[from 0x0027FFCC to 0x0027FFD3];
    
    
    //
    // Define a region for Customer Configuration Area in flash.
    define region FLASH_CCA = mem:[from 0x0027FFD4 to 0x0027FFDF];
    
    //
    // Define the region for Lock Bits in flash.
    define region FLASH_LCK = mem:[from 0x0027FFE0 to 0x0027FFFF];
    
    //
    // Define the region for Image Boot Manager (IBM) Ledger Page.
    //define region LEDGER_PAGE = mem:[from 0x0027C000 to 0x0027C7FF];
    
    //
    // Define the region for Image Boot Manager (IBM)
    //define region BOOTLOADER_PAGE = mem:[from 0x0027F800 to 0x0027FD00];
    
    //
    // 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 FLASH { 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 };
  • Other than revise link script, you also need to revise option->linker->checksum->endAddress to 0x0023FFDF
  • A diff compare reveals that the only change between the default and your variant is to the FLASH memory region, therefore all values between NV_MEM and BOOTLOADER_PAGE (any define with 0x0027) are invalid.

    Regards,
    Ryan
  • YiKai,

    I have modified the "Fill unused code memory" to 0x0023FFDF.

    Ryan,

    I will modify the .icf file according to the datasheet provided by Texas Instruments for the CC2538SF23 and then advise on the issue.

    Thank you both.