Running Bare-Metal Rust Alongside ESP-IDF on the ESP32-S3's Second Core
https://tingouw.com/blog/embedded/esp32/run_rust_on_app_core
#HackerNews #Rust #ESP32 #Embedded #Development #BareMetal #ESPIDF
Running Bare-Metal Rust Alongside ESP-IDF on the ESP32-S3's Second Core
https://tingouw.com/blog/embedded/esp32/run_rust_on_app_core
#HackerNews #Rust #ESP32 #Embedded #Development #BareMetal #ESPIDF
Управляем питанием по-взрослому: конечный автомат для устройств с батарейным питанием
В embedded-проектах с батарейным питанием управление энергопотреблением часто сводят к нескольким вызовам sleep() и проверке кнопки включения. Пока устройство простое — этого хватает. Но как только появляется аккумулятор, зарядка, дисплей, кнопка питания и требования к пользовательскому поведению, такой подход начинает разваливаться. Типичные ситуации, с которыми сталкиваются на практике: ● устройство выключено, но подключили зарядку — что должно происходить? ● зарядка идёт, пользователь нажал кнопку — включаться или нет? ● батарея критически разряжена — как корректно отказать во включении? ● устройство долго не используется — когда и как его выключать? ● контроллер питания подал питание сам по себе — это включение или ошибка? устройство вышло из Deep Sleep — это пробуждение или «холодный старт»?
ПРОГРАММА КОНТРОЛЛЕРА СЕТИ CAN
Продолжаю публикацию статей по структуре "Умный дом" на основе локальной сети CAN. В этой статье описывается программа, которая записывается в каждый контроллер локальной сети. Программа написана любителем, не профессионалом, поэтому за ошибки прошу не судить строго. К тому же сам признаю, что стиль написания программы несколько устарел, но переучиваться не хочется да и поздно. В общем «не стреляйте в музыканта, он играет как может» . Попытался поместить исходный текст программы в статью, но понял что это невозможно из-за большого количества строк программы. Поэтому программу выложил в своем репозитории на github: https://github.com/OldIngineer/MySmartHouse3 . И попытался кратко описать основные моменты программы.
Система "Умный дом" основанная на интерфейсе CAN/TWAI. В качестве контроллера устройств сети выбрана микросхема ESP32-C6. - OldIngineer/MySmartHouse3
Ищем ошибку в работе WiFi у платы ESP32-C3 SuperMini
Статья о небольшой эпопее с поиском ошибки в работе WiFi на плате ESP32-C3 SuperMini, с которой пришлось разбираться в процессе отладки кода прошивки для контроллера батареи АКБ ( О контроллере батареи ИБП (вопрос к читателям Хабра) и О контроллере батареи ИБП (часть 2) ). Симптоматика проблемы с WiFi следующая: после включения питания и начала авторизации по WiFi плата ESP32-C3 SuperMini через какое-то время зависает, вплоть до срабатывания сторожевого таймера. Поиск решения проблемы в интернете не помог, но было замечено, что в эти моменты на плате очень сильно нагревается стабилизатор напряжения 3.3V, да так, что даже рука не терпит, тогда как при работе тестовых примеров (где WiFi работает нормально) такого эффекта не наблюдается. Из-за этого решил копать именно в этом направлении.
With ESP-IDF, I created a custom flash partition table and stored the video streams in their own partitions. The app is under 300 KB, and it compiles, links, and flashes in 12 seconds.
Arduino can do custom partition tables. Maybe it can do custom workflow to build the filesystem images too. It would still take over a minute to compile, though.
🧵 12/N
I am moving the Soul Cage's firmware from Arduino to ESP-IDF. Arduino is completely unusable for developing this app.
I just measured a compile and upload time of 4:33. Four and a half minutes. That's 1:20 to compile and link, 0:49 of mysterious "indexing", and 2:24 to flash. Yeah, it's a huge image, about 15 MB.
What's it doing with 1:20 compile time? This is an 8 core CPU; that's about 2 trillion cycles.
🧵 11/N
My latest tutorial is out! How to use I2C on the #ESP32. I show how to talk to a real TMP102 sensor using #ESPIDF (and a virtual TMP105 sensor with #QEMU).
👇👇👇
https://shawnhymel.com/2954/esp32-how-to-use-i2c-with-esp-idf/?utm_source=mastodon&utm_medium=social&utm_campaign=esp32_iot_course_evergreen
**ESPHome update 2025.08.02: This little maneuvre will cost you … several days.**
TL;DR
Changing the ESPHome framework from Arduino to ESP-IDF is far from trivial. Don’t attempt it at home, if you’re a Home Assistant / ESPHome hobbyist with a poor C++ knowledge.
Read on…
After the last update of ESPHome, some of my compiled firmware images for my ESP32 boards suddenly became too big to fit in their memory. They said that Arduino libraries became too big and bloated. Yelp, I can’t update them anymore!
They (ESPHome developers) said we should switch from Arduion framework to ESP-IDF anyways, because it’s smaller, optimized and closer to the metal.
They said only a small change in esp configuration yaml is needed:
esp32: board: esp32dev framework: type: arduino # <-- change to esp-idfAnd that’s almost1 it!
You wish.
I changed the framework as described above (for one non-critical ESPCam).
I got compile errors (for my lambda functions). But wait, they said everything will work the same, no, even better!
But it looks like there are some differences between Arduino and ESP-IDF framework. For example, there is no String() in esp-idf! Isn’t that a … basic?
Ok, I surrendered and changed my lambda function that returned uptime in human readable format from:
- platform: uptime name: ${devicename} Uptime in Days id: uptime_sensor_days update_interval: 60s on_raw_value: then: - text_sensor.template.publish: id: uptime_human state: !lambda |- int seconds = round(id(uptime_sensor_days).raw_state); int days = seconds / (24 * 3600); seconds = seconds % (24 * 3600); int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; return ( (days ? String(days) + "d " : "") + (hours ? String(hours) + "h " : "") + (minutes ? String(minutes) + "m " : "") + (String(seconds) + "s") ).c_str();Changed the last bold bit (return…) that caused compile errors to:
...std::string result; if (days) result += std::to_string(days) + "d "; if (hours) result += std::to_string(hours) + "h "; if (minutes) result += std::to_string(minutes) + "m "; result += std::to_string(seconds) + "s"; return result;And then it compiled ok.
It also linked ok and uploaded firmware to my ESPCam.
Ping to my ESPCam worked, but sensors (camera web server, uptime, led switch,…) were unavailable.
ESPHome log returned only the following info:
changed lambda. log returns: Uploading: [============================================================] 100% Done... INFO Upload took 6.12 seconds, waiting for result... INFO OTA successful INFO Successfully uploaded program. INFO Starting log output from 192.168.0.15 using esphome API INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.000s INFO Trying to connect to esp32-cam01 @ 192.168.0.15 in the background INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.000s INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.001s INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.000s INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.000s INFO Successfully resolved esp32-cam01 @ 192.168.0.15 in 0.000sThe connection to ESPCam looks ok.
But it wouldn’t connect to ESPHome API:
WARNING Can't connect to ESPHome API for esp32-cam01 @ 192.168.0.15: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.0.15', port=6053))]: [Errno 111] Connect call failed ('192.168.0.15', 6053) (SocketAPIError)I really wasn’t in the mood to research what went wrong and which part of my ESPCam configuration code is not compatible with ESP-IDF.
So I ditched esp-idf framework, reverted it back to arduino, recompiled, uploaded and my espcam works again.
Yes, I’ve searched for possible solutions2, but couldn’t find any that I could use.
My other ESP32 board (the one that has suddenly too big firmware after ESPHome update) will obviously stay in un-updated state for the rest of it’s life. I don’t wan’t to deal with breaking changes, modifying the code, re-learning C++ just to make it work again.
And this little maneuver caused me few days. Don’t go the same path.
Or, if the framework change works for you, please let me know.
Or, maybe I’ll try again when the issues3 are resolved.
https://blog.rozman.info/esphome-update-2025-08-02-this-little-maneuvre-will-cost-you-several-days/