Skip to content

Commit 5425ef4

Browse files
committed
hal: extract hal component from soc component
1 parent 5a9a42b commit 5425ef4

File tree

222 files changed

+147
-107
lines changed

Some content is hidden

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

222 files changed

+147
-107
lines changed

components/bootloader/subproject/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(BOOTLOADER_BUILD 1)
2020
include("${IDF_PATH}/tools/cmake/project.cmake")
2121
set(common_req log esp_rom esp_common xtensa)
2222
if(LEGACY_INCLUDE_COMMON_HEADERS)
23-
list(APPEND common_req soc)
23+
list(APPEND common_req soc hal)
2424
endif()
2525
idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${common_req}")
2626
idf_build_set_property(__OUTPUT_SDKCONFIG 0)

components/bootloader/subproject/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endif
88

99
PROJECT_NAME := bootloader
1010

11-
COMPONENTS := esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom
11+
COMPONENTS := esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom hal
1212

1313
# Clear C and CXX from top level project
1414
CFLAGS =

components/bootloader_support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if(BOOTLOADER_BUILD)
2424
"src/${IDF_TARGET}/flash_encrypt.c"
2525
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
2626
)
27+
list(APPEND priv_requires hal)
2728
else()
2829
list(APPEND srcs
2930
"src/idf/bootloader_sha.c")

components/driver/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ if(IDF_TARGET STREQUAL "esp32s2")
4444
"esp32s2/adc2_init_cal.c"
4545
"spi_slave_hd.c"
4646
"esp32s2/dac.c")
47-
# currently only S2 beta has its own target-specific includes
4847
list(APPEND includes "esp32s2/include")
4948
endif()
5049

5150
idf_component_register(SRCS "${srcs}"
5251
INCLUDE_DIRS ${includes}
5352
PRIV_INCLUDE_DIRS "include/driver"
5453
PRIV_REQUIRES efuse esp_timer esp_ipc
55-
REQUIRES esp_ringbuf freertos soc) #cannot totally hide soc headers, since there are a lot arguments in the driver are chip-dependent
54+
REQUIRES esp_ringbuf freertos soc hal) # cannot totally hide soc headers, since there are a lot arguments in the driver are chip-dependent
5655

5756
# uses C11 atomic feature
5857
set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11)

components/esp_common/src/esp_err_to_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static const esp_err_msg_t esp_err_msg_table[] = {
527527
# ifdef ESP_ERR_FLASH_OP_TIMEOUT
528528
ERR_TBL_IT(ESP_ERR_FLASH_OP_TIMEOUT), /* 24578 0x6002 */
529529
# endif
530-
// components/soc/include/hal/esp_flash_err.h
530+
// components/hal/include/hal/esp_flash_err.h
531531
# ifdef ESP_ERR_FLASH_NOT_INITIALISED
532532
ERR_TBL_IT(ESP_ERR_FLASH_NOT_INITIALISED), /* 24579 0x6003 */
533533
# endif

components/esp_rom/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ idf_component_register(SRCS "patches/esp_rom_crc.c"
55
"patches/esp_rom_uart.c"
66
INCLUDE_DIRS include
77
PRIV_INCLUDE_DIRS "${target}"
8-
PRIV_REQUIRES soc)
8+
PRIV_REQUIRES soc hal)
99

1010
if(BOOTLOADER_BUILD)
1111
set(scripts

components/fatfs/test_fatfs_host/Makefile.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ INCLUDE_DIRS := \
3434
esp_common/include \
3535
bootloader_support/include \
3636
app_update/include \
37+
hal/include \
3738
spi_flash/include \
3839
wear_levelling/include \
3940
)

