hello all, may I bother you again with a question about how to execute code in the RAM of STM8…?
For routines in RAM (as mandatory for STM8 flash block write/erase), I understand the steps are: compile & link routine for address in RAM —> works now using #pragma in C code and —codeseg for linker (see [bugs:#2421]; thanks to Ben Shi!) tell linker to reserve flash space for above RAM routine (required for step 3) —> I implemented an unused routine which contains N _nop_ operations. But isn’t there an easier way, e.g. "const code byte buf[N]“ or so…? modify hexfile to move RAM code to flash address, so after upload and reset a copy of the RAM routine is in flash —> haven’t done that yet. I have to look into srecord like Maarten proposed below during STM8 initialization copy routine from flash to RAM. Specifically, get src, dst and length, and copy to RAM —> under http://www.cream-tea.de/tmp/main.c <http://www.cream-tea.de/tmp/main.c> please find a file where I try to do this in assembler, because linker labels are only accessible via assembler…? This is my first "real“ assembler code, so I’m not quite sure it’ll do the job. Would you please be so kind and have a look at it? when required call RAM routine by name from C this should work, since the linker label still points to RAM…? Can you please check if my understanding is correct? For your help thanks a lot in advance and have a nice day! Regards, Georg > Am 29.09.2015 um 21:46 schrieb Maarten Brock <maartenbr...@users.sf.net > <mailto:maartenbr...@users.sf.net>>: > > You have to link at the ram address else all jumps and calls to it will jump > to flash. You'll have to post-process the generated hex-file to move the > section to an address in flash. And you'll have to use memcpy to copy it from > flash to ram. You can use srecord <http://srecord.sourceforge.net/> for the > post-processing. > > The linker does create symbols with the start address and length but they are > accessable from assembly only. Some small pieces of inline assembly should be > able to fetch them for you. > > int get_length(void) > { > volatile int length; > __asm > ldw x, #l_RAM_CODE > ldw (0x01, sp), x > __endasm; > return length; > } > [bugs:#2421] <http://sourceforge.net/p/sdcc/bugs/2421/> STM8 code in RAM > > Status: closed-fixed > Labels: RAM STM8 > Created: Fri Sep 25, 2015 10:46 PM UTC by gicking > Last Updated: Tue Sep 29, 2015 07:18 PM UTC > Owner: Ben Shi > Attachments: > > RAM_Code.zip > <https://sourceforge.net/p/sdcc/bugs/2421/attachment/RAM_Code.zip> (21.1 kB; > application/zip) > hello, > > STM8 flash w/e block operations have to be executed from RAM. However, when > compiling any source file with option --codeseg MYSEG I get this message: > > sdcc -mstm8 --std-sdcc99 -DSTM8S207 --codeseg MYSEG -c RAM_routines.c -o > RAM_routines.rel > RAM_routines.asm:96: Error: <u> undefined symbol encountered during assembly > removing RAM_routines.rel > make: *** [RAM_routines.rel] Error 1 > The respective error line in file RAM_routines.asm reads > .area MYSEG (CODE) > > Attached please find an example which toggles GPIO from RAM (just type > "make"). Execution from flash works. > > The error occurs under MacOSX and Win7, and sdcc -v yields > > SDCC : > mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 > 3.5.0 #9253 (Jun 20 2015) (Mac OS X i386) > published under GNU General Public License (GPL) > > initial response by Maarten: > > It seems it outputs an extra (CODE) piece that should only be used on Harvard > architectures (e.g. mcs51). > > Sent from sourceforge.net <http://sourceforge.net/> because you indicated > interest in https://sourceforge.net/p/sdcc/bugs/2421/ > <https://sourceforge.net/p/sdcc/bugs/2421/> > Please do not reply to this message. Post your messages on the original page > <https://sourceforge.net/p/sdcc/bugs/2421/> > To unsubscribe from further messages, please visit > https://sourceforge.net/auth/subscriptions/ > <https://sourceforge.net/auth/subscriptions/>
------------------------------------------------------------------------------
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user