You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Arduino String class uses malloc, free and realloc to dynamically allocate memory for the strings. However, the core doesn't define the sbrk() function as the base function needed for malloc to allocate more memory.
Linking .pio\build\ch32v003f4p6_evt_r0\firmware.elf
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::~String()':
String.cpp:(.text._ZN7arduino6StringD2Ev+0x4): undefined reference to `free'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::invalidate()':
String.cpp:(.text._ZN7arduino6String10invalidateEv+0xc): undefined reference to `free'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::changeBuffer(unsigned int)':
String.cpp:(.text._ZN7arduino6String12changeBufferEj+0x10): undefined reference to `realloc'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::String(int, unsigned char)':
String.cpp:(.text._ZN7arduino6StringC2Eih+0x18): undefined reference to `itoa'
So it also uses -nostdlib which causes itoa to not be found and stuff.
The Arduino
String
class uses malloc, free and realloc to dynamically allocate memory for the strings. However, the core doesn't define thesbrk()
function as the base function needed for malloc to allocate more memory.So a sketch like
fails with
So it also uses
-nostdlib
which causesitoa
to not be found and stuff.If I do make the required fixes per Community-PIO-CH32V@d098d4d, I get a successfull compile
and it works during runtime.
Question is, do we want this? Should this be allowed usage on a chip with this little memory?
With the "main branch" / no malloc, a blinky sketch of
uses
and with the malloc branch it uses
So.. even though this sketch shouldn't use malloc, the compiler still adds some baggage, probably because of the nosys and nano specs linking.. :(
The text was updated successfully, but these errors were encountered: