[PR #77] [MERGED] ESP: Fix Powermanagement for non-configured POWER #955

Closed
opened 2026-03-20 18:14:27 +01:00 by sascha_hemi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/OpenEPaperLink/OpenEPaperLink/pull/77
Author: @Mimoja
Created: 7/3/2023
Status: Merged
Merged: 7/4/2023
Merged by: @jjwbruijn

Base: masterHead: powerPins


📝 Commits (1)

  • a60bc91 ESP: Fix Powermanagement for non-configured POWER

📊 Changes

7 files changed (+38 additions, -11 deletions)

View changed files

📝 ESP32_AP-Flasher/include/zbs_interface.h (+1 -1)
📝 ESP32_AP-Flasher/platformio.ini (+5 -0)
📝 ESP32_AP-Flasher/src/flasher.cpp (+14 -3)
📝 ESP32_AP-Flasher/src/powermgt.cpp (+2 -1)
📝 ESP32_AP-Flasher/src/serialap.cpp (+5 -2)
📝 ESP32_AP-Flasher/src/usbflasher.cpp (+7 -3)
📝 ESP32_AP-Flasher/src/zbs_interface.cpp (+4 -1)

📄 Description

We currently have two ways of undefining the PowerPin in software for the ESP32 For once we can set POWER_NO_SOFT_POWER which will lead to some helpful screen messages but will still require the definition of the FLASHER_AP_POWER pin.

The second way (which was replaced with POWER_NO_SOFT_POWER) allowed to set the powerPin array to {-1} to indicate that the pin is undefined. This would then be handled in pretty far down the call stack right before toggeling the pin in powerControl:

 void powerControl(bool powerState, uint8_t* pin, uint8_t pincount) {
    if (pin[0] == -1) return;

This however is leading to an error: pin is n pointer (here an array with additional length) to an uint8_t which can never be -1. Therefore the check wont ever be reached and an invalid gpio number is passed to the gpio hal.
This caused the error:

  E (XXXX) gpio: gpio_set_level(226): GPIO output gpio_num error

to show up in the logs.
We are now proposing three seperate changes to mitigate this behaviour: 1) We are addng the POWER_NO_SOFT_POWER to the Wemos and the M5Stack boards default configs for new users to find.
2) We are replacing the pin[0] check in powerControl with a check on the pincount and a nullptr check as the zbs_interface->begin() allows for no powerPin to be passed in which case we are dereferencing a nullptr.
3) ZBS_interface->begin() is losing its powerPin related default configurations and sanity checks are put in place before every calling.

We have opted to do 3) in this way and not adding the checked into the ZBS_interface->begin() function which is also passed an uint8_t pointer to keep the API of the class stable for reuse in other projects. Changing the interface however would be ideal here


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/OpenEPaperLink/OpenEPaperLink/pull/77 **Author:** [@Mimoja](https://github.com/Mimoja) **Created:** 7/3/2023 **Status:** ✅ Merged **Merged:** 7/4/2023 **Merged by:** [@jjwbruijn](https://github.com/jjwbruijn) **Base:** `master` ← **Head:** `powerPins` --- ### 📝 Commits (1) - [`a60bc91`](https://github.com/OpenEPaperLink/OpenEPaperLink/commit/a60bc912052dd88a8628a1e411b27911f6892356) ESP: Fix Powermanagement for non-configured POWER ### 📊 Changes **7 files changed** (+38 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `ESP32_AP-Flasher/include/zbs_interface.h` (+1 -1) 📝 `ESP32_AP-Flasher/platformio.ini` (+5 -0) 📝 `ESP32_AP-Flasher/src/flasher.cpp` (+14 -3) 📝 `ESP32_AP-Flasher/src/powermgt.cpp` (+2 -1) 📝 `ESP32_AP-Flasher/src/serialap.cpp` (+5 -2) 📝 `ESP32_AP-Flasher/src/usbflasher.cpp` (+7 -3) 📝 `ESP32_AP-Flasher/src/zbs_interface.cpp` (+4 -1) </details> ### 📄 Description We currently have two ways of undefining the PowerPin in software for the ESP32 For once we can set POWER_NO_SOFT_POWER which will lead to some helpful screen messages _but_ will still require the definition of the FLASHER_AP_POWER pin. The second way (which was replaced with POWER_NO_SOFT_POWER) allowed to set the powerPin array to {-1} to indicate that the pin is undefined. This would then be handled in pretty far down the call stack right before toggeling the pin in powerControl: ``` void powerControl(bool powerState, uint8_t* pin, uint8_t pincount) { if (pin[0] == -1) return; ``` This however is leading to an error: pin is n pointer (here an array with additional length) to an uint8_t which can never be -1. Therefore the check wont ever be reached and an invalid gpio number is passed to the gpio hal. This caused the error: ``` E (XXXX) gpio: gpio_set_level(226): GPIO output gpio_num error ``` to show up in the logs. We are now proposing three seperate changes to mitigate this behaviour: 1) We are addng the POWER_NO_SOFT_POWER to the Wemos and the M5Stack boards default configs for new users to find. 2) We are replacing the pin[0] check in powerControl with a check on the pincount and a nullptr check as the zbs_interface->begin() allows for no powerPin to be passed in which case we are dereferencing a nullptr. 3) ZBS_interface->begin() is losing its powerPin related default configurations and sanity checks are put in place before every calling. We have opted to do 3) in this way and not adding the checked into the ZBS_interface->begin() function which is also passed an uint8_t pointer to keep the API of the class stable for reuse in other projects. Changing the interface however would be ideal here --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
sascha_hemi added the pull-request label 2026-03-20 18:14:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/OpenEPaperLink#955