Skip to content

Commit 622482e

Browse files
committed
feat(esp_common): update esp_common
1. add Kconfig file and rename old global macro 2. move some independent files to esp_common
1 parent ba83b0d commit 622482e

File tree

22 files changed

+241
-152
lines changed

22 files changed

+241
-152
lines changed

components/bootloader/subproject/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif()
1818
set(COMPONENTS bootloader esptool_py partition_table esp8266 bootloader_support log spi_flash main)
1919
set(BOOTLOADER_BUILD 1)
2020
include("${IDF_PATH}/tools/cmake/project.cmake")
21-
set(common_req log)
21+
set(common_req log esp_common)
2222
if(LEGACY_INCLUDE_COMMON_HEADERS)
2323
list(APPEND common_req soc)
2424
endif()

components/bootloader/subproject/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CXXFLAGS =
1616

1717
#We cannot include the esp8266 component directly but we need its includes.
1818
CFLAGS += -I $(IDF_PATH)/components/esp8266/include -I $(IDF_PATH)/components/util/include
19+
CFLAGS += -I $(IDF_PATH)/components/esp_common/include
1920

2021
# The bootloader pseudo-component is also included in this build, for its Kconfig.projbuild to be included.
2122
#

components/bootloader_support/src/bootloader_init.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static void update_flash_config(const esp_image_header_t* pfhdr);
568568

569569
static void uart_console_configure(void)
570570
{
571-
#if CONFIG_UART0_SWAP_IO
571+
#if CONFIG_ESP_UART0_SWAP_IO
572572
while (READ_PERI_REG(UART_STATUS(0)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S));
573573

574574
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_UART0_CTS);
@@ -578,25 +578,25 @@ static void uart_console_configure(void)
578578
SET_PERI_REG_MASK(UART_SWAP_REG, 0x4);
579579
#endif
580580

581-
#if CONFIG_CONSOLE_UART_NUM == 1
581+
#if CONFIG_ESP_CONSOLE_UART_NUM == 1
582582
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
583583

584-
CLEAR_PERI_REG_MASK(UART_CONF1(CONFIG_CONSOLE_UART_NUM), UART_RX_FLOW_EN);
585-
CLEAR_PERI_REG_MASK(UART_CONF0(CONFIG_CONSOLE_UART_NUM), UART_TX_FLOW_EN);
584+
CLEAR_PERI_REG_MASK(UART_CONF1(CONFIG_ESP_CONSOLE_UART_NUM), UART_RX_FLOW_EN);
585+
CLEAR_PERI_REG_MASK(UART_CONF0(CONFIG_ESP_CONSOLE_UART_NUM), UART_TX_FLOW_EN);
586586

587-
WRITE_PERI_REG(UART_CONF0(CONFIG_CONSOLE_UART_NUM),
587+
WRITE_PERI_REG(UART_CONF0(CONFIG_ESP_CONSOLE_UART_NUM),
588588
0 // None parity
589589
| (1 << 4) // 1-bit stop
590590
| (3 << 2) // 8-bit data
591591
| 0 // None flow control
592592
| 0); // None Inverse
593593

594-
SET_PERI_REG_MASK(UART_CONF0(CONFIG_CONSOLE_UART_NUM), UART_RXFIFO_RST | UART_TXFIFO_RST);
595-
CLEAR_PERI_REG_MASK(UART_CONF0(CONFIG_CONSOLE_UART_NUM), UART_RXFIFO_RST | UART_TXFIFO_RST);
594+
SET_PERI_REG_MASK(UART_CONF0(CONFIG_ESP_CONSOLE_UART_NUM), UART_RXFIFO_RST | UART_TXFIFO_RST);
595+
CLEAR_PERI_REG_MASK(UART_CONF0(CONFIG_ESP_CONSOLE_UART_NUM), UART_RXFIFO_RST | UART_TXFIFO_RST);
596596
#endif
597597

598-
#ifdef CONFIG_CONSOLE_UART_BAUDRATE
599-
uart_div_modify(CONFIG_CONSOLE_UART_NUM, BOOTLOADER_CONSOLE_CLK_FREQ / CONFIG_CONSOLE_UART_BAUDRATE);
598+
#ifdef CONFIG_ESP_CONSOLE_UART_BAUDRATE
599+
uart_div_modify(CONFIG_ESP_CONSOLE_UART_NUM, BOOTLOADER_CONSOLE_CLK_FREQ / CONFIG_ESP_CONSOLE_UART_BAUDRATE);
600600
#endif
601601
}
602602

