How to make a smaller .bin?
-
Hi all,
I'm going to be deploying a bunch of M5Stack core units with LTE modems. I have been writing a small firmware that I can push to them OTA in case a unit gets lost or stolen. This way, the original firmware if replaced with a "if found, return to..." message. It's very simple but still compiles to 346KB, which does not OTA very quickly (Carrier problem. I have another thread that explains why.). I'd really like to get this to a smaller size, if I can. Is there a way to either optimize the compiler to shed code that it doesn't use (ie. wifi, etc), or can I manually trim down the M5stack library?
Thanks!!
#define SerialMon Serial void debug(String msg) { SerialMon.print(msg); M5.Lcd.print(msg); } void debugln(String msg) { SerialMon.println(msg); M5.Lcd.println(msg); } void setup() { M5.begin(); SerialMon.begin(115200); M5.Lcd.clear(TFT_BLACK); M5.Lcd.setTextSize(3); M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK); debugln(F("If found, call")); debugln(F("xxxxxxxx")); debugln(F("xxxxxxxxxxxxx")); debugln(F("")); debugln(F("or return to")); debugln(F("xxxxxxxxxx")); debugln(F("xxxxxxxx")); debugln(F("xxxxxxxxxxxx")); debugln(F("xxxxxxxxxxxx")); } void loop() { }
-
https://github.com/Bodmer/TFT_eSPI
compiles to 293KB#define SerialMon Serial #include <TFT_eSPI.h> TFT_eSPI Tft = TFT_eSPI(); void debug(String msg) { SerialMon.print(msg); Tft.print(msg); } void debugln(String msg) { SerialMon.println(msg); Tft.println(msg); } void setup() { SerialMon.begin(115200); Tft.init(); Tft.fillScreen(TFT_BLACK); Tft.setTextSize(3); Tft.setTextColor(TFT_WHITE, TFT_BLACK); debugln(F("If found, call")); debugln(F("xxxxxxxx")); debugln(F("xxxxxxxxxxxxx")); debugln(F("")); debugln(F("or return to")); debugln(F("xxxxxxxxxx")); debugln(F("xxxxxxxx")); debugln(F("xxxxxxxxxxxx")); debugln(F("xxxxxxxxxxxx")); } void loop() { }
-
That helps! Thank you!
I'm going to drop the SerialMon stuff too. I only added it just in case I had a unit with a faulty screen, but then I realized that if the screen were faulty, no one would see the message to bring it back to me. And why would I want a unit with a faulty screen? LOL!
-
@flypeek It definitely compiles smaller! I got it down to around 250KB with the SerialMon disabled. The only issue I have is that it doesn't light up the backlight on the screen. I can see the text is there if I hold up a flashlight to it. Any idea how to light it up? I've been doing some searching, and it doesn't look like it's a simple HIGH/LOW sent to pin 32. The M5Stack.Lcd library says it's PWM controlled.
Thanks!
-
1.M5Stack.Lcd use Brightness (0: Off - 255:Full)
https://github.com/m5stack/m5-docs/blob/master/docs/en/api/lcd.md#setbrightnesshttps://github.com/Bodmer/TFT_eSPI#tips
or 2.edit User_Setup.h or rename// ######################################################## // Section 2. Define the pins that are used to interface with the display here //####################################################### // If a backlight control signal is available then define the TFT_BL pin in Section 2 // below. The backlight will be turned ON when tft.begin() is called, but the library // needs to know if the LEDs are ON with the pin HIGH or LOW. If the LEDs are to be // driven with a PWM signal or turned OFF/ON then this must be handled by the user // sketch. e.g. with digitalWrite(TFT_BL, LOW); #define TFT_BL 32 // LED back-light control pin #define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)