Hi,
thanks a lot for the hint, your observation is 100% correct!
However, even when I correct the jump address from main.map the LED
doesn't blink. Then I included the delay loop into main() to avoid
function calls altogether (->main now at 0xa0), but still no blinking. Darn!
Any idea what could be wrong? Thanks a lot in advance!
Regards, Georg
PS:
- I can only assume that stm8gal does jump to the specified address,
based on "jump to 0x8000" works correctly. But I'll look into it again.
- any proposal how I to share files without attaching them to this
newsletter? Thanks!
Am 21.11.20 um 21:33 schrieb Basil Hussain:
Hi,
I think I know why your code isn't working as expected.
If your example code is compiled and linked as specified, but we walk
through normal execution - as if it had been programmed and booted
normally - the flow from power-on goes as follows:
1. 0x8000 - Beginning of flash; executes reset vector, INT instruction
jumping to 0x8007.
2. 0x8007 - _sdcc_init_data() code; ends with jump to
_sdcc_program_startup(), at 0x8004.
3. 0x8004 - _sdcc_program_startup() code; just jumps to main(), at
0x00D7.
So, you see, your main() function does not live at 0x00A0! What does
live there is the delay_ms() function, because it has been placed
*before* main() (even though it doesn't ultimately get used, as it's
usage within main is inlined).
When you are using stm8gal to tell the bootloader to 'GO' to 0x00A0,
it is jumping in to delay_ms(), which is probably getting some garbage
value from the stack as an argument and going in to an infinite loop
or some other unexpected behaviour, and not blinking the LED.
Try instead substituting value of "-j" arg with whatever address
main() is actually at - check the .map file after linking.
Regards,
Basil Hussain
On 21/11/2020 17:05, Georg Icking-Konert wrote:
hello,
I want to write a STM8 program which is executed from RAM. But unlike
the example in
https://lujji.github.io/blog/executing-code-from-ram-on-stm8/ it is
not stored in flash and copied to RAM during runtime. Instead the
hexfile is uploaded to RAM via the ROM bootloader, and then invoked
via the bootloader "GO" command.
Below please find a simple "blink" example (adapted from
https://lujji.github.io/blog/bare-metal-programming-stm8/#First-program).
It woks if compiled for flash and uploaded via bootloader.
Then I tried to do the same for RAM:
1) compile via "sdcc -mstm8 -c main.c --codeseg RAM_SEG"
2) link via "sdcc -mstm8 -lstm8 -Wl-bRAM_SEG=0x00a0 main.rel" -->
hexfile with code in RAM (0xa0..0xfa) and flash (0x8000..0x807b, ISR
vector table...?)
3) manually remove the flash content in main.ihx --> hexfile with
code only in RAM
4) upload & call via "stm8gal -port /dev/ttyUSB0 -w main.ihx -reset 0
-j 0xa0" (see https://github.com/gicking/stm8gal)
But unfortunately that doesn't seem to work (LED doesn't blink). Any
idea how I can create a "RAM only" code via SDCC? For your help
thanks a lot in advance!
Regards,
Georg
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user