components/esp8266/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ else()
2525
"source/chip_boot.c"
2626
"source/backtrace.c"
2727
"source/esp_sleep.c"
28-
"source/esp_err_to_name.c"
2928
"source/esp_timer.c"
3029
"source/esp_wifi_os_adapter.c"
3130
"source/esp_wifi.c"
@@ -54,6 +53,7 @@ else()
5453

5554
set(include_dirs "include" "include/driver")
5655

56+
set(requires "esp_common")
5757
set(priv_requires "wpa_supplicant" "log" "spi_flash" "tcpip_adapter" "esp_ringbuf" "bootloader_support" "nvs_flash" "util")
5858
set(fragments linker.lf ld/esp8266_fragments.lf ld/esp8266_bss_fragments.lf)
5959

components/esp8266/Kconfig

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -94,67 +94,12 @@ config SOC_IRAM_SIZE
9494
default 0x8000 if SOC_FULL_ICACHE
9595
default 0xC000 if !SOC_FULL_ICACHE
9696

97-
choice CONSOLE_UART
98-
prompt "UART for console output"
99-
default CONSOLE_UART_DEFAULT
100-
help
101-
Select whether to use UART for console output (through stdout and stderr).
102-
103-
- Default is to use UART0.
104-
- If "Custom" is selected, UART0 or UART1 can be chosen.
105-
- If "None" is selected, there will be no console output on any UART.
106-
107-
config CONSOLE_UART_DEFAULT
108-
bool "Default: UART0"
109-
config CONSOLE_UART_CUSTOM
110-
bool "Custom"
111-
config CONSOLE_UART_NONE
112-
bool "None"
113-
endchoice
114-
115-
choice CONSOLE_UART_NUM
116-
prompt "UART peripheral to use for console output (0-1)"
117-
depends on CONSOLE_UART_CUSTOM
118-
default CONSOLE_UART_CUSTOM_NUM_0
119-
help
120-
Configrate output console UART for "ets_printf", "printf", "ESP_LOGX" and so on.
121-
122-
config CONSOLE_UART_CUSTOM_NUM_0
123-
bool "UART0"
124-
config CONSOLE_UART_CUSTOM_NUM_1
125-
bool "UART1"
126-
endchoice
127-
128-
config CONSOLE_UART_NUM
129-
int
130-
default 0 if CONSOLE_UART_DEFAULT || CONSOLE_UART_NONE
131-
default 0 if CONSOLE_UART_CUSTOM_NUM_0
132-
default 1 if CONSOLE_UART_CUSTOM_NUM_1
133-
134-
config CONSOLE_UART_BAUDRATE
135-
int "UART console baud rate"
136-
depends on CONSOLE_UART_DEFAULT || CONSOLE_UART_CUSTOM
137-
default 74880
138-
range 1200 4000000
139-
140-
config UART0_SWAP_IO
141-
bool "Swap UART0 I/O pins"
142-
default n
143-
help
144-
Enable this option, UART0's I/O pins are swaped: TXD <-> RTS, RTX <-> CTS.
145-
14697
config DISABLE_ROM_UART_PRINT
14798
bool "Disable ROM UART print"
14899
default n
149100
help
150101
"Disable main part of ROM UART print when rom bootloader process."
151102

152-
config PANIC_FULL_STACK
153-
bool "Output full stack data of task"
154-
default n
155-
help
156-
Output full stack data of task although some stack space is not used.
157-
158103
choice ESP_PANIC
159104
prompt "Panic handler behaviour"
160105
default ESP_PANIC_PRINT_REBOOT
@@ -189,51 +134,6 @@ config ESP_PANIC_GDBSTUB
189134
The UART's baudrate should be 115200 or others which can be recognized by xtensa GDB.
190135
endchoice
191136

192-
config MAIN_TASK_STACK_SIZE
193-
int "Main task stack size"
194-
default 3584
195-
help
196-
Configure the "main task" stack size. This is the stack of the task
197-
which calls app_main(). If app_main() returns then this task is deleted
198-
and its stack memory is freed.
199-
200-
config TASK_WDT
201-
bool "Initialize Task Watchdog Timer on startup"
202-
default y
203-
help
204-
The Task Watchdog Timer can be used to make sure individual tasks are still
205-
running. Enabling this option will cause the Task Watchdog Timer to be
206-
initialized automatically at startup. The Task Watchdog timer can be
207-
initialized after startup as well.
208-
209-
config TASK_WDT_PANIC
210-
bool "Invoke panic handler on Task Watchdog timeout"
211-
default y
212-
help
213-
If this option is enabled, the Task Watchdog Timer will be configured to
214-
trigger the panic handler when it times out. And it may cost some time.
215-
216-
choice TASK_WDT_TIMEOUT_S
217-
prompt "Task Watchdog timeout period (seconds)"
218-
default TASK_WDT_TIMEOUT_15N
219-
help
220-
Timeout period configuration for the Task Watchdog Timer in seconds.
221-
This is also configurable at run time.
222-
223-
config TASK_WDT_TIMEOUT_13N
224-
bool "6.5536s"
225-
config TASK_WDT_TIMEOUT_14N
226-
bool "13.1072s"
227-
config TASK_WDT_TIMEOUT_15N
228-
bool "26.2144s"
229-
endchoice
230-
231-
config TASK_WDT_TIMEOUT_S
232-
int
233-
default 13 if TASK_WDT_TIMEOUT_13N
234-
default 14 if TASK_WDT_TIMEOUT_14N
235-
default 15 if TASK_WDT_TIMEOUT_15N
236-
237137
config RESET_REASON
238138
bool "Enable reset reason"
239139
default y
@@ -249,12 +149,6 @@ config WIFI_PPT_TASKSTACK_SIZE
249149
which calls promiscuous callback function. So if user's function is
250150
complex, the stack must be set larger.
251151

252-
config EVENT_LOOP_STACK_SIZE
253-
int "Event loop stack size"
254-
default 2048
255-
help
256-
Configure the Event loop task stack size per application.
257-
258152
config ESP8266_CORE_GLOBAL_DATA_LINK_IRAM
259153
bool "Link libcore.a internal global data to IRAM"
260154
default y
@@ -307,16 +201,6 @@ config ESP8266_BOOT_COPY_APP
307201
Enable this option, when it is that "OTA1" application is to run after update by OTA,
308202
bootloader will copy "OTA1" application to "OTA0" partition and run "OTA0".
309203

310-
config ESP_ERR_TO_NAME_LOOKUP
311-
bool "Enable lookup of error code strings"
312-
default "y"
313-
help
314-
Functions esp_err_to_name() and esp_err_to_name_r() return string
315-
representations of error codes from a pre-generated lookup table.
316-
This option can be used to turn off the use of the look-up table in
317-
order to save memory but this comes at the price of sacrificing
318-
distinguishable (meaningful) output string representations.
319-
320204
choice ESP8266_TIME_SYSCALL
321205
prompt "Timers used for gettimeofday function"
322206
default ESP8266_TIME_SYSCALL_USE_FRC1

components/esp8266/Makefile.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ESP8266_COMPONENT_PATH := $(COMPONENT_PATH)
4242

