Skip to content

Commit

Permalink
Merge #19561 #19563
Browse files Browse the repository at this point in the history
19561: cpu/esp32: fix compilation issues with GCC 12.2 [backport 2023.04] r=maribu a=kaspar030

# Backport of #19450

### Contribution description

This PR provides the changes in `cpu/esp32` and `cpu/esp_common` to fix the compilation issues with GCC v12.2.  It is required as the first step in the preparation of the upgrade to ESP-IDF version 5.1.

**Please note**: Insead of fixing the ESP-IDF 4.4 code itself by a big bunch of patches to fix the compilation problems with GCC v12.2, it temporarily disables some warnings. The reason is that the ESP-IDF 5.1 requires GCC v12.2 and should be fixed for this compiler version by the vendor.

### Testing procedure

Green CI

The change were already tested with all ESP-specific modules like `esp_now`, `esp_wifi`, `esp_spi`  and `esp_ble` for all supported ESP platforms.

### Issues/PRs references

Prerequisite for RIOT-OS/riotdocker#227
Fixes issue #19421

19563: treewide: fix typos and false positives found by codespell [backport 2023.04] r=maribu a=MrKevinWeiss

# Backport of #19528

### Contribution description

This fixes some typos and adds one correctly used abbreviation to the ignore list.



Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
  • Loading branch information
3 people authored May 10, 2023
3 parents f10a5b4 + fcd8e8e + a3e77f6 commit 89fc055
Show file tree
Hide file tree
Showing 49 changed files with 366 additions and 89 deletions.
2 changes: 1 addition & 1 deletion boards/e180-zg120b-tb/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ peripherals, different energy modes and short wake-up times.
| HWCRYPTO | &mdash; | &mdash; | | AES128/AES256, SHA1, SHA256 |
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | USART0 | RX: PA1, TX: PA0 | Default STDIO output |

Expand Down
2 changes: 1 addition & 1 deletion boards/ikea-tradfri/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Pin 1 is on the top-left side with only 6 contacts.
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PD15, MISO: PD14, CLK: PD13 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | USART0 | RX: PB15, TX: PB14 | Default STDIO output |
| | 1 | LEUART0 | RX: PB15, TX: PB14 | Baud rate limited (see below) |
Expand Down
2 changes: 1 addition & 1 deletion boards/slstk3400a/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| SPI | 0 | USART0 | MOSI: PE10, MISO: PE11, CLK: PE12 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| UART | 0 | USART1 | RX: PA0, TX: PF2 | Default STDIO output |
| | 1 | LEUART0 | RX: PD5, TX: PD4 | Baud rate limited (see below) |

Expand Down
2 changes: 1 addition & 1 deletion boards/slstk3401a/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PC6, MISO: PC7, CLK: PC8 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | USART0 | RX: PA1, TX: PA0 | Default STDIO output |
| | 1 | LEUART0 | RX: PD11, TX: PD10 | Baud rate limited (see below) |
Expand Down
4 changes: 2 additions & 2 deletions boards/slstk3402a/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PC6, MISO: PC7, CLK: PC8 | |
| Timer | 0 | WTIMER0 + WTIMER1 | | WTIMER0 is used as prescaler (must be adjecent) |
| Timer | 1 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | WTIMER0 + WTIMER1 | | WTIMER0 is used as prescaler (must be adjacent) |
| Timer | 1 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 2 | LETIMER0 | | |
| UART | 0 | USART0 | RX: PA1, TX: PA0 | Default STDIO output |
| | 1 | LEUART0 | RX: PD11, TX: PD10 | Baud rate limited (see below) |
Expand Down
2 changes: 1 addition & 1 deletion boards/sltb001a/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ is the top-left contact, marked on the silkscreen.
| RTT | &mdash; | RTCC | | 1 Hz interval. Either RTT or RTC (see below) |
| RTC | &mdash; | RTCC | | 1 Hz interval. Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PC6, MISO: PC7, CLK: PC8 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | USART0 | RX: PA1, TX: PA0 | Default STDIO output |
| | 1 | LEUART0 | RX: PD11, TX: PD10 | Baud rate limited (see below) |
Expand Down
2 changes: 1 addition & 1 deletion boards/slwstk6220a/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTT | &mdash; | RTC | | Either RTT or RTC (see below) |
| RTC | &mdash; | RTC | | Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PD0, MISO: PD1, CLK: PD2 | |
| Timer | 0 | TIMER1 + TIMER2 | | TIMER1 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER1 + TIMER2 | | TIMER1 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | UART0 | RX: PE1, TX: PE0 | STDIO output |
| | 1 | LEUART0 | RX: PD5, TX: PD4 | Baud rate limited (see below) |
Expand Down
2 changes: 1 addition & 1 deletion boards/stk3200/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTT | &mdash; | RTC | | Either RTT or RTC (see below) |
| RTC | &mdash; | RTC | | Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PD7, MISO: PD6, CLK: PC15 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| UART | 0 | LEUART0 | RX: PD5, TX: PD4 | STDIO Output, Baud rate limited (see below) |

