Skip to content

Commit 4ce47b0

Browse files
committed
Merge branch 'feature/master_build_c3_example' into 'master'
CI: enable example builds for C3 Closes IDF-2364 See merge request espressif/esp-idf!11968
2 parents 2c0962f + 04df1f3 commit 4ce47b0

File tree

47 files changed

+244
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+244
-93
lines changed

components/esp_wifi/esp32c3/esp_adapter.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,12 @@ static void IRAM_ATTR wifi_rtc_disable_iso_wrapper(void)
420420
#endif
421421
}
422422

423-
static void IRAM_ATTR wifi_clock_enable_wrapper(void)
423+
static void wifi_clock_enable_wrapper(void)
424424
{
425425
wifi_module_enable();
426426
}
427427

428-
static void IRAM_ATTR wifi_clock_disable_wrapper(void)
428+
static void wifi_clock_disable_wrapper(void)
429429
{
430430
wifi_module_disable();
431431
}

components/freemodbus/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
idf_build_get_property(target IDF_TARGET)
2-
if(${target} STREQUAL "esp32c3")
3-
return() # TODO ESP32-C3 IDF-2173
4-
endif()
52

63
# The following five lines of boilerplate have to be in your project's
74
# CMakeLists in this exact order for cmake to work correctly

components/freemodbus/port/port.h

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define PORT_COMMON_H_
1818

1919
#include "freertos/FreeRTOS.h"
20-
#include "freertos/xtensa_api.h"
2120
#include "esp_log.h" // for ESP_LOGE macro
2221
#include "mbconfig.h"
2322

components/freertos/port/riscv/include/freertos/portmacro.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern "C" {
3838
#include <stdbool.h>
3939
#include <stdio.h>
4040
#include <limits.h>
41+
#include "esp_timer.h" /* required for FreeRTOS run time stats */
4142

4243
#include "sdkconfig.h"
4344
#include "esp_attr.h"
@@ -270,7 +271,7 @@ static inline unsigned portENTER_CRITICAL_NESTED(void) {
270271

271272
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
272273
/* Coarse resolution time (us) */
273-
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do{(void)x; }while(0)
274+
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
274275
#endif
275276

276277
extern void esp_vApplicationIdleHook( void );

components/freertos/port/xtensa/include/freertos/portmacro.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static inline void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t comp
302302

303303
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
304304
/* Coarse resolution time (us) */
305-
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) x = (uint32_t)esp_timer_get_time()
305+
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
306306
#endif
307307

308308
void vPortYield( void );

components/hal/include/hal/spi_types.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ FLAG_ATTR(spi_event_t)
4949
#define SPI_HOST SPI1_HOST
5050
#define HSPI_HOST SPI2_HOST
5151
#define VSPI_HOST SPI3_HOST
52-
#else // !CONFIG_IDF_TARGET_ESP32
52+
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
5353
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later
5454
#define SPI_HOST SPI1_HOST
5555
#define FSPI_HOST SPI2_HOST
5656
#define HSPI_HOST SPI3_HOST
57+
#elif CONFIG_IDF_TARGET_ESP32C3
58+
/* No SPI3_host on C3 */
59+
#define SPI_HOST SPI1_HOST
60+
#define FSPI_HOST SPI2_HOST
61+
#define HSPI_HOST SPI2_HOST
5762
#endif
5863

5964
/** @endcond */

components/mbedtls/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,12 @@ set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls)
182182
target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_targets})
183183

184184
if(CONFIG_ESP_TLS_USE_DS_PERIPHERAL)
185-
# Link target (esp32s2) library to component library
186-
target_link_libraries(${COMPONENT_LIB} PUBLIC ${target})
185+
# Link target (e.g. esp32s2) library to component library
186+
idf_component_get_property(target_lib ${target} COMPONENT_LIB)
187+
set_property(TARGET mbedcrypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:${target_lib}>)
188+
# The linker seems to be unable to resolve all the dependencies without increasing this
189+
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 6)
190+
target_link_libraries(${COMPONENT_LIB} PUBLIC ${target_lib})
187191
endif()
188192

189193
# Link esp-cryptoauthlib to mbedtls

components/wpa_supplicant/src/common/bss.c

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "drivers/driver.h"
1515
#include "eap_peer/eap.h"
1616
#include "wpa_supplicant_i.h"
17-
#include "config.h"
1817
#include "scan.h"
1918
#include "bss.h"
2019
#ifdef ESP_SUPPLICANT

components/wpa_supplicant/src/common/scan.c

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "utils/common.h"
1212
#include "common/ieee802_11_defs.h"
13-
#include "config.h"
1413
#include "wpa_supplicant_i.h"
1514
#include "drivers/driver.h"
1615
#include "common/ieee802_11_common.h"

