cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards
https://cyberman54.github.io/ESP32-Paxcounter/
Other
1.69k stars 397 forks source link

Add CI & fix build errors & migrate RGB LED library #907

Closed cyberman54 closed 1 year ago

t-huyeng commented 1 year ago

Looks like m5fire.h is still failing: https://github.com/cyberman54/ESP32-Paxcounter/actions/runs/3372792309/jobs/5596639072

/home/runner/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/ci/firmware_m5fire_v3.3.2.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/home/runner/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/home/runner/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 2132 bytes

I guess also a problem with memory.

cyberman54 commented 1 year ago

Yes, i saw that, but it makes no sense. M5fire has more memory than M5core, and same code for M5core compiles successfully. I assume this issue is caused by a faulty external board definition file, either in Platformio ESP32 or Arduino-Espressif32. I will check that.

cyberman54 commented 1 year ago

Next level for improving CI would be to integrate the hal files for boards with the new ESP32 S3 CPU. Those use another toolchain. See code branch S3-usb-stick. Currently a separate platformio.ini setup seems to be required. But maybe it is possible to get these boards in the common CI workflow, too?

cyberman54 commented 1 year ago

I analyzed the memory shortage issue with m5fire. It is indeed a shortage in IRAM0 segment. I did not yet fully understand why this happenes with m5fire only. I assume a correlation with platformio's board definition file, possibly it's this PSRAM related setting, because this may decrease IRAM0 capacity from 192KB to 128KB due to 64 KB reserved for Cache. We're using PSRAM on TTGO T-Beam, too, but the board definition file for T-Beam does not use the above PSRAM strategy setting.

Meanwhile, as a - non practical - workaround i disabled all peripherals in M5fire hal file, to reduce the IRAM0 footprint. This way the hal file compiles.

cyberman54 commented 1 year ago

I figured out, IRAM0 shortage comes from enabling "PSRAM" memory. This is for boards which sport ESP32 external SPI RAM chip. This reduces usable IRAM0 size of ESP32 from 194KB by 64KB to 128KB, which can result in memory shortage, depending on the selected build options. Workaround is currently not using PSRAM to keep the 64KB IRAM0 for the code. Final solution must find a way to reduce IRAM0 footprint of the application. I wil check see what's possible here.

t-huyeng commented 1 year ago

Next level for improving CI would be to integrate the hal files for boards with the new ESP32 S3 CPU. Those use another toolchain. See code branch S3-usb-stick. Currently a separate platformio.ini setup seems to be required. But maybe it is possible to get these boards in the common CI workflow, too?

Are there major changes in the rest of the code or can we "just" combine the two platformio.ini files?

cyberman54 commented 1 year ago

Compared with current main and development branch it's now 100% same code base (which was my goal to achieve), only the toolchain for building is another, due to the other CPU type S3. Thus, it's only the platformio.ini.

But the problem is in build.py, which grabs the board type from the hal file and then sets the platformio board environment variable accordingly. This does not seem to work with platformio, it looks like board environment variable has to be set before pio run.

t-huyeng commented 1 year ago

Okay thanks for the explanation. I will try to look into this.

An easy approach could be to have the platformio.ini for the s3 in the master/dev branch named platformio-s3-orgi.ini or something like this and then we can just add/copy this to the respective CI workflow as file.

Working on it here: https://github.com/t-huyeng/ESP32-Paxcounter/tree/build-workflow

t-huyeng commented 1 year ago

The CI-build currently fails: https://github.com/t-huyeng/ESP32-Paxcounter/actions/runs/3394251652/jobs/5642579727 due to Error: Unknown board ID 'ESP32-S3-DevKitC-1'

building locally works. Board should probably be esp32-s3-devkitc-1 see https://docs.platformio.org/en/latest/boards/espressif32/esp32-s3-devkitc-1.html

Update: Workflows are working.

See https://github.com/cyberman54/ESP32-Paxcounter/pull/909