### User interface
Expand Down
2 changes: 1 addition & 1 deletion boards/stk3600/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTC | &mdash; | RTC | | Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PD0, MISO: PD1, CLK: PD2 | |
| | 1 | USART2 | MOSI: NC, MISO: PC3, CLK: PC4 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | UART0 | RX: PE1, TX: PE0 | STDIO output |
| | 1 | LEUART0 | RX: PD5, TX: PD4 | Baud rate limited (see below) |
Expand Down
2 changes: 1 addition & 1 deletion boards/stk3700/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PIN 1 is the bottom-left contact when the header faces you horizontally.
| RTC | &mdash; | RTC | | Either RTC or RTT (see below) |
| SPI | 0 | USART1 | MOSI: PD0, MISO: PD1, CLK: PD2 | |
| | 1 | USART2 | MOSI: NC, MISO: PC3, CLK: PC4 | |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjecent) |
| Timer | 0 | TIMER0 + TIMER1 | | TIMER0 is used as prescaler (must be adjacent) |
| | 1 | LETIMER0 | | |
| UART | 0 | UART0 | RX: PE1, TX: PE0 | STDIO output |
| | 1 | LEUART0 | RX: PD5, TX: PD4 | Baud rate limited (see below) |
Expand Down
13 changes: 13 additions & 0 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ CFLAGS += -D_CONST=const
# TODO no relaxation yet
ifneq (,$(filter riscv%,$(TARGET_ARCH)))
CFLAGS += -mno-relax -march=rv32imc -mabi=ilp32 -DRISCV_NO_RELAX
GCC_NEW_RISCV_ISA ?= $(shell echo "typedef int dont_be_pedantic;" | \
$(TARGET_ARCH)-gcc -march=rv32imac -mabi=ilp32 \
-misa-spec=2.2 -E - > /dev/null 2>&1 && \
echo 1 || echo 0)
ifeq (1,$(GCC_NEW_RISCV_ISA))
CFLAGS += -misa-spec=2.2
endif
endif

ifneq (,$(filter xtensa%,$(TARGET_ARCH)))
Expand Down Expand Up @@ -243,6 +250,12 @@ endif

LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections

# all ESP32x SoCs have to load executable code into IRAM
# warning 'LOAD segment with RWX permissions' has to be disabled therefore
ifeq (1,$(GCC_NEW_RISCV_ISA))
LINKFLAGS += -Wl,--no-warn-rwx-segments
endif

# Libraries needed when using esp_wifi_any pseudomodule
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
LINKFLAGS += -L$(ESP32_SDK_LIB_WIFI_DIR)/$(CPU_FAM)
Expand Down
11 changes: 11 additions & 0 deletions cpu/esp32/bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,24 @@ INCLUDES = \
# CONFIG_ESPTOOLPY_FLASHFREQ_* and CONFIG_FLASHMODE_*
CFLAGS = -include '$(RIOTBUILD_CONFIG_HEADER_C)' \

