Dear @Omar_Anguiano
I tried to import AN12604SW booloader source code into MCU Expresso IDE, because i dont have IAR license (NXP use IAR for bootloader demostration).
I'm stuck in hardfaut, after debugging step by step,I found the fault reason is the function "is_valid_application_location", NXP sample code will check "applicationAddress == (uint32_t)&Reset_Handler", and "Reset_Handler" is set by IAR Linker.
How can we set "Reset_Handler" value in MCU ExpressoSDK?
Below is the code of NXP and Linker by IAR
bool is_valid_application_location(uint32_t applicationAddress)
{
// Verify that the jumpLocation is non zero and then either within flash or RAM, both calculations are:
// (jumpLocation >= startAddress) && (jumpLocation < (startAddress + size))
if ((!applicationAddress) || // address is not null AND
(applicationAddress == 0xffffffff) || // address is not blank Flash (0xff) AND
(applicationAddress == (uint32_t)&Reset_Handler)||
(*(uint32_t *)applicationAddress == 0xffffffff))
{
return false;
}
bool isValid = true;
//const uint32_t minThumb2InstructionSize = 2; // smallest thumb2 instruction size is 16-bit.
// Check if the application address is in valid executable memory range
// status_t status = find_map_entry(applicationAddress, minThumb2InstructionSize, &map);
// if ((status == kStatus_Success) && (map->memoryProperty & kMemoryIsExecutable))
{
// isValid = true;
}
return isValid;
}
- Linker
* Entry Point */
ENTRY(Reset_Handler)
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
/* Specify the memory areas */
MEMORY
{
m_flash_config (RX) : ORIGIN = 0x60000000, LENGTH = 0x00001000
m_ivt (RX) : ORIGIN = 0x60001000, LENGTH = 0x00001000
m_interrupts (RX) : ORIGIN = 0x60002000, LENGTH = 0x00000400
m_text (RX) : ORIGIN = 0x60002400, LENGTH = 0x03FFDC00
m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00040000
}
/* Define output sections */
SECTIONS
{
.flash_config :
{
. = ALIGN(4);
__FLASH_BASE = .;
KEEP(* (.boot_hdr.conf)) /* flash config section */
. = ALIGN(4);
} > m_flash_config
ivt_begin= ORIGIN(m_flash_config) + LENGTH(m_flash_config);
.ivt : AT(ivt_begin)
{
. = ALIGN(4);
KEEP(* (.boot_hdr.ivt)) /* ivt section */
KEEP(* (.boot_hdr.boot_data)) /* boot section */
KEEP(* (.boot_hdr.dcd_data)) /* dcd section */
. = ALIGN(4);
} > m_ivt
Thank you.