Merge branch 'refactor/create_esp_hw_support' into 'master'

Create esp_hw_support

Closes IDF-2161

See merge request espressif/esp-idf!10513
This commit is contained in:
Angus Gratton
2020-10-29 07:51:46 +08:00
463 changed files with 158 additions and 159 deletions

View File

@@ -80,6 +80,7 @@
/components/esp_http_server/ @esp-idf-codeowners/app-utilities
/components/esp_https_ota/ @esp-idf-codeowners/app-utilities
/components/esp_https_server/ @esp-idf-codeowners/app-utilities
/components/esp_hw_support/ @esp-idf-codeowners/system
/components/esp_ipc/ @esp-idf-codeowners/system
/components/esp_local_ctrl/ @esp-idf-codeowners/app-utilities
/components/esp_netif/ @esp-idf-codeowners/network

View File

@@ -15,10 +15,10 @@ if(NOT IDF_TARGET)
"in by the parent build process.")
endif()
set(COMPONENTS bootloader esptool_py partition_table soc bootloader_support log spi_flash micro-ecc main efuse)
set(COMPONENTS bootloader esptool_py esp_hw_support hal partition_table soc bootloader_support log spi_flash micro-ecc main efuse)
set(BOOTLOADER_BUILD 1)
include("${IDF_PATH}/tools/cmake/project.cmake")
set(common_req log esp_rom esp_common xtensa)
set(common_req log esp_rom esp_common esp_hw_support hal xtensa)
if(LEGACY_INCLUDE_COMMON_HEADERS)
list(APPEND common_req soc hal)
endif()

View File

@@ -8,7 +8,7 @@ endif
PROJECT_NAME := bootloader
COMPONENTS := esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom hal
COMPONENTS := esp_hw_support esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom hal
# Clear C and CXX from top level project
CFLAGS =

View File

@@ -56,8 +56,8 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_time.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@@ -43,9 +43,9 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_time.*(.literal .text .literal.* .text.*)
*libsoc.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@@ -44,9 +44,9 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_time.*(.literal .text .literal.* .text.*)
*libsoc.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@@ -25,7 +25,7 @@ else()
# Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here.
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS include
REQUIRES ${target} espcoredump esp_timer esp_ipc esp_pm
REQUIRES ${target} espcoredump esp_timer esp_ipc esp_pm esp_hw_support
PRIV_REQUIRES soc
LDFRAGMENTS "linker.lf")

View File

@@ -0,0 +1,8 @@
idf_component_register(SRCS "compare_set.c"
"cpu_util.c"
INCLUDE_DIRS include
REQUIRES soc
LDFRAGMENTS linker.lf)
idf_build_get_property(target IDF_TARGET)
add_subdirectory(port/${target})

View File

@@ -0,0 +1,7 @@
## `esp_hw_support` ##
This component contains hardware-related operations for supporting the system. These operations
are one level above that of `hal` in that these(1) use system services such as memory allocation, logging, scheduling
or (2) may be multi-step operations involving/affecting multiple parts of the SoC.
Implementations that don't fit other components cleanly, but are not worth creating a new component for (yet) may also be placed here as long as they don't pull dependencies other than the core system components.

View File

@@ -0,0 +1,4 @@
COMPONENT_SRCDIRS := . port/$(IDF_TARGET)
COMPONENT_ADD_INCLUDEDIRS := . include port/$(IDF_TARGET)/private_include
port/$(IDF_TARGET)/rtc_clk.o: CFLAGS += -fno-jump-tables -fno-tree-switch-conversion

View File

