Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rmt): Solve neopixel issue #9906

Merged
merged 3 commits into from
Jun 20, 2024
Merged

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Jun 20, 2024

Description of Change

If neopixelWrite() is used from different tasks / isr_callbacks, it may result in a concurrency problem because of many detach/attach calls in sequence, but not in synch.

This commit avoids initializing the neopixel GPIO again, after a first use.
It also improves a lot the response time of neopixelWrite().
It still allows to change RMT pin configuration or pin function correctly.

Tests scenarios

Tested using ESP32-S3. Please check the code from #9903

Related links

Fix #9903

if neopixelWrite() is used from different tasks/isr_callbacks, it may result in a concurrency problem and many detach/attach calls in sequence, but not in synch.

This commit avoids initializing the neopixel GPIO again.
@SuGlider SuGlider added the Area: Peripherals API Relates to peripheral's APIs. label Jun 20, 2024
@SuGlider SuGlider added this to the 3.0.2 milestone Jun 20, 2024
@SuGlider SuGlider self-assigned this Jun 20, 2024
Copy link
Contributor

github-actions bot commented Jun 20, 2024

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "feat(rmt): Solve neopixel issue":
    • body's lines must not be longer than 100 characters

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

Messages
📖 You might consider squashing your 3 commits (simplifying branch history).

👋 Hello SuGlider, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 75ba8bb

Copy link
Contributor

github-actions bot commented Jun 20, 2024

Test Results

 56 files   56 suites   5m 18s ⏱️
 21 tests  21 ✅ 0 💤 0 ❌
135 runs  135 ✅ 0 💤 0 ❌

Results for commit 75ba8bb.

♻️ This comment has been updated with latest results.