components/hal/CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
idf_build_get_property(target IDF_TARGET)
2+
3+
set(srcs "wdt_hal_iram.c"
4+
"mpu_hal.c")
5+
set(includes "${target}/include" "include")
6+
7+
if(NOT BOOTLOADER_BUILD)
8+
list(APPEND srcs
9+
"cpu_hal.c"
10+
"rmt_hal.c"
11+
"rtc_io_hal.c"
12+
"dac_hal.c"
13+
"adc_hal.c"
14+
"spi_hal.c"
15+
"spi_hal_iram.c"
16+
"spi_slave_hal.c"
17+
"spi_slave_hal_iram.c"
18+
"touch_sensor_hal.c"
19+
"pcnt_hal.c"
20+
"i2s_hal.c"
21+
"sigmadelta_hal.c"
22+
"timer_hal.c"
23+
"ledc_hal.c"
24+
"ledc_hal_iram.c"
25+
"i2c_hal.c"
26+
"i2c_hal_iram.c"
27+
"gpio_hal.c"
28+
"uart_hal.c"
29+
"uart_hal_iram.c"
30+
"spi_flash_hal.c"
31+
"spi_flash_hal_iram.c"
32+
"soc_hal.c"
33+
"twai_hal.c")
34+
35+
if(${target} STREQUAL "esp32")
36+
list(APPEND srcs
37+
"mcpwm_hal.c"
38+
"sdio_slave_hal.c"
39+
"esp32/adc_hal.c"
40+
"esp32/brownout_hal.c"
41+
"esp32/touch_sensor_hal.c")
42+
if(NOT BOOTLOADER_BUILD AND CONFIG_ETH_USE_ESP32_EMAC)
43+
list(APPEND srcs "esp32/emac_hal.c")
44+
endif()
45+
endif()
46+
47+
if(${target} STREQUAL "esp32s2")
48+
list(APPEND srcs
49+
"spi_flash_hal_gpspi.c"
50+
"spi_slave_hd_hal.c"
51+
"esp32s2/adc_hal.c"
52+
"esp32s2/brownout_hal.c"
53+
"esp32s2/cp_dma_hal.c"
54+
"esp32s2/systimer_hal.c"
55+
"esp32s2/touch_sensor_hal.c"
56+
"esp32s2/usb_hal.c")
57+
endif()
58+
59+
if(${target} STREQUAL "esp32s3")
60+
list(APPEND srcs
61+
"esp32s3/brownout_hal.c"
62+
"esp32s3/systimer_hal.c"
63+
"esp32s3/touch_sensor_hal.c")
64+
endif()
65+
endif()
66+
67+
idf_component_register(SRCS ${srcs}
68+
INCLUDE_DIRS ${includes}
69+
PRIV_INCLUDE_DIRS ${priv_include}
70+
REQUIRES soc
71+
LDFRAGMENTS linker.lf)
72+
73+
File renamed without changes.

components/hal/component.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
COMPONENT_SRCDIRS := . esp32
2+
COMPONENT_ADD_INCLUDEDIRS := esp32/include include
3+
COMPONENT_ADD_LDFRAGMENTS += linker.lf
4+
5+
COMPONENT_OBJEXCLUDE += ./spi_slave_hd_hal.o ./spi_flash_hal_gpspi.o ./spi_slave_hd_hal.o
6+
7+
ifndef CONFIG_ETH_USE_ESP32_EMAC
8+
COMPONENT_OBJEXCLUDE += esp32/emac_hal.o
9+
endif
10+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/hal/linker.lf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[mapping:hal]
2+
archive: libhal.a
3+
entries:
4+
spi_hal_iram (noflash)
5+
spi_slave_hal_iram (noflash)
6+
if UART_ISR_IN_IRAM = y:
7+
uart_hal_iram (noflash)
8+
else:
9+
uart_hal_iram (default)
10+
spi_flash_hal_iram (noflash)
11+
ledc_hal_iram (noflash)
12+
i2c_hal_iram (noflash)
13+
spi_flash_hal_gpspi (noflash)
14+
cpu_hal (noflash)
15+
soc_hal (noflash)
16+
wdt_hal_iram (noflash)
17+
systimer_hal (noflash)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/nvs_flash/test_nvs_host/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ else
3636
COMPILER := gcc
3737
endif
3838

39-
CPPFLAGS += -I../include -I../src -I./ -I../../esp_common/include -I../../esp32/include -I ../../mbedtls/mbedtls/include -I ../../spi_flash/include -I ../../soc/include -I ../../xtensa/include -I ../../../tools/catch -fprofile-arcs -ftest-coverage
39+
CPPFLAGS += -I../include -I../src -I./ -I../../esp_common/include -I../../esp32/include -I ../../mbedtls/mbedtls/include -I ../../spi_flash/include -I ../../hal/include -I ../../xtensa/include -I ../../../tools/catch -fprofile-arcs -ftest-coverage
4040
CFLAGS += -fprofile-arcs -ftest-coverage
4141
CXXFLAGS += -std=c++11 -Wall -Werror
4242
LDFLAGS += -lstdc++ -Wall -fprofile-arcs -ftest-coverage

