`FLASH' overflowed BluePill

Post here first, or if you can't find a relevant section!
Post Reply
jevta
Posts: 2
Joined: Wed Jun 09, 2021 6:21 pm

`FLASH' overflowed BluePill

Post by jevta »

Hello everyone,
I’m trying to create a PID voltage controller on an RC filter with bluepill. And I’m getting this error:

c:/users/sa�a/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\SAA~1\AppData\Local\Temp\arduino_build_724040/PID_RC_BluePill.ino.elf section `.rodata' will not fit in region `FLASH'
c:/users/sa�a/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 1644 bytes
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Generic STM32F1 series.

This simple code will not fit in the FLASH region for some reason. The code was tested on arduino uno and nucleo 64 board (the same stm32duino) so it is working.

Here is the code:

//bluepill

float Kp = 1.0 , Ki = 1.0, Kd = 1.0 ; // PID gain values
float Pout , Iout , Dout , Output; // PID final ouput variables
float now , lasttime = 0 , timechange; // important time
float Input , lastinput , Setpoint = 200.0; // input-based variables
float error , errorsum = 0, Derror; // output of the PID components
int settime = 100; // this = 1 second, so Ki and Kd do not need modification


void setup (){
Serial.begin(9600); // serial setup for verification
} // end void setup (){


void loop (){
now = millis() ; // get current milliseconds
timechange = (now - lasttime); // calculate difference
if (timechange >= settime) { // run PID when the time is at the set time
Input = (analogRead(PA1)/4.0); // read Input and normalize to output range
error = Setpoint - abs(Input); // calculate error
errorsum = errorsum + error; // add curent error to running total of error
Derror = (Input - lastinput); // calculate slope of the input
Pout = Kp * error; // calculate PID gains
Iout = Ki * errorsum ;
Dout = Kd * Derror ;


if (Iout > 255) // check for integral windup and correct
Iout = 255;
if (Iout < 0)
Iout = 0;
Output = Pout + Iout + Dout ; // prep the output variable
if (Output > 255) // sanity check of the output, keeping it within the
Output = 255; // available output range
if (Output < 0)
Output = 0;


lastinput = Input; // save the input and time for the next loop
lasttime = now;

analogWrite (PA0, Output); // write the output to PWM pin 3
Serial.print (Setpoint); // print some information to the serial monitor
Serial.print (" : ");
Serial.print (Input);
Serial.print (" : ");
Serial.println (Output);


} // end if (timechange >= settime)
} // end void loop ()

I've tested the bootloader on the bluepill (HID) on simple sketches like blink and analog to serial communication (and that is working also).

I am using Windows OS.

Thanks in advance!
by GonzoG » Wed Jun 09, 2021 9:28 pm
I've compiled it and it needs about 40kB of flash with everything enabled and -O3 (fastest) optimization and 34kB with -Os (smallest) optimazation.

Are you sure you've selected correct MCU (board) ??
there are F103 bluepills with 32, 64 and 128 kB of flash.
Go to full post
ag123
Posts: 1656
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: `FLASH' overflowed BluePill

Post by ag123 »

blue pills stm32f103c8 has 64k flash, you'd need to search around the logs to find out the size of your binary
there is also a command like to try to figure out

Code: Select all

arm-none-eabi-objdump --all-headers sketch.elf
and check if you happen to pull in any libraries you didn't need
Last edited by ag123 on Wed Jun 09, 2021 9:30 pm, edited 1 time in total.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: `FLASH' overflowed BluePill

Post by GonzoG »

I've compiled it and it needs about 40kB of flash with everything enabled and -O3 (fastest) optimization and 34kB with -Os (smallest) optimazation.

Are you sure you've selected correct MCU (board) ??
there are F103 bluepills with 32, 64 and 128 kB of flash.
jevta
Posts: 2
Joined: Wed Jun 09, 2021 6:21 pm

Re: `FLASH' overflowed BluePill

Post by jevta »

Well, this is embarrassing, I even compiled the program on PlatformIO just to check if everything is okay with the program and it is (and it runs). In the list menu I clicked on the C6 version instead of the C8. That is why I was getting this error. Its the programmers fault not the compilers. :lol: :lol: :lol: Dont do late night programming. :mrgreen: Thank you all for replying! Great community!
Post Reply

Return to “General discussion”