components/wpa_supplicant/src/esp_supplicant/esp_common.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static void esp_register_action_frame(struct wpa_supplicant *wpa_s)
194194
}
195195

196196
static void esp_supplicant_sta_conn_handler(void* arg, esp_event_base_t event_base,
197-
int event_id, void* event_data)
197+
int32_t event_id, void* event_data)
198198
{
199199
u8 bssid[ETH_ALEN];
200200
u8 *ie;
@@ -221,7 +221,7 @@ static void esp_supplicant_sta_conn_handler(void* arg, esp_event_base_t event_ba
221221
}
222222

223223
static void esp_supplicant_sta_disconn_handler(void* arg, esp_event_base_t event_base,
224-
int event_id, void* event_data)
224+
int32_t event_id, void* event_data)
225225
{
226226
struct wpa_supplicant *wpa_s = &g_wpa_supp;
227227
wpas_rrm_reset(wpa_s);

components/wpa_supplicant/src/esp_supplicant/esp_scan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
extern struct wpa_supplicant g_wpa_supp;
3434

3535
static void esp_scan_done_event_handler(void* arg, esp_event_base_t event_base,
36-
int event_id, void* event_data)
36+
int32_t event_id, void* event_data)
3737
{
3838
struct wpa_supplicant *wpa_s = &g_wpa_supp;
3939
if (!wpa_s->scanning) {

examples/ethernet/iperf/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ See common pin assignments for Ethernet examples from [upper level](../README.md
2323
### Software Tools Preparation
2424

2525
1. Install iperf tool on PC
26-
* Debian/Ubuntu: `sudo apt-get install iperf`
26+
* Debian/Ubuntu: `sudo apt-get install iperf`
2727
* macOS: `brew install iperf`(if using Homebrew) or `sudo port install iperf`(if using MacPorts)
2828
* Windows(MSYS2): Downloads binaries from [here]( https://iperf.fr/iperf-download.php#windows)
2929

examples/ethernet/iperf/main/ethernet_example_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void app_main(void)
5252
ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
5353

5454
/* Register commands */
55-
register_system();
55+
register_system_common();
5656
register_ethernet();
5757

5858
printf("\n =======================================================\n");

examples/peripherals/pcnt/pulse_count_event/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
| Supported Targets | ESP32 | ESP32-S2 |
2+
| ----------------- | ----- | -------- |
3+
14
# Pulse Count Event Example
25

36
(See the README.md file in the upper level 'examples' directory for more information about examples.)

examples/peripherals/pcnt/rotary_encoder/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
| Supported Targets | ESP32 | ESP32-S2 |
2+
| ----------------- | ----- | -------- |
3+
14
# Rotary Encoder Example
25

36
(See the README.md file in the upper level 'examples' directory for more information about examples.)
47

58
The PCNT peripheral is designed to count the number of rising and/or falling edges of an input signal. Each PCNT unit has two channels, which makes it possible to extract more information from two input signals than only one signal.
69
This example shows how to make use of the HW features to decode the differential signals generated from a common rotary encoder -- [EC11](https://tech.alpsalpine.com/prod/e/html/encoder/incremental/ec11/ec11_list.html).
710

8-
The signals a rotary encoder produces (and what can be handled by this example) are based on a 2-bit gray code available on 2 digital data signal lines. The typical encoders use 3 output pins: 2 for the signals and one for the common signal usually GND.
11+
The signals a rotary encoder produces (and what can be handled by this example) are based on a 2-bit gray code available on 2 digital data signal lines. The typical encoders use 3 output pins: 2 for the signals and one for the common signal usually GND.
912

1013
Typical signals:
1114

examples/peripherals/rmt/ir_protocols/main/ir_protocols_main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void example_ir_rx_task(void *arg)
2828
{
2929
uint32_t addr = 0;
3030
uint32_t cmd = 0;
31-
uint32_t length = 0;
31+
size_t length = 0;
3232
bool repeat = false;
3333
RingbufHandle_t rb = NULL;
3434
rmt_item32_t *items = NULL;
@@ -77,7 +77,7 @@ static void example_ir_tx_task(void *arg)
7777
uint32_t addr = 0x10;
7878
uint32_t cmd = 0x20;
7979
rmt_item32_t *items = NULL;
80-
uint32_t length = 0;
80+
size_t length = 0;
8181
ir_builder_t *ir_builder = NULL;
8282

8383
rmt_config_t rmt_tx_config = RMT_DEFAULT_CONFIG_TX(CONFIG_EXAMPLE_RMT_TX_GPIO, example_tx_channel);

examples/peripherals/spi_master/hd_eeprom/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
For different chip and host used, the connections may be different.
1010

11-
| | ESP32 | ESP32 | ESP32S2 |
12-
| ---- | ----- | ----- | ------- |
13-
| Host | SPI1 | HSPI | FSPI |
14-
| VCC | 3.3V | 3.3V | 3.3V |
15-
| GND | GND | GND | GND |
16-
| DO | 7 | 18 | 37 |
17-
| DI | 8 | 23 | 35 |
18-
| SK | 6 | 19 | 36 |
19-
| CS | 13 | 13 | 34 |
20-
| ORG | GND | GND | GND |
11+
| | ESP32 | ESP32 | ESP32S2 | ESP32C3 |
12+
| ---- | ----- | ----- | ------- | ------- |
13+
| Host | SPI1 | HSPI | FSPI | SPI2 |
14+
| VCC | 3.3V | 3.3V | 3.3V | 3.3V |
15+
| GND | GND | GND | GND | GND |
16+
| DO | 7 | 18 | 37 | 2 |
17+
| DI | 8 | 23 | 35 | 7 |
18+
| SK | 6 | 19 | 36 | 6 |
19+
| CS | 13 | 13 | 34 | 10 |
20+
| ORG | GND | GND | GND | GND |
2121

2222
### Notes
2323

examples/peripherals/spi_master/hd_eeprom/main/spi_eeprom_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
# define PIN_NUM_MOSI 35
4949
# define PIN_NUM_CLK 36
5050
# define PIN_NUM_CS 34
51+
#elif defined CONFIG_IDF_TARGET_ESP32C3
52+
# define EEPROM_HOST SPI2_HOST
53+
# define DMA_CHAN EEPROM_HOST
54+
55+
# define PIN_NUM_MISO 2
56+
# define PIN_NUM_MOSI 7
57+
# define PIN_NUM_CLK 6
58+
# define PIN_NUM_CS 10
5159
#endif
5260

5361
static const char TAG[] = "main";

examples/peripherals/spi_master/lcd/main/pretty_effect.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ static inline uint16_t get_bgnd_pixel(int x, int y)
2626
y+=8;
2727
return pixels[y][x];
2828
}
29-
#elif defined CONFIG_IDF_TARGET_ESP32S2
30-
//esp32s2 doesn't have enough memory to hold the decoded image, calculate instead
29+
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
30+
//esp32s2/c3 doesn't have enough memory to hold the decoded image, calculate instead
3131
static inline uint16_t get_bgnd_pixel(int x, int y)
3232
{
3333
return ((x<<3)^(y<<3)^(x*y));
@@ -69,8 +69,8 @@ esp_err_t pretty_effect_init(void)
6969
{
7070
#ifdef CONFIG_IDF_TARGET_ESP32
7171
return decode_image(&pixels);
72-
#elif defined CONFIG_IDF_TARGET_ESP32S2
73-
//esp32s2 doesn't have enough memory to hold the decoded image, calculate instead
72+
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
73+
//esp32s2/c3 doesn't have enough memory to hold the decoded image, calculate instead
7474
return ESP_OK;
7575
#endif
7676
}

examples/peripherals/spi_master/lcd/main/spi_master_example_main.c

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
#define PIN_NUM_DC 4
5353
#define PIN_NUM_RST 5
5454
#define PIN_NUM_BCKL 6
55+
#elif defined CONFIG_IDF_TARGET_ESP32C3
56+
#define LCD_HOST SPI2_HOST
57+
#define DMA_CHAN LCD_HOST
58+
59+
#define PIN_NUM_MISO 2
60+
#define PIN_NUM_MOSI 7
61+
#define PIN_NUM_CLK 6
62+
#define PIN_NUM_CS 10
63+
64+
#define PIN_NUM_DC 9
65+
#define PIN_NUM_RST 18
66+
#define PIN_NUM_BCKL 19
5567
#endif
5668

5769
//To speed up transfers, every SPI transfer sends a bunch of lines. This define specifies how many. More means more memory use,
+20-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
## SPI slave example
22

3-
These two projects illustrate the SPI Slave driver. They're supposed to be flashed into two separate ESP32s connected to eachother using the SPI pins defined in app_main.c. Once connected and flashed, they will use the spi master and spi slave driver to communicate with eachother. The example also includes a handshaking line to allow the master to only poll the slave when it is actually ready to parse a transaction.
3+
These two projects illustrate the SPI Slave driver. They're supposed to be flashed into two separate Espressif chips connected to eachother using the SPI pins defined in app_main.c. Once connected and flashed, they will use the spi master and spi slave driver to communicate with eachother. The example also includes a handshaking line to allow the master to only poll the slave when it is actually ready to parse a transaction.
4+
5+
The default GPIOs used in the example are the following:
6+
7+
| Signal | ESP32 | ESP32-S2 | ESP32-C3 |
8+
|-----------|--------|----------|----------|
9+
| Handshake | GPIO2 | GPIO2 | GPIO3 |
10+
| MOSI | GPIO12 | GPIO12 | GPIO7 |
11+
| MISO | GPIO13 | GPIO13 | GPIO2 |
12+
| SCLK | GPIO15 | GPIO15 | GPIO6 |
13+
| CS | GPIO14 | GPIO14 | GPIO10 |
14+
415

516
Please run wires between the following GPIOs between the slave and master to make the example function:
617

7-
| Signal | Slave | Master |
8-
|-----------|--------|--------|
9-
| Handshake | GPIO2 | GPIO2 |
10-
| MOSI | GPIO12 | GPIO12 |
11-
| MISO | GPIO13 | GPIO13 |
12-
| SCLK | GPIO15 | GPIO15 |
13-
| CS | GPIO14 | GPIO14 |
18+
| Slave | Master |
19+
|------------|-----------|
20+
| Handshake | Handshake |
21+
| MOSI | MOSI |
22+
| MISO | MISO |
23+
| SCLK | SCLK |
24+
| CS | CS |
1425

15-
Be aware that the example by default uses lines normally reserved for JTAG. If this is an issue, either because of hardwired JTAG hardware or because of the need to do JTAG debugging, feel free to change the GPIO settings by editing defines in the top of main.c in the master/slave source code.
26+
Be aware that the example by default uses lines normally reserved for JTAG on ESP32. If this is an issue, either because of hardwired JTAG hardware or because of the need to do JTAG debugging, feel free to change the GPIO settings by editing defines in the top of main.c in the master/slave source code.

examples/peripherals/spi_slave/receiver/main/app_main.c

+15
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,23 @@ sending a transaction. As soon as the transaction is done, the line gets set low
4949
/*
5050
Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed.
5151
*/
52+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
5253
#define GPIO_HANDSHAKE 2
5354
#define GPIO_MOSI 12
5455
#define GPIO_MISO 13
5556
#define GPIO_SCLK 15
5657
#define GPIO_CS 14
5758

59+
#elif CONFIG_IDF_TARGET_ESP32C3
60+
#define GPIO_HANDSHAKE 3
61+
#define GPIO_MOSI 7
62+
#define GPIO_MISO 2
63+
#define GPIO_SCLK 6
64+
#define GPIO_CS 10
65+
66+
#endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
67+
68+
5869
#ifdef CONFIG_IDF_TARGET_ESP32
5970
#define RCV_HOST HSPI_HOST
6071
#define DMA_CHAN 2
@@ -63,6 +74,10 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
6374
#define RCV_HOST SPI2_HOST
6475
#define DMA_CHAN RCV_HOST
6576

77+
#elif defined CONFIG_IDF_TARGET_ESP32C3
78+
#define RCV_HOST SPI2_HOST
79+
#define DMA_CHAN RCV_HOST
80+
6681
#endif
6782

6883

examples/peripherals/spi_slave/sender/main/app_main.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,23 @@ task waits for this semaphore to be given before queueing a transmission.
5050
/*
5151
Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed.
5252
*/
53+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
5354
#define GPIO_HANDSHAKE 2
5455
#define GPIO_MOSI 12
5556
#define GPIO_MISO 13
5657
#define GPIO_SCLK 15
5758
#define GPIO_CS 14
5859

60+
#elif CONFIG_IDF_TARGET_ESP32C3
61+
#define GPIO_HANDSHAKE 3
62+
#define GPIO_MOSI 7
63+
#define GPIO_MISO 2
64+
#define GPIO_SCLK 6
65+
#define GPIO_CS 10
66+
67+
#endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
68+
69+
5970
#ifdef CONFIG_IDF_TARGET_ESP32
6071
#define SENDER_HOST HSPI_HOST
6172
#define DMA_CHAN 2
@@ -64,6 +75,10 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
6475
#define SENDER_HOST SPI2_HOST
6576
#define DMA_CHAN SENDER_HOST
6677

78+
#elif defined CONFIG_IDF_TARGET_ESP32C3
79+
#define SENDER_HOST SPI2_HOST
80+
#define DMA_CHAN SENDER_HOST
81+
6782
#endif
6883

6984

@@ -78,7 +93,7 @@ static void IRAM_ATTR gpio_handshake_isr_handler(void* arg)
7893
//Sometimes due to interference or ringing or something, we get two irqs after eachother. This is solved by
7994
//looking at the time between interrupts and refusing any interrupt too close to another one.
8095
static uint32_t lasthandshaketime;
81-
uint32_t currtime=xthal_get_ccount();
96+
uint32_t currtime=esp_cpu_get_ccount();
8297
uint32_t diff=currtime-lasthandshaketime;
8398
if (diff<240000) return; //ignore everything <1ms after an earlier irq
8499
lasthandshaketime=currtime;

0 commit comments

Comments
 (0)