4343
$(PHY_INIT_DATA_OBJ): $(ESP8266_COMPONENT_PATH)/include/internal/phy_init_data.h $(BUILD_DIR_BASE)/include/sdkconfig.h
4444
$(summary) CC $(notdir $@)
45-
printf "#include \"internal/phy_init_data.h\"\n" | $(CC) -I $(BUILD_DIR_BASE)/include -I $(ESP8266_COMPONENT_PATH) -I $(ESP8266_COMPONENT_PATH)/include -c -o $@ -xc -
45+
printf "#include \"internal/phy_init_data.h\"\n" | $(CC) -I $(BUILD_DIR_BASE)/include -I $(ESP8266_COMPONENT_PATH) -I $(ESP8266_COMPONENT_PATH)/include -I $(ESP8266_COMPONENT_PATH)/../esp_common/include -c -o $@ -xc -
4646

4747
$(PHY_INIT_DATA_BIN): $(PHY_INIT_DATA_OBJ)
4848
$(summary) BIN $(notdir $@)

components/esp8266/include/esp_event_loop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "freertos/FreeRTOS.h"
2424
#include "freertos/queue.h"
2525

26-
#define EVENT_LOOP_STACKSIZE CONFIG_EVENT_LOOP_STACK_SIZE
26+
#define EVENT_LOOP_STACKSIZE CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE
2727

2828
#ifdef __cplusplus
2929
extern "C" {

components/esp8266/sdkconfig.rename

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# sdkconfig replacement configurations for deprecated options formatted as
2+
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
3+
4+
CONFIG_MAIN_TASK_STACK_SIZE CONFIG_ESP_MAIN_TASK_STACK_SIZE
5+
CONFIG_CONSOLE_UART CONFIG_ESP_CONSOLE_UART
6+
CONFIG_CONSOLE_UART_DEFAULT CONFIG_ESP_CONSOLE_UART_DEFAULT
7+
CONFIG_CONSOLE_UART_CUSTOM CONFIG_ESP_CONSOLE_UART_CUSTOM
8+
CONFIG_CONSOLE_UART_NONE CONFIG_ESP_CONSOLE_UART_NONE
9+
CONFIG_CONSOLE_UART_NUM CONFIG_ESP_CONSOLE_UART_NUM
10+
CONFIG_CONSOLE_UART_CUSTOM_NUM_0 CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0
11+
CONFIG_CONSOLE_UART_CUSTOM_NUM_1 CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_1
12+
CONFIG_CONSOLE_UART_BAUDRATE CONFIG_ESP_CONSOLE_UART_BAUDRATE
13+
CONFIG_UART0_SWAP_IO CONFIG_ESP_UART0_SWAP_IO
14+
15+
CONFIG_TASK_WDT CONFIG_ESP_TASK_WDT
16+
CONFIG_TASK_WDT_PANIC CONFIG_ESP_TASK_WDT_PANIC
17+
CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S

components/esp8266/source/ets_printf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
#include "esp8266/uart_register.h"
2525
#include "esp8266/rom_functions.h"
2626

27-
#ifndef CONFIG_CONSOLE_UART_NONE
27+
#ifndef CONFIG_ESP_CONSOLE_UART_NONE
2828
static void uart_putc(int c)
2929
{
3030
while (1) {
31-
uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(CONFIG_CONSOLE_UART_NUM)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S);
31+
uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(CONFIG_ESP_CONSOLE_UART_NUM)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S);
3232

3333
if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) < 126)
3434
break;
3535
}
3636

37-
WRITE_PERI_REG(UART_FIFO(CONFIG_CONSOLE_UART_NUM) , c);
37+
WRITE_PERI_REG(UART_FIFO(CONFIG_ESP_CONSOLE_UART_NUM) , c);
3838
}
3939
#else
4040
#define uart_putc(_c) { }

components/esp8266/source/phy_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat
7272
esp_err_t status = ESP_OK;
7373
uint8_t sta_mac[6];
7474
uint8_t *local_init_data = calloc(1, 256);
75-
#ifdef CONFIG_CONSOLE_UART_BAUDRATE
76-
const uint32_t uart_baudrate = CONFIG_CONSOLE_UART_BAUDRATE;
75+
#ifdef CONFIG_ESP_CONSOLE_UART_BAUDRATE
76+
const uint32_t uart_baudrate = CONFIG_ESP_CONSOLE_UART_BAUDRATE;
7777
#else
7878
const uint32_t uart_baudrate = 74880; // ROM default baudrate
7979
#endif

