FLEXSPI_SoftwareReset causes MCU reset under a certain condition

cancel
Showing results for 
Search instead for 
Did you mean: 

FLEXSPI_SoftwareReset causes MCU reset under a certain condition

Jump to solution
123 Views
Contributor IV

I'm using the MIMXRT1062DVJ6A with external flash (Maconix MX25L25645G) on the FLEXSPI bus in QPI mode. It's 256 Mbit part, so we added 4-byte addressing commands to the customLUT to support it. It works perfectly.

I have two projects that I run on this setup; the factory image, which also serves a bootloader, and a downloadable image, which is the application. The downloadable project is a clone of the factory project—it has no source files of its own, but symbolic links to source files in the factory project. The memory maps are different, though, and there are a couple of macros for the factory code to be able to find the downloaded application and jump to it. The factory image will not change during the lifetime of the product; either it or the downloaded application can get a new application, which the factory code will then program into flash memory.

My factory program uses the canonical jump_to_application() function that loads the stack pointer and program counter from interrupt vector table. After finding there is a valid application available, which is done very early in the boot, it calls jump_to_application() and everything works great until I try to initialize the flash driver. As soon as FLEXSPI_SoftwareReset() is called, and it's only called once after boot—the jump_to_application() call happens well before FLEXSPI_Init(), the processor goes back to the breakpoint I have set at main().

When I examine the interrupt vectors I find they are all pointing to addresses in the downloaded code's memory map. I see the SP and PC registers getting set correctly, and can run or step through over a hundred lines of code (the flash is XIP) that makes calls to various peripherals and even reads lots of flash memory flash memory. But when I get into FLEXSPI_Init() and it calls FLEXSPI_SoftwareReset(), i go right back to main(). A cold boot with no application to jump to runs without any issue of this sort.

I'm open to suggestions. Got any?

0 Kudos
1 Solution
69 Views
Contributor IV

Problem solved. My application code is a clone of the factory code. The linkscripts folder either didn't make it into the application project, or was deleted. The result was that my flexspi_nor_flash_ops.o and fsl_flexspi.o modules didn't loaded properly. I copied linkscripts folder from the factory to the application project, and all is now well.

View solution in original post

5 Replies
108 Views
Contributor IV

Sorry for being unclear. the jump_to_application() call takes me from the factory code to the main() function in my application code. From there, it calls eventually calls FLEXSPI_Init(). When FLEXSPI_Init() calls FLEXSPI_SoftwareReset(), the processor resets and code starts executing all over again at the main() in my factory code.

I think a couple of addresses might be helpful. The factory code links and loads starting at 0x600000000. The application code it jumps to is built to link and load starting at 0x60280000. On boot up, the processor starts with the code flashed flashed into the lower address. The value passed to jump_to_application() is 0x60280000. When code in the upper address calls FLEXSPI_SoftwareReset(), I hit the breakpoint I set at main() in code starting at the lower address.

It's as if the FLEXSPI_SoftwareReset() actually resets the processor, not just the peripheral. According to the SDK reference manual, "This function sets the software reset flags for both AHB and buffer domain and resets both AHB buffer and also IP FIFOs." It appears as though the processor itself is getting a reset,

0 Kudos
114 Views
NXP TechSupport
NXP TechSupport

Hi,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Actually, I'm still not very clear with your question, whether you mean that execute the FLEXSPI_Init() which includes the FLEXSPI_SoftwareReset() prior to executing the jump_to_application(), then it will fail to jump to the downloadable application, even it causes the reset event, is it right?
If not, can you describe your question again?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
89 Views
Contributor IV

Here's a screen shot for a Bus Fault that happened when I tried to call FLEXSPI_Init following the jump from my factory/bootloader code to my application.

0 Kudos
103 Views
Contributor IV

Here's my main code.

int main ( void )
{
*(volatile uint32_t*) 0xe000ed24 = 0x70000;

#ifdef DOWNLOAD_BUILD
// these are used to ensure that the application and graphics bitmaps CRCs get included
const uint8_t* fwHash __attribute__ ((unused)) = applicationHash;
const uint8_t* bmHash __attribute__ ((unused)) = bitmapsHash;
#endif

#ifdef WATCHDOG_ENABLED
wdog_config_t config;
#endif

BOARD_ConfigMPU();

#ifdef FACTORY_BUILD
if( 0 == strcmp(jumpCommand, "jump to application") )
{
unsigned long appAddr = APP_ADDR;

memset( jumpCommand, 0, sizeof(jumpCommand) );
jump_to_application(appAddr);
}
#endif

The jumpCommand string is located in uninitialized RAM. jump_to_application is

void jump_to_application(unsigned long app_link_location)
{
// vTaskEndScheduler();
// Cortex-M3/M4/M7 assembler code
//
asm(" ldr sp, [r0,#0]"); // load the stack pointer value from the program's reset vector
asm(" ldr pc, [r0,#4]"); // load the program counter value from the program's reset vector to cause operation to continue from there
}

 If jump_to_application() is not called, the program runs without any problem. But if jump_to_application() is called, program execution starts at main() in the application code and runs fine until FLEXSPI_Iinit(), where it returns to main() in the factory/bootloader code.

0 Kudos
70 Views
Contributor IV

Problem solved. My application code is a clone of the factory code. The linkscripts folder either didn't make it into the application project, or was deleted. The result was that my flexspi_nor_flash_ops.o and fsl_flexspi.o modules didn't loaded properly. I copied linkscripts folder from the factory to the application project, and all is now well.

View solution in original post