Hi,
I am using the MPC5645S. I am trying to build a Boot-loader. I can store a Firmware in the flash and I am able to jump to the application.
The main run correctly. However, I have a problem when a function is executed in the main. The debugger says that I try to access on an illegal memory.
Should I set the functions to a section to had a proper access?
To set a function to a section we should use the following instruction?
#pragma push
#pragma section ".app_flash"
__declspec(section ".app_flash")
FUNCTION
#pragma pop
Thanks,
Josep
Hi,
Just before executing the jump (where it crash) check if there are valid data on destination address of the jump which is 0x1D3C6.
If not (I expect not) then you are trying to access memory with no valid code or uninitialized memory at all.
Make sure when you are accessing memory that it contains valid code or it have no restrictions for access.
Peter
Hi,
The core register values before crash are the followings:
When the program crash we can see this registers:
There are a lot of instructions that can cause the crash. All functions and buffers that are stored in "int_flash" section could cause a crash.
Example 1:
1. Start bootloader.
2. Load and store application.
3. Jump to main.c (application).
4. Open a function that was been stored in "int_flash" section.
5. Program crash.
Example 2:
1. Start bootloader.
2. Load and store application.
3. Jump to main.c (application).
4. Open a function that was been stored in "APP_FLASH" section.
5. Execute instructions.
6. Read a buffer that was stored in "int_flash" section.
7. Program crash.
Hi,
Are you aware that every compiler use different #pragma definitions?
Is good to specify at least basic information about your project.
What is the last instruction before your program crash?
Check instruction and core registers to find out if you are accessing memory which can be accessed.
Peter
Hi,
The memory map of my project is:
MEMORY
{
resetvector: org = 0x00000000, len = 0x00000008
init: org = 0x00000020, len = 0x00000FE0
exception_handlers: org = 0x00001000, len = 0x00001000
EE_group: org = 0x00002000, len = 0x0000D000 /* (Emulated EEprom) */
int_flash: org = 0x00020000, len = 0x001E4000
BOOT_FLASH: org = 0x00014000, len = 0x00008000 /* Added Bootloader Block (48k)*
APP_FLASH: org = 0x0001C000, len = 0x00004000
int_sram: org = 0x40000000, len = 0x0000A000
heap : org = 0x4000EC00, len = 0x00000400
stack : org = 0x4000F000, len = 0x00001000
int_gram: org = 0x60000000, len = 0x00100000 /* 1M */
ext_dram: org = 0x20000000, len = 0x02000000 /* 32MB for now */
ext_qspi: org = 0x70000000, len = 0x00800000 /* QSPI 8MB */
}
On the bootloader I upload the app_flash area and the int_flash area. On the app_flash area there are only the main function.
#pragma push
#pragma section ".app_flash"
__declspec(section ".app_flash")
void main(void){
CODE
}
#pragma pop
The other functions are stored on int_flash area.
My program crash when the program try to execute a function that is stored in int_flash section.
For example:
1. (*(APPFn)APP_ENTRY_ADDRESS)(); // jump to app and should not back
2. Enter in main (0x1c000 address)
2. Initialize local variables.
3. Open the first function. ==> Program Crash.
Thanks,
Josep
Hi,
Can you check core registers values (registers which are used by last instruction) and instruction which cause crash?
This is a simple way how to find out where you are trying to access and why it crash.
Peter