code runs under debugger, not without

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

code runs under debugger, not without

2,208 次查看
GoatRope
Contributor II

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);
}

标签 (1)
0 项奖励
回复
12 回复数

2,069 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

HI @GoatRope ,

  Seems you forget to attach the simple project, please help to attach it again thanks, I will check the code details at first.

 

Best Regards,

Kerry

0 项奖励
回复

2,050 次查看
GoatRope
Contributor II

Attached zip

1,994 次查看
GoatRope
Contributor II

Hi Kerry - any feedback on this? 

Is the zip sufficient to analyze? 

0 项奖励
回复

1,981 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @GoatRope ,

  Thanks so much for your shared project and the information.

   As you are our key customers, to our working flow, we have the FAE to follow you directly, so, my boss already switch your case to our FAE side directly.

  Do you get NXP FAE contact information to you directly by email or not?

   If still no information, please kindly let me know, thanks.

 

Best Regards,

Kerry

0 项奖励
回复

1,959 次查看
GoatRope
Contributor II

Yes I got email from NXP and replied with project zip and some info. Have no solution yet. Thank you Kerry!

0 项奖励
回复

2,057 次查看
GoatRope
Contributor II

Seem to have problem uploading, I let 18MB file sit > 15mins uploading, didnt finish. I'll try again with reduced to 8MB. 

0 项奖励
回复

2,169 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @GoatRope ,

   You can share your issues project here, then we can find time to help you to check it.

    You can delete all the important code to you, just leave the code that can reproduce the issues.

   From your description, your bootloader is just the app which do the flexRAM reallocation, and debugging also confirms the working, just boot have issues, you can share the project for analysis, thanks.

Best Regards,

kerry

0 项奖励
回复

2,150 次查看
GoatRope
Contributor II

Yes Kerry - under debugger I reallocate RAM, copy code ther, jump to main, various Init functions, turn on user LED. Without debugger no LED. Attached is a simplified project. 

I'll look thru to see if I can tell you any unusual stuff I did, please keep in mind I am new to this so I could have something obvious. One thing to note is I use a custom linker file at build/msd_djb.ld. Also I reduced Flash size for this bootloader so I do not erase any previously loaded application code at every debug session. See in common.h:

#define APP_LOCATION_BASE ( ( SECTOR_0_LOCATION + BOOTLOADER_RESERVED ))
#define APP_LOCATION_VECTORS ( ( SECTOR_0_LOCATION + BOOTLOADER_RESERVED + APP_TEXT_OFFSET ))

0 项奖励
回复

2,146 次查看
GoatRope
Contributor II

Also FWIW I did not see proper operation with the "Reset before Running" box checked ( in the JLink tab of Debug Configurations ). Unchecked => OK. Not sure what this is about. 

0 项奖励
回复

2,193 次查看
mjbcswitzerland
Specialist V

Hi

When you load the boot loader using the debugger where do you store it (usually in internal QSPI flash)?
To be able to boot the code needs a header (which is recognised by the internal ROM loader and configures the FlexSPI) - do you have this in the image? [debuggers may be using a config file that configures some things on connect].

See also https://www.utasker.com/iMX/RT1024.html for ready made boot loader for the 1024 (various interfaces like USB, UART, SD card, memory stick, Ethernet, etc., dynamic FlexRAM reconfiguration, encryption, operation in XiP, ITC or SDRAM and clone protection).

Regards

Mark

For i.MX and Kinetis stock availability see https://www.utasker.com/Shop/semi.html

0 项奖励
回复

2,189 次查看
GoatRope
Contributor II

Thanks, Mark. I do have ivt, bd, dcd in the image per map, along with XIP_BOOT_HEADER_ENABLE and I added XIP_BOOT_HEADER_DCD_ENABLE. I'm assuming these are what you refer to.  Yes stored at 0x60000000 and 0x60002000 like usual. 

Utasker may be an option - things are in flux. 

0 项奖励
回复

2,182 次查看
mjbcswitzerland
Specialist V

Hi

Yes, that sounds basically correct like that.

The uTasker loader can be used with any application code and could be a solution for you since it is proven (used in various industrial i.MX RT products for a number of years), documented and supported as well as being very flexible and can be build for any i.MX RT10xx part (incl. 1024) in a few minutes (GCC make file, MCUXpresso, IAR, Keil or Rowley Crossworks).

There are some documents and videos that may help to get a full picture of what it offers as a turn-key solution:
https://www.utasker.com/docs/iMX/Loader.pdf
https://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf
https://www.utasker.com/docs/iMX/MCUXpresso.pdf
https://www.youtube.com/watch?v=5iT7KP691ls&list=PLWKlVb_MqDQEOCnsNOJO8gd3jDCwiyKKe&index=11
https://www.youtube.com/watch?v=fnfLQ-nbscI&list=PLWKlVb_MqDQEOCnsNOJO8gd3jDCwiyKKe&index=12

Regards

Mark



0 项奖励
回复