components/soc/CMakeLists.txt

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,19 @@ idf_build_get_property(target IDF_TARGET)
33
idf_component_register(SRCS "src/cpu_util.c"
44
"src/memory_layout_utils.c"
55
"src/lldesc.c"
6-
"src/hal/cpu_hal.c"
7-
"src/hal/rmt_hal.c"
8-
"src/hal/rtc_io_hal.c"
9-
"src/hal/dac_hal.c"
10-
"src/hal/adc_hal.c"
11-
"src/hal/spi_hal.c"
12-
"src/hal/spi_hal_iram.c"
13-
"src/hal/spi_slave_hal.c"
14-
"src/hal/spi_slave_hal_iram.c"
15-
"src/hal/touch_sensor_hal.c"
166
"src/soc_include_legacy_warn.c"
17-
"src/hal/pcnt_hal.c"
18-
"src/hal/i2s_hal.c"
19-
"src/hal/sigmadelta_hal.c"
20-
"src/hal/timer_hal.c"
21-
"src/hal/ledc_hal.c"
22-
"src/hal/ledc_hal_iram.c"
23-
"src/hal/i2c_hal.c"
24-
"src/hal/i2c_hal_iram.c"
25-
"src/hal/gpio_hal.c"
26-
"src/hal/uart_hal.c"
27-
"src/hal/uart_hal_iram.c"
28-
"src/hal/spi_flash_hal.c"
29-
"src/hal/spi_flash_hal_iram.c"
30-
"src/hal/mpu_hal.c"
31-
"src/hal/soc_hal.c"
32-
"src/hal/wdt_hal_iram.c"
337
"src/compare_set.c"
34-
"src/hal/twai_hal.c"
8+
REQUIRES hal #cpu.h directly includes HAL header
359
PRIV_REQUIRES ${target}
3610
LDFRAGMENTS linker.lf)
3711

38-
if(CONFIG_IDF_TARGET_ESP32)
39-
target_sources(${COMPONENT_LIB} PRIVATE "src/hal/mcpwm_hal.c"
40-
"src/hal/sdio_slave_hal.c")
41-
elseif(CONFIG_IDF_TARGET_ESP32S2)
42-
target_sources(${COMPONENT_LIB} PRIVATE "src/hal/spi_flash_hal_gpspi.c")
43-
target_sources(${COMPONENT_LIB} PRIVATE "src/hal/spi_slave_hd_hal.c")
44-
endif()
4512

4613
# Since there can be chip-specific HAL headers which can include the common
4714
# HAL header via include_next, process the build scripts here first so that
4815
# include directories appear first in the compile command.
4916
add_subdirectory(src/${target})
5017
target_include_directories(${COMPONENT_LIB} PUBLIC include)
18+
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::hal)
5119

5220
add_subdirectory(soc)
5321
target_link_libraries(${COMPONENT_LIB} PUBLIC "soc_${target}")

components/soc/component.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
SOC_NAME := $(IDF_TARGET)
22

3-
COMPONENT_SRCDIRS := src src/hal
3+
COMPONENT_SRCDIRS := src
44
COMPONENT_ADD_INCLUDEDIRS :=
5-
COMPONENT_OBJEXCLUDE += src/hal/spi_slave_hd_hal.o
65

76
# Since there can be chip-specific HAL headers which can include the common
87
# HAL header via include_next, process the build scripts here first so that

components/soc/linker.lf

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,4 @@ entries:
99
rtc_sleep (noflash_text)
1010
rtc_time (noflash_text)
1111
rtc_wdt (noflash_text)
12-
spi_hal_iram (noflash)
13-
spi_slave_hal_iram (noflash)
14-
if UART_ISR_IN_IRAM = y:
15-
uart_hal_iram (noflash)
16-
else:
17-
uart_hal_iram (default)
18-
spi_flash_hal_iram (noflash)
19-
ledc_hal_iram (noflash)
20-
i2c_hal_iram (noflash)
21-
spi_flash_hal_gpspi (noflash)
2212
lldesc (noflash)
23-
cpu_hal (noflash)
24-
soc_hal (noflash)
25-
wdt_hal_iram (noflash)
26-
systimer_hal (noflash)

components/soc/src/esp32/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
set(srcs "adc_hal.c"
2-
"brownout_hal.c"
1+
set(srcs
32
"rtc_clk.c"
43
"rtc_clk_init.c"
54
"rtc_init.c"
@@ -8,17 +7,12 @@ set(srcs "adc_hal.c"
87
"rtc_time.c"
98
"rtc_wdt.c"
109
"soc_memory_layout.c"
11-
"touch_sensor_hal.c")
12-
13-
if(NOT BOOTLOADER_BUILD AND CONFIG_ETH_USE_ESP32_EMAC)
14-
list(APPEND srcs "emac_hal.c")
15-
endif()
10+
)
1611

1712
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
1813

1914
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
2015
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
21-
target_include_directories(${COMPONENT_LIB} PRIVATE ../hal)
2216

2317
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
2418
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

components/soc/src/esp32s2/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
set(srcs "adc_hal.c"
1+
set(srcs
22
"dac_hal.c"
3-
"brownout_hal.c"
4-
"cp_dma_hal.c"
53
"rtc_clk.c"
64
"rtc_clk_init.c"
75
"rtc_init.c"
86
"rtc_pm.c"
97
"rtc_sleep.c"
108
"rtc_time.c"
119
"rtc_wdt.c"
12-
"soc_memory_layout.c"
13-
"systimer_hal.c"
14-
"touch_sensor_hal.c"
15-
"usb_hal.c")
10+
"soc_memory_layout.c")
1611

1712
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
1813

1914
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
2015
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
21-
target_include_directories(${COMPONENT_LIB} PRIVATE ../hal)
2216

2317
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
2418
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

components/soc/src/esp32s3/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
set(srcs "brownout_hal.c"
1+
set(srcs
22
"rtc_clk_init.c"
33
"rtc_clk.c"
44
"rtc_init.c"
55
"rtc_pm.c"
66
"rtc_sleep.c"
77
"rtc_time.c"
8-
"soc_memory_layout.c"
9-
"systimer_hal.c"
10-
"touch_sensor_hal.c")
8+
"soc_memory_layout.c")
119

1210
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
1311

1412
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
1513
target_include_directories(${COMPONENT_LIB} PUBLIC . include)
16-
target_include_directories(${COMPONENT_LIB} PRIVATE ../hal)
1714

1815
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
1916
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/rtc_clk.c" PROPERTIES

components/spi_flash/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ else()
4545
endif()
4646

4747
idf_component_register(SRCS "${srcs}"
48+
REQUIRES hal
4849
PRIV_REQUIRES "${priv_requires}"
4950
INCLUDE_DIRS include
5051
PRIV_INCLUDE_DIRS private_include

components/spi_flash/sim/Makefile.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ INCLUDE_DIRS := \
3636
esp_timer/include \
3737
bootloader_support/include \
3838
app_update/include \
39+
hal/include \
3940
spi_flash/include \
4041
)

components/spi_flash/sim/stubs/Makefile.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ INCLUDE_DIRS := \
3030
esp_timer/include \
3131
bootloader_support/include \
3232
app_update/include \
33+
hal/include \
3334
spi_flash/include \
3435
)
3536

components/spiffs/test_spiffs_host/Makefile.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ INCLUDE_DIRS := \
3535
bootloader_support/include \
3636
app_update/include \
3737
spi_flash/include \
38+
hal/include \
3839
wear_levelling/include \
3940
)

components/wear_levelling/test_wl_host/Makefile.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ INCLUDE_DIRS := \
3333
esp32/include \
3434
bootloader_support/include \
3535
app_update/include \
36+
hal/include \
3637
spi_flash/include \
3738
)

components/xtensa/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ idf_component_register(SRCS ${srcs}
2525
PRIV_REQUIRES ${priv_requires})
2626

2727
if(NOT BOOTLOADER_BUILD)
28-
target_link_libraries(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${target}/libhal.a")
28+
target_link_libraries(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${target}/libxt_hal.a")
2929
endif()

components/xtensa/component.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
COMPONENT_ADD_INCLUDEDIRS := include esp32/include
22

3-
COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/esp32/libhal.a
3+
COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/esp32/libxt_hal.a
44

55
COMPONENT_ADD_LDFRAGMENTS += linker.lf
66

0 commit comments

Comments
 (0)