@@ -21,6 +21,9 @@
#include "soc/soc_memory_layout.h"
#include "xtensa/xtruntime.h"
#ifdef __cplusplus
extern "C" {
#endif
static inline void __attribute__((always_inline)) compare_and_set_native(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
{
@@ -53,4 +56,8 @@ static inline void __attribute__((always_inline)) compare_and_set_native(volatil
void compare_and_set_extram(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -21,6 +21,9 @@
#include "soc/compare_set.h"
#include "xtensa/xtruntime.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_SPIRAM_WORKAROUND_NEED_VOLATILE_SPINLOCK
#define NEED_VOLATILE_MUX volatile
@@ -154,5 +157,9 @@ static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *l
#endif
}
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -14,6 +14,7 @@
#pragma once
#include "esp_rom_sys.h"
/**
* @file soc_log.h
* @brief SOC library logging functions

View File

@@ -0,0 +1,11 @@
[mapping:esp_hw_support]
archive: libesp_hw_support.a
entries:
cpu_util (noflash_text)
rtc_clk (noflash)
rtc_init:rtc_vddsdio_set_config (noflash)
rtc_periph (noflash_text)
rtc_pm (noflash_text)
rtc_sleep (noflash_text)
rtc_time (noflash_text)
rtc_wdt (noflash_text)

View File

@@ -1,18 +1,17 @@
set(srcs
"rtc_clk.c"
"regi2c_ctrl.c"
"rtc_clk_init.c"
"rtc_init.c"
"rtc_pm.c"
"rtc_sleep.c"
"rtc_time.c"
"rtc_wdt.c"
"soc_memory_layout.c")
target_include_directories(${COMPONENT_LIB} PUBLIC .)
target_include_directories(${COMPONENT_LIB} PRIVATE private_include)
set(srcs
"rtc_clk.c"
"rtc_clk_init.c"
"rtc_init.c"
"rtc_pm.c"
"rtc_sleep.c"
"rtc_time.c"
"rtc_wdt.c")
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

View File

@@ -14,6 +14,9 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#define MHZ (1000000)
#ifdef __cplusplus

View File

@@ -1,4 +1,7 @@
set(srcs
target_include_directories(${COMPONENT_LIB} PUBLIC .)
target_include_directories(${COMPONENT_LIB} PUBLIC private_include)
set(srcs
"rtc_clk.c"
"rtc_clk_init.c"
"rtc_init.c"
@@ -6,13 +9,10 @@ set(srcs
"rtc_sleep.c"
"rtc_time.c"
"rtc_wdt.c"
"soc_memory_layout.c"
)
"regi2c_ctrl.c")
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

View File

@@ -14,6 +14,9 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#define MHZ (1000000)
#define DPORT_CPUPERIOD_SEL_80 0

View File

@@ -1,16 +1,16 @@
set(srcs
"rtc_clk_init.c"
"rtc_clk.c"
"rtc_init.c"
"rtc_pm.c"
"rtc_sleep.c"
"rtc_time.c"
"soc_memory_layout.c")
target_include_directories(${COMPONENT_LIB} PUBLIC .)
target_include_directories(${COMPONENT_LIB} PUBLIC private_include)
set(srcs
"rtc_clk.c"
"rtc_clk_init.c"
"rtc_init.c"
"rtc_pm.c"
"rtc_sleep.c"
"rtc_time.c")
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

View File

@@ -14,6 +14,9 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#define MHZ (1000000)
#define DPORT_CPUPERIOD_SEL_80 0

View File

@@ -0,0 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "${include_dirs}"
PRIV_REQUIRES cmock test_utils esp_hw_support)

View File

@@ -27,9 +27,8 @@ INCLUDE_DIRS := \
esp_system/include \
xtensa/include \
xtensa/esp32/include \
soc/soc/esp32/include \
soc/esp32/include \
soc/include \
soc/soc/include \
esp32/include \
esp_common/include \
bootloader_support/include \

View File

@@ -2,7 +2,7 @@ COMPONENTS_DIR=../..
COMPILER_ICLUDE_DIR=$(shell echo `which xtensa-esp32-elf-gcc | xargs dirname | xargs dirname`/xtensa-esp32-elf)
CFLAGS=-std=gnu99 -Og -ggdb -ffunction-sections -fdata-sections -nostdlib -Wall -Werror=all -Wno-int-to-pointer-cast -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-macro-redefined -Wno-constant-conversion -Wno-incompatible-pointer-types-discards-qualifiers -Wno-typedef-redefinition -Wno-incompatible-pointer-types -Wextra \
-Wno-unused-parameter -Wno-sign-compare -Wno-address -Wno-unused-variable -DESP_PLATFORM -D IDF_VER=\"v3.1\" -MMD -MP -DWITH_POSIX -DLWIP_NO_CTYPE_H=1
INC_DIRS=-I . -I ./build/config -I $(COMPONENTS_DIR)/newlib/platform_include -I $(COMPONENTS_DIR)/newlib/include -I $(COMPONENTS_DIR)/driver/include -I $(COMPONENTS_DIR)/esp32/include -I $(COMPONENTS_DIR)/ethernet/include -I $(COMPONENTS_DIR)/freertos/include -I $(COMPONENTS_DIR)/heap/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include -I $(COMPONENTS_DIR)/lwip/include/apps -I $(COMPONENTS_DIR)/lwip/lwip/src/include/netif -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/port/esp32/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/include/apps/ping -I $(COMPONENTS_DIR)/lwip/include/apps/sntp -I $(COMPONENTS_DIR)/soc/esp32/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/tcpip_adapter/include -I $(COMPONENTS_DIR)/esp_rom/include -I $(COMPONENTS_DIR)/esp_common/include -I $(COMPONENTS_DIR)/xtensa/include -I $(COMPONENTS_DIR)/xtensa/esp32/include -I $(COMPONENTS_DIR)/esp_wifi/include -I $(COMPONENTS_DIR)/esp_event/include -I $(COMPONENTS_DIR)/freertos/xtensa/include -I $(COMPONENTS_DIR)/esp_system/include -I $(COMPONENTS_DIR)/esp_timer/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/soc/soc/include -I $(COMPONENTS_DIR)/soc/src/esp32/include -I $(COMPONENTS_DIR)/soc/soc/esp32/include -I $(COMPONENTS_DIR)/esp_netif/include -I $(COMPONENTS_DIR)/esp_eth/include -I $(COMPONENTS_DIR)/esp_netif/lwip -I $(COMPONENTS_DIR)/hal/include -I $(COMPONENTS_DIR)/hal/esp32/include -I $(COMPILER_ICLUDE_DIR)/include
INC_DIRS=-I . -I ./build/config -I $(COMPONENTS_DIR)/newlib/platform_include -I $(COMPONENTS_DIR)/newlib/include -I $(COMPONENTS_DIR)/driver/include -I $(COMPONENTS_DIR)/esp32/include -I $(COMPONENTS_DIR)/ethernet/include -I $(COMPONENTS_DIR)/freertos/include -I $(COMPONENTS_DIR)/heap/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include -I $(COMPONENTS_DIR)/lwip/include/apps -I $(COMPONENTS_DIR)/lwip/lwip/src/include/netif -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/port/esp32/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/include/apps/ping -I $(COMPONENTS_DIR)/lwip/include/apps/sntp -I $(COMPONENTS_DIR)/soc/esp32/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/tcpip_adapter/include -I $(COMPONENTS_DIR)/esp_rom/include -I $(COMPONENTS_DIR)/esp_common/include -I $(COMPONENTS_DIR)/xtensa/include -I $(COMPONENTS_DIR)/xtensa/esp32/include -I $(COMPONENTS_DIR)/esp_wifi/include -I $(COMPONENTS_DIR)/esp_event/include -I $(COMPONENTS_DIR)/freertos/xtensa/include -I $(COMPONENTS_DIR)/esp_system/include -I $(COMPONENTS_DIR)/esp_timer/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/soc/src/esp32/include -I $(COMPONENTS_DIR)/soc/esp32/include -I $(COMPONENTS_DIR)/esp_netif/include -I $(COMPONENTS_DIR)/esp_eth/include -I $(COMPONENTS_DIR)/esp_netif/lwip -I $(COMPONENTS_DIR)/hal/include -I $(COMPONENTS_DIR)/hal/esp32/include -I $(COMPILER_ICLUDE_DIR)/include
TEST_NAME=test
FUZZ=afl-fuzz
GEN_CFG=generate_config

View File

@@ -28,8 +28,8 @@ CFLAGS=-g -Wno-unused-value -Wno-missing-declarations -Wno-pointer-bool-conversi
-I$(COMPONENTS_DIR)/lwip/port/esp32/include \
-I$(COMPONENTS_DIR)/lwip/lwip/src/include/lwip/apps \
-I$(COMPONENTS_DIR)/soc/include \
-I$(COMPONENTS_DIR)/soc/soc/include \
-I$(COMPONENTS_DIR)/soc/soc/esp32/include \
-I$(COMPONENTS_DIR)/soc/include \
-I$(COMPONENTS_DIR)/soc/esp32/include \
-I$(COMPONENTS_DIR)/soc/src/esp32/include \
-I$(COMPONENTS_DIR)/tcpip_adapter/include \
-I$(COMPONENTS_DIR)/xtensa/include \

View File

@@ -1,16 +1,8 @@
idf_build_get_property(target IDF_TARGET)
idf_component_register(SRCS "src/cpu_util.c"
"src/memory_layout_utils.c"
"src/lldesc.c"
"src/soc_include_legacy_warn.c"
"src/compare_set.c"
REQUIRES hal #cpu.h directly includes HAL header
idf_component_register(SRCS "lldesc.c"
"soc_include_legacy_warn.c"
"memory_layout_utils.c"
INCLUDE_DIRS include
PRIV_REQUIRES ${target}
LDFRAGMENTS linker.lf)
add_subdirectory(soc)
add_subdirectory(src/${target})
target_link_libraries(${COMPONENT_LIB} PUBLIC "soc_${target}")
idf_build_get_property(target IDF_TARGET)
add_subdirectory(${target})

View File

@@ -1,33 +1,10 @@
## `soc` ##
The `soc` component provides provides hardware description and hardware support functionality for targets supported by ESP-IDF. This is reflected in the component's subdirectories:
- `soc/include` - abstraction
- `soc/soc` - description
- `soc/src` - implementation
#### `soc/include` ####
`soc/include` contains header files which provide a hardware-agnostic interface to the SoC. The interface consists of
function declarations and abstracted types that other, higher level components can make use of in order to have code portable to
all targets ESP-IDF supports.
The `soc` subdirectory contains other useful interface for SoC-level operations or concepts, such as the memory layout, spinlocks, etc.
#### `soc/soc` ####
The `soc/soc` subdirectory contains description of the underlying hardware:
The `soc` component provides hardware description for targets supported by ESP-IDF.
- `xxx_reg.h` - defines registers related to the hardware
- `xxx_struct.h` - hardware description in C `struct`
- `xxx_channel.h` - definitions for hardware with multiple channels
- `xxx_caps.h` - features/capabilities of the hardware
- `xxx_pins.h` - pin definitions
- `xxx_periph.h/*.c` - includes all headers related to a peripheral; declaration and definition of IO mapping for that hardware
Since the hardware description is target-specific, there are subdirectories for each target containing copies of the files above.
Furthermore, the files in this directory should be standalone, i.e. should not include files from outside directories.
#### `soc/src` ####
Provides the interface about the memory, I2C, and Real_Time Clock functions.
- `xxx_periph.h/*.c` - includes all headers related to a peripheral; declaration and definition of IO mapping for that hardware

View File

@@ -1,14 +1,4 @@
SOC_NAME := $(IDF_TARGET)
COMPONENT_SRCDIRS := src
COMPONENT_ADD_INCLUDEDIRS :=
# Since there can be chip-specific HAL headers which can include the common
# HAL header via include_next, process the build scripts here first so that
# include directories appear first in the compile command.
-include $(COMPONENT_PATH)/src/$(SOC_NAME)/component.mk
COMPONENT_ADD_INCLUDEDIRS += include
-include $(COMPONENT_PATH)/soc/component.mk
COMPONENT_SRCDIRS := . $(IDF_TARGET)
COMPONENT_ADD_INCLUDEDIRS := include $(IDF_TARGET) $(IDF_TARGET)/include
COMPONENT_ADD_LDFRAGMENTS += linker.lf

View File

@@ -1,18 +1,22 @@
add_library(soc_esp32 STATIC
set(srcs
"adc_periph.c"
"dac_periph.c"
"gpio_periph.c"
"i2c_periph.c"
"i2s_periph.c"
"interrupts.c"
"pcnt_periph.c"
"ledc_periph.c"
"rtc_io_periph.c"
"rtc_periph.c"
"sdio_slave_periph.c"
"sdmmc_periph.c"
"interrupts.c"
"soc_memory_layout.c"
"spi_periph.c"
"ledc_periph.c"
"i2s_periph.c"
"i2c_periph.c"
"uart_periph.c"
"touch_sensor_periph.c")
"touch_sensor_periph.c"
"uart_periph.c")
target_include_directories(soc_esp32 PUBLIC include ../include private_include)
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
target_include_directories(${COMPONENT_LIB} PUBLIC . include)

Some files were not shown because too many files have changed in this diff Show More