Copy link
Contributor

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32S30⚠️ +520.00⚠️ +0.01000.000.00
ESP32S20⚠️ +640.00⚠️ +0.02000.000.00
ESP32C30⚠️ +380.00⚠️ +0.01000.000.00
ESP32C60⚠️ +380.00⚠️ +0.02000.000.00
ESP32H20⚠️ +400.00⚠️ +0.01000.000.00
ESP320⚠️ +360.00⚠️ +0.01000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
ArduinoOTA/examples/BasicOTA⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
AsyncUDP/examples/AsyncUDPClient00000000--00
AsyncUDP/examples/AsyncUDPMulticastServer00000000--00
AsyncUDP/examples/AsyncUDPServer00000000--00
BLE/examples/BLE5_extended_scan00--000000--
BLE/examples/BLE5_multi_advertising00--000000--
BLE/examples/BLE5_periodic_advertising00--000000--
BLE/examples/BLE5_periodic_sync00--000000--
BLE/examples/Beacon_Scanner00--00000000
BLE/examples/Client00--00000000
BLE/examples/EddystoneTLM_Beacon00--0000--00
BLE/examples/EddystoneURL_Beacon00--0000--00
BLE/examples/Notify00--00000000
BLE/examples/Scan00--00000000
BLE/examples/Server00--00000000
BLE/examples/Server_multiconnect00--00000000
BLE/examples/UART00--00000000
BLE/examples/Write00--00000000
BLE/examples/iBeacon00--00000000
DNSServer/examples/CaptivePortal00000000--00
EEPROM/examples/eeprom_class000000000000
EEPROM/examples/eeprom_extra000000000000
EEPROM/examples/eeprom_write000000000000
ESP32/examples/AnalogOut/LEDCFade000000000000
ESP32/examples/AnalogOut/LEDCSoftwareFade000000000000
ESP32/examples/AnalogOut/SigmaDelta000000000000
ESP32/examples/AnalogOut/ledcFrequency000000000000
ESP32/examples/AnalogOut/ledcWrite_RGB000000000000
ESP32/examples/AnalogRead000000000000
ESP32/examples/AnalogReadContinuous000000000000
ESP32/examples/ArduinoStackSize000000000000
ESP32/examples/CI/CIBoardsTest⚠️ +440⚠️ +440⚠️ +380⚠️ +360⚠️ +36000
ESP32/examples/Camera/CameraWebServer0000------00
ESP32/examples/ChipID/GetChipID000000000000
ESP32/examples/DeepSleep/ExternalWakeUp0000------00
ESP32/examples/DeepSleep/TimerWakeUp00000000--00
ESP32/examples/DeepSleep/TouchWakeUp0000------00
ESP32/examples/FreeRTOS/BasicMultiThreading⚠️ +440⚠️ +440⚠️ +320⚠️ +320⚠️ +34000
ESP32/examples/FreeRTOS/Mutex000000000000
ESP32/examples/FreeRTOS/Queue000000000000
ESP32/examples/FreeRTOS/Semaphore000000000000
ESP32/examples/GPIO/BlinkRGB⚠️ +440⚠️ +440⚠️ +340⚠️ +320⚠️ +32000
ESP32/examples/GPIO/FunctionalInterrupt000000000000
ESP32/examples/GPIO/FunctionalInterruptStruct000000000000
ESP32/examples/GPIO/GPIOInterrupt000000000000
ESP32/examples/HWCDC_Events00--⚠️ +360⚠️ +360⚠️ +360--
ESP32/examples/MacAddress/GetMacAddress000000000000
ESP32/examples/RMT/RMTCallback⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +360⚠️ +360
ESP32/examples/RMT/RMTLoopback⚠️ +440⚠️ +440⚠️ +360⚠️ +380⚠️ +360⚠️ +360
ESP32/examples/RMT/RMTReadXJT⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +380⚠️ +360
ESP32/examples/RMT/RMTWriteNeoPixel⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +360⚠️ +360
ESP32/examples/RMT/RMT_CPUFreq_Test⚠️ +440⚠️ +440⚠️ +380⚠️ +380⚠️ +400⚠️ +360
ESP32/examples/RMT/RMT_EndOfTransmissionState⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +380⚠️ +360
ESP32/examples/RMT/RMT_LED_Blink⚠️ +440⚠️ +440⚠️ +360⚠️ +380⚠️ +380⚠️ +360
ESP32/examples/ResetReason/ResetReason000000000000
ESP32/examples/ResetReason/ResetReason2000000000000
ESP32/examples/Serial/BaudRateDetect_Demo000000000000
ESP32/examples/Serial/OnReceiveError_BREAK_Demo000000000000
ESP32/examples/Serial/OnReceive_Demo000000000000
ESP32/examples/Serial/RS485_Echo_Demo000000000000
ESP32/examples/Serial/RxFIFOFull_Demo000000000000
ESP32/examples/Serial/RxTimeout_Demo000000000000
ESP32/examples/Serial/Serial_All_CPU_Freqs000000000000
ESP32/examples/Serial/Serial_STD_Func_OnReceive000000000000
ESP32/examples/Serial/onReceiveExample000000000000
ESP32/examples/TWAI/TWAIreceive000000000000
ESP32/examples/TWAI/TWAItransmit000000000000
ESP32/examples/Template/ExampleTemplate000000000000
ESP32/examples/Time/SimpleTime00000000--00
ESP32/examples/Timer/RepeatTimer000000000000
ESP32/examples/Timer/WatchdogTimer000000000000
ESP32/examples/Touch/TouchButtonV20000--------
ESP32/examples/Touch/TouchInterrupt0000------00
ESP32/examples/Touch/TouchRead0000------00
ESP32/examples/Utilities/HEXBuilder000000000000
ESP32/examples/Utilities/MD5Builder000000000000
ESP32/examples/Utilities/SHA1Builder000000000000
ESP_I2S/examples/ES8388_loopback⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +36000
ESP_I2S/examples/Record_to_WAV00--------00
ESP_I2S/examples/Simple_tone000000000000
ESP_NOW/examples/ESP_NOW_Broadcast_Master00000000--00
ESP_NOW/examples/ESP_NOW_Broadcast_Slave00000000--00
ESP_NOW/examples/ESP_NOW_Network00000000--00
ESP_NOW/examples/ESP_NOW_Serial00000000--00
ESP_SR/examples/Basic⚠️ +440----------
ESPmDNS/examples/mDNS-SD_Extended00000000--00
ESPmDNS/examples/mDNS_Web_Server00000000--00
Ethernet/examples/ETH_W5500_Arduino_SPI⚠️ +440⚠️ +360⚠️ +360⚠️ +360⚠️ +36000
Ethernet/examples/ETH_W5500_IDF_SPI⚠️ +480⚠️ +480⚠️ +360⚠️ +360⚠️ +36000
FFat/examples/FFat_Test000000000000
FFat/examples/FFat_time00000000--00
HTTPClient/examples/Authorization00000000--00
HTTPClient/examples/BasicHttpClient00000000--00
HTTPClient/examples/BasicHttpsClient00000000--00
HTTPClient/examples/HTTPClientEnterprise00000000--00
HTTPClient/examples/ReuseConnection00000000--00
HTTPClient/examples/StreamHttpClient00000000--00
HTTPUpdate/examples/httpUpdate⚠️ +440⚠️ +640⚠️ +360⚠️ +360--00
HTTPUpdate/examples/httpUpdateSPIFFS⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
HTTPUpdate/examples/httpUpdateSecure⚠️ +440⚠️ +520⚠️ +360⚠️ +360--00
HTTPUpdateServer/examples/WebUpdater⚠️ +440⚠️ +480⚠️ +360⚠️ +360--00
Insights/examples/DiagnosticsSmokeTest000000----00
Insights/examples/MinimalDiagnostics000000----00
LittleFS/examples/LITTLEFS_test000000000000
LittleFS/examples/LITTLEFS_time00000000--00
NetBIOS/examples/ESP_NBNST00000000--00
NetworkClientSecure/examples/WiFiClientInsecure00000000--00
NetworkClientSecure/examples/WiFiClientPSK00000000--00
NetworkClientSecure/examples/WiFiClientSecure00000000--00
NetworkClientSecure/examples/WiFiClientSecureEnterprise00000000--00
NetworkClientSecure/examples/WiFiClientSecureProtocolUpgrade00000000--00
NetworkClientSecure/examples/WiFiClientShowPeerCredentials00000000--00
NetworkClientSecure/examples/WiFiClientTrustOnFirstUse00000000--00
PPP/examples/PPP_Basic⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +36000
Preferences/examples/Prefs2Struct000000000000
Preferences/examples/StartCounter000000000000
RainMaker/examples/RMakerCustom⚠️ +440⚠️ +440⚠️ +360----00
RainMaker/examples/RMakerCustomAirCooler⚠️ +520⚠️ +400⚠️ +360----00
RainMaker/examples/RMakerSonoffDualR3⚠️ +440⚠️ +520⚠️ +360----00
RainMaker/examples/RMakerSwitch⚠️ +440⚠️ +440⚠️ +360----00
SD/examples/SD_Test⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +36000
SD/examples/SD_time⚠️ +480⚠️ +440⚠️ +360⚠️ +360--00
SD_MMC/examples/SD2USBMSC⚠️ +440----------
SD_MMC/examples/SDMMC_Test00--------00
SD_MMC/examples/SDMMC_time00--------00
SPI/examples/SPI_Multiple_Buses⚠️ +440⚠️ +440------00
SPIFFS/examples/SPIFFS_Test000000000000
SPIFFS/examples/SPIFFS_time00000000--00
SimpleBLE/examples/SimpleBleDevice00----000000
TFLiteMicro/examples/hello_world000000000000
Ticker/examples/Blinker⚠️ +440⚠️ +440⚠️ +340⚠️ +340⚠️ +34000
Ticker/examples/TickerBasic⚠️ +440⚠️ +440⚠️ +320⚠️ +340⚠️ +32000
Ticker/examples/TickerParameter⚠️ +440⚠️ +440⚠️ +340⚠️ +320⚠️ +32000
USB/examples/CompositeDevice⚠️ +44000--------
USB/examples/ConsumerControl⚠️ +44000--------
USB/examples/CustomHIDDevice⚠️ +44000--------
USB/examples/FirmwareMSC⚠️ +44000--------
USB/examples/Gamepad⚠️ +44000--------
USB/examples/HIDVendor⚠️ +44000--------
USB/examples/Keyboard/KeyboardLogout⚠️ +44000--------
USB/examples/Keyboard/KeyboardMessage⚠️ +44000--------
USB/examples/Keyboard/KeyboardReprogram⚠️ +44000--------
USB/examples/Keyboard/KeyboardSerial⚠️ +44000--------
USB/examples/KeyboardAndMouseControl⚠️ +44000--------
USB/examples/MIDI/MidiController⚠️ +44000--------
USB/examples/MIDI/MidiInterface⚠️ +44000--------
USB/examples/MIDI/MidiMusicBox⚠️ +44000--------
USB/examples/MIDI/ReceiveMidi⚠️ +44000--------
USB/examples/Mouse/ButtonMouseControl⚠️ +44000--------
USB/examples/SystemControl⚠️ +44000--------
USB/examples/USBMSC⚠️ +44000--------
USB/examples/USBSerial⚠️ +44000--------
USB/examples/USBVendor⚠️ +44000--------
Update/examples/AWS_S3_OTA_Update⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
Update/examples/HTTPS_OTA_Update00000000--00
Update/examples/HTTP_Client_AES_OTA_Update⚠️ +480⚠️ +480⚠️ +360⚠️ +360--00
Update/examples/HTTP_Server_AES_OTA_Update⚠️ +480⚠️ +480⚠️ +360⚠️ +360--00
Update/examples/OTAWebUpdater⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
Update/examples/SD_Update⚠️ +440⚠️ +440⚠️ +360⚠️ +360⚠️ +36000
WebServer/examples/AdvancedWebServer⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
WebServer/examples/FSBrowser00000000--00
WebServer/examples/Filters⚠️ +440⚠️ +480⚠️ +360⚠️ +360--00
WebServer/examples/HelloServer⚠️ +440⚠️ +520⚠️ +360⚠️ +360--00
WebServer/examples/HttpAdvancedAuth⚠️ +480⚠️ +560⚠️ +360⚠️ +360--00
WebServer/examples/HttpAuthCallback⚠️ +480⚠️ +480⚠️ +360⚠️ +360--00
WebServer/examples/HttpAuthCallbackInline⚠️ +440⚠️ +520⚠️ +360⚠️ +360--00
WebServer/examples/HttpBasicAuth⚠️ +440⚠️ +520⚠️ +360⚠️ +360--00
WebServer/examples/HttpBasicAuthSHA1⚠️ +360⚠️ +440⚠️ +360⚠️ +360--00
WebServer/examples/HttpBasicAuthSHA1orBearerToken⚠️ +400⚠️ +440⚠️ +360⚠️ +360--00
WebServer/examples/MultiHomedServers⚠️ +520⚠️ +440⚠️ +360⚠️ +360--00
WebServer/examples/PathArgServer00000000--00
WebServer/examples/SDWebServer⚠️ +480⚠️ +560⚠️ +360⚠️ +360--00
WebServer/examples/SimpleAuthentification00000000--00
WebServer/examples/UploadHugeFile⚠️ +480⚠️ +160⚠️ +360⚠️ +360--00
WebServer/examples/WebServer00000000--00
WebServer/examples/WebUpdate⚠️ +440⚠️ +440⚠️ +360⚠️ +360--00
WiFi/examples/FTM/FTM_Initiator00000000--00
WiFi/examples/FTM/FTM_Responder00000000--00
WiFi/examples/SimpleWiFiServer⚠️ +480⚠️ +440⚠️ +360⚠️ +360--00
WiFi/examples/WPS00000000--00
WiFi/examples/WiFiAccessPoint⚠️ +440⚠️ +480⚠️ +360⚠️ +360--00
WiFi/examples/WiFiBlueToothSwitch00--0000--00
WiFi/examples/WiFiClient00000000--00
WiFi/examples/WiFiClientBasic00000000--00
WiFi/examples/WiFiClientConnect00000000--00
WiFi/examples/WiFiClientEnterprise00000000--00
WiFi/examples/WiFiClientEvents00000000--00
WiFi/examples/WiFiClientStaticIP00000000--00
WiFi/examples/WiFiIPv600000000--00
WiFi/examples/WiFiMulti00000000--00
WiFi/examples/WiFiMultiAdvanced00000000--00
WiFi/examples/WiFiScan00000000--00
WiFi/examples/WiFiScanAsync00000000--00
WiFi/examples/WiFiScanDualAntenna00000000--00
WiFi/examples/WiFiSmartConfig00000000--00
WiFi/examples/WiFiTelnetToSerial00000000--00
WiFi/examples/WiFiUDPClient00000000--00
WiFiProv/examples/WiFiProv00000000--00
Wire/examples/WireMaster000000000000
Wire/examples/WireScan000000000000
Wire/examples/WireSlave000000000000
BluetoothSerial/examples/DiscoverConnect----------00
BluetoothSerial/examples/GetLocalMAC----------00
BluetoothSerial/examples/SerialToSerialBT----------00
BluetoothSerial/examples/SerialToSerialBTM----------00
BluetoothSerial/examples/SerialToSerialBT_Legacy----------00
BluetoothSerial/examples/SerialToSerialBT_SSP----------00
BluetoothSerial/examples/bt_classic_device_discovery----------00
BluetoothSerial/examples/bt_remove_paired_devices----------00
ESP32/examples/DeepSleep/SmoothBlink_ULP_Code----------00
ESP32/examples/Touch/TouchButton----------00
Ethernet/examples/ETH_LAN8720----------00
Ethernet/examples/ETH_TLK110----------00

@@ -491,14 +503,15 @@ bool rmtInit(int pin, rmt_ch_dir_t channel_direction, rmt_reserve_memsize_t mem_
while (xSemaphoreTake(g_rmt_block_lock, portMAX_DELAY) != pdPASS) {}

// allocate the rmt bus object and sets all fields to NULL
rmt_bus_handle_t bus = (rmt_bus_handle_t)heap_caps_calloc(1, sizeof(struct rmt_obj_s), MALLOC_CAP_DEFAULT);
bus = (rmt_bus_handle_t)heap_caps_calloc(1, sizeof(struct rmt_obj_s), MALLOC_CAP_DEFAULT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if bus was not NULL, would you not leak it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No... It was already released by detach.

@me-no-dev me-no-dev added the Status: Pending Merge Pull Request is ready to be merged label Jun 20, 2024
@SuGlider SuGlider merged commit 0ef2986 into espressif:master Jun 20, 2024
56 checks passed
@SuGlider SuGlider deleted the rmt_neo_pixel branch June 20, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

NeoPixel can crash system.
4 participants