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(sdmmc): Add SDMMC support for P4 + remove BUILTIN LED #10460

Merged
merged 17 commits into from
Oct 21, 2024

Conversation

P-R-O-C-H-Y
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y commented Oct 14, 2024

Description of Change

This PR adds power pin setting for SDMMC, as on P4 the SDMMC IO Power pins is controlled by external power supply.
Also the NEOPIXEL LED and BUILTIN LED got removed, as the P4 Function EV board don't have controllable LED (only power LED)

Tests scenarios

Tested on ESP32-P4 Function EV Board V1.4

Related links

#10278

@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Libraries Issue is related to Library support. label Oct 14, 2024
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Oct 14, 2024
@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: Review needed Issue or PR is awaiting review label Oct 14, 2024
Copy link
Contributor

github-actions bot commented Oct 14, 2024

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "Update libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino ":
    • summary looks empty
    • type/action looks empty
  • the commit message "feat(sdmmc): Add support for P4":
    • summary looks too short
  • the commit message "fix(board): Remove builtin led":
    • summary looks too short
  • the commit message "fix(ci): codespell fix":
    • summary looks too short
  • the commit message "fix(sdmmc): Remove periman":
    • summary looks too short

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

⚠️ Please consider squashing your 17 commits (simplifying branch history).
⚠️
	The **target branch** for this Pull Request **must be the default branch** of the project (`master`).

	If you would like to add this feature to a different branch, please state this in the PR description and we will consider it.

👋 Hello P-R-O-C-H-Y, 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.
- 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 a753474

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Test Results

 56 files  ±0   56 suites  ±0   4m 9s ⏱️ -7s
 21 tests ±0   21 ✅ ±0  0 💤 ±0  0 ❌ ±0 
134 runs   - 1  134 ✅  - 1  0 💤 ±0  0 ❌ ±0 

Results for commit a753474. ± Comparison against base commit 59ca4e2.

♻️ This comment has been updated with latest results.

@P-R-O-C-H-Y P-R-O-C-H-Y changed the title feat(sdmmc): Add support for P4 feat(sdmmc): Add SDMMC support for P4 + remove BUILTIN LED Oct 14, 2024
Copy link
Contributor

github-actions bot commented Oct 14, 2024

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
ESP32P4000.000.00000.000.00
ESP32S30‼️ +23K0.00‼️ +5.960‼️ +8K0.00‼️ +26.70
ESP320‼️ +16K0.00‼️ +4.590⚠️ +13160.00‼️ +2.87
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32P4ESP32S3ESP32
ExampleFLASHRAMFLASHRAMFLASHRAM
SD_MMC/examples/SD2USBMSC--‼️ +23K‼️ +8K--
SD_MMC/examples/SDMMC_Test--‼️ +21K⚠️ +1688‼️ +16K⚠️ +608
SD_MMC/examples/SDMMC_time--‼️ +15K‼️ +2K‼️ +14K⚠️ +1316

@lucasssvaz lucasssvaz self-requested a review October 15, 2024 13:08
@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Oct 15, 2024
@@ -186,6 +203,19 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_
}
_mode1bit = mode1bit;

#ifdef SOC_SDMMC_IO_POWER_EXTERNAL
sd_pwr_ctrl_ldo_config_t ldo_config = {
.ldo_chan_id = _pin_power,
Copy link
Member

Choose a reason for hiding this comment

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

Are you not by any chance confusing GPIO number with LDO channel number here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I get it wrong here.
Should it be always channel 4 for P4 or should I let the user to specify?

Copy link
Member

Choose a reason for hiding this comment

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

This depends on the development board. ESP32-P4 EV board powers IO lines of slot 0 using LDO channel 4. Other boards may use other LDO channels or even use an external LDO, or directly power them from VDD.

I think you need to define this in the board-specific header file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Solved :)

@igrr
Copy link
Member

igrr commented Oct 15, 2024

host.slot = SDMMC_HOST_SLOT_1;

For P4 EV board, SD card should use slot 0. Slot 1 is used for SDIO connection to the C6 module.

See espressif/esp-bsp#405 for an example.

@me-no-dev me-no-dev removed the Status: Pending Merge Pull Request is ready to be merged label Oct 16, 2024
@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: In Progress Issue is in progress label Oct 16, 2024
@me-no-dev me-no-dev added this to the 3.1.0 milestone Oct 17, 2024
@lucasssvaz lucasssvaz self-requested a review October 17, 2024 15:24
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review and removed Status: In Progress Issue is in progress labels Oct 21, 2024
#elif SOC_SDMMC_USE_IOMUX && defined(BOARD_HAS_SDMMC) && defined(CONFIG_IDF_TARGET_ESP32P4)
// ESP32-P4 can use either IOMUX or GPIO matrix
#elif defined(BOARD_HAS_SDMMC) && defined(CONFIG_IDF_TARGET_ESP32P4)
#if defined(BOARD_SDMMC_SLOT) && (BOARD_SDMMC_SLOT == 0)
_pin_clk = SDMMC_SLOT0_IOMUX_PIN_NUM_CLK;
Copy link
Member

Choose a reason for hiding this comment

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

Does this actually work? IIUC, the current sdmmc driver expects all pins to be set to 0 for IOMUX slots.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the pins for Peripheral manager.
Later the config is cleared, as the SDMMC_SLOT_CONFIG_DEFAULT for P4 is setting the pins in the config.

sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();

#if defined(CONFIG_IDF_TARGET_ESP32P4) && defined(BOARD_SDMMC_SLOT) && (BOARD_SDMMC_SLOT == 0)
  host.slot = SDMMC_HOST_SLOT_0;
  // reconfigure slot_config to remove all pins in order to use IO_MUX
  slot_config = {
    .cd = SDMMC_SLOT_NO_CD,
    .wp = SDMMC_SLOT_NO_WP,
    .width = 4,
    .flags = 0,
  };
#else

Copy link
Member Author

Choose a reason for hiding this comment

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

For P4 it will be always this config:

#define SDMMC_SLOT_CONFIG_DEFAULT() {\
    .clk = GPIO_NUM_43, \
    .cmd = GPIO_NUM_44, \
    .d0 = GPIO_NUM_39, \
    .d1 = GPIO_NUM_40, \
    .d2 = GPIO_NUM_41, \
    .d3 = GPIO_NUM_42, \
    .d4 = GPIO_NUM_45, \
    .d5 = GPIO_NUM_46, \
    .d6 = GPIO_NUM_47, \
    .d7 = GPIO_NUM_48, \
    .cd = SDMMC_SLOT_NO_CD, \
    .wp = SDMMC_SLOT_NO_WP, \
    .width   = SDMMC_SLOT_WIDTH_DEFAULT, \
    .flags = 0, \
}

Copy link
Member Author

Choose a reason for hiding this comment

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

As both IOMUX and GPIO Matrix are supported, this will never be used for P4.

#if SOC_SDMMC_USE_IOMUX && !SOC_SDMMC_USE_GPIO_MATRIX

/**
 * Macro defining default configuration of SDMMC host slot
 */
#define SDMMC_SLOT_CONFIG_DEFAULT() {\
    .cd = SDMMC_SLOT_NO_CD, \
    .wp = SDMMC_SLOT_NO_WP, \
    .width   = SDMMC_SLOT_WIDTH_DEFAULT, \
    .flags = 0, \
}

@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Oct 21, 2024
@me-no-dev
Copy link
Member

@me-no-dev me-no-dev merged commit 83d3568 into espressif:release/v3.1.x Oct 21, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Libraries Issue is related to Library support. Status: Pending Merge Pull Request is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants