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

cpu/esp32/periph: add low-level SDMMC peripheral driver for ESP32 and ESP32-S3 #19786

Merged
merged 8 commits into from
Jan 7, 2024

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Jul 2, 2023

Contribution description

This PR implements the low-level SDIO/SDMMC peripheral driver for ESP32 and ESP32-S3 SD/MMC host controller according to the definition in #19539.

The PR also enables the SD Card Slot for esp32-wrover-kit and esp32-olimex-evb.

Testing procedure

BOARD=esp32-wrover-kit make -C tests/drivers/sdmmc
BOARD=esp32-wrover-kit make -C tests/sys/vfs_default

Issues/PRs references

Depends on PR #19539
Depends on PR #19899
Depends on PR #20104

@github-actions github-actions bot added Area: doc Area: Documentation Area: pkg Area: External package ports Area: boards Area: Board ports Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration labels Jul 2, 2023
@gschorcht gschorcht added Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first labels Jul 2, 2023
@gschorcht gschorcht force-pushed the cpu/esp32/periph/sdmmc branch 3 times, most recently from 91e15a1 to 0993984 Compare July 3, 2023 10:20
bors bot added a commit that referenced this pull request Jul 7, 2023
19487: nanocoap: implement extended tokens (RFC 8974) r=benpicco a=benpicco



19808: boards: add ESP32-S3-USB-OTG support r=benpicco a=gschorcht

### Contribution description

This PR provides the support for the [ESP32-S3-USB-OTG](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/user_guide.html) board.

The SD card can only be used in SPI mode at the moment. As soon as PR #19786 is merged, the SD/MMC support can be enabled and the SD card can then be used in SD mode with 4-bit data bus width.

The display uses uses the ST7789 driver IC that is compatible with the ST7735. For that purpose the ST7735 driver is extended by a pseudomodule definition `st7789` for the ST7789 which is enabled by the board and enables automatically the `st7789` (e57c48a). Vise versa, board's `Makefile.dep` enables automatically the `st7789` pseudomodule if the `st7735` is used. The pseudomodule `st7789` is just used to increase the upper limit for supported lines. This change is also part of PR #19807.

~The PR includes a very small documentation fix for ESP32-S3-DevKit board that was noticed during the development of this board definition (1155b6a).~

### Testing procedure

The board has been tested with all basic tests for supported hardware including `tests/driver/st3375`:

![IMG_20230707_105556](https://github.com/RIOT-OS/RIOT/assets/31932013/88d4ac11-0c02-4339-a423-7900e1c0904c)

- [x] tests/drivers/st3375
- [x] tests/periph/gpio
- [x] tests/periph/pwm
- [x] tests/periph/spi
- [x] tests/periph/uart
- [x] tests/sys/usbus_cdc_ecm 

### Issues/PRs references


Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
bors bot added a commit that referenced this pull request Aug 23, 2023
19539: drivers/periph_sdmmc: define a High-level SDIO/SD/MMC API and low-level SDMMC periperal driver interface r=benpicco a=gschorcht

### Contribution description

This PR provides a SDIO/SD/MMC Device API (SDMMC). It implements a SD host controller driver that provides a high-level functions using a low-level SDIO/SD/MMC peripheral driver for accessing

- MultiMediaCards (MMC) and Embedded MultiMediaCards (eMMC)
- SD Memory Cards (SD Cards) with Standard Capacity (SDSC), High Capacity (SDHC) or Extended Capacity (SDXC).

It supports:

- 1-bit, 4-bit and 8-bit data bus width
- Default Speed and High Speed
- Auto-CLK

The SDIO/SD/MMC device API (SDMMC) is divided into two parts:

1. The high-level API that implements the SD Host Controller driver and allows
   - to inititialize and identify different types of cards,
   - to access them either blockwise or bytewise,
   - to get information about the used card, and
   - to send single commands or application specific commands to the card.

2. The low-level SDIO/SD/MMC peripheral driver implements the low-level functions required by the high-level device API. It has to be implemented for each MCU.

### Limitations:

- Only one card per SDIO/SD/MMC device is supported.
- eMMCs specific features are not supported.
- UHS-I, UHS-II and UHS-III are not supported.

### Testing procedure

PR #19540, PR #19760 or PR #19786 is needed to test this PR.

### Issues/PRs references

Prerequisite for PR #19540
Prerequisite for PR #19760
Prerequisite for PR #19786

19815: cpu/sam0_common/periph/sdhc: busy waiting and clock fixes r=benpicco a=benpicco



19860: drivers/ft5x06: fix vendor ID for FT6xx6 and FTxxxx register addresses r=benpicco a=gschorcht

### Contribution description

This PR provides a fix of the vendor ID for FT6xx6 touch panel driver ICs and a fix of register addresses for FTxxxx.

According to the [Application Note for FT6x06 CTPM](https://cdn-shop.adafruit.com/datasheets/FT6x06_AN_public_ver0.1.3.pdf), the vendor ID of FT6x06 touch panel driver ICs is `0x11` instead of `0xcd`. Although there are no information found in the Web about the FT6x36, the FT6336U touch panel of a ESP32-S3 WT32 SC01 Plus is also working with `0x11` as vendor ID so that it seems that FT6x36 is also using `0x11` as vendor ID.

Figured out with a `stm32f723e-disco` board (revision D03). Without this PR, `tests/drivers/ft5x06` gives:
```
+------------Initializing------------+
[ft5x06] init: invalid vendor ID: '0x11' (expected: 0xcd)
[Error] Initialization failed
```
With this PR it works as expected.
```
+------------Initializing------------+
Initialization successful
main(): This is RIOT! (Version: 2023.10-devel-96-gbb9011-drivers/ft5x06_fix_vendor_id)
FT5x06 test application

+------------Initializing------------+
[ft5x06] init: configuring touchscreen interrupt
Initialization successful
1 touch detected
[ft5x06] read gesture_id '0x00'
Touch 1 - X: 151, Y:138
[ft5x06] read gesture_id '0x00'
```

Some background information found in the Web:

- According to the [STM32CubeF7](https://github.com/STMicroelectronics/STM32CubeF7/blob/c20e6dd15bd2a90e19f28cadc703aeb26825d211/Drivers/BSP/STM32F723E-Discovery/stm32f723e_discovery_ts.c#L24-L27) the FRIDA LCD panel mounted on the `stm32f723e-disco` board either uses FT6x36 (prior revision D) or FT3x67 (revision D). However, the FT5x06 driver type for the card is defined as FT6x06, which does not seem correct: https://github.com/RIOT-OS/RIOT/blob/bb9011c3fbfe7c20bde99ce2462ef564d555ea08/boards/stm32f723e-disco/include/board.h#L59
- According to the [STM32CubeF7](https://github.com/STMicroelectronics/STM32CubeF7/blob/c20e6dd15bd2a90e19f28cadc703aeb26825d211/Drivers/BSP/Components/ft6x06/ft6x06.h#L269-L270), the vendor ID for FT6x36 should be `0xcd`. However, the FT6336U on ESP32-S3 WT32 SC01 Plus works with vendor ID `0x11`.
- The [Adafruit FT6206 library](https://github.com/adafruit/Adafruit_FT6206_Library/blob/95118cd9831890616a1afb55d323b6261dee15af/Adafruit_FT6206.h#L28) uses `0x11` as vendor id.
- The `stm32l496g-disco` board uses a FT6236 which has vendor ID `0xcd`.

So the information available on the web is confusing. Maybe, a better solution would be to accept `0x11` as well as `0xcd` as vendor ID for FT6xxx touch panels. Unfortunately, there are no documents available on the registers directly from FocalTech 😟 so it seems to be more speculation than knowledge.

### Testing procedure


### Issues/PRs references



19886: cpu/efm32: fix DAC configuration r=benpicco a=gschorcht

### Contribution description

The EFM32 MCU allows the reference voltage to be configured per DAC device, not per DAC channel. Also, the DAC reference voltage was defined in the configuration but not used anywhere.

At the moment we have only defined one board (`stwstk6220a`) that uses the DAC, so changing the configuration interface shouldn't be critical.

### Testing procedure

`tests/periph/dac` should still work for the `stwstk6220a`
```
BOARD=slwstk6220a make -j8 -C tests/periph/dac flash
```
I don't have a `stwstk6220a` board (EFM32 Series 0) so that I can't test it. I could only test it for the `sltb009a` board (EFM32 Series 1) with the change for VDAC in PR #19887.

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
@benpicco benpicco removed the State: waiting for other PR State: The PR requires another PR to be merged first label Aug 23, 2023
@gschorcht gschorcht force-pushed the cpu/esp32/periph/sdmmc branch from eab2fbc to 196fef6 Compare August 23, 2023 22:41
@gschorcht gschorcht added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 12, 2023
@riot-ci
Copy link

riot-ci commented Sep 12, 2023

Murdock results

✔️ PASSED

60ab86b tests/pkg/fatfs_vfs: add SDMMC support

Success Failures Total Runtime
8085 0 8085 10m:56s

Artifacts

@gschorcht gschorcht added the State: waiting for other PR State: The PR requires another PR to be merged first label Sep 12, 2023
@gschorcht gschorcht force-pushed the cpu/esp32/periph/sdmmc branch from 196fef6 to c2017a8 Compare September 13, 2023 04:56
@gschorcht gschorcht removed the State: waiting for other PR State: The PR requires another PR to be merged first label Sep 13, 2023
@gschorcht gschorcht added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Sep 15, 2023
@gschorcht
Copy link
Contributor Author

🤔 Merging failed because of asserts for unused variables, should be fixed now.

@benpicco
Copy link
Contributor

Please squash again!

For small changes you can always squash & force push directly, GitHub nowadays shows the changes between the force pushes as long as you are just rebasing within the branch and not onto e.g. master.

@benpicco benpicco added this pull request to the merge queue Dec 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 24, 2023
@gschorcht gschorcht force-pushed the cpu/esp32/periph/sdmmc branch from c0fdc91 to c345b81 Compare December 24, 2023 14:22
@benpicco benpicco added this pull request to the merge queue Dec 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 24, 2023
@gschorcht
Copy link
Contributor Author

🤔 I don't know why the compilation of tests/drivers/mtd_raw fails in CI for esp32-olimex-evb while it works for esp32-wrover-kit. It seems that the compilation with TEST_KCONFIG=1 is missing the tlsf module, but I can't reproduce it locally with command:

python3 dist/tools/compile_test/compile_like_murdock.py -a tests/drivers/mtd_raw -b  esp32-olimex-evb -j8

@benpicco
Copy link
Contributor

If you don't want to bother with resolving this, you can just wait for another week and it will resolve itself. (#20211)

Thank you for your work and Merry Christmas! 🎄

@gschorcht gschorcht added this pull request to the merge queue Dec 25, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 25, 2023
@benpicco benpicco removed this from the Release 2023.10 milestone Jan 2, 2024
@benpicco benpicco added this pull request to the merge queue Jan 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 3, 2024
#if defined(MODULE_MTD_NATIVE) || defined(MODULE_MTD_MCI)
fatfs.dev = mtd_dev_get(0);
#elif defined(MODULE_MTD_SDMMC)
fatfs.dev = mtd_sdmmc_dev0;
Copy link
Contributor

Choose a reason for hiding this comment

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

mtd_sdmmc_dev0 is not declared in this file

@gschorcht
Copy link
Contributor Author

@benpicco Have you ever been able to successfully run tests/pkg/fatfs or tests/pkg/fatfs_vfs with an SD card? The tests do not work for me, not even with sdcard_spi. In tests/pkg/fatfs, I can execute mount successfully, but when executing the commands touch or write, I get either the error

> touch test4.txt
[FAILED] (f_close error 1)
> 
> write test3.txt hello
writing 5 bytes to test3.txt ...[FAILED] (f_write error 1)

or the system hangs.

@gschorcht gschorcht force-pushed the cpu/esp32/periph/sdmmc branch from c345b81 to 60ab86b Compare January 7, 2024 16:15
@gschorcht
Copy link
Contributor Author

@benpicco Have you ever been able to successfully run tests/pkg/fatfs or tests/pkg/fatfs_vfs with an SD card? The tests do not work for me, not even with sdcard_spi. In tests/pkg/fatfs, I can execute mount successfully, but when executing the commands touch or write, I get either the error

> touch test4.txt
[FAILED] (f_close error 1)
> 
> write test3.txt hello
writing 5 bytes to test3.txt ...[FAILED] (f_write error 1)

or the system hangs.

@benpicco PR #20234 fixes the problem.

@benpicco benpicco added this pull request to the merge queue Jan 7, 2024
Merged via the queue into RIOT-OS:master with commit bbf5e23 Jan 7, 2024
25 checks passed
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.01 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants