guild icon
Toit
#Firmware is "too big" to fit on ESP32C6 - the echo example
Thread channel in help
AbedN
AbedN 02/18/2025 01:54 PM
Hi,
I am encountering this seemingly weird issue (appearently after the recent update) when flashing the echo envelop firmware onto esp32-c6 (https://github.com/toitlang/template-custom-envelope.git)
bitphlipphar
bitphlipphar 02/18/2025 02:46 PM
Do you know which partition layout you're using here?
bitphlipphar
bitphlipphar 02/18/2025 02:47 PM
bitphlipphar
bitphlipphar 02/18/2025 02:48 PM
The OTA partitions are 1,703,936 bytes, so that seems to fit.
bitphlipphar
bitphlipphar 02/18/2025 02:48 PM
Are you building a debug build by any chance?
floitsch
floitsch 02/18/2025 02:49 PM
Did you maybe enable a big module in the sdkconfig?
AbedN
AbedN 02/19/2025 10:26 AM
apparently I made a mistake somewhere but now the issue is gone when i re-ran make and flashed the envelope in build/esp; Thanks all!
๐Ÿฅณ1
AbedN
AbedN 02/20/2025 01:00 PM
@floitsch @bitphlipphar Hi, I ran into the same issue again however it seems legit now; i am trying to deploy an edge ML model (it worked with native esp idf environment) based on the custom enevlope template you have on github; the build result was just slighly over the limit to fit onto an esp32c6 board (1745120 > 1703936); i wonder if there's a way to squeeze that further (perhaps via a compiler option?)(edited)
floitsch
floitsch 02/20/2025 01:01 PM
You could also just use a different partition table.
bitphlipphar
bitphlipphar 02/20/2025 01:01 PM
You can also change the partition layout and give yourself some more space? @floitsch may have a recipe for you :๐Ÿ™‚:
bitphlipphar
bitphlipphar 02/20/2025 01:01 PM
What Florian said.
AbedN
AbedN 02/20/2025 01:01 PM
how can i do that?
floitsch
floitsch 02/20/2025 01:01 PM
Also, you can disabled code that you don't use. (Like, for example, BLE, FAT support, ...)
floitsch
floitsch 02/20/2025 01:02 PM
Since you are already using a custom envelope, you can just modify the partition-table in it.
floitsch
floitsch 02/20/2025 01:03 PM
The make init copied over a partition table file (partitions.csv).
floitsch
floitsch 02/20/2025 01:03 PM
You can either modify that, or download the OTA-1C0000 one from here: https://github.com/toitlang/envelopes/tree/main/partitions/esp32/ota-1c0000
Toit envelopes for different configurations. Contribute to toitlang/envelopes development by creating an account on GitHub.
AbedN
AbedN 02/20/2025 01:47 PM
That worked, thanks!, how do i disable functionalities in toit? (i,e, i2c, spi, ....) I am planning to use another i2c implementation in the c code and that seems to interfer with the current toit implementation(edited)
floitsch
floitsch 02/20/2025 01:49 PM
I think I was wrong there. There is currently no support to disable "crucial" peripherals.
We should probably add sdkconfig options.
floitsch
floitsch 02/20/2025 01:50 PM
Some already have (like espnow, ethernet, fatfs) and these can be changed in the sdkconfig file.(edited)
floitsch
floitsch 02/20/2025 01:51 PM
Are you running into the issue that your code uses the new I2C driver and Toit uses the old one? (Espressif rewrote a lot of their drivers).(edited)
AbedN
AbedN 02/20/2025 01:53 PM
not sure tbh the cause of that but when i use my i2c code (it's the arduino one) and flash it onto the mcu, the device continues rebooting
floitsch
floitsch 02/20/2025 01:53 PM
Do you have any output?
AbedN
AbedN 02/20/2025 01:53 PM
yes let me just find that
AbedN
AbedN 02/20/2025 01:56 PM
floitsch
floitsch 02/20/2025 01:56 PM
Yes. That's the error.
floitsch
floitsch 02/20/2025 01:58 PM
You have three options:
- use the old API for now (but that would probably require an older Arduino version).
- patch the Toit SDK file
- wait until I upgraded the I2C driver.

The simplest is to just patch the SDK file: https://github.com/toitlang/toit/blob/ad90af0e51ca51da14de5f01cbb58adbd19ef5d1/src/resources/i2c_esp32.cc#L18
Just change that to #if 0 and the i2c could won't be compiled anymore. I think you can just change your local file in the toit folder.
Program your microcontrollers in a fast and robust high-level language. - toitlang/toit
floitsch
floitsch 02/20/2025 01:58 PM
I have plans to update the driver, but I can't tell when I will find the time for it.
floitsch
floitsch 02/20/2025 01:59 PM
It's the next driver I will update, but it might still take a few weeks.
AbedN
AbedN 02/20/2025 02:00 PM
do you mean i change the entire i2c_esp32.cc code into #if 0 ?
floitsch
floitsch 02/20/2025 02:01 PM
No. Just the #ifdef TOIT_ESP32 into #if 0.(edited)
floitsch
floitsch 02/20/2025 02:01 PM
(line 18).
AbedN
AbedN 02/20/2025 03:42 PM
Hi, that didn't help unfortunately. I am currently trying to access the sensor via its toit driver (it's the LIS3DH), using the provided examples on github: https://github.com/nilwes/LIS3DH.git; wierdly enough all examples cause the device to crash and reboot, i tried even flashing it out in a fresh jaguar environment but the issue still persists; any ideas? could that be the reason why the crash happened when i accessed the sensor in the enevlope c app?(edited)
floitsch
floitsch 02/20/2025 03:44 PM
Aah. I see the issue now.
floitsch
floitsch 02/20/2025 03:45 PM
So the error message is about the RMT driver.
floitsch
floitsch 02/20/2025 03:45 PM
Basically, the esp-idf checks at boot if the firmware contains more than one driver for their peripherals.
floitsch
floitsch 02/20/2025 03:45 PM
At the moment it complains about the RMT driver (E (399) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver.
floitsch
floitsch 02/20/2025 03:45 PM
So that wasn't a complaint about the i2c driver, but the RMT driver.
AbedN
AbedN 02/20/2025 03:46 PM
ah lemme try disabling that then
floitsch
floitsch 02/20/2025 03:46 PM
You can just disable it in the rmt_esp32.c file.
floitsch
floitsch 02/20/2025 03:46 PM
It's not clear if you can reenable the i2c.
floitsch
floitsch 02/20/2025 03:46 PM
I think the esp-idf just goes through the drivers one by one, and RMT was the first one to be hit.
floitsch
floitsch 02/20/2025 03:47 PM
I would expect that you need to disable most of the peripherals for Toit.
floitsch
floitsch 02/20/2025 03:47 PM
I have already migrated ADC, and i2s. So those should be ok.
floitsch
floitsch 02/20/2025 03:49 PM
A bit unfortunate that you can't use the Toit level for the sensor. We do have a driver for it.
floitsch
floitsch 02/20/2025 03:50 PM
Would it make sense to just migrate to Toit, or is your Arduino code using things for which there doesn't exist a Toit driver yet?
AbedN
AbedN 02/20/2025 04:06 PM
well weirdly enough now by just disabling rmt (and keeping all other perfs intact) the enevlope worked, however I am getting this: , what do you think?(edited)
floitschfloitsch
Would it make sense to just migrate to Toit, or is your Arduino code using things for which there doesn't exist a Toit driver yet?
AbedN
AbedN 02/20/2025 04:07 PM
this is what I'll be working on next actually
AbedNOPAbedN
well weirdly enough now by just disabling rmt (and keeping all other perfs intact) the enevlope worked, however I am getting this: , what do you think?(edited)
floitsch
floitsch 02/20/2025 04:28 PM
That's a safe guard so that Toit code doesn't use the wrong new. The linking probably made it apply to Arduino code as well.
floitsch
floitsch 02/20/2025 04:29 PM
I need to run now, but I will try to explain later. Hopefully with a work around
AbedN
AbedN 02/20/2025 04:29 PM
no worries, is there a way to disable it?
AbedNOPAbedN
no worries, is there a way to disable it?
floitsch
floitsch 02/20/2025 04:30 PM
Yes. That would be the workaround
AbedN
AbedN 02/20/2025 06:43 PM
Hey I did try setting "throwing_new_allowed" true in top.cc and now it's working! thanks for pointing it out(edited)
๐Ÿ‘1
floitsch
floitsch 02/20/2025 08:07 PM
So the problem is, that Toit does garbage collection. However, it doesn't do it when new and malloc fail. So if your code encounters OOMs you have to call the Toit GC and try again.
You could, in theory, patch the new that caused problems and do that automatically (after all, we were not allowed to call it), but it wouldn't do anything for malloc calls.
53 messages in total