Skip to content

feat(core): Add wait time before setup #11367

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tanakamasayuki
Copy link
Contributor

Description of Change

Added initialization time for UART, etc.
Default value is 0.

Tests scenarios

Arduino-esp32 core v3.2.0 with M5STACK_STICKC_PLUS2 Board

now or default

void setup() {
}

void loop() {
}

output

------------------------------
  Total Size        :   378124 B ( 369.3 KB)
  Free Bytes        :   336868 B ( 329.0 KB)
  Allocated Bytes   :    33972 B (  33.2 KB)
  Minimum Free Bytes:   330908 B ( 323.2 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
SPIRAM Memory Info:
------------------------------------------
  Total Size        :  2097152 B (2048.0 KB)
  Free Bytes        :  2095104 B (2046.0 KB)
  Allocated Bytes   :        0 B (   0.0 KB)
  Minimum Free Bytes:  2095104 B (2046.0 KB)
  Largest Free Block:  2064372 B (2016.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
     1 : UART_TX[0]
     3 : UART_RX[0]
============ After Setup End =============

Output is cut off because UART is not yet initialized.

set wait

uint64_t getArduinoSetupWaitTick(void) {
  return 1000;
}

void setup() {
}

void loop() {
}

output

=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32
  Package           : PICO-V3-02
  Revision          : 3.00
  Cores             : 2
  CPU Frequency     : 240 MHz
  XTAL Frequency    : 40 MHz
  Features Bitfield : 0x000000b3
  Embedded Flash    : Yes
  Embedded PSRAM    : Yes
  2.4GHz WiFi       : Yes
  Classic BT        : Yes
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   378124 B ( 369.3 KB)
  Free Bytes        :   336956 B ( 329.1 KB)
  Allocated Bytes   :    33916 B (  33.1 KB)
  Minimum Free Bytes:   331256 B ( 323.5 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
SPIRAM Memory Info:
------------------------------------------
  Total Size        :  2097152 B (2048.0 KB)
  Free Bytes        :  2095104 B (2046.0 KB)
  Allocated Bytes   :        0 B (   0.0 KB)
  Minimum Free Bytes:  2095104 B (2046.0 KB)
  Largest Free Block:  2064372 B (2016.0 KB)
  Bus Mode          : QSPI
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         :  8388608 B (8 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  3264.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00340000, size:  3264.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00670000, size:  1536.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x007F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : May 15 2025 12:17:22
  Compile Host OS   : windows
  ESP-IDF Version   : v5.4.1-1-g2f7dcd862a-dirty
  Arduino Version   : 3.2.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : M5STACK_STICKC_PLUS2
  Arduino Variant   : m5stack_stickc_plus2
  Arduino FQBN      : esp32:esp32:m5stack_stickc_plus2:UploadSpeed=1500000,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=8M,PartitionScheme=default_8MB,DebugLevel=verbose,PSRAM=enabled,LoopCore=1,EventsCore=1,EraseFlash=none
============ Before Setup End ============
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   378124 B ( 369.3 KB)
  Free Bytes        :   336868 B ( 329.0 KB)
  Allocated Bytes   :    33972 B (  33.2 KB)
  Minimum Free Bytes:   330908 B ( 323.2 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
SPIRAM Memory Info:
------------------------------------------
  Total Size        :  2097152 B (2048.0 KB)
  Free Bytes        :  2095104 B (2046.0 KB)
  Allocated Bytes   :        0 B (   0.0 KB)
  Minimum Free Bytes:  2095104 B (2046.0 KB)
  Largest Free Block:  2064372 B (2016.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
     1 : UART_TX[0]
     3 : UART_RX[0]
============ After Setup End =============

All output.

Added initialization time for UART, etc.
Default value is 0.
Copy link
Contributor

github-actions bot commented May 15, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "Update Arduino.h":
    • summary looks empty
    • type/action looks empty
  • the commit message "Update Arduino.h":
    • summary looks empty
    • type/action looks empty

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 10 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).

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


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for 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.
- 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 756bde2

Copy link
Contributor

github-actions bot commented May 15, 2025

Test Results

 76 files   76 suites   12m 41s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit 756bde2.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a wait time mechanism before continuing with the setup process for the ESP32 core, allowing for additional initialization time (such as for UART) before executing subsequent code.

  • Added a weak function getArduinoSetupWaitTick() to provide a configurable delay value.
  • Introduced a vTaskDelay call in the loopTask() to pause execution based on the wait tick value.

@@ -44,10 +44,15 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) {
return false;
}

__attribute__((weak)) uint64_t getArduinoSetupWaitTick(void) {
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

Consider adding a brief comment above getArduinoSetupWaitTick() to explain its purpose, expected behavior, and the significance of its return value (in ticks) for clarity.

Copilot uses AI. Check for mistakes.

void loopTask(void *pvParameters) {
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
// sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0));
vTaskDelay(getArduinoSetupWaitTick());
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

It may be beneficial to clarify (via a comment) that vTaskDelay expects the delay in ticks and that getArduinoSetupWaitTick is expected to provide a meaningful tick value when overridden.

Copilot uses AI. Check for mistakes.

Add function definition and SET_SETUP_WAIT_TICH function
@@ -228,6 +228,12 @@ bool shouldPrintChipDebugReport(void);
return true; \
}

uint64_t getArduinoSetupWaitTick(void);
#define SET_SETUP_WAIT_TICH(tick) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#define SET_SETUP_WAIT_TICH(tick) \
#define SET_SETUP_WAIT_TICK(tick) \

@Jason2866
Copy link
Collaborator

Please do not add weak defines. There are two open issues where weak defines generate weird issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants