From f5b03c9ea35b72e8c611f5eaf6ccb9ecbbdfc8d7 Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 26 Mar 2019 16:30:43 +0800 Subject: [PATCH] misc adjustment of esp32 component --- .../subproject/main/esp32.bootloader.rom.ld | 5 + components/bt/bt.c | 2 +- components/driver/gpio.c | 2 +- components/driver/i2c.c | 2 +- components/driver/i2s.c | 2 +- components/driver/include/driver/can.h | 2 +- components/driver/include/driver/mcpwm.h | 2 +- components/driver/include/driver/pcnt.h | 2 +- components/driver/include/driver/touch_pad.h | 2 +- components/driver/ledc.c | 2 +- components/driver/mcpwm.c | 2 +- components/driver/periph_ctrl.c | 2 +- components/driver/rmt.c | 2 +- components/driver/spi_common.c | 2 +- components/driver/spi_master.c | 2 +- components/driver/spi_slave.c | 2 +- components/driver/timer.c | 2 +- components/driver/uart.c | 2 +- components/esp32/CMakeLists.txt | 3 - components/esp32/cache_err_int.c | 2 +- components/esp32/component.mk | 3 +- components/esp32/cpu_start.c | 2 +- components/esp32/crosscore_int.c | 2 +- components/esp32/dport_access.c | 2 +- components/esp32/dport_panic_highint_hdl.S | 8 +- components/esp32/esp_adapter.c | 2 +- components/esp32/gdbstub.c | 2 +- components/esp32/include/esp_deep_sleep.h | 94 ------------------ components/esp32/include/esp_deepsleep.h | 2 - components/esp32/include/esp_intr.h | 78 +-------------- components/esp32/include/esp_intr_alloc.h | 34 ++++--- components/esp32/int_wdt.c | 2 +- components/esp32/intr_alloc.c | 2 +- components/esp32/linker.lf | 5 - components/esp32/panic.c | 5 +- components/esp32/task_wdt.c | 2 +- components/esp_common/CMakeLists.txt | 2 + .../include/esp_freertos_hooks.h | 0 .../{esp32 => esp_common}/include/esp_ipc.h | 0 .../src}/esp_err_to_name.c.in | 0 .../src}/freertos_hooks.c | 0 components/{esp32 => esp_common/src}/ipc.c | 0 components/espcoredump/src/core_dump_common.c | 10 +- components/espcoredump/src/core_dump_port.c | 6 +- components/freertos/CMakeLists.txt | 5 +- components/freertos/port.c | 4 +- components/freertos/tasks.c | 2 +- components/freertos/xtensa_vector_defaults.S | 4 +- components/freertos/xtensa_vectors.S | 50 +++++----- components/heap/test/test_malloc.c | 2 +- components/mbedtls/port/esp_bignum.c | 2 +- components/xtensa/CMakeLists.txt | 2 + components/xtensa/component.mk | 2 + components/{ => xtensa}/esp32/libhal.a | Bin .../include/esp_debug_helpers.h} | 39 ++------ components/xtensa/include/esp_panic.h | 4 + .../xtensa/include/esp_private/panic_reason.h | 11 ++ components/xtensa/linker.lf | 5 + docs/Doxyfile | 4 +- tools/ci/executable-list.txt | 2 +- {components/esp32/ld => tools}/elf_to_ld.sh | 0 tools/gen_esp_err_to_name.py | 3 +- 62 files changed, 146 insertions(+), 302 deletions(-) delete mode 100644 components/esp32/include/esp_deep_sleep.h delete mode 100644 components/esp32/include/esp_deepsleep.h rename components/{esp32 => esp_common}/include/esp_freertos_hooks.h (100%) rename components/{esp32 => esp_common}/include/esp_ipc.h (100%) rename components/{esp32 => esp_common/src}/esp_err_to_name.c.in (100%) rename components/{esp32 => esp_common/src}/freertos_hooks.c (100%) rename components/{esp32 => esp_common/src}/ipc.c (100%) rename components/{ => xtensa}/esp32/libhal.a (100%) rename components/{esp32/include/esp_panic.h => xtensa/include/esp_debug_helpers.h} (76%) create mode 100644 components/xtensa/include/esp_panic.h create mode 100644 components/xtensa/include/esp_private/panic_reason.h rename {components/esp32/ld => tools}/elf_to_ld.sh (100%) diff --git a/components/bootloader/subproject/main/esp32.bootloader.rom.ld b/components/bootloader/subproject/main/esp32.bootloader.rom.ld index b39af891d..c9639540a 100644 --- a/components/bootloader/subproject/main/esp32.bootloader.rom.ld +++ b/components/bootloader/subproject/main/esp32.bootloader.rom.ld @@ -2,3 +2,8 @@ PROVIDE ( ets_update_cpu_frequency = 0x40008550 ); /* Updates g_ticks_per_us on PROVIDE ( MD5Final = 0x4005db1c ); PROVIDE ( MD5Init = 0x4005da7c ); PROVIDE ( MD5Update = 0x4005da9c ); + +/* bootloader will use following functions from xtensa hal library */ +xthal_get_ccount = 0x4000c050; +xthal_get_ccompare = 0x4000c078; +xthal_set_ccompare = 0x4000c058; diff --git a/components/bt/bt.c b/components/bt/bt.c index a7126bdf0..c35f42e4a 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -30,7 +30,7 @@ #include "esp_types.h" #include "esp_system.h" #include "esp_task.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_attr.h" #include "esp_phy_init.h" #include "esp_bt.h" diff --git a/components/driver/gpio.c b/components/driver/gpio.c index 0c9f55388..eda39c3f3 100644 --- a/components/driver/gpio.c +++ b/components/driver/gpio.c @@ -13,7 +13,7 @@ // limitations under the License. #include #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "freertos/FreeRTOS.h" #include "freertos/xtensa_api.h" diff --git a/components/driver/i2c.c b/components/driver/i2c.c index 1cc422614..70772fa36 100644 --- a/components/driver/i2c.c +++ b/components/driver/i2c.c @@ -15,7 +15,7 @@ #include #include "esp_types.h" #include "esp_attr.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_log.h" #include "malloc.h" #include "freertos/FreeRTOS.h" diff --git a/components/driver/i2s.c b/components/driver/i2s.c index a813934b5..5f83c21a5 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -33,7 +33,7 @@ #include "driver/dac.h" #include "adc1_i2s_private.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_err.h" #include "esp_log.h" #include "esp_pm.h" diff --git a/components/driver/include/driver/can.h b/components/driver/include/driver/can.h index da0613aac..8c1d4200f 100644 --- a/components/driver/include/driver/can.h +++ b/components/driver/include/driver/can.h @@ -21,7 +21,7 @@ extern "C" { #include "freertos/FreeRTOS.h" #include "esp_types.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_err.h" #include "gpio.h" diff --git a/components/driver/include/driver/mcpwm.h b/components/driver/include/driver/mcpwm.h index 301ca4192..6e4edac45 100644 --- a/components/driver/include/driver/mcpwm.h +++ b/components/driver/include/driver/mcpwm.h @@ -19,7 +19,7 @@ #include "soc/soc.h" #include "driver/gpio.h" #include "driver/periph_ctrl.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #ifdef __cplusplus diff --git a/components/driver/include/driver/pcnt.h b/components/driver/include/driver/pcnt.h index e96450d0b..ce32050e5 100644 --- a/components/driver/include/driver/pcnt.h +++ b/components/driver/include/driver/pcnt.h @@ -2,7 +2,7 @@ #define __PCNT_H__ #include -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_err.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" diff --git a/components/driver/include/driver/touch_pad.h b/components/driver/include/driver/touch_pad.h index 21e2e2ec7..8d8c72040 100644 --- a/components/driver/include/driver/touch_pad.h +++ b/components/driver/include/driver/touch_pad.h @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_err.h" #include "esp_intr_alloc.h" #include "soc/touch_channel.h" diff --git a/components/driver/ledc.c b/components/driver/ledc.c index 82b6dde64..996e1dbbd 100644 --- a/components/driver/ledc.c +++ b/components/driver/ledc.c @@ -13,7 +13,7 @@ // limitations under the License. #include #include -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" diff --git a/components/driver/mcpwm.c b/components/driver/mcpwm.c index 6eeb935f3..761176ecf 100644 --- a/components/driver/mcpwm.c +++ b/components/driver/mcpwm.c @@ -15,7 +15,7 @@ #include #include "esp_log.h" #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" diff --git a/components/driver/periph_ctrl.c b/components/driver/periph_ctrl.c index 0b06ed1bc..f0a01a61a 100644 --- a/components/driver/periph_ctrl.c +++ b/components/driver/periph_ctrl.c @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/xtensa_api.h" diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 54ec46da8..0b1384682 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -18,7 +18,7 @@ #include "freertos/semphr.h" #include "freertos/xtensa_api.h" #include "freertos/ringbuf.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_err.h" #include "esp_intr_alloc.h" diff --git a/components/driver/spi_common.c b/components/driver/spi_common.c index f27a28101..09562e013 100644 --- a/components/driver/spi_common.c +++ b/components/driver/spi_common.c @@ -20,7 +20,7 @@ #include "esp32/rom/ets_sys.h" #include "esp_types.h" #include "esp_attr.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_err.h" diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 7e7effa84..568c02a80 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -126,7 +126,7 @@ We have two bits to control the interrupt: #include "esp32/rom/ets_sys.h" #include "esp_types.h" #include "esp_attr.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_err.h" diff --git a/components/driver/spi_slave.c b/components/driver/spi_slave.c index edfa95e62..dbb7a3eac 100644 --- a/components/driver/spi_slave.c +++ b/components/driver/spi_slave.c @@ -20,7 +20,7 @@ #include "esp32/rom/ets_sys.h" #include "esp_types.h" #include "esp_attr.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_err.h" diff --git a/components/driver/timer.c b/components/driver/timer.c index a7a17306c..9fa3d5516 100644 --- a/components/driver/timer.c +++ b/components/driver/timer.c @@ -14,7 +14,7 @@ #include #include "esp_log.h" #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "freertos/FreeRTOS.h" #include "freertos/xtensa_api.h" diff --git a/components/driver/uart.c b/components/driver/uart.c index 7761089b8..b8f607445 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -14,7 +14,7 @@ #include #include "esp_types.h" #include "esp_attr.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_err.h" diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index e16888ac6..a6b61623e 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -20,12 +20,10 @@ else() "esp_adapter.c" "esp_timer_esp32.c" "esp_himem.c" - "freertos_hooks.c" "gdbstub.c" "hw_random.c" "int_wdt.c" "intr_alloc.c" - "ipc.c" "panic.c" "pm_esp32.c" "pm_trace.c" @@ -70,7 +68,6 @@ else() target_linker_script(${COMPONENT_TARGET} "ld/esp32.peripherals.ld") - target_link_libraries(${COMPONENT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/libhal.a") target_link_libraries(${COMPONENT_TARGET} gcc) target_link_libraries(${COMPONENT_TARGET} "-u call_user_start_cpu0") diff --git a/components/esp32/cache_err_int.c b/components/esp32/cache_err_int.c index b844c72f7..fd17edf65 100644 --- a/components/esp32/cache_err_int.c +++ b/components/esp32/cache_err_int.c @@ -25,7 +25,7 @@ #include #include "freertos/FreeRTOS.h" #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_attr.h" #include "soc/dport_reg.h" #include "sdkconfig.h" diff --git a/components/esp32/component.mk b/components/esp32/component.mk index a067b6035..8f999b26d 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -17,8 +17,7 @@ LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.project.ld esp32.peripherals.ld #ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the #linker will ignore panic_highint_hdl.S as it has no other files depending on any #symbols in it. -COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/libhal.a \ - -L $(COMPONENT_PATH)/ld \ +COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/ld \ -T esp32_out.ld \ -u ld_include_panic_highint_hdl \ $(addprefix -T ,$(LINKER_SCRIPTS)) \ diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index 83a4915b7..a7ff14b32 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -60,7 +60,7 @@ #include "esp_phy_init.h" #include "esp32/cache_err_int.h" #include "esp_coexist_internal.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "esp_core_dump.h" #include "esp_app_trace.h" #include "esp_private/dbg_stubs.h" diff --git a/components/esp32/crosscore_int.c b/components/esp32/crosscore_int.c index 2b8f1df48..3802a5600 100644 --- a/components/esp32/crosscore_int.c +++ b/components/esp32/crosscore_int.c @@ -16,7 +16,7 @@ #include "esp_attr.h" #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp32/rom/ets_sys.h" diff --git a/components/esp32/dport_access.c b/components/esp32/dport_access.c index 02bb8ee18..1f1a4dda1 100644 --- a/components/esp32/dport_access.c +++ b/components/esp32/dport_access.c @@ -25,7 +25,7 @@ #include #include "esp_attr.h" #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp32/rom/ets_sys.h" #include "esp32/rom/uart.h" diff --git a/components/esp32/dport_panic_highint_hdl.S b/components/esp32/dport_panic_highint_hdl.S index bddde3cdf..a329ec7d5 100644 --- a/components/esp32/dport_panic_highint_hdl.S +++ b/components/esp32/dport_panic_highint_hdl.S @@ -17,7 +17,7 @@ #include #include #include "freertos/xtensa_context.h" -#include "esp_panic.h" +#include "esp_private/panic_reason.h" #include "sdkconfig.h" #include "soc/soc.h" #include "soc/dport_reg.h" @@ -137,8 +137,8 @@ xt_highint4: /* This section is for dport access register protection */ /* Allocate exception frame and save minimal context. */ /* Because the interrupt cause code has protection that only - allows one cpu to enter in the dport section of the L4 - interrupt at one time, there's no need to have two + allows one cpu to enter in the dport section of the L4 + interrupt at one time, there's no need to have two _l4_intr_stack for each cpu */ /* This int is edge-triggered and needs clearing. */ @@ -192,7 +192,7 @@ xt_highint4: #endif // CONFIG_FREERTOS_UNICORE /* The linker has no reason to link in this file; all symbols it exports are already defined - (weakly!) in the default int handler. Define a symbol here so we can use it to have the + (weakly!) in the default int handler. Define a symbol here so we can use it to have the linker inspect this anyway. */ .global ld_include_panic_highint_hdl diff --git a/components/esp32/esp_adapter.c b/components/esp32/esp_adapter.c index 7224414e8..1dfcb342c 100644 --- a/components/esp32/esp_adapter.c +++ b/components/esp32/esp_adapter.c @@ -29,7 +29,7 @@ #include "esp_types.h" #include "esp_system.h" #include "esp_task.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_attr.h" #include "esp_log.h" #include "esp_heap_caps.h" diff --git a/components/esp32/gdbstub.c b/components/esp32/gdbstub.c index 3bc5423fe..9ce9f460a 100644 --- a/components/esp32/gdbstub.c +++ b/components/esp32/gdbstub.c @@ -23,7 +23,7 @@ #include "soc/uart_reg.h" #include "soc/io_mux_reg.h" #include "esp_private/gdbstub.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "driver/gpio.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/components/esp32/include/esp_deep_sleep.h b/components/esp32/include/esp_deep_sleep.h deleted file mode 100644 index ea4601818..000000000 --- a/components/esp32/include/esp_deep_sleep.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -/** - * @file esp_deep_sleep.h - * @brief legacy definitions of esp_deep_sleep APIs - * - * This file provides compatibility for applications using esp_deep_sleep_* APIs. - * New applications should use functions defined in "esp_sleep.h" instead. - * These functions and types will be deprecated at some point. - */ - -#warning esp_deep_sleep.h will be deprecated in the next release. Use esp_sleep.h instead. - -#include "esp_sleep.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef esp_sleep_pd_domain_t esp_deep_sleep_pd_domain_t; -typedef esp_sleep_pd_option_t esp_deep_sleep_pd_option_t; -typedef esp_sleep_ext1_wakeup_mode_t esp_ext1_wakeup_mode_t; -typedef esp_sleep_wakeup_cause_t esp_deep_sleep_wakeup_cause_t; - -inline static esp_err_t esp_deep_sleep_enable_ulp_wakeup(void) -{ - return esp_sleep_enable_ulp_wakeup(); -} - -inline static esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us) -{ - return esp_sleep_enable_timer_wakeup(time_in_us); -} - -inline static esp_err_t esp_deep_sleep_enable_touchpad_wakeup(void) -{ - return esp_sleep_enable_touchpad_wakeup(); -} - -inline static touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status() -{ - return esp_sleep_get_touchpad_wakeup_status(); -} - -inline static esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level) -{ - return esp_sleep_enable_ext0_wakeup(gpio_num, level); -} - -inline static esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode) -{ - return esp_sleep_enable_ext1_wakeup(mask, mode); -} - -inline static esp_err_t esp_deep_sleep_pd_config( - esp_deep_sleep_pd_domain_t domain, - esp_deep_sleep_pd_option_t option) -{ - return esp_sleep_pd_config(domain, option); -} - -inline static esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause() -{ - return esp_sleep_get_wakeup_cause(); -} - -#define ESP_DEEP_SLEEP_WAKEUP_UNDEFINED ESP_SLEEP_WAKEUP_UNDEFINED -#define ESP_DEEP_SLEEP_WAKEUP_EXT0 ESP_SLEEP_WAKEUP_EXT0 -#define ESP_DEEP_SLEEP_WAKEUP_EXT1 ESP_SLEEP_WAKEUP_EXT1 -#define ESP_DEEP_SLEEP_WAKEUP_TIMER ESP_SLEEP_WAKEUP_TIMER -#define ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD ESP_SLEEP_WAKEUP_TOUCHPAD -#define ESP_DEEP_SLEEP_WAKEUP_ULP ESP_SLEEP_WAKEUP_ULP - - - -#ifdef __cplusplus -} -#endif - diff --git a/components/esp32/include/esp_deepsleep.h b/components/esp32/include/esp_deepsleep.h deleted file mode 100644 index 3f0151b6a..000000000 --- a/components/esp32/include/esp_deepsleep.h +++ /dev/null @@ -1,2 +0,0 @@ -#warning esp_deepsleep.h has been renamed to esp_sleep.h, please update include directives -#include "esp_sleep.h" diff --git a/components/esp32/include/esp_intr.h b/components/esp32/include/esp_intr.h index 10039ccd8..c29dc9bfd 100644 --- a/components/esp32/include/esp_intr.h +++ b/components/esp32/include/esp_intr.h @@ -12,78 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef __ESP_INTR_H__ -#define __ESP_INTR_H__ - -#include "esp32/rom/ets_sys.h" -#include "freertos/xtensa_api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ESP_CCOMPARE_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_CCOMPARE_INUM, (func), (void *)(arg)) - -#define ESP_EPWM_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_EPWM_INUM, (func), (void *)(arg)) - -#define ESP_MPWM_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_MPWM_INUM, (func), (void *)(arg)) - -#define ESP_SPI1_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_SPI1_INUM, (func), (void *)(arg)) - -#define ESP_SPI2_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_SPI2_INUM, (func), (void *)(arg)) - -#define ESP_SPI3_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_SPI3_INUM, (func), (void *)(arg)) - -#define ESP_I2S0_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_I2S0_INUM, (func), (void *)(arg)) - -#define ESP_PCNT_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_PCNT_INUM, (func), (void *)(arg)) - -#define ESP_LEDC_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_LEDC_INUM, (func), (void *)(arg)) - -#define ESP_WMAC_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_WMAC_INUM, (func), (void *)(arg)) - -#define ESP_FRC_TIMER1_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_FRC_TIMER1_INUM, (func), (void *)(arg)) - -#define ESP_FRC_TIMER2_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_FRC_TIMER2_INUM, (func), (void *)(arg)) - -#define ESP_GPIO_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_GPIO_INUM, (func), (void *)(arg)) - -#define ESP_UART0_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_UART0_INUM, (func), (void *)(arg)) - -#define ESP_WDT_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_WDT_INUM, (func), (void *)(arg)) - -#define ESP_RTC_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_RTC_INUM, (func), (void *)(arg)) - -#define ESP_SLC_INTR_ATTACH(func, arg) \ - xt_set_interrupt_handler(ETS_SLC_INUM, (func), (void *)(arg)) - -#define ESP_RMT_CTRL_INTRL(func,arg)\ - xt_set_interrupt_handler(ETS_RMT_CTRL_INUM, (func), (void *)(arg)) - -#define ESP_INTR_ENABLE(inum) \ - xt_ints_on((1< #include #include "esp_err.h" +#include "freertos/xtensa_api.h" #ifdef __cplusplus extern "C" { @@ -80,7 +81,10 @@ extern "C" { // This is used to provide SystemView with positive IRQ IDs, otherwise sheduler events are not shown properly #define ETS_INTERNAL_INTR_SOURCE_OFF (-ETS_INTERNAL_PROFILING_INTR_SOURCE) -typedef void (*intr_handler_t)(void *arg); +#define ESP_INTR_ENABLE(inum) xt_ints_on((1<3 * is requested, because these types of interrupts aren't C-callable. @@ -158,7 +162,7 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar * * * This essentially does the same as esp_intr_alloc, but allows specifying a register and mask - * combo. For shared interrupts, the handler is only called if a read from the specified + * combo. For shared interrupts, the handler is only called if a read from the specified * register, ANDed with the mask, returns non-zero. By passing an interrupt status register * address and a fitting mask, this can be used to accelerate interrupt handling in the case * a shared interrupt is triggered; by checking the interrupt statuses first, the code can @@ -171,7 +175,7 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar * choice of interrupts that this routine can choose from. If this value * is 0, it will default to allocating a non-shared interrupt of level * 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared - * interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return + * interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return * from this function with the interrupt disabled. * @param intrstatusreg The address of an interrupt status register * @param intrstatusmask A mask. If a read of address intrstatusreg has any of the bits @@ -198,9 +202,9 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre * If the current core is not the core that registered this interrupt, this routine will be assigned to * the core that allocated this interrupt, blocking and waiting until the resource is successfully released. * - * @note - * When the handler shares its source with other handlers, the interrupt status - * bits it's responsible for should be managed properly before freeing it. see + * @note + * When the handler shares its source with other handlers, the interrupt status + * bits it's responsible for should be managed properly before freeing it. see * ``esp_intr_disable`` for more details. Please do not call this function in ``esp_ipc_call_blocking``. * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus @@ -214,7 +218,7 @@ esp_err_t esp_intr_free(intr_handle_t handle); /** * @brief Get CPU number an interrupt is tied to - * + * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus * * @return The core number where the interrupt is allocated @@ -223,7 +227,7 @@ int esp_intr_get_cpu(intr_handle_t handle); /** * @brief Get the allocated interrupt for a certain handle - * + * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus * * @return The interrupt number @@ -232,13 +236,13 @@ int esp_intr_get_intno(intr_handle_t handle); /** * @brief Disable the interrupt associated with the handle - * - * @note + * + * @note * 1. For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the * CPU the interrupt is allocated on. Other interrupts have no such restriction. - * 2. When several handlers sharing a same interrupt source, interrupt status bits, which are + * 2. When several handlers sharing a same interrupt source, interrupt status bits, which are * handled in the handler to be disabled, should be masked before the disabling, or handled - * in other enabled interrupts properly. Miss of interrupt status handling will cause infinite + * in other enabled interrupts properly. Miss of interrupt status handling will cause infinite * interrupt calls and finally system crash. * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus diff --git a/components/esp32/int_wdt.c b/components/esp32/int_wdt.c index efef92511..38e4aabdf 100644 --- a/components/esp32/int_wdt.c +++ b/components/esp32/int_wdt.c @@ -23,7 +23,7 @@ #include "freertos/task.h" #include #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_attr.h" #include "esp_freertos_hooks.h" #include "soc/timer_group_struct.h" diff --git a/components/esp32/intr_alloc.c b/components/esp32/intr_alloc.c index 3260ca809..35e602397 100644 --- a/components/esp32/intr_alloc.c +++ b/components/esp32/intr_alloc.c @@ -26,7 +26,7 @@ #include "esp_err.h" //#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE #include "esp_log.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_attr.h" #include "esp_intr_alloc.h" #include "esp_ipc.h" diff --git a/components/esp32/linker.lf b/components/esp32/linker.lf index f4b9a5d5f..c6575dc66 100644 --- a/components/esp32/linker.lf +++ b/components/esp32/linker.lf @@ -3,11 +3,6 @@ archive: libesp32.a entries: panic (noflash) -[mapping] -archive: libhal.a -entries: - * (noflash_text) - [mapping] archive: libgcc.a entries: diff --git a/components/esp32/panic.c b/components/esp32/panic.c index 5924a1f97..4f3488623 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -33,7 +33,8 @@ #include "soc/rtc_wdt.h" #include "esp_private/gdbstub.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" +#include "esp_private/panic_reason.h" #include "esp_attr.h" #include "esp_err.h" #include "esp_core_dump.h" @@ -382,7 +383,7 @@ static void illegal_instruction_helper(XtExcFrame *frame) panicPutStr("Memory dump at 0x"); panicPutHex(epc); panicPutStr(": "); - + panicPutHex(*pepc); panicPutStr(" "); panicPutHex(*(pepc + 1)); diff --git a/components/esp32/task_wdt.c b/components/esp32/task_wdt.c index ce4d7a6ad..d7edf732a 100644 --- a/components/esp32/task_wdt.c +++ b/components/esp32/task_wdt.c @@ -25,7 +25,7 @@ #include "freertos/semphr.h" #include #include "esp_err.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_attr.h" #include "esp_freertos_hooks.h" diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt index df3501ff3..eca7fb3fe 100644 --- a/components/esp_common/CMakeLists.txt +++ b/components/esp_common/CMakeLists.txt @@ -11,6 +11,8 @@ else() "src/esp_err_to_name.c" "src/esp_timer.c" "src/ets_timer_legacy.c" + "src/freertos_hooks.c" + "src/ipc.c" "src/pm_locks.c" "src/stack_check.c") set(COMPONENT_ADD_INCLUDEDIRS "include") diff --git a/components/esp32/include/esp_freertos_hooks.h b/components/esp_common/include/esp_freertos_hooks.h similarity index 100% rename from components/esp32/include/esp_freertos_hooks.h rename to components/esp_common/include/esp_freertos_hooks.h diff --git a/components/esp32/include/esp_ipc.h b/components/esp_common/include/esp_ipc.h similarity index 100% rename from components/esp32/include/esp_ipc.h rename to components/esp_common/include/esp_ipc.h diff --git a/components/esp32/esp_err_to_name.c.in b/components/esp_common/src/esp_err_to_name.c.in similarity index 100% rename from components/esp32/esp_err_to_name.c.in rename to components/esp_common/src/esp_err_to_name.c.in diff --git a/components/esp32/freertos_hooks.c b/components/esp_common/src/freertos_hooks.c similarity index 100% rename from components/esp32/freertos_hooks.c rename to components/esp_common/src/freertos_hooks.c diff --git a/components/esp32/ipc.c b/components/esp_common/src/ipc.c similarity index 100% rename from components/esp32/ipc.c rename to components/esp_common/src/ipc.c diff --git a/components/espcoredump/src/core_dump_common.c b/components/espcoredump/src/core_dump_common.c index 762db1993..bbd3e29ce 100644 --- a/components/espcoredump/src/core_dump_common.c +++ b/components/espcoredump/src/core_dump_common.c @@ -14,7 +14,7 @@ #include #include #include "esp32/rom/crc.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "esp_partition.h" #include "esp_core_dump_priv.h" @@ -37,15 +37,15 @@ static esp_err_t esp_core_dump_write_binary(void *frame, core_dump_write_config_ task_num = esp_core_dump_get_tasks_snapshot(tasks, CONFIG_ESP32_CORE_DUMP_MAX_TASKS_NUM, &tcb_sz); ESP_COREDUMP_LOGI("Found tasks: (%d)!", task_num); - + // Take TCB padding into account, actual TCB size will be stored in header if (tcb_sz % sizeof(uint32_t)) tcb_sz_padded = (tcb_sz / sizeof(uint32_t) + 1) * sizeof(uint32_t); else tcb_sz_padded = tcb_sz; - + // Verifies all tasks in the snapshot - for (i = 0; i < task_num; i++) { + for (i = 0; i < task_num; i++) { task_is_valid = esp_core_dump_process_tcb(frame, &tasks[i], tcb_sz); // Check if task tcb is corrupted if (!task_is_valid) { @@ -67,7 +67,7 @@ static esp_err_t esp_core_dump_write_binary(void *frame, core_dump_write_config_ // Add core dump header size data_len += sizeof(core_dump_header_t); ESP_COREDUMP_LOG_PROCESS("Core dump len = %lu (%d %d)", data_len, task_num, write_cfg->bad_tasks_num); - + // Prepare write if (write_cfg->prepare) { err = write_cfg->prepare(write_cfg->priv, &data_len); diff --git a/components/espcoredump/src/core_dump_port.c b/components/espcoredump/src/core_dump_port.c index e045b19a4..3e3414a4c 100644 --- a/components/espcoredump/src/core_dump_port.c +++ b/components/espcoredump/src/core_dump_port.c @@ -13,7 +13,7 @@ // limitations under the License. #include #include -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "esp_core_dump_priv.h" const static DRAM_ATTR char TAG[] __attribute__((unused)) = "esp_core_dump_port"; @@ -41,7 +41,7 @@ uint32_t esp_core_dump_get_tasks_snapshot(core_dump_task_header_t* const tasks, bool esp_core_dump_process_tcb(void *frame, core_dump_task_header_t *task_snaphort, uint32_t tcb_sz) { XtExcFrame *exc_frame = (XtExcFrame*)frame; - + if (!esp_tcb_addr_is_sane((uint32_t)task_snaphort->tcb_addr, tcb_sz)) { ESP_COREDUMP_LOG_PROCESS("Bad TCB addr %x!", task_snaphort->tcb_addr); return false; @@ -74,7 +74,7 @@ bool esp_core_dump_process_tcb(void *frame, core_dump_task_header_t *task_snapho } bool esp_core_dump_process_stack(core_dump_task_header_t* task_snaphort, uint32_t *length) -{ +{ uint32_t len = 0; bool task_is_valid = false; len = (uint32_t)task_snaphort->stack_end - (uint32_t)task_snaphort->stack_start; diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index a73a29fdb..29aa5efb6 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -1,8 +1,8 @@ set(COMPONENT_ADD_INCLUDEDIRS include) set(COMPONENT_PRIV_INCLUDEDIRS include/freertos) -set(COMPONENT_SRCS "FreeRTOS-openocd.c" - "croutine.c" +set(COMPONENT_SRCS "croutine.c" "event_groups.c" + "FreeRTOS-openocd.c" "list.c" "port.c" "portasm.S" @@ -20,6 +20,7 @@ set(COMPONENT_SRCS "FreeRTOS-openocd.c" # app_trace is required by FreeRTOS headers only when CONFIG_SYSVIEW_ENABLE=y, # but requirements can't depend on config options, so always require it. set(COMPONENT_REQUIRES app_trace) +set(COMPONENT_PRIV_REQUIRES esp_common) set(COMPONENT_ADD_LDFRAGMENTS linker.lf) register_component() diff --git a/components/freertos/port.c b/components/freertos/port.c index 5cd46c7c7..b00a9a853 100644 --- a/components/freertos/port.c +++ b/components/freertos/port.c @@ -103,7 +103,7 @@ #include "FreeRTOS.h" #include "task.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "esp_heap_caps.h" #include "esp_private/crosscore_int.h" @@ -446,7 +446,7 @@ void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT, __FUNCTION__, __LINE__); #else - vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT); + vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT); #endif prev=*addr; if (prev==compare) { diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 0fd71afac..403797bec 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -78,7 +78,7 @@ task.h is included from an application file. */ #include "esp32/rom/ets_sys.h" #include "esp_newlib.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" /* FreeRTOS includes. */ #include "FreeRTOS.h" diff --git a/components/freertos/xtensa_vector_defaults.S b/components/freertos/xtensa_vector_defaults.S index 592dc323b..507b30ba3 100644 --- a/components/freertos/xtensa_vector_defaults.S +++ b/components/freertos/xtensa_vector_defaults.S @@ -13,12 +13,12 @@ // limitations under the License. #include "xtensa_rtos.h" -#include "esp_panic.h" +#include "esp_private/panic_reason.h" #include "sdkconfig.h" #include "soc/soc.h" /* -This file contains the default handlers for the high interrupt levels as well as some specialized exceptions. +This file contains the default handlers for the high interrupt levels as well as some specialized exceptions. The default behaviour is to just exit the interrupt or call the panic handler on the exceptions */ diff --git a/components/freertos/xtensa_vectors.S b/components/freertos/xtensa_vectors.S index 101f08ab6..e5e63bcf1 100644 --- a/components/freertos/xtensa_vectors.S +++ b/components/freertos/xtensa_vectors.S @@ -34,14 +34,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. medium level interrupts, by calling xt_set_interrupt_handler(). These handlers can be written in C, and must obey C calling convention. The handler table is indexed by the interrupt number. Each handler may be - provided with an argument. + provided with an argument. Note that the system timer interrupt is handled specially, and is dispatched to the RTOS-specific handler. This timer cannot be hooked by application code. - Optional hooks are also provided to install a handler per level at - run-time, made available by compiling this source file with + Optional hooks are also provided to install a handler per level at + run-time, made available by compiling this source file with '-DXT_INTEXC_HOOKS' (useful for automated testing). !! This file is a template that usually needs to be modified to handle !! @@ -81,17 +81,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This allows more flexibility in locating code without the performance overhead of the 'l32r' literal data load in cases where the destination is in range of 'call0'. There is an additional benefit in that 'call0' - has a longer range than 'j' due to the target being word-aligned, so + has a longer range than 'j' due to the target being word-aligned, so the 'l32r' sequence is less likely needed. - 3. The use of 'call0' with -mlongcalls requires that register a0 not be - live at the time of the call, which is always the case for a function + 3. The use of 'call0' with -mlongcalls requires that register a0 not be + live at the time of the call, which is always the case for a function call but needs to be ensured if 'call0' is used as a jump in lieu of 'j'. 4. This use of 'call0' is independent of the C function call ABI. *******************************************************************************/ #include "xtensa_rtos.h" -#include "esp_panic.h" +#include "esp_private/panic_reason.h" #include "sdkconfig.h" #include "soc/soc.h" #include "soc/dport_reg.h" @@ -365,7 +365,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* -------------------------------------------------------------------------------- Panic handler. - Should be reached by call0 (preferable) or jump only. If call0, a0 says where + Should be reached by call0 (preferable) or jump only. If call0, a0 says where from. If on simulator, display panic message and abort, else loop indefinitely. -------------------------------------------------------------------------------- */ @@ -437,7 +437,7 @@ panic_print_hex_a: panic_print_hex_ok: s32i a5,a3,0 slli a2,a2,4 - + addi a4,a4,-1 bnei a4,0,panic_print_hex_loop movi a5,' ' @@ -456,12 +456,12 @@ panic_print_hex_ok: -------------------------------------------------------------------------------- Hooks to dynamically install handlers for exceptions and interrupts. Allows automated regression frameworks to install handlers per test. - Consists of an array of function pointers indexed by interrupt level, + Consists of an array of function pointers indexed by interrupt level, with index 0 containing the entry for user exceptions. Initialized with all 0s, meaning no handler is installed at each level. See comment in xtensa_rtos.h for more details. - *WARNING* This array is for all CPUs, that is, installing a hook for + *WARNING* This array is for all CPUs, that is, installing a hook for one CPU will install it for all others as well! -------------------------------------------------------------------------------- */ @@ -491,7 +491,7 @@ _xt_intexc_hooks: the appropriate stack frame, saves a few vector-specific registers and calls XT_RTOS_INT_ENTER to save the rest of the interrupted context and enter the RTOS, then sets up a C environment. It then calls the - user's interrupt handler code (which may be coded in C) and finally + user's interrupt handler code (which may be coded in C) and finally calls XT_RTOS_INT_EXIT to transfer control to the RTOS for scheduling. While XT_RTOS_INT_EXIT does not return directly to the interruptee, @@ -867,7 +867,7 @@ _xt_syscall_exc: -------------------------------------------------------------------------------- Co-Processor Exception Handler (jumped to from User Exception Handler). These exceptions are generated by co-processor instructions, which are only -allowed in thread code (not in interrupts or kernel code). This restriction is +allowed in thread code (not in interrupts or kernel code). This restriction is deliberately imposed to reduce the burden of state-save/restore in interrupts. -------------------------------------------------------------------------------- */ @@ -984,7 +984,7 @@ _xt_coproc_exc: or a4, a4, a2 /* a4 = CPENABLE | (1 << n) */ wsr a4, CPENABLE -/* +/* Keep loading _xt_coproc_owner_sa[n] atomic (=load once, then use that value everywhere): _xt_coproc_release assumes it works like this in order not to need locking. @@ -1030,8 +1030,8 @@ locking. /* The config-specific HAL macro invoked below destroys a2-5, preserves a0-1. - It is theoretically possible for Xtensa processor designers to write TIE - that causes more address registers to be affected, but it is generally + It is theoretically possible for Xtensa processor designers to write TIE + that causes more address registers to be affected, but it is generally unlikely. If that ever happens, more registers needs to be saved/restored around this macro invocation, and the value in a15 needs to be recomputed. */ @@ -1056,8 +1056,8 @@ locking. /* The config-specific HAL macro invoked below destroys a2-5, preserves a0-1. - It is theoretically possible for Xtensa processor designers to write TIE - that causes more address registers to be affected, but it is generally + It is theoretically possible for Xtensa processor designers to write TIE + that causes more address registers to be affected, but it is generally unlikely. If that ever happens, more registers needs to be saved/restored around this macro invocation. */ @@ -1138,12 +1138,12 @@ _xt_lowint1: /* Save rest of interrupt context and enter RTOS. */ call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ - /* !! We are now on the RTOS system stack !! */ + /* !! We are now on the RTOS system stack !! */ /* Set up PS for C, enable interrupts above this level and clear EXCM. */ #ifdef __XTENSA_CALL0_ABI__ movi a0, PS_INTLEVEL(1) | PS_UM - #else + #else movi a0, PS_INTLEVEL(1) | PS_UM | PS_WOE #endif wsr a0, PS @@ -1175,7 +1175,7 @@ _xt_lowint1: the appropriate stack frame, saves a few vector-specific registers and calls XT_RTOS_INT_ENTER to save the rest of the interrupted context and enter the RTOS, then sets up a C environment. It then calls the - user's interrupt handler code (which may be coded in C) and finally + user's interrupt handler code (which may be coded in C) and finally calls XT_RTOS_INT_EXIT to transfer control to the RTOS for scheduling. While XT_RTOS_INT_EXIT does not return directly to the interruptee, @@ -1602,7 +1602,7 @@ and used for purposes requiring very short service times. Here are templates for high priority (level 2+) interrupt vectors. They assume only one interrupt per level to avoid the burden of identifying -which interrupts at this level are pending and enabled. This allows for +which interrupts at this level are pending and enabled. This allows for minimum latency and avoids having to save/restore a2 in addition to a0. If more than one interrupt per high priority level is configured, this burden is on the handler which in any case must provide a way to save and restore @@ -1727,12 +1727,12 @@ _NMIExceptionVector: WINDOW OVERFLOW AND UNDERFLOW EXCEPTION VECTORS AND ALLOCA EXCEPTION HANDLER -Here is the code for each window overflow/underflow exception vector and +Here is the code for each window overflow/underflow exception vector and (interspersed) efficient code for handling the alloca exception cause. Window exceptions are handled entirely in the vector area and are very -tight for performance. The alloca exception is also handled entirely in +tight for performance. The alloca exception is also handled entirely in the window vector area so comes at essentially no cost in code size. -Users should never need to modify them and Cadence Design Systems recommends +Users should never need to modify them and Cadence Design Systems recommends they do not. Window handlers go at predetermined vector locations according to the diff --git a/components/heap/test/test_malloc.c b/components/heap/test/test_malloc.c index 46516dac3..bffb498d1 100644 --- a/components/heap/test/test_malloc.c +++ b/components/heap/test/test_malloc.c @@ -17,7 +17,7 @@ #include "soc/io_mux_reg.h" #include "esp_heap_caps.h" -#include "esp_panic.h" +#include "esp_debug_helpers.h" #include "sdkconfig.h" diff --git a/components/mbedtls/port/esp_bignum.c b/components/mbedtls/port/esp_bignum.c index 189d9ff06..3f748efb3 100644 --- a/components/mbedtls/port/esp_bignum.c +++ b/components/mbedtls/port/esp_bignum.c @@ -31,7 +31,7 @@ #include "soc/hwcrypto_reg.h" #include "esp_system.h" #include "esp_log.h" -#include "esp_intr.h" +#include "esp_intr_alloc.h" #include "esp_intr_alloc.h" #include "esp_attr.h" diff --git a/components/xtensa/CMakeLists.txt b/components/xtensa/CMakeLists.txt index 09dd93c47..03492eedc 100644 --- a/components/xtensa/CMakeLists.txt +++ b/components/xtensa/CMakeLists.txt @@ -5,3 +5,5 @@ set(COMPONENT_ADD_INCLUDEDIRS "include" "${IDF_TARGET}/include") set(COMPONENT_ADD_LDFRAGMENTS linker.lf) register_component() + +target_link_libraries(${COMPONENT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a") diff --git a/components/xtensa/component.mk b/components/xtensa/component.mk index 69e9ad2b4..81a0e33e7 100644 --- a/components/xtensa/component.mk +++ b/components/xtensa/component.mk @@ -1,4 +1,6 @@ COMPONENT_ADD_INCLUDEDIRS := include esp32/include +COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/esp32/libhal.a + COMPONENT_ADD_LDFRAGMENTS += linker.lf diff --git a/components/esp32/libhal.a b/components/xtensa/esp32/libhal.a similarity index 100% rename from components/esp32/libhal.a rename to components/xtensa/esp32/libhal.a diff --git a/components/esp32/include/esp_panic.h b/components/xtensa/include/esp_debug_helpers.h similarity index 76% rename from components/esp32/include/esp_panic.h rename to components/xtensa/include/esp_debug_helpers.h index b9e192f04..981fa34a5 100644 --- a/components/esp32/include/esp_panic.h +++ b/components/xtensa/include/esp_debug_helpers.h @@ -1,39 +1,24 @@ -#ifndef PANIC_H -#define PANIC_H +#pragma once #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif -#define PANIC_RSN_NONE 0 -#define PANIC_RSN_DEBUGEXCEPTION 1 -#define PANIC_RSN_DOUBLEEXCEPTION 2 -#define PANIC_RSN_KERNELEXCEPTION 3 -#define PANIC_RSN_COPROCEXCEPTION 4 -#define PANIC_RSN_INTWDT_CPU0 5 -#define PANIC_RSN_INTWDT_CPU1 6 -#define PANIC_RSN_CACHEERR 7 -#define PANIC_RSN_MAX 7 - - #ifndef __ASSEMBLER__ #include "esp_err.h" - -/** - * @brief If an OCD is connected over JTAG. set breakpoint 0 to the given function - * address. Do nothing otherwise. - * @param data Pointer to the target breakpoint position - */ - -void esp_set_breakpoint_if_jtag(void *fn); - #define ESP_WATCHPOINT_LOAD 0x40000000 #define ESP_WATCHPOINT_STORE 0x80000000 #define ESP_WATCHPOINT_ACCESS 0xC0000000 +/** + * @brief If an OCD is connected over JTAG. set breakpoint 0 to the given function + * address. Do nothing otherwise. + * @param fn Pointer to the target breakpoint position + */ +void esp_set_breakpoint_if_jtag(void *fn); + /** * @brief Set a watchpoint to break/panic when a certain memory range is accessed. * @@ -45,7 +30,7 @@ void esp_set_breakpoint_if_jtag(void *fn); * * @return ESP_ERR_INVALID_ARG on invalid arg, ESP_OK otherwise * - * @warning The ESP32 watchpoint hardware watches a region of bytes by effectively + * @warning The ESP32 watchpoint hardware watches a region of bytes by effectively * masking away the lower n bits for a region with size 2^n. If adr does * not have zero for these lower n bits, you may not be watching the * region you intended. @@ -68,10 +53,8 @@ static inline bool esp_stack_ptr_is_sane(uint32_t sp) { return !(sp < 0x3ffae010UL || sp > 0x3ffffff0UL || ((sp & 0xf) != 0)); } -#endif +#endif #ifdef __cplusplus } #endif - -#endif diff --git a/components/xtensa/include/esp_panic.h b/components/xtensa/include/esp_panic.h new file mode 100644 index 000000000..587c7953b --- /dev/null +++ b/components/xtensa/include/esp_panic.h @@ -0,0 +1,4 @@ +#pragma once +#warning "esp_panic.h is deprecated, please use esp_debug_helpers.h or/and esp_private/panic_reason.h" +#include "esp_private/panic_reason.h" +#include "esp_debug_helpers.h" diff --git a/components/xtensa/include/esp_private/panic_reason.h b/components/xtensa/include/esp_private/panic_reason.h new file mode 100644 index 000000000..a83c5de77 --- /dev/null +++ b/components/xtensa/include/esp_private/panic_reason.h @@ -0,0 +1,11 @@ +#pragma once + +#define PANIC_RSN_NONE 0 +#define PANIC_RSN_DEBUGEXCEPTION 1 +#define PANIC_RSN_DOUBLEEXCEPTION 2 +#define PANIC_RSN_KERNELEXCEPTION 3 +#define PANIC_RSN_COPROCEXCEPTION 4 +#define PANIC_RSN_INTWDT_CPU0 5 +#define PANIC_RSN_INTWDT_CPU1 6 +#define PANIC_RSN_CACHEERR 7 +#define PANIC_RSN_MAX 7 diff --git a/components/xtensa/linker.lf b/components/xtensa/linker.lf index 6486410ce..f79db6296 100644 --- a/components/xtensa/linker.lf +++ b/components/xtensa/linker.lf @@ -2,3 +2,8 @@ archive: libxtensa.a entries: eri (noflash_text) + +[mapping] +archive: libhal.a +entries: + * (noflash_text) diff --git a/docs/Doxyfile b/docs/Doxyfile index 87add4255..5e91f268c 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -161,9 +161,9 @@ INPUT = \ ../../components/esp_common/include/esp_int_wdt.h \ ../../components/esp_common/include/esp_task_wdt.h \ ## Hooks - ../../components/esp32/include/esp_freertos_hooks.h \ + ../../components/esp_common/include/esp_freertos_hooks.h \ ## Inter-Processor Call - ../../components/esp32/include/esp_ipc.h \ + ../../components/esp_common/include/esp_ipc.h \ ## Over The Air Updates (OTA) ../../components/app_update/include/esp_ota_ops.h \ ## ESP HTTPS OTA diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 75a8e9d10..707861073 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -1,6 +1,6 @@ # Some tools components/app_update/gen_empty_partition.py -components/esp32/ld/elf_to_ld.sh +tools/elf_to_ld.sh components/espcoredump/espcoredump.py components/heap/test_multi_heap_host/test_all_configs.sh components/idf_test/unit_test/TestCaseScript/IDFUnitTest/__init__.py diff --git a/components/esp32/ld/elf_to_ld.sh b/tools/elf_to_ld.sh similarity index 100% rename from components/esp32/ld/elf_to_ld.sh rename to tools/elf_to_ld.sh diff --git a/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index 0b55263c3..8db629065 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -319,7 +319,8 @@ def main(): idf_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) parser = argparse.ArgumentParser(description='ESP32 esp_err_to_name lookup generator for esp_err_t') - parser.add_argument('--c_input', help='Path to the esp_err_to_name.c.in template input.', default=idf_path + '/components/esp32/esp_err_to_name.c.in') + parser.add_argument('--c_input', help='Path to the esp_err_to_name.c.in template input.', + default=idf_path + '/components/esp_common/src/esp_err_to_name.c.in') parser.add_argument('--c_output', help='Path to the esp_err_to_name.c output.', default=idf_path + '/components/esp32/esp_err_to_name.c') parser.add_argument('--rst_output', help='Generate .rst output and save it into this file') args = parser.parse_args()