CC2640R2F BLE5.0 Bluetooth protocol stack generates off-chip command files
[Copy link]
This post was last edited by Jacktang on 2020-4-15 07:39
How to convert the standard SDK connector command file into an OAD-compliant connector command file. The following takes cc26xx_app_and_stack.icf as an example.
Allocate metadata vector and application starting point memory.
We expect the flash range to be application and stack code and data.
Replace:
// Code and RO Data
place in FLASH_ALL { readonly };
with:
// Code and RO Data
place in FLASH { readonly };
Then redefine flash from OAD_FLASH_START to FLASH_END. This will take up 30 pages. OAD_FLASH_START represents the code where the application/protocol stack starts.
define region FLASH = mem:[from OAD_FLASH_START to FLASH_END];
Then define the OAD metadata macro
// OAD specific
define symbol OAD_HDR_SIZE = 16; // Size of metadata vector
define symbol OAD_HDR_START = FLASH_START;
define symbol OAD_HDR_END = OAD_HDR_START + OAD_HDR_SIZE - 1;
Finally define OAD_FLASH_START, metadata vector and interrupt table calculation.
Calibrate the interrupt vector table
The interrupt vector table is the key to the correct startup of the application, so the interrupt vector table is mapped at the beginning of the flash, but due to the metadata table, the interrupt vector table needs to be moved.
First, define the following macros:
define symbol INT_VEC_SIZE = 64;
define symbol INT_VEC_START = OAD_HDR_START + OAD_HDR_SIZE;
define symbol INT_VEC_END = INT_VEC_START + INT_VEC_SIZE - 1;
Then define the range according to the defined symbols:
define region INT_VEC = mem:[from INT_VEC_START to INT_VEC_END];
Finally, for the memory placement, the following needs to be added so that the interrupt vector table section is placed correctly:
// Interrupt Vector Table
place at start of INT_VEC { readonly section .intvec };
keep { readonly section .intvec };
Keep page 31 (BIM+CCFGs)
Because the project should not compile the ccfg_app_ble.c file, it should not be linked here. Remove the following two lines of commands:
// CCFG
place at end of FLASH_LAST_PAGE { readonly section .ccfg };
keep { section .ccfg };
CCFGs should be compiled and linked by BIM. This step ensures that page 31 is not used by the user.
OAD images are page aligned.
Library OAD image files always occupy 31 pages after compilation, so alignment is not required. OAD image generation tools can also fill 0XFF at boundaries.
Stack size changes
Usually, the stack size should not be changed, but if necessary, it can be changed in the project according to the OAD configuration type.
Only APP+Stack can be changed, Library OAD is an unchangeable stack configuration. Make the entry point always the same address at the beginning of the page. To force the linker to page alignment, just add the linker definition PAGE_ALIGN=1 in the stack project.
When only the protocol stack OAD is configured, the protocol stack OAD can be page aligned, and the application can run normally as long as the entry point is the same.
Generate OAD image metadata vector
OAD_Image_Tool can generate metadata vector and insert it into a given image to produce an OAD-ready image file, which can be a hex file or a bin file containing metadata of target interrupts.
OAD_Image_Tool is a tool written in Python and can be found in the Tools folder.
It can be used in Post_build in IAR, for example, add ./oad_image_tool.exe -t offchip -o out.hex -m 0x0000 -i app in.hex.
The out.hex file will be an OAD-ready image with metadata to tell the OAD Target that it is an application image of off-chip OAD.
How to generate OAD image file
The following figure shows how to edit the IAR post-production step of the OAD image tool. This menu can be accessed by right-clicking on the project -> Options.
$TOOLS_BLE_DIR$\oad\oad_image_tool.exe $PROJ_DIR$\FlashROM_OAD_Offchip\Exe$TARGET_BNAME$.hex -t offchip -i app --imgVer 0 -ob $PROJ_DIR$\FlashROM_OAD_Offchip\Exe$TARGET_BNAME$.bin -m 0x0000 --r 0x0000
After compiling this command, run oad_image_tool.exe to generate the corresponding bin and hex files.
|