MallocArray / airgradient_esphome

ESPHome definition for an AirGradient DIY device to send data to HomeAssistant and AirGradient servers
GNU General Public License v3.0
205 stars 29 forks source link

Bluetooth proxy for airgradient one (ESP32 C3) #70

Open Motya-HA opened 1 week ago

Motya-HA commented 1 week ago

I am trying to add Bluetooth proxy to airgradient one (ESP32 C3)

esp32_ble_tracker:
  id: ble_tracker
  scan_parameters:
    continuous: false

bluetooth_proxy:
  active: true

However, I am getting the following error:

Linking .pioenvs/guest-room-ag/firmware.elf
RAM:   [==        ]  17.8% (used 58356 bytes from 327680 bytes)
Error: The program size (1861062 bytes) is greater than maximum allowed (1835008 bytes)
*** [checkprogsize] Explicit exit, status 1
Flash: [==========]  101.4% (used 1861062 bytes from 1835008 bytes)
========================= [FAILED] Took 122.54 seconds =========================

I do not understand why bluetooth proxy lines can overflow flash

MallocArray commented 1 week ago

By adding that feature, it has to load the entire bluetooth stack into the storage, and it ends up being more than this device can hold. I saw similar things when looking to add the serial_improv feature.

It looks like it is just a bit over, so you could try removing things you don't need, like the Captive Portal, or if you are using the multi-page display config, switch to single.

If you aren't using the API upload to the AirGradient dashboard you could remove that as well.

raccettura commented 1 week ago

I've been playing with this as well. You need to use the esp-idf framework vs the default arduino framework to make it work, however switching the framework seems to cause some kind of reboot loop I can't quite figure out (my code is inspired by this repo, but not exactly the same thing). I think the first step is figuring out how to run the esp-idf framework which per the docs saves significant memory. Even for those not looking to use bluetooth_proxy some memory savings might be welcome to do other things that I can't even imagine.

Disabling the co2 sensor to free up a uart to enable serial logging shows me repeated:

[13:48:59]ESP-ROM:esp32c3-api1-20210207
[13:48:59]Build:Feb  7 2021
[13:48:59]rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
[13:48:59]Saved PC:0x40049a42
[13:48:59]SPIWP:0xee
[13:48:59]mode:QIO, clock div:1
[13:48:59]load:0x3fcd5810,len:0x1684
[13:48:59]ets_loader.c 78 
[13:49:00]ESP-ROM:esp32c3-api1-20210207
[13:49:00]Build:Feb  7 2021
[13:49:00]rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
[13:49:00]Saved PC:0x40049a42
[13:49:00]SPIWP:0xee
[13:49:00]mode:QIO, clock div:1
[13:49:00]load:0x3fcd5810,len:0x1684
[13:49:00]ets_loader.c 78 

I'd start with there if anyone wants to pick up where I left off for the afternoon.