I wrote code for a bootloader which works fine under debugger ( old JLink ) but not at repowering the 1024 eval board.
Code reallocates FlexRAM to 128K ITC and 64K OCRAM then copies itself into RAM then SystemInit is called before jumping to main(). Early in main ( before tasks ) I set the user LED. For this testing the LED is in an infinite loop.
Specific procedure is to download code under debug, either stop debugger or not, repower, and get no LED. Same issue if I download via GUI Flash tool - no LED at repower. RT1024 eval board DIP switches for internal - { 1234} = { 0010}
How does debug operation differ from booting from flash?
Very new to this so could be something obvious. ResetISR and main() below.
========================
void ResetISR(void) {
// Disable interrupts
__asm volatile ("cpsid i");
__asm volatile ("MSR MSP, %0" : : "r" (&_vStackTop) : );
SCB->VTOR = (uint32_t)g_pfnVectors;
// Address of register IOMUXC_GPR_GPR17 A5FF: DT DT OC OC IT IT IT IT ( DT 10 , OC 01, IT 11 )
__asm volatile (
"LDR R0, =0x400ac044\n"
"LDR R1, =0x0000A5FF\n"
"STR R1,[R0]\n");
// Address of register IOMUXC_GPR_GPR16
// Also in here is vector table offset in bits 31 ~7
// The 4 corresponds to setting the FLEXRAM_BANK_CFG_SEL bit in register IOMUXC_GPR_GPR16
__asm volatile (
"LDR R0,=0x400ac040\n"
"LDR R1,[R0]\n"
"ORR R1,R1,#4\n"
"STR R1,[R0]\n");
unsigned int LoadAddr, ExeAddr, SectionLen;
unsigned int *SectionTableAddr;
SectionTableAddr = &__code_section_table;
// read fields from table
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
copy_code(LoadAddr, ExeAddr, SectionLen);
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
// At this point, SectionTableAddr = &__bss_section_table;
// Zero fill the bss segment
while (SectionTableAddr < &__bss_section_table_end) {
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
bss_init(ExeAddr, SectionLen);
}
SystemInit();
uint32_t x=0;
while ( x<10000000 )
{
x++;
}
#if defined (__REDLIB__)
// Call the Redlib library, which in turn calls main()
__main();
#else
main();
#endif
======================
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
USB_HostApplicationInit();
GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 1U);
//GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 0);
usb_echo("looping LED...\r\n");
while(1)
{
GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 1);
}