cc2538: Add header file for flash CCA page and use it
Create a dedicated header file with all the definitions for the flash lock bit page and customer configuration area. This avoids duplicating those definitions in the startup-gcc.c files of all CC2538-based platforms, and this also allows to easily manipulate the CCA from outside startup-gcc.c (e.g. for on-the-air firmware update). The definitions are now complete contrary to what was in startup-gcc.c: - Definitions have been added to select the bootloader backdoor pin and active level if enabled. - Definitions have been added to access the page and debug lock bits. The debug lock bit can be used to prevent someone from reading back a programmed firmware through JTAG if the firmware binary image has to be confidential, which should be combined with a disabled bootloader backdoor. - The application entry point is now tied to the beginning of the .text section instead of to the beginning of the flash. This allows projects using custom linker scripts to place the application entry point anywhere in the flash, which can be useful e.g. for on-the-air firmware update. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
This commit is contained in:
parent
65806f53eb
commit
a2686e581e
3 changed files with 106 additions and 18 deletions
|
@ -38,13 +38,11 @@
|
|||
*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "flash-cca.h"
|
||||
#include "sys-ctrl.h"
|
||||
#include "uart.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define FLASH_START_ADDR 0x00200000
|
||||
#define BOOTLOADER_BACKDOOR_DISABLE 0xEFFFFFFF
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern int main(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -92,22 +90,19 @@ void uart_isr(void);
|
|||
/* Allocate stack space */
|
||||
static unsigned long stack[512];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Customer Configuration Area in the Lock Page
|
||||
* Holds Image Vector table address (bytes 2012 - 2015) and
|
||||
* Image Valid bytes (bytes 2008 -2011)
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned long bootldr_cfg;
|
||||
unsigned long image_valid;
|
||||
unsigned long image_vector_addr;
|
||||
} lock_page_cca_t;
|
||||
/* Linker construct indicating .text section location */
|
||||
extern uint8_t _text[0];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
__attribute__ ((section(".flashcca"), used))
|
||||
const lock_page_cca_t __cca = {
|
||||
BOOTLOADER_BACKDOOR_DISABLE, /* Bootloader backdoor disabled */
|
||||
0, /* Image valid bytes */
|
||||
FLASH_START_ADDR /* Vector table located at the start of flash */
|
||||
const flash_cca_lock_page_t __cca = {
|
||||
FLASH_CCA_BOOTLDR_CFG_DISABLE, /* Bootloader backdoor disabled */
|
||||
FLASH_CCA_IMAGE_VALID, /* Image valid */
|
||||
&_text, /* Vector table located at the start of .text */
|
||||
/* Unlock all pages and debug */
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
__attribute__ ((section(".vectors"), used))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue