Skip to content

V2.0.0: Use of Flash functions results in "Multiple definition of _asm_val", "Multiple definition of _asm_addr" #53

@MrSurly

Description

@MrSurly

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*)&params) + 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*)&params)+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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions