SDCC 4.3.0
STM8S103F3 (has 1024 bytes of ram)
Hello,
i think i found another bug.
The ram size is not checked at all.
The following code compiles without warning or error.
char arr1[8000];
int main(void)
{
char arr2[8000];
arr2;
// sysclock_init(0);
for (uint16_t i = 0; i < sizeof(arr1); i++)
{
arr1[i] = i & 0xff;
arr2[i] = i & 0xff;
}
return 0;
}
What did you do to tell the linker how much memory you have? SDCC has no intrinsic knowledge about every derivative.
Hello,
thank you for the hint.
I added the linker options -C -I and -X to the makefile, nothing happens, the code ist still compiled and linked without warning or error.
E:\Projects\Microcontroller\stm8\tbasic\basic_ucnet2\basict - ram - bug>make.exe all
"Cleaning done..."
sdcc -lstm8 -mstm8 --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192 -DF_CPU=16000000 -I./ -I../include -c tbasic.c -o tbasic.rel
sdcc -lstm8 -mstm8 --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192 -DF_CPU=16000000 -I./ -I../include -c ../src/stm8_init.c -o ../src/stm8_init.rel
sdcc -lstm8 -mstm8 --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192 -DF_CPU=16000000 -I./ -I../include -c ../src/uart.c -o ../src/uart.rel
"Linking tbasic.c with libs, Intel-Hex-File: tbasic.ihx"
sdcc -lstm8 -mstm8 -I./ -I../include --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192 --out-fmt-ihx tbasic.rel ../src/stm8_init.rel ../src/uart.rel
" "
" ------ Programm build sucessfull -----"
" "
Device : stm8s103f3 / Flashsize: 8192 bytes
Program : at address 0x8000 592 Bytes (7.2% full)
E:\Projects\Microcontroller\stm8\tbasic\basic_ucnet2\basict - ram - bug>pause
Drücken Sie eine beliebige Taste . . .
Hmm, it would surely be good to have working checks. We could also have a sensible default (AFAIK no STM8 device has more than 8 KB of RAM). But in the end the check can never be accurate, as SDCC doesn't know how much memory will be needed for the stack.
Last edit: Philipp Klaus Krause 2024-01-31
Hello,
i think the linker memory check options exists and they should work.
Of course has this bug not the highest priority.