esp-rs / esp-idf-hal

embedded-hal implementation for Rust on ESP32 and ESP-IDF
https://docs.esp-rs.org/esp-idf-hal/
Apache License 2.0
450 stars 168 forks source link

ESP32C3 unmapped GPIOs #8

Closed sehraf closed 2 years ago

sehraf commented 2 years ago

https://github.com/esp-rs/esp-idf-hal/blob/fb2c9f7657a302600494c44fc1c1073f62c49248/src/gpio.rs#L909..L924 Here the GPIOs 11-17 for the ESP32C3 are unmapped. Is this intentional?

sehraf commented 2 years ago

SPI0/1: GPIO12-17 are usually used for SPI flash and PSRAM and not recommended for other uses.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-reference/peripherals/gpio.html

jessebraham commented 2 years ago

I have some changes that I'll be PRing soon making a few small small corrections in the GPIO module. During my time digging through the various datasheets, I realized that all of the chips have a range of GPIO with the same recommendation made:

"The pins used for embedded flash are not recommended for other uses.".

I have listed the applicable pins below:

Chip GPIOs
ESP32 6 - 11, 16 - 17
ESP32-C3 12 - 17
ESP32-S2 26 - 32
ESP32-S3 26 - 32, 33 - 37*

* When using Octal Flash and/or Octal PSRAM

Presently these pins are unmapped when using the ESP32-C3, but for the remaining chips some or all of these pins are mapped. So my question is, do we want to:

  1. include all of these pins for every chip
  2. include none of these pins for for every chip
  3. include or exclude these pins on a per-chip basis

There also seem to be a number of unmapped GPIOs already for the ESP32, ESP32-S2, and ESP32-S3. I have not been able to find much information on why these are presently unmapped. Is there a specific reference which was used for these, or can they be added in as well?

ivmarkov commented 2 years ago

There also seem to be a number of unmapped GPIOs already for the ESP32, ESP32-S2, and ESP32-S3. I have not been able to find much information on why these are presently unmapped. Is there a specific reference which was used for these, or can they be added in as well?

I've just used a few sample boards as a reference without digging into the ESP32 data sheets

These pins were unmapped for that boards. I know realize, that specific boards may not map some pins also due to missing space etc.

Given that modeling specific board layouts is not realistic, we should just map all of these missing pins.

Now, regarding what to do with the pins used for flash, I guess either (1) or (2), but definitely not (3).

I have a preference for (1) because if somebody wants to use those, I guess we should allow that, despite the strings attached?

jessebraham commented 2 years ago

I've just used a few sample boards as a reference without digging into the ESP32 data sheets

These pins were unmapped for that boards. I know realize, that specific boards may not map some pins also due to missing space etc.

Given that modeling specific board layouts is not realistic, we should just map all of these missing pins.

Sounds good, I will add all pins covered in the Pin Description sections of each datasheet.

Now, regarding what to do with the pins used for flash, I guess either (1) or (2), but definitely not (3).

I have a preference for (1) because if somebody wants to use those, I guess we should allow that, despite the strings attached?

I tend to agree, I don't feel it's our responsibility to hold people's hands too much. Breaking rules is fun sometimes :)

I have added comments in the source indicating the recommendations, and will add a note in the README as well. At least we'll have mentioned it.