?ASlink-Warning-Undefined Global '_assert_failed' referenced by module 'stm8s_clk'

Debian 12. VS Code, the latest version.
I copied files from the example here platform-ststm8/examples/spl-uart-simple-printf at master · platformio/platform-ststm8 · GitHub , but it is not built:

$ pio run
Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: stm8sblue.html
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:

* framework-ststm8spl @ 0.20301.181217 (2.3.1)
* tool-stm8binutils @ 0.230.0 (2.30)
* toolchain-sdcc @ 1.40100.12072 (4.1.0)
  LDF: Library Dependency Finder → bit.ly/configure-pio-ldf
  LDF Modes: Finder \~ chain, Compatibility \~ soft
  Found 0 compatible libraries
  Scanning dependencies…
  No dependencies
  Building in release mode
  Linking .pio/build/stm8sblue/firmware.elf

?ASlink-Warning-Undefined Global ‘\_assert_failed’ referenced by module ‘stm8s_clk’

?ASlink-Warning-Undefined Global ‘\_assert_failed’ referenced by module ‘stm8s_uart1’
\*\*\* \[.pio/build/stm8sblue/firmware.elf\] Error 1

Compiles fine on Windows.

Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8sblue.html
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash        
DEBUG: Current (stlink) External (stlink)
PACKAGES:
 - framework-ststm8spl @ 0.20301.181217 (2.3.1)
 - tool-stm8binutils @ 0.230.0 (2.30)
 - toolchain-sdcc @ 1.40200.0 (4.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\stm8sblue\SPL\stm8s_clk.rel
Compiling .pio\build\stm8sblue\SPL\stm8s_uart1.rel
Compiling .pio\build\stm8sblue\src\main.rel
Compiling .pio\build\stm8sblue\src\stm8s_it.rel
Linking .pio\build\stm8sblue\firmware.elf
Checking size .pio\build\stm8sblue\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 1024 bytes)
Flash: [=====     ]  52.3% (used 4282 bytes from 8192 bytes)
Building .pio\build\stm8sblue\firmware.hex
=========================== [SUCCESS] Took 3.41 seconds ===========================

If you’re working on Linux, try using the SDCC 4.2.0 toolchain instead of SDCC 4.1.0 by adding

[env]
platform_packages =
  toolchain-sdcc@https://github.com/maxgerhardt/toolchain-sdcc.git

at the top of your platformio.ini.

On Windows I try to use STVD IDE.

Now I get new error:
Executing task in folder HeatingDetector: platformio run

## Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)

Tool Manager: Installing git+https://github.com/maxgerhardt/toolchain-sdcc.git
git version 2.39.5
Cloning into ‘/home/destructor/.platformio/.cache/tmp/pkg-installing-hb2c1oji’…
remote: Enumerating objects: 3926, done.
remote: Counting objects: 100% (3926/3926), done.
remote: Compressing objects: 100% (924/924), done.
remote: Total 3926 (delta 2968), reused 3926 (delta 2968), pack-reused 0 (from 0)
Receiving objects: 100% (3926/3926), 19.08 MiB | 8.74 MiB/s, done.
Resolving deltas: 100% (2968/2968), done.
Tool Manager: toolchain-sdcc@1.40200.0+sha.d0b830b has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8sblue.html
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:

* framework-ststm8spl @ 0.20301.181217 (2.3.1)
* tool-stm8binutils @ 0.230.0 (2.30)
* toolchain-sdcc @ 1.40200.0+sha.d0b830b
  LDF: Library Dependency Finder → https://bit.ly/configure-pio-ldf
  LDF Modes: Finder \~ chain, Compatibility \~ soft
  Found 0 compatible libraries
  Scanning dependencies…
  No dependencies
  Building in release mode
  Compiling .pio/build/stm8sblue/SPL/stm8s_adc1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_awu.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_beep.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_clk.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_exti.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_flash.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_gpio.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_i2c.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_itc.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_iwdg.rel
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_itc.c:60: warning 59: function ‘ITC_GetCPUCC’ must return value
  Compiling .pio/build/stm8sblue/SPL/stm8s_rst.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_spi.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim2.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim4.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_uart1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_wwdg.rel
  Compiling .pio/build/stm8sblue/src/main.rel
  Compiling .pio/build/stm8sblue/src/stm8s_it.rel
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘file’
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘line’
  src/stm8s_it.h:45: syntax error: token → ‘\__interrupt’ ; column 12
  \*\*\* \[.pio/build/stm8sblue/src/stm8s_it.rel\] Error 1
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim2.c:1110: warning 116: right shifting more than size of object changed to zero
  ====================================================================== \[FAILED\] Took 7.03 seconds ======================================================================

