-
Notifications
You must be signed in to change notification settings - Fork 2k
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: add support for ESP32-S2 #18506
cpu/esp32: add support for ESP32-S2 #18506
Conversation
* ESP32-S2 has two timer groups with two timers each, resulting in a total of | ||
* four timers. Since one timer is used as system timer, up to three timers | ||
* with one channel each can be used in RIOT as timer devices | ||
* TIMER_DEV(0) ... TIMER_DEV(2). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't TIMER_NUMOF
be 3 then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the hardware counter implementation for periph/timer
is used (MODULE_ESP_HW_COUNTER
is defined), there are three timer devices, but the third timer device uses a high-level interrupt that cannot be disabled. Therefore, the number of timer devices is limited to two, so only TIMER_DEV(0)
and TIMER_DEV(1)
can be used.
In case of the hardware timer implementation for periph/timer
(MODULE_ESP_HW_COUNTER
is not defined), the number of timers TIMER_NUMOF
is derived from SOC_TIMER_GROUP_TOTAL_TIMERS
here
RIOT/cpu/esp32/include/periph_cpu.h
Line 659 in c908a60
#define TIMER_NUMOF (SOC_TIMER_GROUP_TOTAL_TIMERS - 1) |
Awesome, works like a charm! Whitespace gets added to the variable --- a/cpu/esp32/bootloader/Makefile
+++ b/cpu/esp32/bootloader/Makefile
@@ -321,7 +321,8 @@ ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool_v3.2.py
# require to export these values.
FLASH_MODE ?= dio # ESP-IDF uses dio as default flash mode for the bootloader
FLASH_FREQ ?= 40m # lowest frequency all ESP32x SoC support
-FLASH_SIZE ?= 2 # smallesrt size all ESP32x SoC support
+# smallesrt size all ESP32x SoC support
+FLASH_SIZE ?= 2 otherwise I get
--- a/cpu/esp_common/esp-xtensa/thread_arch.c
+++ b/cpu/esp_common/esp-xtensa/thread_arch.c
@@ -286,7 +286,7 @@ void IRAM_ATTR thread_yield_higher(void)
ets_soft_int_type = ETS_SOFT_INT_YIELD;
WSR(BIT(ETS_SOFT_INUM), interrupt);
critical_exit();
-#elif defined(CPU_FAM_ESP32)
+#elif defined(DPORT_CPU_INTR_FROM_CPU_0_REG)
/* generate the software interrupt to switch the context */
DPORT_WRITE_PERI_REG(DPORT_CPU_INTR_FROM_CPU_0_REG, DPORT_CPU_INTR_FROM_CPU_0);
#else |
Strange, this isn't a change made in this PR and I didn't test it after rebasing. It isn't a problem for the other ESP32x SoCs, probably because Maybe, it would be better to define the |
Hm, the default size |
Yea I don't know who thought it was a great idea that whitespace before a comment should be added to a variable, but we also had this problem with pkts recently: #18494 |
Even if we can fix the problem for this variable in some way, the question remains why the default definition of |
But isn't the problem that only ESP32-S2 uses the default definition of |
I don't understand why the default definition in RIOT/cpu/esp32/Makefile.include Lines 16 to 19 in 5b6dff0
|
Ah I found the reason why --- a/cpu/esp32/Makefile.include
+++ b/cpu/esp32/Makefile.include
@@ -14,9 +14,9 @@ else ifneq (,$(filter esp32c3 esp32s3,$(CPU_FAM)))
export FLASH_SIZE ?= 2
BOOTLOADER_POS = 0x0000
else ifneq (,$(filter esp32s2,$(CPU_FAM)))
- FLASH_MODE ?= qio
- FLASH_FREQ ?= 80m
- FLASH_SIZE ?= 4
+ export FLASH_MODE ?= qio
+ export FLASH_FREQ ?= 80m
+ export FLASH_SIZE ?= 4
BOOTLOADER_POS = 0x1000
else
$(error Unkwnown ESP32x SoC variant (family)) |
68bbb63
to
1ece3d7
Compare
I looked at it 100 times and still missed this 😟 |
I had to rebase to fix it. |
I still need this patch for it to compile --- a/cpu/esp_common/esp-xtensa/thread_arch.c
+++ b/cpu/esp_common/esp-xtensa/thread_arch.c
@@ -286,7 +286,7 @@ void IRAM_ATTR thread_yield_higher(void)
ets_soft_int_type = ETS_SOFT_INT_YIELD;
WSR(BIT(ETS_SOFT_INUM), interrupt);
critical_exit();
-#elif defined(CPU_FAM_ESP32)
+#elif defined(DPORT_CPU_INTR_FROM_CPU_0_REG)
/* generate the software interrupt to switch the context */
DPORT_WRITE_PERI_REG(DPORT_CPU_INTR_FROM_CPU_0_REG, DPORT_CPU_INTR_FROM_CPU_0);
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash
Hm, |
Sorry, this is one of the many quirks of the make based dependency resolution. It doesn't matter if the variable is "official", if one iteration sets a value that the next doesn't understand, the dep resolution fails. |
b6599c3
to
34acec2
Compare
Now there is only a KConfig mismatch left for this to be merged 😃 |
Hm, when I test it with
all provided features are the same as without |
To get FLASH_* settings visible in cpu/esp32/bootloader/Makefile, they have to be exported in cpu/esp32/Makefile.include
34acec2
to
18cf35b
Compare
@benpicco I squashed the fix suggested by @MrKevinWeiss directly into commit 1862d4e. I added a new commit 18cf35b to fix the default |
I fixed it for ESP32-S2 and ESP32-S3 instead of opening a separate PR for this very small change, even though this PR is not related to ESP32-S3. |
@benpicco Thanks for reviewing and merging. |
The next big challenge will be to upgrade ESP-IDF to version 5.0, which includes a lot of changes, also in the APIs. ESP-IDF 5.0 is required to support ESP32-C2 and ESP32-H2. |
@kaspar030 @MrKevinWeiss thanks for your ideas to solve the last remaining compile problems. |
Contribution description
This PR is a split-off from PR #18235, which provides
This PR requires PRs #18502, #18503, #18504, #18505 and #18509 to be compilable in CI.
Testing procedure
Beside of Green CI some basic tests should work (Of course, I have already tested all of them and many more):
tests/shell
tests/periph_cpuid
tests/periph_gpio
tests/periph_hwrng
tests/periph_i2c
tests/periph_spi
tests/periph_rtt
tests/periph_timer
examples/gnrc_networking
usingesp_wifi
as optional module.Issues/PRs references
Depends on #18502
Depends on #18503
Depends on #18504
Depends on #18505
Depends on #18509