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: Read/Write to Flash: hal_flash.c missing

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

Hello everyone,

I need to assign a proprietary IEEE Address to the device, and following the documentation Z-Stack Generic Application User's Guide (SWRU394) section 5.4, the best way to do it is by means of the Secondary IEEE Address, which is located at flash address CC2538 (512K) -- 0x27FFCC-0x27FFD3 as stated in the documentation.

The key point is that I need to set the IEEE Address during run-time at the very beginning of the code, because it comes from an external MCU. Thus, I have been looking on how to change the secondary IEEE address value in the code, and haven't found anything, so I assumed the only way to do it is by writing directly to the Flash memory. If you know another way, please tell me.

The problem arises when I try to use the HAL driver for writing in the flash:

I am using the GenericApp project as base, and it includes the hal_flash.h in the project files, with functions prototype for void HalFlashWrite(uint16 addr, uint8 *buf, uint16 cnt); and void HalFlashRead(uint8 pg, uint16 offset, uint8 *buf, uint16 cnt); but when I try to use the HalFlashWrite() function in ZMain.c, the following error is raised during compliation in the linking stage:

Linking 
Error[Li005]: no definition for "HalFlashWrite" [referenced from C:\Texas Instruments\Z-Stack Mesh 1.0.0\Projects\zstack\Samples\GenericApp_test\CC2538\Router - OTA ImageA + Bootloader\Obj\ 
ZMain.o] 
Error while running Linker 

Then, I have found out that there is no hal_flash.c file included in the project, and that there is no such file in the Components\hal\target\CC2538 folder. I can only find the hal_flash.c file for CC2530 target...

Which is the assumed procedure to follow for reading/writing to Flash in CC2538? Is it possible to copy the hal_flash.c file from CC2530 to CC2538 target and include it to the project?

Do you have any other proposals for changing the IEEE Address value in the code?

Thank you in advance,

Gaspar

PS:Using CC2538, with Z-Stack Mesh v1.0.0 due to compatibility reasons, but I have been looking for hal_flash.c in other Z-Stack releases like HA and 3.0.1

  • Hi,

    HalFlashWrite() is only used for CC2530/CC2531.

    flashWrite() in armcm3flashutil.c should be used for CC2538.
  • That's just what I was looking for!

    Thank you for tour quick and simple response, just perfect!

    Regards,

    Gaspar

  • Hello JasonB,

    I am facing new problems on this matter. When I try to rewrite to the flash the SecondaryAddress, the flashWrite() method is not doing it correctly, but can't identify which is the problem.

    I just reproduce a simple situation like:

    uint8 ieeeprova[Z_EXTADDR_LEN] = {0x22, 0x44, 0x66, 0x88, 0x11, 0x33, 0x55, 0x77};
    flashWrite((uint8*)HAL_FLASH_IEEE_ADDR, HAL_FLASH_IEEE_SIZE, ieeeprova);

    that is called when a specific message is received from the UART.

    Do you have any example of using the flashWrite for IEEE Address or other example?

    Thank you in advance!

    Note: definitions of address are done in hal_board_cfg.h :

    #define HAL_FLASH_IEEE_ADDR ( 0x0027FFCC )

    #define HAL_FLASH_IEEE_SIZE ( 8 ) // Re-defining Z_EXTADDR_LEN here

  • I am not getting any possible solution....

    flashWrite() method is not writing to flash during runtime. Is the page which the Secondary Address belongs to (0x0027F800) protected against writing? How can I write to the Secondary Address during run-time?

    Thankss
  • Page number 255 is the Lock Bit Page/CCA and is not accessible unless FLASH_CTRL_FCTL .UPPER_PAGE_ACCESS is set. Please refer to Chapter 8 of the User's Guide and your project's configuration linker file.

    Regards,
    Ryan