You didn’t copy stm8s_it.h from the original example correctly. (original source). Large blocks of code are just missing in regards to handling SDCC. Could it be that you let some tool autogenerate this code, which was meant to be for a totally different compiler?

I actually tested the original https://github.com/platformio/platform-ststm8/blob/develop/examples/spl-uart-simple-printf example on Linux, without any modifications regarding the toolchain etc., and it built fine.

CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8sblue.html
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:
 - framework-ststm8spl @ 0.20301.181217 (2.3.1)
 - tool-stm8binutils @ 0.230.0 (2.30)
 - toolchain-sdcc @ 1.40100.12072 (4.1.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/stm8sblue/SPL/stm8s_clk.rel
Compiling .pio/build/stm8sblue/SPL/stm8s_uart1.rel
Compiling .pio/build/stm8sblue/src/main.rel
Compiling .pio/build/stm8sblue/src/stm8s_it.rel
Linking .pio/build/stm8sblue/firmware.elf
Checking size .pio/build/stm8sblue/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 1024 bytes)
Flash: [=====     ]  53.1% (used 4352 bytes from 8192 bytes)
Building .pio/build/stm8sblue/firmware.hex
======================================= [SUCCESS] Took 47.17 seconds =======================================

Ok, I changed that file as you advised, but faced a new error:
Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:

  • framework-ststm8spl @ 0.20301.181217 (2.3.1)

  • tool-stm8binutils @ 0.230.0 (2.30)

  • toolchain-sdcc @ 1.40200.0+sha.d0b830b
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio/build/stm8sblue/src/stm8s_it.rel
    Linking .pio/build/stm8sblue/firmware.elf
    Checking size .pio/build/stm8sblue/firmware.elf
    Error: The program size (24477 bytes) is greater than maximum allowed (8192 bytes)
    *** [checkprogsize] Explicit exit, status 1
    Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
    RAM: [ ] 0.0% (used 0 bytes from 1024 bytes)

    Flash: [==========] 298.8% (used 24477 bytes from 8192 bytes)

It’s still using the other toolchain. Execute

rm -rf ~/.platformio/packages/*

and compile again to get a clean state, and remove any platform_packages in the platformio.ini.

It does not help! Error is the same:

Executing task in folder HeatingDetector: platformio run

## Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: Redirecting…
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:

* framework-ststm8spl @ 0.20301.181217 (2.3.1)

* tool-stm8binutils @ 0.230.0 (2.30)

* toolchain-sdcc @ 1.40200.0+sha.d0b830b
  LDF: Library Dependency Finder → https://bit.ly/configure-pio-ldf
  LDF Modes: Finder \~ chain, Compatibility \~ soft
  Found 0 compatible libraries
  Scanning dependencies…
  No dependencies
  Building in release mode
  Compiling .pio/build/stm8sblue/SPL/stm8s_adc1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_awu.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_beep.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_clk.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_exti.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_flash.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_gpio.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_i2c.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_itc.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_iwdg.rel
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_itc.c:60: warning 59: function ‘ITC_GetCPUCC’ must return value
  Compiling .pio/build/stm8sblue/SPL/stm8s_rst.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_spi.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim2.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim4.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_uart1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_wwdg.rel
  Compiling .pio/build/stm8sblue/src/main.rel
  Compiling .pio/build/stm8sblue/src/stm8s_it.rel
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘file’
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘line’
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim2.c:1110: warning 116: right shifting more than size of object changed to zero
  Linking .pio/build/stm8sblue/firmware.elf
  Checking size .pio/build/stm8sblue/firmware.elf
  Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
  Error: The program size (24477 bytes) is greater than maximum allowed (8192 bytes)
  \*\*\* \[checkprogsize\] Explicit exit, status 1
  RAM:   \[          \]   0.0% (used 0 bytes from 1024 bytes)
  Flash: \[==========\]  298.8% (used 24477 bytes from 8192 bytes)
  ====================================================================== \[FAILED\] Took 2.06 seconds ======================================================================

* The terminal process “platformio ‘run’” terminated with exit code: 1.

* Terminal will be reused by tasks, press any key to close it.

* Executing task in folder HeatingDetector: platformio run

## Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: spl)

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: Redirecting…
PLATFORM: ST STM8 (2.1.0) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:

* framework-ststm8spl @ 0.20301.181217 (2.3.1)

* tool-stm8binutils @ 0.230.0 (2.30)

* toolchain-sdcc @ 1.40200.0+sha.d0b830b
  LDF: Library Dependency Finder → Library dependency…
  LDF Modes: Finder \~ chain, Compatibility \~ soft
  Found 0 compatible libraries
  Scanning dependencies…
  No dependencies
  Building in release mode
  Compiling .pio/build/stm8sblue/SPL/stm8s_adc1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_awu.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_beep.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_clk.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_exti.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_flash.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_gpio.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_i2c.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_itc.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_iwdg.rel
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_itc.c:60: warning 59: function ‘ITC_GetCPUCC’ must return value
  Compiling .pio/build/stm8sblue/SPL/stm8s_rst.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_spi.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim2.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_tim4.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_uart1.rel
  Compiling .pio/build/stm8sblue/SPL/stm8s_wwdg.rel
  Compiling .pio/build/stm8sblue/src/main.rel
  Compiling .pio/build/stm8sblue/src/stm8s_it.rel
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘file’
  src/main.c:135: warning 85: in function assert_failed unreferenced function argument : ‘line’
  /home/destructor/.platformio/packages/framework-ststm8spl/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim2.c:1110: warning 116: right shifting more than size of object changed to zero
  Linking .pio/build/stm8sblue/firmware.elf
  Checking size .pio/build/stm8sblue/firmware.elf
  Error: The program size (24477 bytes) is greater than maximum allowed (8192 bytes)
  Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
  \*\*\* \[checkprogsize\] Explicit exit, status 1
  RAM:   \[          \]   0.0% (used 0 bytes from 1024 bytes)
  Flash: \[==========\]  298.8% (used 24477 bytes from 8192 bytes)
  ====================================================================== \[FAILED\] Took 2.35 seconds ======================================================================

* The terminal process “platformio ‘run’” terminated with exit code: 1.

* Terminal will be reused by tasks, press any key to close it.

And new packages were downloaded automatically.

It’s still being used.

Do

rm -rf ~/.platformio/packages/*
rm -rf ~/.platformio/.cache

and recompile

This directory does not exist in my OS.

For how many years has PlatformIO not yet achieved stability in operation. So, to build a minimal project for STM8 on STVD + Cosmic, I needed to watch 1 video on YouTube and a few hours of perseverance. And to build the same minimal project on PlatformIO, I spent 3 days, without achieving the result.

I do not understand now why I need PlatformIO. For STM32 I use STM32CubeIDE, for Arduino I use Arduino IDE, Raspberry and other Python based MCU are not interested for me (I don’t know Python). Why do I need PlatformIO on Linux OS?

This is due to your stm8s_conf.h now. All includes for all subsystems were activated. SDCC is very poor at producing optimized code and doing link-time-optimization and dead code elimination. PlatformIO has an optimization that the C files from the SDK are not compiled in if their respective header file is not activated in the stm8s_conf.h (see platform code). Again, if you take the code exactly from https://github.com/platformio/platform-ststm8/blob/develop/examples/spl-uart-simple-printf/src/stm8s_conf.h, it compiles fine.

Compiling .pio\build\stm8sblue\src\stm8s_it.rel
src\main.c:135: warning 85: in function assert_failed unreferenced function argument : 'file'
src\main.c:135: warning 85: in function assert_failed unreferenced function argument : 'line'
Linking .pio\build\stm8sblue\firmware.elf
Checking size .pio\build\stm8sblue\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 1024 bytes)
Flash: [=======   ]  70.4% (used 5771 bytes from 8192 bytes)
Building .pio\build\stm8sblue\firmware.hex
=========================== [SUCCESS] Took 3.16 seconds =========================== *  Terminal will be reused by tasks, press any key to close it. 

You might want to look into this dead-code-elimination optimizer that can be integrated into PlatformIO:

https://github.com/maxgerhardt/pio-stm8-dce/

Yeah, I’ve changed stm8s_conf.h, and my code was built successfully! But why is such a large size for a UART working? If we compare it with Arduino IDE + Mini Pro MCU, all flash size fits in 1 KB. Where is an advantage here?

The Arduino AVR core typically does not use printf() for UART output. printf() as a dynamic string construction / formatting function has a huge overhead. Also, AVR-GCC is better at producing optimized (and dead code elimininated code..) than SDCC for STM8.

I’m sure if you didn’t use printf(), but instead the regular UART1_SendData8() from the SPL (stm8s_uart1.h etc.), the size would again go down.

You’re right. I’ve just deleted #include<stdio.h> and related code, after these actions flash size became 4024 bytes. Then I tried to build as a release, but the size did not change.