I am trying to edit the startup code for the MCUXpresso LPC51U68 board so that I can flash an enhanced image to the board See instructions in section 3.5.6 (pg. 17) of this user manual (NXP_LPC51U68_UM). I changed the bolded lines from the user manual in the startup code that I downloaded from the SDK for the LPC51U68 board (on NXP's website). I wrote the IMAGEHEADER_T fuction from the user manual in the startup code also.
My edits to the startup code ended up looking like this:
__attribute__ ((used, section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
// Core Level - CM0P
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
0, // Reserved
0, // Reserved
0, // Reserved
__valid_user_code_checksum, // LPC MCU checksum
0, // ECRP
(void*) 0xEDDC9494, // Enhanced image marker (This was added)
imageHeader, // Pointer to enhanced image header (This was added)
SVC_Handler, // SVCall handler
0, // Reserved
0, // Reserved
PendSV_Handler, // The PendSV handler
SysTick_Handler, // The SysTick handler
and this is the definition for the image header (should be exactly as appears in the user manual):
/*Image Header*/
const IMAGEHEADER_T imageHeader = {
IMAGE_ENH_BLOCK_MARKER, //Required marker for image header
IMG_NO_CRC, //No CRC, makes development easier
0x00000000, //crc32_len
0x00000000, //crc32_val
0x00000000 //version
HOWEVER, after making these edits I found that the startup code won't compile. When I checked the memory at offset 0x24 to see if it receive the enhanced image flag 0xEDDC9494, it wasn't there. I tried typing some garbage in the startup code and then building and compiling to see if I got an error and there was no error. How do I get my startup code to compile???
If i create a default LPC51U68 SDK project with MCUXpresso there are no defines for the mentioned structs and values. So you need to do it yourself.
//*****************************************************************************
//*****************************************************************************
#define IMAGE_SINGLE_ENH_SIG 0xEDDC9494
#define IMAGE_ENH_BLOCK_MARKER 0xFEEDA5A5
#define IMG_NORMAL 0
#define IMG_NO_CRC 1
typedef struct IMAGEHEADER_STRUCT
{
unsigned int header_marker;
unsigned int img_type;
unsigned int crc32_len;
unsigned int crc32_val;
unsigned int version;
} IMAGEHEADER_T;
/* Image header */
const IMAGEHEADER_T imageHeader = {
IMAGE_ENH_BLOCK_MARKER, /* Required marker for image header */
IMG_NO_CRC, /* No CRC, makes development easier */
0x00000000, /* crc32_len */
0x00000000, /* crc32_val */
0x00000000 /* version */
};
//*****************************************************************************
// The vector table.
// This relies on the linker script to place at correct location in memory.
//*****************************************************************************
extern void (* const g_pfnVectors[])(void);
extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
__attribute__ ((used, section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
// Core Level - CM0P
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
0, // Reserved
0, // Reserved
0, // Reserved
__valid_user_code_checksum, // LPC MCU checksum
0, // ECRP
(void*) IMAGE_SINGLE_ENH_SIG, // Enhanced image marker @0x24
(void*) &imageHeader, // Pointer to enhanced image header @0x28
SVC_Handler, // SVCall handler
0, // Reserved
0, // Reserved
PendSV_Handler, // The PendSV handler
SysTick_Handler, // The SysTick handler
// Chip Level - LPC51U68
...
}; /* End of g_pfnVectors */
This should compile. However i dont know whats the enhanced image is for.
User contributions licensed under CC BY-SA 3.0