2024-04-29 04:42 AM - edited 2024-04-29 04:43 AM
I am working on NUCLEO-H563ZI evaluation board interfacing with QSPI external memory. I have done below steps,
I am able to do read and write.
I have created the external loader file.
I am able to run application code in external memory with debugger support.
Now i am trying to run application code from external memory with bootloader code but i am always ending up with code crash. Could anybody give a clue how to debug this issue?
Note: I have flashed the application code in external memory using cube programmer with external loader.
I have enabled the memory mapped mode in boot up code and able to see the app code in Ext memory.
I have written jump code like below and changed linker script also,
/* Disable Systick interrupt */
SysTick->CTRL = 0;
/* Jump to application */
jumpToApplication = (pFunction)(*(__IO uint32_t*)(APPLICATION_ADDRESS + 4));
__set_MSP(*(__IO uint32_t*)APPLICATION_ADDRESS);
jumpToApplication();
Solved! Go to Solution.
2024-05-09 05:38 AM
You'd need to split the data into TWO .BIN covering the individual regions which are otherwise a long way apart, resulting in a file that's 2GB in size, and clearly not going to fit within a device with a fraction of that capacity.
A .HEX or .ELF can be sparse
2024-04-30 12:58 AM
Hello @Nagarajan ,
->but i am always ending up with code crash.
Could you please precise the exact line of code or function where the code crashes?
I recommend you to take a look at AN5188, this application note provides details on how to boot from internal Flash memory, and then jump to user-application execution from an external memory.
May be the ExtMem_Boot example can help you.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-04-30 03:03 AM
I followed exactly the same instruction given in AN5188 and written Boot and app code like example code you given for STM32H7 only, but when i execute the jumpToApplication(); line, i am always getting Hard fault error.
Before executing jumpToApplication(); line, i am able to see the actual external memory data like below,
After executing jumpToApplication(); line, i am seeing corrupted data in external memory like below, but the data is not corrupted actually.
2024-04-30 09:00 AM
Hi @Nagarajan ,
Is ICache enabled?
If the ICache is enabled, I recommend you to take a look at How to avoid a hard fault when ICACHE is enabled on the STM32H5 series.
This article presents a quick guidance on how to prevent hard fault occurrences when the ICACHE is enabled on the STM32H5 MCU.
I hope this help you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-04-30 10:56 AM
Don't repeat the clock and memory initialization in the application code.
Get the loader code to bring up the system in the desired configuration, at least the key settings for clock, plls, pins, external memories. Other pins/peripherals you can defer until later. Teardown any other interrupts you have going before transferring control.
Watch HAL_Init() and don't be doing SystemClock_Config() for a second time.
Watch also what SystemInit() is doing with SCB->VTOR, I'd use a linker symbol over a define, but make sure the vector table is pointing at your new location.
2024-05-02 01:09 AM
I checked all initialization function, i didn't find any issue in that besides if i change into internal flash location, it jumps to that other internal flash location perfectly without any issue it works fine. When i change it to external memory location only iam facing issue. My doubt is when control jumps to external memory location how it holds the QSPI memory mapped mode in new location? because all QSPI initialization and memory mapped mode have done in boot code not in application code.
2024-05-02 01:16 AM - edited 2024-05-02 01:18 AM
Both iCache and Dcache are disabled in boot code as well as application code. Is it mandatory to enable it in app code?
Below is the MPU configuration for boot code, Please let me know if i need to change anything in that.
void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct = {0};
MPU_Attributes_InitTypeDef MPU_AttributesInit = {0};
/* Disables the MPU */
HAL_MPU_Disable();
/** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x90000000;
MPU_InitStruct.LimitAddress = 0x90FFFFFF;
MPU_InitStruct.AttributesIndex = MPU_ATTRIBUTES_NUMBER0;
MPU_InitStruct.AccessPermission = MPU_REGION_ALL_RW;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
MPU_AttributesInit.Number = MPU_REGION_NUMBER0;
MPU_AttributesInit.Attributes = MPU_DEVICE_GRE | MPU_WRITE_THROUGH
| MPU_TRANSIENT | MPU_NO_ALLOCATE;
HAL_MPU_ConfigMemoryAttributes(&MPU_AttributesInit);
/* Enables the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}
2024-05-06 01:31 AM
I am able to download the entire code in external QSPI flash with the help of external loader but if i want to keep particular section alone in external memory, i am getting the below error while downloading. Could you please help me to find the reason for this issue. I attached linker script with this chat.
This below variable only i want to move to external memory,
uint8_t buff[10] __attribute__((section(".extflash")));
Note: As i couldnt upload the .ld file directly, i just changed as a .c file.
2024-05-06 08:30 AM
Use STM32 Cube Programmer, show complete error, ideally with adequate logging to be able to get some clue as to what is happening.
Show whole memory map for the built file, only see internal FLASH addresses in your screen shot
2024-05-06 11:20 PM