Program stopped when instantiating String class, plate stm32f103c8 with arduino framework in VSCode

A few days ago I asked for help in the community about compilation problems, which you can see here “previous question” ,When doing the suggested, I compile successfully, but I noticed that my code goes into an infinite loop, I checked it using the debug

,is stuck in this place,
the code to reproduce the error is the following

    String i="";
    void setup()
      Serial1.begin(4800);                      // the Serial31 baud rate
      Serial3.begin(4800);                      // the Serial3 port of Arduino baud rate.
      pinMode(PB12, OUTPUT); //Salida LED embutido
      digitalWrite(PB12, LOW);
    void loop()
      if (Serial3.available()>0)   {            // if date is comming from softwareSerial3 port ==> data is comming from Serial31 shield  
        Serial1.write(;  }        // if no data transmission ends, write buffer to hardware Serial3 port  }
      if (Serial1.available()>0)  {             // if data is available on hardwareSerial3 port ==> data is comming from PC or notebook
        Serial3.write(;          // write it to the Serial1 shield

If I coment the String instance it works, if I leave it it never turns on the PB12 led

File .ini

    ;platform = ststm32
    ;platform = ststm32@3.5.0
    platform =
    board = genericSTM32F103C8
    framework = arduino
    monitor_speed = 4800
    debug_tool = stlink
    upload_protocol = stlink

When debugging, what is the call stack? (i.e., what are the functions caleld before that error handler?)

You mean this? Excuse me, I speak Spanish and the translation of many things is not very clear to me

Yeah that’s the correct callstack. But unfortunately the lower functions were not decoded "??. Can you add the line

build_flags = -g3 -ggdb

to the platformio.ini, rebuild, reupload and then look into the debugger again into the call stack?

if I press step into several times it shows this

If I just press step over, it shows me this

I did this

Can you step through setup() and loop() line by line and see where it crashes? Or doesn’t it even reach the setup()?

When commenting the String i = “”; enter the setup and turn on the led that is on pin PB12, and according to the debuger, enter the loop, but when I call it it stops


Apparently it stops when trying to write the pin

I could already reproduce the error. When compiling the linker complains about end symbol not being defined, which is needed for dynamic memory allocations, as it is used by the String class. This is because the used linker file doesn’t define that symbol. The fix is to go into .platformio\packages\framework-arduinoststm32-maple\STM32F1\variants\generic_stm32f103c\ld\ and add end = _end; after line 183. I’m writing up an issue.


See genericSTM32F103C8: Undefined reference to 'end' symbol causes crash at malloc · Issue #208 · platformio/platform-ststm32 · GitHub

1 Like


I did it and it worked !!!, once again, thank you very much !!

1 Like