I noticed that as I was flashing to an attiny85 over usbtinyisp that the behavior wasn’t changing. So I disconnected my circuit and flashed, plugged it back in and nothing changed. I noticed that my forward hadn’t changed in a while so I defined some oddball ints and hit build. Firmware size didn’t change. Not even a byte.
I went through and deleted the firmware elf files and such to make sure it was creating a new file at least, but the firmware size stayed the same. I must be missing something. It’s like its stuck building an older version of my code. Is there a cached copy somewhere that I’m missing? I’m new to using Platform so it’s entirely possible.
Yes. It matches what it is in my programio.ini. It remains stuck if I do a clean and rebuild. Even if I create dummy methods, the size remains the same. I know that it is writing to the chip because I get the flashing lights and all from the programmer, but the size should change right?
But if you don’t call them, the optimizer passes of the compiler will sweep them out again. Same with global variables that you define but not use. The default optimization level given to gcc in PlatformIO is -Os (optimize-for-size) after all.
Do you have a reproducable minimal example (code + changes + platformio.ini) of this?
will get completely optimized away since they’re not used in the execution flow of the program (in setup() and loop(). And even if, the compiler would optimize the variable and the entire function away and directly replace with the constant 6 if the return value of the function is needed, which will hardly increase the binary size.
Your variable last_servo_out is weird though. It has no explicit beginning value (so it will be implictly 0), and you check for its value but you never write a new value to it.
But then my code should be doing something other than sweeping the servo, but yet it’s stuck flashing that firmware. The way the code is right now, it would run every loop. That would create a different behavior than sweeping from 800 to 2200 mircos.
I created a few new counters and added them together, that shouldn’t be cleaned up by the optimizer. The thing is that the firmware sized is unchanged. Not even a difference of 1 byte. RAM (40 bytes) or flash (1430 bytes).
Pushed some changes and still getting the same firmware size.
Yep! Missed that while throwing code in while trying simplify the issue.
I set build_flags to -Os and -O0 in the ini file and still got the same sizes for RAM and flash. Added an analogWrite() for my blah variable to an unused pin and got the same sizes again. Wipe everything and reinstall Windows?
In lib/Servo8Bit/ there is the file example.cpp that defines the main function. You’ve accidentally copied the example file and it overshadows the entire code that you have placed in src/main.cpp, since example.cpp overwrites the main() entry point by itself and doesn’t continue to call into setup() or loop() or anything – remove the file https://github.com/TunaLobster/ServoTester/blob/master/lib/Servo8Bit/example.cpp and things will make start to make sense again.
Note: PlatformIO automatically ignores the “examples” folder of a library, but in the case of a example.cpp file being placed directly next to the library’s source code, it will build it.