# TODO: required to be able to compile with GCC 12.1, remove them after upgrade to ESP-IDF 5.1
CFLAGS += -Wno-error=format=
CFLAGS += -Wno-format

ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/riscv/include
CFLAGS += -DCONFIG_IDF_TARGET_ARCH_RISCV
CFLAGS += -march=rv32imc
CFLAGS += -Wno-error=format=
CFLAGS += -nostartfiles
CFLAGS += -Wno-format
GCC_NEW_RISCV_ISA ?= $(shell echo "typedef int dont_be_pedantic;" | \
$(TARGET_ARCH)-gcc -march=rv32imac -mabi=ilp32 \
-misa-spec=2.2 -E - > /dev/null 2>&1 && \
echo 1 || echo 0)
ifeq (1,$(GCC_NEW_RISCV_ISA))
CFLAGS += -misa-spec=2.2
endif
endif

ifneq (,$(filter xtensa%,$(TARGET_ARCH)))
Expand Down
15 changes: 15 additions & 0 deletions cpu/esp32/esp-idf/esp_idf_cflags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ CFLAGS += -Wno-enum-compare
# those are false positives.
CFLAGS += -Wno-cast-align

# TODO: required to be able to compile with GCC 12.1, remove them after upgrade to ESP-IDF 5.1
CFLAGS += -Wno-attributes
CFLAGS += -Wno-enum-conversion
CFLAGS += -Wno-error=format=
CFLAGS += -Wno-format
CFLAGS += -Wno-use-after-free
CFLAGS += -Wno-incompatible-pointer-types

# additional CFLAGS required for RISC-V architecture
ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/riscv/include
Expand All @@ -42,4 +50,11 @@ ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
CFLAGS += -Wno-error=format=
CFLAGS += -nostartfiles
CFLAGS += -Wno-format
GCC_NEW_RISCV_ISA ?= $(shell echo "typedef int dont_be_pedantic;" | \
$(TARGET_ARCH)-gcc -march=rv32imac -mabi=ilp32 \
-misa-spec=2.2 -E - > /dev/null 2>&1 && \
echo 1 || echo 0)
ifeq (1,$(GCC_NEW_RISCV_ISA))
CFLAGS += -misa-spec=2.2
endif
endif
2 changes: 1 addition & 1 deletion cpu/esp32/esp-idf/esp_idf_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void IRAM_ATTR esp_log_writev(esp_log_level_t level,
* We use the log level set for the given tag instead of using
* the given log level.
*/
esp_log_level_t act_level = LOG_DEBUG;
esp_log_level_t act_level = (esp_log_level_t)LOG_DEBUG;
size_t i;
for (i = 0; i < ARRAY_SIZE(_log_levels); i++) {
if (strcmp(tag, _log_levels[i].tag) == 0) {
Expand Down
4 changes: 4 additions & 0 deletions cpu/esp32/esp-idf/nvs_flash/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ include ../esp_idf.mk
# those are false positives.
CFLAGS += -Wno-cast-align

# TODO: required to be able to compile with GCC 12.1, remove them after upgrade to ESP-IDF 5.1
CFLAGS += -Wno-error=format=
CFLAGS += -Wno-format

# additional CFLAGS required for RISC-V architecture
ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
CFLAGS += -Wno-error=format=
Expand Down
10 changes: 0 additions & 10 deletions cpu/esp32/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,6 @@ typedef enum {
#define GPIO_DRIVE_20 GPIO_DRIVE_STRONG /**< 20 mA (default) */
#define GPIO_DRIVE_30 GPIO_DRIVE_STRONGEST /**< 30 mA */

#define HAVE_GPIO_IRQ_TRIG_T
typedef enum {
GPIO_TRIGGER_NONE = 0,
GPIO_TRIGGER_EDGE_RISING = 1,
GPIO_TRIGGER_EDGE_FALLING = 2,
GPIO_TRIGGER_EDGE_BOTH = 3,
GPIO_TRIGGER_LEVEL_LOW = 4,
GPIO_TRIGGER_LEVEL_HIGH = 5
} gpio_irq_trig_t;

/* END: GPIO LL overwrites */

#endif /* ndef DOXYGEN */
Expand Down
26 changes: 20 additions & 6 deletions cpu/esp32/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,22 @@ int adc_init(adc_t line)
}

if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_1) {
/* ensure compatibility of given adc_channel_t with adc1_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC1_CHANNEL_MAX);
/* initialize the ADC1 unit if needed */
_adc1_ctrl_init();
/* set the attenuation and configure its associated GPIO pin mux */
adc1_config_channel_atten(_adc_hw[rtcio].adc_channel, ADC_ATTEN_DB_11);
adc1_config_channel_atten((adc1_channel_t)_adc_hw[rtcio].adc_channel,
ADC_ATTEN_DB_11);
}
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
/* ensure compatibility of given adc_channel_t with adc2_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC2_CHANNEL_MAX);
/* initialize the ADC2 unit if needed */
_adc2_ctrl_init();
/* set the attenuation and configure its associated GPIO pin mux */
adc2_config_channel_atten(_adc_hw[rtcio].adc_channel, ADC_ATTEN_DB_11);
adc2_config_channel_atten((adc2_channel_t)_adc_hw[rtcio].adc_channel,
ADC_ATTEN_DB_11);
}
else {
return -1;
Expand All @@ -165,13 +171,17 @@ int32_t adc_sample(adc_t line, adc_res_t res)

if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_1) {
adc1_config_width(_adc_esp_res_map[res].res);
raw = adc1_get_raw(_adc_hw[rtcio].adc_channel);
/* ensure compatibility of given adc_channel_t with adc1_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC1_CHANNEL_MAX);
raw = adc1_get_raw((adc1_channel_t)_adc_hw[rtcio].adc_channel);
if (raw < 0) {
return -1;
}
}
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
if (adc2_get_raw(_adc_hw[rtcio].adc_channel,
/* ensure compatibility of given adc_channel_t with adc2_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC2_CHANNEL_MAX);
if (adc2_get_raw((adc2_channel_t)_adc_hw[rtcio].adc_channel,
_adc_esp_res_map[res].res, &raw) < 0) {
return -1;
}
Expand All @@ -189,10 +199,14 @@ int adc_set_attenuation(adc_t line, adc_atten_t atten)
assert(rtcio != RTCIO_NA);

if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_1) {
return adc1_config_channel_atten(_adc_hw[rtcio].adc_channel, atten);
/* ensure compatibility of given adc_channel_t with adc1_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC1_CHANNEL_MAX);
return adc1_config_channel_atten((adc1_channel_t)_adc_hw[rtcio].adc_channel, atten);
}
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
return adc2_config_channel_atten(_adc_hw[rtcio].adc_channel, atten);
/* ensure compatibility of given adc_channel_t with adc2_channel_t */
assert(_adc_hw[rtcio].adc_channel < (adc_channel_t)ADC2_CHANNEL_MAX);
return adc2_config_channel_atten((adc2_channel_t)_adc_hw[rtcio].adc_channel, atten);
}

return -1;
Expand Down
4 changes: 2 additions & 2 deletions cpu/esp32/periph/flashpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void IRAM_ATTR esp_flashpage_init(void)
p_addr, 64, p_numof, 0);
Cache_Resume_ICache(autoload);

