Hi
I want to run a function (hw_InitLL()) that resides in Program Code from Bootloader .
What i did to accomplish this
in linker files of both program and bootloader :
m_hw_InitLL (RX) : ORIGIN = 0x000020C0, LENGTH = 0x00000200
SECTIONS
/* The HwInit code goes first into INTERNAL_FLASH */
.hw_InitLL :
{
*(.hw_InitLL)
} > m_hw_InitLL
in Program code :
void hw_InitLL(void) __attribute__((section(".hw_InitLL")));
void hw_InitLL(void)
{
// do some hw initialisation
// in this example i return without any other code
}
if i check the linker output after building both projects, i see function InitLL at address 0x20C0 which i wanted.
When i run hw_InitLL(); in program code, then it executes fine as expected. U can see assembly and memory content in this prtscr
in BL code :
When i run ((void (*) (void)) 0x000020C0) (); , then it jumps to addess 0x20C0 as expected. i can see the memory content is the same, but there are other assembly instructions in disassembly window (see prtscr). When i step further i run into a hardware fault
I did use a HardwareFault component in processor expert. This gives me stacked_lr : 5159 -> "Unable to retrieve disassembly data from backend".
My Question
Why do i see the same memory content but is codewarrior not able to show these as assembly instructions?
Why do i run into a hardwarefault?
Is there any way to execute that piece of code from 2 different places?
I will tell u why this is so important .. I want to use my BL in different hardware. When for example i use hardware with different ports assigned to different functions , like controlling a motor, i dont want the ports in an unitialized stated during the time needed to update the firmware.
So what i do is this -> Program code gets instruction to update firmware -> write an update flag in Eflash -> reset -> BL starts and run hw_InitLL() (must run from program code) -> BL erase flash and update with new program
I appreciate anyone's help very much.
Thank u
Steve
Solved! Go to Solution.
Hi Alice,
No need to post parts of the code . I found the solution,
i just need to call the function with an uneven address, so 0x020C1 instead of 0x020C0
Googling, I found:
The mechanism for switching makes use of the fact that all instructions must be (at least) halfword-aligned, which means that bit[0] of the branch target address is redundant. Therefore this bit can be re-used to indicate the target instruction set at that address. Bit[0] cleared to 0 means ARM and bit[0] set to 1 means Thumb.
Thank you for the help !
Steve
Hi Alice,
No need to post parts of the code . I found the solution,
i just need to call the function with an uneven address, so 0x020C1 instead of 0x020C0
Googling, I found:
The mechanism for switching makes use of the fact that all instructions must be (at least) halfword-aligned, which means that bit[0] of the branch target address is redundant. Therefore this bit can be re-used to indicate the target instruction set at that address. Bit[0] cleared to 0 means ARM and bit[0] set to 1 means Thumb.
Thank you for the help !
Steve
Hello Alice,
Thank u for the response .
To answer your questions.
Are sure you have flash the function correctly -> both programs are flashed in different FLASH area's , when i debug bootloader code i make sure i don't wipe Program code. i'm sure the hw_InitLL() instructions are still in flash when i call them. Thats what u see in the examples at address 0x20C0.
I also tried to run the code without debugger as this is maybe just a debugger issue, but then it also dont work .
U are right that the debugger says No source available, thats what i try to figure out why this is. I just want to execute "RAW "assembly instructions from flash address 0x020C0 and jump back in bootloader code . But the moment i the code at 0x20C0 starts to execute, it seems to generate an exception error.
hw_InitLL() resides only in Program Code. I compile BL code and Program code separate.
And what's different between the two test above you said. -> one test is in Program Code that shows the moment i jump into hw_InitLL() , the other test is in BL code where i jump to the address where hw_InitLL() code is located .
Thank u :smileyhappy:
Hello steve,
Through the "Actions" button you can attach fiels :
Also i will say hello to you email .
BR
Alice
Hello Steve,
"reset -> BL starts and run hw_InitLL() (must run from program code) -> BL erase flash and update with new program"
In Bl, how do you jump to “hw_InitLL()”,and are sure you have flash the function correctly ,? for i see it show :
And what's different between the two test above you said.
I see you use the chip of KE02, could you please show some code or project , i will be
facility to debug then find .
BR
Alice