Skip to content

Commit 2917651

Browse files
committed
esp_rom: extract common ets apis into esp_rom_sys.h
1 parent 35007bd commit 2917651

File tree

140 files changed

+490
-410
lines changed

Some content is hidden

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

140 files changed

+490
-410
lines changed

components/app_trace/app_trace.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
#include "soc/timer_periph.h"
167167
#include "freertos/FreeRTOS.h"
168168
#include "esp_app_trace.h"
169+
#include "esp_rom_sys.h"
169170

170171
#if CONFIG_APPTRACE_ENABLE
171172
#define ESP_APPTRACE_MAX_VPRINTF_ARGS 256
@@ -180,13 +181,13 @@ const static char *TAG = "esp_apptrace";
180181
#define ESP_APPTRACE_LOG( format, ... ) \
181182
do { \
182183
esp_apptrace_log_lock(); \
183-
ets_printf(format, ##__VA_ARGS__); \
184+
esp_rom_printf(format, ##__VA_ARGS__); \
184185
esp_apptrace_log_unlock(); \
185186
} while(0)
186187
#else
187188
#define ESP_APPTRACE_LOG( format, ... ) \
188189
do { \
189-
ets_printf(format, ##__VA_ARGS__); \
190+
esp_rom_printf(format, ##__VA_ARGS__); \
190191
} while(0)
191192
#endif
192193

components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,17 @@ File : SEGGER_SYSVIEW_Config_FreeRTOS.c
6161
Purpose : Sample setup configuration of SystemView with FreeRTOS.
6262
Revision: $Rev: 3734 $
6363
*/
64+
#include "sdkconfig.h"
6465
#include "freertos/FreeRTOS.h"
6566
#include "SEGGER_SYSVIEW.h"
66-
#if CONFIG_IDF_TARGET_ESP32
67-
#include "esp32/rom/ets_sys.h"
68-
#include "esp32/clk.h"
69-
#elif CONFIG_IDF_TARGET_ESP32S2
70-
#include "esp32s2/rom/ets_sys.h"
71-
#include "esp32s2/clk.h"
72-
#endif
7367
#include "esp_app_trace.h"
7468
#include "esp_app_trace_util.h"
7569
#include "esp_intr_alloc.h"
7670
#include "soc/soc.h"
7771
#include "soc/interrupts.h"
7872
#if CONFIG_IDF_TARGET_ESP32
79-
#include "esp32/rom/ets_sys.h"
8073
#include "esp32/clk.h"
8174
#elif CONFIG_IDF_TARGET_ESP32S2
82-
#include "esp32s2/rom/ets_sys.h"
8375
#include "esp32s2/clk.h"
8476
#endif
8577

components/app_trace/sys_view/esp32/SEGGER_RTT_esp32.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@
1818
#include "SEGGER_SYSVIEW.h"
1919
#include "SEGGER_SYSVIEW_Conf.h"
2020

21-
#if CONFIG_IDF_TARGET_ESP32
22-
#include "esp32/rom/ets_sys.h"
23-
#elif CONFIG_IDF_TARGET_ESP32S2
24-
#include "esp32s2/rom/ets_sys.h"
25-
#endif
2621
#include "esp_app_trace.h"
27-
2822
#include "esp_log.h"
23+
2924
const static char *TAG = "segger_rtt";
3025

3126
#define SYSVIEW_EVENTS_BUF_SZ 255U

components/app_trace/test/test_trace.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <stdarg.h>
66
#include "unity.h"
77
#include "driver/timer.h"
8+
#include "esp_rom_sys.h"
89
#include "soc/cpu.h"
910
#include "freertos/FreeRTOS.h"
1011
#include "freertos/semphr.h"
@@ -31,7 +32,7 @@ const static char *TAG = "esp_apptrace_test";
3132
else \
3233
ret = xSemaphoreTake(s_print_lock, portMAX_DELAY); \
3334
if (ret == pdTRUE) { \
34-
ets_printf(format, ##__VA_ARGS__); \
35+
esp_rom_printf(format, ##__VA_ARGS__); \
3536
if (xPortInIsrContext()) \
3637
xSemaphoreGiveFromISR(s_print_lock, NULL); \
3738
else \
@@ -41,7 +42,7 @@ const static char *TAG = "esp_apptrace_test";
4142
#else
4243
#define ESP_APPTRACE_TEST_LOG( format, ... ) \
4344
do { \
44-
ets_printf(format, ##__VA_ARGS__); \
45+
esp_rom_printf(format, ##__VA_ARGS__); \
4546
} while(0)
4647
#endif
4748

@@ -138,7 +139,7 @@ static void esp_apptrace_test_timer_isr(void *arg)
138139
if (res != ESP_OK) {
139140
} else {
140141
if (0) {
141-
ets_printf("tim-%d-%d: Written chunk%d %d bytes, %x\n",
142+
esp_rom_printf("tim-%d-%d: Written chunk%d %d bytes, %x\n",
142143
tim_arg->group, tim_arg->id, tim_arg->data.wr_cnt, tim_arg->data.buf_sz, tim_arg->data.wr_cnt & tim_arg->data.mask);
143144
}
144145
tim_arg->data.wr_err = 0;
@@ -161,9 +162,9 @@ static void esp_apptrace_test_timer_isr_crash(void *arg)
161162
memset(tim_arg->data.buf + 2 * sizeof(uint32_t), tim_arg->data.wr_cnt & tim_arg->data.mask, tim_arg->data.buf_sz - 2 * sizeof(uint32_t));
162163
int res = ESP_APPTRACE_TEST_WRITE_FROM_ISR(tim_arg->data.buf, tim_arg->data.buf_sz);
163164
if (res != ESP_OK) {
164-
ets_printf("tim-%d-%d: Failed to write trace %d %x!\n", tim_arg->group, tim_arg->id, res, tim_arg->data.wr_cnt & tim_arg->data.mask);
165+
esp_rom_printf("tim-%d-%d: Failed to write trace %d %x!\n", tim_arg->group, tim_arg->id, res, tim_arg->data.wr_cnt & tim_arg->data.mask);
165166
} else {
166-
ets_printf("tim-%d-%d: Written chunk%d %d bytes, %x\n",
167+
esp_rom_printf("tim-%d-%d: Written chunk%d %d bytes, %x\n",
167168
tim_arg->group, tim_arg->id, tim_arg->data.wr_cnt, tim_arg->data.buf_sz, tim_arg->data.wr_cnt & tim_arg->data.mask);
168169
tim_arg->data.wr_cnt++;
169170
}
@@ -404,7 +405,7 @@ static void esp_apptrace_test(esp_apptrace_test_cfg_t *test_cfg)
404405
#if ESP_APPTRACE_TEST_USE_PRINT_LOCK == 1
405406
s_print_lock = xSemaphoreCreateBinary();
406407
if (!s_print_lock) {
407-
ets_printf("%s: Failed to create print lock!", TAG);
408+
esp_rom_printf("%s: Failed to create print lock!", TAG);
408409
return;
409410
}
410411
xSemaphoreGive(s_print_lock);

components/bootloader_support/src/bootloader_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include "esp32/rom/spi_flash.h"
2222
#elif CONFIG_IDF_TARGET_ESP32S2
2323
#include "esp32s2/rom/spi_flash.h"
24-
#include "esp32s2/rom/ets_sys.h"
2524
#endif
2625
#include "esp_rom_crc.h"
2726
#include "esp_rom_gpio.h"
27+
#include "esp_rom_sys.h"
2828
#include "esp_flash_partitions.h"
2929
#include "bootloader_flash.h"
3030
#include "bootloader_common.h"
@@ -259,7 +259,7 @@ void bootloader_common_vddsdio_configure(void)
259259
cfg.drefl = 3;
260260
cfg.force = 1;
261261
rtc_vddsdio_set_config(cfg);
262-
ets_delay_us(10); // wait for regulator to become stable
262+
esp_rom_delay_us(10); // wait for regulator to become stable
263263
}
264264
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
265265
}

components/bootloader_support/src/bootloader_console.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,19 @@
2121
#include "soc/gpio_sig_map.h"
2222
#include "soc/rtc.h"
2323
#include "hal/clk_gate_ll.h"
24-
#ifdef CONFIG_IDF_TARGET_ESP32
25-
#include "esp32/rom/ets_sys.h"
26-
#elif CONFIG_IDF_TARGET_ESP32S2
27-
#include "esp32s2/rom/ets_sys.h"
24+
#if CONFIG_IDF_TARGET_ESP32S2
2825
#include "esp32s2/rom/usb/cdc_acm.h"
2926
#include "esp32s2/rom/usb/usb_common.h"
3027
#endif
3128
#include "esp_rom_gpio.h"
3229
#include "esp_rom_uart.h"
30+
#include "esp_rom_sys.h"
3331

3432
#ifdef CONFIG_ESP_CONSOLE_UART_NONE
3533
void bootloader_console_init(void)
3634
{
37-
ets_install_putc1(NULL);
38-
ets_install_putc2(NULL);
35+
esp_rom_install_channel_putc(1, NULL);
36+
esp_rom_install_channel_putc(2, NULL);
3937
}
4038
#endif // CONFIG_ESP_CONSOLE_UART_NONE
4139

@@ -44,7 +42,7 @@ void bootloader_console_init(void)
4442
{
4543
const int uart_num = CONFIG_ESP_CONSOLE_UART_NUM;
4644

47-
ets_install_uart_printf();
45+
esp_rom_install_channel_putc(1, esp_rom_uart_putc);
4846

4947
// Wait for UART FIFO to be empty.
5048
esp_rom_uart_tx_wait_idle(0);
@@ -53,8 +51,7 @@ void bootloader_console_init(void)
5351
// Some constants to make the following code less upper-case
5452
const int uart_tx_gpio = CONFIG_ESP_CONSOLE_UART_TX_GPIO;
5553
const int uart_rx_gpio = CONFIG_ESP_CONSOLE_UART_RX_GPIO;
56-
// Switch to the new UART (this just changes UART number used for
57-
// ets_printf in ROM code).
54+
// Switch to the new UART (this just changes UART number used for esp_rom_printf in ROM code).
5855
esp_rom_uart_set_as_console(uart_num);
5956
// If console is attached to UART1 or if non-default pins are used,
6057
// need to reconfigure pins using GPIO matrix
@@ -96,6 +93,6 @@ void bootloader_console_init(void)
9693

9794
esp_rom_uart_usb_acm_init(s_usb_cdc_buf, sizeof(s_usb_cdc_buf));
9895
esp_rom_uart_set_as_console(ESP_ROM_UART_USB);
99-
ets_install_putc1(bootloader_console_write_char_usb);
96+
esp_rom_install_channel_putc(1, bootloader_console_write_char_usb);
10097
}
10198
#endif //CONFIG_ESP_CONSOLE_USB_CDC

components/bootloader_support/src/bootloader_console_loader.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@
1313
// limitations under the License.
1414

1515
/**
16-
* This file is contains console-related functions which should be located in iram_loader_seg,
16+
* This file contains console-related functions which should be located in iram_loader_seg,
1717
* to be available in the "loader" phase, when iram_seg may be overwritten.
1818
*/
1919
#include <stdint.h>
2020
#include <stddef.h>
2121
#include "sdkconfig.h"
2222
#include "bootloader_console.h"
2323
#include "esp_rom_uart.h"
24-
#ifdef CONFIG_IDF_TARGET_ESP32
25-
#include "esp32/rom/ets_sys.h"
26-
#elif CONFIG_IDF_TARGET_ESP32S2
27-
#include "esp32s2/rom/ets_sys.h"
24+
#include "esp_rom_sys.h"
25+
#if CONFIG_IDF_TARGET_ESP32S2
2826
#include "esp32s2/rom/usb/chip_usb_dw_wrapper.h"
2927
#include "esp32s2/rom/usb/usb_dc.h"
3028
#include "esp32s2/rom/usb/cdc_acm.h"
3129
#include "esp32s2/rom/usb/usb_persist.h"
3230
#endif
3331

3432
#ifdef CONFIG_ESP_CONSOLE_USB_CDC
35-
/* The following functions replace ets_write_char_uart, esp_rom_uart_tx_one_char,
33+
/* The following functions replace esp_rom_uart_putc, esp_rom_uart_tx_one_char,
3634
* and uart_tx_one_char_uart ROM functions. The main difference is that
3735
* uart_tx_one_char_uart calls cdc_acm_fifo_fill for each byte passed to it,
3836
* which results in very slow console output. The version here uses a TX buffer.
@@ -79,10 +77,10 @@ void bootloader_console_deinit(void)
7977
bootloader_console_flush_usb();
8078
usb_dc_prepare_persist();
8179
chip_usb_set_persist_flags(USBDC_PERSIST_ENA);
82-
ets_delay_us(100);
80+
esp_rom_delay_us(100);
8381
for (int i = 0; i < 10; i++) {
8482
usb_dc_check_poll_for_interrupts();
8583
}
86-
ets_install_putc1(NULL);
84+
esp_rom_install_channel_putc(1, NULL);
8785
#endif
8886
}

components/bootloader_support/src/bootloader_utility.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
#include "esp_attr.h"
2020
#include "esp_log.h"
2121

22+
#include "esp_rom_sys.h"
2223
#if CONFIG_IDF_TARGET_ESP32
2324
#include "esp32/rom/cache.h"
24-
#include "esp32/rom/ets_sys.h"
2525
#include "esp32/rom/spi_flash.h"
2626
#include "esp32/rom/rtc.h"
2727
#include "esp32/rom/secure_boot.h"
2828
#elif CONFIG_IDF_TARGET_ESP32S2
2929
#include "esp32s2/rom/cache.h"
30-
#include "esp32s2/rom/ets_sys.h"
3130
#include "esp32s2/rom/spi_flash.h"
3231
#include "esp32s2/rom/rtc.h"
3332
#include "esp32s2/rom/secure_boot.h"
@@ -766,7 +765,7 @@ void bootloader_reset(void)
766765
{
767766
#ifdef BOOTLOADER_BUILD
768767
bootloader_atexit();
769-
ets_delay_us(1000); /* Allow last byte to leave FIFO */
768+
esp_rom_delay_us(1000); /* Allow last byte to leave FIFO */
770769
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
771770
while (1) { } /* This line will never be reached, used to keep gcc happy */
772771
#else

components/bootloader_support/src/esp32/bootloader_esp32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#include "soc/spi_periph.h"
3636

3737
#include "esp32/rom/cache.h"
38-
#include "esp32/rom/ets_sys.h"
3938
#include "esp_rom_gpio.h"
4039
#include "esp_rom_efuse.h"
40+
#include "esp_rom_sys.h"
4141
#include "esp32/rom/spi_flash.h"
4242
#include "esp32/rom/rtc.h"
4343

@@ -354,7 +354,7 @@ static void bootloader_check_wdt_reset(void)
354354
void abort(void)
355355
{
356356
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
357-
ets_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
357+
esp_rom_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
358358
#endif
359359
if (esp_cpu_in_ocd_debug_mode()) {
360360
__asm__("break 0,0");

components/bootloader_support/src/esp32/bootloader_sha.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
4545
size_t word_len = data_len / 4;
4646
uint32_t *sha_text_reg = (uint32_t *)(SHA_TEXT_BASE);
4747

48-
//ets_printf("word_len %d so far %d\n", word_len, words_hashed);
4948
while (word_len > 0) {
5049
size_t block_count = words_hashed % BLOCK_WORDS;
5150
size_t copy_words = (BLOCK_WORDS - block_count);
@@ -56,7 +55,6 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
5655
while (REG_READ(SHA_256_BUSY_REG) != 0) { }
5756

5857
// Copy to memory block
59-
//ets_printf("block_count %d copy_words %d\n", block_count, copy_words);
6058
for (int i = 0; i < copy_words; i++) {
6159
sha_text_reg[block_count + i] = __builtin_bswap32(w[i]);
6260
}
@@ -70,7 +68,6 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
7068

7169
// If we loaded a full block, run the SHA engine
7270
if (block_count == BLOCK_WORDS) {
73-
//ets_printf("running engine @ count %d\n", words_hashed);
7471
if (words_hashed == BLOCK_WORDS) {
7572
REG_WRITE(SHA_256_START_REG, 1);
7673
} else {

components/bootloader_support/src/esp32/secure_boot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "esp_log.h"
2020

2121
#include "esp32/rom/cache.h"
22-
#include "esp32/rom/ets_sys.h"
2322
#include "esp_rom_crc.h"
2423

2524
#include "soc/efuse_periph.h"

components/bootloader_support/src/esp32s2/bootloader_esp32s2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include "bootloader_mem.h"
2929
#include "bootloader_console.h"
3030

31+
#include "esp_rom_sys.h"
3132
#include "esp32s2/rom/cache.h"
32-
#include "esp32s2/rom/ets_sys.h"
3333
#include "esp32s2/rom/spi_flash.h"
3434
#include "esp32s2/rom/rtc.h"
3535

@@ -279,7 +279,7 @@ static void bootloader_check_wdt_reset(void)
279279
void abort(void)
280280
{
281281
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
282-
ets_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
282+
esp_rom_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
283283
#endif
284284
if (esp_cpu_in_ocd_debug_mode()) {
285285
__asm__("break 0,0");

components/bt/controller/bt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#include "esp_ipc.h"
4747
#endif
4848

49+
#include "esp_rom_sys.h"
50+
4951
#if CONFIG_BT_ENABLED
5052

5153
/* Macro definition
@@ -1433,7 +1435,7 @@ esp_err_t esp_bt_controller_disable(void)
14331435
btdm_wakeup_request(false);
14341436
}
14351437
while (!btdm_power_state_active()) {
1436-
ets_delay_us(1000);
1438+
esp_rom_delay_us(1000);
14371439
}
14381440
}
14391441

components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "esp_log.h"
1313
#include "mesh_util.h"
14+
#include "esp_rom_sys.h"
1415

1516
#ifdef __cplusplus
1617
extern "C" {
@@ -65,7 +66,7 @@ extern "C" {
6566
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
6667
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
6768

68-
#define printk ets_printf
69+
#define printk esp_rom_printf
6970

7071
#define _STRINGIFY(x) #x
7172
#define STRINGIFY(s) _STRINGIFY(s)

components/driver/esp32/adc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include <esp_types.h>
1615
#include <stdlib.h>
1716
#include <ctype.h>
17+
#include "sdkconfig.h"
18+
#include "esp_types.h"
1819
#include "esp_log.h"
1920
#include "sys/lock.h"
2021
#include "soc/rtc.h"
@@ -28,9 +29,6 @@
2829
#include "driver/rtc_cntl.h"
2930
#include "driver/gpio.h"
3031
#include "driver/adc.h"
31-
#include "sdkconfig.h"
32-
33-
#include "esp32/rom/ets_sys.h"
3432

3533
#ifndef NDEBUG
3634
// Enable built-in checks in queue.h in debug builds

0 commit comments

Comments
 (0)