IMPORTANT NOTE: This is a new problem with existing code that worked fine before updating platformio. Something in either an updated framework or platform is causing this.
platformio.ini:
[env]
[env:mb208]
platform = ststm8
framework = arduino
build_flags = -DDEBUG=1
board = mb208
board_build.mcu = stm8s208c8t6
board_build.f_cpu = 2000000
board_upload.maximum_size = 32768
upload_protocol = stlinkv2
Code in question:
void save_params() {
#warning save_params is disabled
return;
FLASH_Unlock(FLASH_MEMTYPE_DATA);
params.magic_value = PARAMS_MAGIC;
params.checksum = chksum(((uint8_t*)¶ms) + offsetof(params_t, data), sizeof(params.data));
for(int i = 0; i < sizeof(params); ++i) {
FLASH_EraseByte(PARAMS_ADX + i);
}
for(int i = 0; i < sizeof(params); ++i) {
FLASH_ProgramByte(PARAMS_ADX + i, *(((uint8_t*)¶ms)+i));
}
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
#endif
If I comment any 3 of the 4 FLASH_* functions, the issue goes away. Seems just having FLASH_EraseByte or FLASH_ProgramByte a single time, and no other FLASH functions is enough to trigger the error.
... lots of stuff that works ...
Linking .pio/build/mb208/firmware.elf
Multiple definition of _asm_val
Multiple definition of _asm_addr
Multiple definition of _asm_val
Multiple definition of _asm_addr
Multiple definition of _asm_val
Multiple definition of _asm_addr
*** [.pio/build/mb208/firmware.elf] Error 1
========================================== [FAILED] Took 1.78 seconds ==========================================
make: *** [Makefile:19: build] Error 1
Actual link command that fails:
sdcc -o .pio/build/mb208/firmware.elf -mstm8 --nostdlib --code-size 32768 --iram-size 6144 --out-fmt-elf .pio/build/mb208/_pio_main_ref.c.rel .pio/build/mb208/src/clock.c.rel .pio/build/mb208/src/cmd.c.rel .pio/build/mb208/src/common.c.rel .pio/build/mb208/src/crc8.c.rel .pio/build/mb208/src/debug.c.rel .pio/build/mb208/src/device_config.c.rel .pio/build/mb208/src/globals.c.rel .pio/build/mb208/src/i2c.c.rel .pio/build/mb208/src/main.c.rel .pio/build/mb208/src/params.c.rel .pio/build/mb208/src/protect.c.rel .pio/build/mb208/src/state.c.rel .pio/build/mb208/src/stm8s_it.c.rel .pio/build/mb208/src/temp.c.rel .pio/build/mb208/src/time.c.rel .pio/build/mb208/src/uart.c.rel -L/home/epoulsen/.platformio/packages/toolchain-sdcc/share/sdcc/lib/stm8 -L/home/epoulsen/.platformio/packages/framework-arduinoststm8/STM8S_StdPeriph_Driver/lib .pio/build/mb208/libFrameworkArduinoVariant.lib .pio/build/mb208/libFrameworkArduino.lib -lstm8 -lSTM8S208
IMPORTANT NOTE: This is a new problem with existing code that worked fine before updating
platformio. Something in either an updated framework or platform is causing this.platformio.ini:Code in question:
If I comment any 3 of the 4Seems just havingFLASH_*functions, the issue goes away.FLASH_EraseByteorFLASH_ProgramBytea single time, and no other FLASH functions is enough to trigger the error.Actual link command that fails:
sdcc -o .pio/build/mb208/firmware.elf -mstm8 --nostdlib --code-size 32768 --iram-size 6144 --out-fmt-elf .pio/build/mb208/_pio_main_ref.c.rel .pio/build/mb208/src/clock.c.rel .pio/build/mb208/src/cmd.c.rel .pio/build/mb208/src/common.c.rel .pio/build/mb208/src/crc8.c.rel .pio/build/mb208/src/debug.c.rel .pio/build/mb208/src/device_config.c.rel .pio/build/mb208/src/globals.c.rel .pio/build/mb208/src/i2c.c.rel .pio/build/mb208/src/main.c.rel .pio/build/mb208/src/params.c.rel .pio/build/mb208/src/protect.c.rel .pio/build/mb208/src/state.c.rel .pio/build/mb208/src/stm8s_it.c.rel .pio/build/mb208/src/temp.c.rel .pio/build/mb208/src/time.c.rel .pio/build/mb208/src/uart.c.rel -L/home/epoulsen/.platformio/packages/toolchain-sdcc/share/sdcc/lib/stm8 -L/home/epoulsen/.platformio/packages/framework-arduinoststm8/STM8S_StdPeriph_Driver/lib .pio/build/mb208/libFrameworkArduinoVariant.lib .pio/build/mb208/libFrameworkArduino.lib -lstm8 -lSTM8S208