Hey,
i used SDCC on a 8051 for a long time but since i always missed a
debugger I started testing a STM8 with SDCC, stm8-gdb, openocd and a
STM8-Discovery board.
As a test I began to port FreeRTOS to the STM8.
Unfortunately i run into a segmentation fault when using the flags
"--debug" and "--out-fmt-elf" at the same time with static declarations
so i wrote a simple test.c.
#include <stdint.h>
#include <stdio.h>
#define UART1_SR (*(volatile uint8_t *)0x5230)
#define UART_SR_TXE (1 << 7)
#define UART1_DR (*(volatile uint8_t *)0x5231)
int putchar(int c) {
while(!(UART1_SR & UART_SR_TXE));
UART1_DR = c;
return(c);
}
void print(const char *t) {
printf("%s", t);
}
void main(void) {
static const char *text = "Hallo Welt!\n";
print( text );
return;
}
sdcc -mstm8 -o obj/ --debug --out-fmt-elf --all-callee-saves \
--fverbose-asm --float-reent --no-peep --stack-auto \
-Isrc -c src/test.c
Compilation works fine in three cases:
- when the string "test" is not declared as static
- when the "--debug" flag is missing in the command line
- when the "--out-fmt-elf" flag is missing in the command line
but all together will lead to a Segmentation fault
I need the compile flags because i want to use stm8-gdb but FreeRTOS
uses this static declarations in its heap_1.c file.
heap_1.c starting at line 59:
extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#else
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#endif /* configAPPLICATION_ALLOCATED_HEAP */
/* Index into the ucHeap array. */
static size_t xNextFreeByte = ( size_t ) 0;
/*-----------------------------------------------------------*/
void *pvPortMalloc( size_t xWantedSize )
{
void *pvReturn = NULL;
static uint8_t *pucAlignedHeap = NULL;
The Problem seems to come from the assembler because
sdcc -mstm8 -o obj/ --debug --out-fmt-elf --all-callee-saves \
--fverbose-asm --float-reent --no-peep --stack-auto \
-Isrc -S src/test.c
does not give an error.
Can some one give me a tip where to start looking up for this fault?
Best regards
Michael
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user