Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MrSurly opened this issue Nov 23, 2021 · 1 comment

Comments

@MrSurly
Copy link

MrSurly commented Nov 23, 2021

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

@MrSurly
Copy link
Author

MrSurly commented Nov 23, 2021

Pinning platform version to 1.0.3 and it compiles again:

@MrSurly MrSurly changed the title Use of Flash functions results in "Multiple definition of _asm_val", "Multiple definition of _asm_addr" V2.0.0: Use of Flash functions results in "Multiple definition of _asm_val", "Multiple definition of _asm_addr" Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant