cancel
Showing results for 
Search instead for 
Did you mean: 

Start/Reset app with custom bootloader

Wyrm
Associate II

Edit: fixed a typo -- pa

Hellow! When i debugging an application with a pre-installed bootloader in the Keil environment, I used the following script:

FUNC void DebugSetup (void) {
// </h>
SP = _RDWORD(0x08040800); // Setup Stack Pointer
PC = _RDWORD(0x08040804); // Setup Program Counter
_WDWORD(0xE000ED08, 0x08040800); // VTOR to Image Base
}

FUNC void OnResetExec(void) {
DebugSetup();
}

DebugSetup(); // Debugger Setup

in vscode plugin i add to launch.json

"preRunCommands": [
"set $sp = *(unsigned int *)0x08018000",
"set $pc = *(unsigned int *)0x08018004",
"set {unsigned int}0xE000ED08 = 0x08018000",
],


And it works fine until I do a reset, is there a way to fix this?
For example, something like "postRestartSessionCommands". 

10 REPLIES 10
Wyrm
Associate II

Yes, you are absolutely right, error was in my code because the function variables were on the stack.
And it worked in my projects because Keil doesn't allocate a stack, like GCC And this is the way to UB

I attached screenshots where the bootloader starts with 0x08000000 and stack like in map file

изображение.png

__initial_sp 0x20001a80 Data 0 startup_stm32f765xx.o(STACK)


My Keil sct file

LR_IROM1 0x08000000 0x00010000 { ; load region size_region
ER_IROM1 0x08000000 0x00010000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}
RW_IRAM1 0x20000000 0x00080000 { ; RW data
.ANY (+RW +ZI)
}
}

LR_APP_INFO 0x08010000 0x00000100 {
ER_APP_INFO 0x08010000 0x00000100 {
*(.ARM.__app_info)
}


Sorry for wasting your time on such basic error. I'm so ashamed that I wasted so much time on this mistake.. Thank you!