components/esp8266/source/startup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "FreeRTOS.h"
3535
#include "task.h"
36+
#include "esp_task.h"
3637

3738
#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
3839
#include "esp_newlib.h"
@@ -93,7 +94,7 @@ static void user_init_entry(void *param)
9394
esp_reset_reason_init();
9495
#endif
9596

96-
#ifdef CONFIG_TASK_WDT
97+
#ifdef CONFIG_ESP_TASK_WDT
9798
esp_task_wdt_init();
9899
#endif
99100

@@ -175,7 +176,7 @@ void call_start_cpu(size_t start_addr)
175176
esp_newlib_init();
176177
#endif
177178

178-
assert(xTaskCreate(user_init_entry, "uiT", CONFIG_MAIN_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES, NULL) == pdPASS);
179+
assert(xTaskCreate(user_init_entry, "uiT", ESP_TASK_MAIN_STACK, NULL, configMAX_PRIORITIES, NULL) == pdPASS);
179180

180181
vTaskStartScheduler();
181182
}

components/esp8266/source/task_wdt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
static const char *TAG = "wdt";
2525

26-
#ifdef CONFIG_TASK_WDT_PANIC
26+
#ifdef CONFIG_ESP_TASK_WDT_PANIC
2727
/**
2828
* @brief Task watch dog interrupt function and it should do panic
2929
*/
@@ -43,7 +43,7 @@ esp_err_t esp_task_wdt_init(void)
4343
{
4444
CLEAR_WDT_REG_MASK(WDT_CTL_ADDRESS, BIT0);
4545

46-
#ifdef CONFIG_TASK_WDT_PANIC
46+
#ifdef CONFIG_ESP_TASK_WDT_PANIC
4747
const uint32_t panic_time_param = 11;
4848

4949
// Just for soft restart
@@ -59,9 +59,9 @@ esp_err_t esp_task_wdt_init(void)
5959
const uint32_t panic_time_param = 1;
6060
#endif
6161

62-
ESP_LOGD(TAG, "task watch dog trigger time parameter is %u", CONFIG_TASK_WDT_TIMEOUT_S);
62+
ESP_LOGD(TAG, "task watch dog trigger time parameter is %u", CONFIG_ESP_TASK_WDT_TIMEOUT_S);
6363

64-
WDT_REG_WRITE(WDT_OP_ADDRESS, CONFIG_TASK_WDT_TIMEOUT_S); // 2^n * 0.8ms, mask 0xf, n = 13 -> (2^13 = 8192) * 0.8 * 0.001 = 6.5536
64+
WDT_REG_WRITE(WDT_OP_ADDRESS, CONFIG_ESP_TASK_WDT_TIMEOUT_S); // 2^n * 0.8ms, mask 0xf, n = 13 -> (2^13 = 8192) * 0.8 * 0.001 = 6.5536
6565
WDT_REG_WRITE(WDT_OP_ND_ADDRESS, panic_time_param); // 2^n * 0.8ms, mask 0xf, n = 11 -> (2^11 = 2048) * 0.8 * 0.001 = 1.6384
6666

6767
SET_PERI_REG_BITS(PERIPHS_WDT_BASEADDR + WDT_CTL_ADDRESS, WDT_CTL_RSTLEN_MASK, 7 << WDT_CTL_RSTLEN_LSB, 0);

components/esp_common/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ if(BOOTLOADER_BUILD)
44
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections")
55
else()
66
# Regular app build
7-
idf_component_register(SRCS "src/stack_check.c"
8-
INCLUDE_DIRS include)
7+
idf_component_register(SRCS "src/stack_check.c" "src/esp_err_to_name.c"
8+
INCLUDE_DIRS include
9+
PRIV_REQUIRES "tcpip_adapter")
910

1011
set_source_files_properties(
1112
"src/stack_check.c"

0 commit comments

Comments
 (0)