DEBUG("%s DCache MMU set paddr=%08x vaddr=%08x size=%d n=%u\n", __func__,
p_addr, (uint32_t)&_fp_mem_start, CONFIG_ESP_FLASHPAGE_CAPACITY,
DEBUG("%s DCache MMU set paddr=%08"PRIx32" vaddr=%08"PRIx32" size=%d n=%"PRIu32"\n",
__func__, p_addr, (uint32_t)&_fp_mem_start, CONFIG_ESP_FLASHPAGE_CAPACITY,
p_numof);

if (res != ESP_OK) {
Expand Down
4 changes: 2 additions & 2 deletions cpu/esp32/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ int gpio_init(gpio_t pin, gpio_mode_t mode)
(mode == GPIO_OD_PU) ||
(mode == GPIO_IN_OD_PU)) ? GPIO_PULLUP_ENABLE
: GPIO_PULLUP_DISABLE;
cfg.pull_down_en = (mode == GPIO_IN_PD) ? GPIO_PULLUP_ENABLE
: GPIO_PULLUP_DISABLE;
cfg.pull_down_en = (mode == GPIO_IN_PD) ? GPIO_PULLDOWN_ENABLE
: GPIO_PULLDOWN_DISABLE;
cfg.intr_type = GPIO_INTR_DISABLE;

#ifdef ESP_PM_WUP_PINS
Expand Down
Loading

0 comments on commit 89fc055

Please sign in to comment.