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

[debug] Add ESP32 partition table logging to dump_config #8012

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

edwardtfn
Copy link
Contributor

What does this implement/fix?

This enhances the DebugComponent by adding functionality to log detailed partition table information during the dump_config() process. The partition table details are displayed in a clean, aligned format, providing developers with clear insights into the device's flash memory layout.

Features:

  1. Logs the following attributes for each partition:
    • Name
    • Type
    • Subtype
    • Start Address
    • Size
  2. Uses the esp_partition API for ESP32 devices running either Arduino or ESP-IDF.
  3. Ensures alignment of columns for improved readability.

Example Log Output:

[23:37:05][C][debug:033]: Partition table:
[23:37:05][C][debug:034]:   Name         Type Subtype  Address    Size
[23:37:05][C][debug:038]:   nvs          1    2        0x00009000 0x00005000
[23:37:05][C][debug:038]:   otadata      1    0        0x0000E000 0x00002000
[23:37:05][C][debug:038]:   app0         0    16       0x00010000 0x003C0000
[23:37:05][C][debug:038]:   app1         0    17       0x003D0000 0x003C0000
[23:37:05][C][debug:038]:   eeprom       1    153      0x00790000 0x00001000
[23:37:05][C][debug:038]:   spiffs       1    130      0x00791000 0x0000F000

Why This Change is Useful:

  1. Improved Debugging: Developers can verify partition configurations directly from logs, without requiring advanced knowledge or tools.
  2. Diagnostic Aid: Identifies potential issues related to insufficient partition sizes or incorrect layouts.
  3. Consistency: Provides a clear and formatted output to improve log readability.

Implementation Details:

  • Platform-Specific: The feature is implemented for ESP32 devices using either Arduino or ESP-IDF framework.
  • Formatted Output: Ensures aligned columns using fixed-width formatting for better clarity.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable): N/A

Pull request in esphome-docs with documentation (if applicable): N/A

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml: N/A

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

This enhances the `DebugComponent` by adding functionality to log detailed partition table information during the `dump_config()` process. The partition table details are displayed in a clean, aligned format, providing developers with clear insights into the device's flash memory layout.

#### **Features:**
1. Logs the following attributes for each partition:
   - Name
   - Type
   - Subtype
   - Start Address
   - Size
2. Uses the `esp_partition` API for ESP32 devices running either Arduino or ESP-IDF.
3. Ensures alignment of columns for improved readability.

#### **Example Log Output:**
```
[23:37:05][C][debug:033]: Partition table:
[23:37:05][C][debug:034]:   Name         Type Subtype  Address    Size
[23:37:05][C][debug:038]:   nvs          1    2        0x00009000 0x00005000
[23:37:05][C][debug:038]:   otadata      1    0        0x0000E000 0x00002000
[23:37:05][C][debug:038]:   app0         0    16       0x00010000 0x003C0000
[23:37:05][C][debug:038]:   app1         0    17       0x003D0000 0x003C0000
[23:37:05][C][debug:038]:   eeprom       1    153      0x00790000 0x00001000
[23:37:05][C][debug:038]:   spiffs       1    130      0x00791000 0x0000F000
```

#### **Why This Change is Useful:**
1. **Improved Debugging:** Developers can verify partition configurations directly from logs, without requiring physical access or external tools.
2. **Diagnostic Aid:** Identifies potential issues related to insufficient partition sizes or incorrect layouts.
3. **Consistency:** Provides a clear and formatted output to improve log readability.

#### **Implementation Details:**
- **Platform-Specific:** The feature is implemented for ESP32 devices using the ESP-IDF framework.
- **Formatted Output:** Ensures aligned columns using fixed-width formatting for better clarity.
@probot-esphome
Copy link

Hey there @OttoWinter, mind taking a look at this pull request as it has been labeled with an integration (debug) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@codecov-commenter
Copy link

codecov-commenter commented Dec 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.77%. Comparing base (4d8b5ed) to head (3783ce6).
Report is 1842 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8012      +/-   ##
==========================================
+ Coverage   53.70%   53.77%   +0.06%     
==========================================
  Files          50       50              
  Lines        9408     9840     +432     
  Branches     1654     1361     -293     
==========================================
+ Hits         5053     5291     +238     
- Misses       4056     4223     +167     
- Partials      299      326      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DjordjeMandic
Copy link
Member

Would this work on ESP8266?

@edwardtfn
Copy link
Contributor Author

edwardtfn commented Dec 26, 2024

This implementation is only for ESP32, but it's probably not that hard to implement something similar for ESP8266 as we probably can find some Arduino library to get the required info, but I would prefer to leave ESP8266 to another PR.

@edwardtfn edwardtfn changed the title [debug] Add partition table logging to dump_config [debug] Add ESP32 partition table logging to dump_config Dec 26, 2024
@jesserockz jesserockz merged commit fef50af into esphome:dev Jan 13, 2025
26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants