Skip to content

Commit

Permalink
Merge branch 'feature/enable_hal_util_host_test' into 'master'
Browse files Browse the repository at this point in the history
feat(hal): enable hal host test

Closes IDF-8275

See merge request espressif/esp-idf!26384
  • Loading branch information
suda-morris committed Oct 12, 2023
2 parents ade6384 + 66497af commit ca1cd88
Show file tree
Hide file tree
Showing 23 changed files with 196 additions and 40 deletions.
4 changes: 2 additions & 2 deletions components/efuse/test_apps/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

21 changes: 15 additions & 6 deletions components/esp_rom/linux/esp_rom_sys.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -16,7 +16,8 @@ static void call_linux_putc(char c);

static void (*s_esp_rom_putc)(char c) = call_linux_putc;

static void call_linux_putc(char c) {
static void call_linux_putc(char c)
{
putc(c, stdout);
}

Expand Down Expand Up @@ -52,7 +53,7 @@ static int _cvt(unsigned long long val, char *buf, long radix, const char *digit
static int esp_rom_vprintf(void (*putc)(char c), const char *fmt, va_list ap)
{
#ifdef BINARY_SUPPORT
char buf[sizeof(long long)*8];
char buf[sizeof(long long) * 8];
int i;
#else
char buf[32];
Expand Down Expand Up @@ -118,7 +119,7 @@ static int esp_rom_vprintf(void (*putc)(char c), const char *fmt, va_list ap)
val = va_arg(ap, long long);
} else if (islong) {
val = (long long)va_arg(ap, long);
} else{
} else {
val = (long long)va_arg(ap, int);
}
if ((c == 'd') || (c == 'D')) {
Expand All @@ -129,7 +130,7 @@ static int esp_rom_vprintf(void (*putc)(char c), const char *fmt, va_list ap)
} else {
if (islong) {
val &= (((long long)1) << (sizeof(long) * 8)) - 1;
} else{
} else {
val &= (((long long)1) << (sizeof(int) * 8)) - 1;
}
}
Expand All @@ -143,7 +144,7 @@ static int esp_rom_vprintf(void (*putc)(char c), const char *fmt, va_list ap)
(*putc)('0');
(*putc)('x');
zero_fill = true;
left_prec = sizeof(unsigned long)*2;
left_prec = sizeof(unsigned long) * 2;
case 'd':
case 'D':
case 'u':
Expand Down Expand Up @@ -286,3 +287,11 @@ soc_reset_reason_t esp_rom_get_reset_reason(int cpu_no)
{
return RESET_REASON_CHIP_POWER_ON;
}

void __assert_func(const char *file, int line, const char *func, const char *failedexpr)
{
esp_rom_printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
failedexpr, file, line,
func ? ", function: " : "", func ? func : "");
while (1) {}
}
4 changes: 0 additions & 4 deletions components/hal/.build-test-rules.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
components/hal/test_apps/hal_utils:
enable:
- if: IDF_TARGET == "linux"
disable:
- if: IDF_TARGET == "linux"
temporary: true
reason: env not ready
63 changes: 37 additions & 26 deletions components/hal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@

idf_build_get_property(target IDF_TARGET)

# On Linux, there is currently no HAL, hence this simple component registration
if(${target} STREQUAL "linux")
idf_component_register()
return()
set(srcs "hal_utils.c")
set(includes "platform_port/include")

# target specific include must be added before the generic one
# becuase of the "include_next" directive used by the efuse_hal.h
if(NOT ${target} STREQUAL "linux")
list(APPEND includes "${target}/include")
endif()
list(APPEND includes "include")

set(srcs "mpu_hal.c"
"efuse_hal.c"
"hal_utils.c"
"${target}/efuse_hal.c")
if(CONFIG_SOC_MPU_SUPPORTED)
list(APPEND srcs "mpu_hal.c")
endif()

if(CONFIG_SOC_EFUSE_SUPPORTED)
list(APPEND srcs "efuse_hal.c" "${target}/efuse_hal.c")
endif()

set(includes "${target}/include" "include" "platform_port/include")
if(CONFIG_SOC_LP_TIMER_SUPPORTED)
list(APPEND srcs "lp_timer_hal.c")
endif()

if(NOT CONFIG_HAL_WDT_USE_ROM_IMPL)
if(CONFIG_SOC_WDT_SUPPORTED AND NOT CONFIG_HAL_WDT_USE_ROM_IMPL)
list(APPEND srcs "wdt_hal_iram.c")
endif()

if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
list(APPEND srcs "mmu_hal.c")
if(CONFIG_SOC_MMU_PERIPH_NUM)
list(APPEND srcs "mmu_hal.c")
endif()

# We wrap Cache ROM APIs as Cache HAL APIs for: 1. internal ram ; 2. unified APIs
# ESP32 cache structure / ROM APIs are different and we have a patch `cache_hal_esp32.c` for it.
if(${target} STREQUAL "esp32")
list(APPEND srcs "esp32/cache_hal_esp32.c")
else()
elseif(NOT ${target} STREQUAL "linux")
list(APPEND srcs "cache_hal.c")
endif()
endif()

if(CONFIG_SOC_LP_TIMER_SUPPORTED)
list(APPEND srcs "lp_timer_hal.c")
endif()

if(NOT BOOTLOADER_BUILD)
list(APPEND srcs
"rtc_io_hal.c"
"gpio_hal.c"
"uart_hal.c"
"uart_hal_iram.c")

if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
list(APPEND srcs
"spi_flash_hal.c"
"spi_flash_hal_iram.c"
)
if(CONFIG_SOC_SPI_FLASH_SUPPORTED)
list(APPEND srcs "spi_flash_hal.c" "spi_flash_hal_iram.c")
endif()
if(CONFIG_SOC_FLASH_ENC_SUPPORTED)
list(APPEND srcs "spi_flash_encrypt_hal_iram.c")
endif()
Expand All @@ -60,6 +59,18 @@ if(NOT BOOTLOADER_BUILD)
list(APPEND srcs "systimer_hal.c")
endif()

if(CONFIG_SOC_UART_SUPPORTED)
list(APPEND srcs "uart_hal.c" "uart_hal_iram.c")
endif()

if(CONFIG_SOC_GPIO_PORT)
list(APPEND srcs "gpio_hal.c")
endif()

if(CONFIG_SOC_RTCIO_PIN_COUNT)
list(APPEND srcs "rtc_io_hal.c")
endif()

if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "timer_hal.c")
endif()
Expand Down
4 changes: 3 additions & 1 deletion components/hal/test_apps/hal_utils/pytest_hal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
@pytest.mark.linux
@pytest.mark.host_test
def test_hal_utils(dut: Dut) -> None:
dut.run_all_single_board_cases()
dut.expect_exact('Press ENTER to see the list of tests.')
dut.write('*')
dut.expect_unity_test_output()
12 changes: 12 additions & 0 deletions components/soc/esp32/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ config SOC_CLK_TREE_SUPPORTED
bool
default y

config SOC_MPU_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL
int
default 5
Expand Down
3 changes: 3 additions & 0 deletions components/soc/esp32/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
#define SOC_BOD_SUPPORTED 1
#define SOC_ULP_FSM_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_MPU_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

#if SOC_CAPS_ECO_VER < 200
#define SOC_DPORT_WORKAROUND 1
Expand Down
8 changes: 8 additions & 0 deletions components/soc/esp32c2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ config SOC_ASSIST_DEBUG_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_26M
bool
default y
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32c2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#define SOC_BOD_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_ASSIST_DEBUG_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_26M 1
Expand Down
8 changes: 8 additions & 0 deletions components/soc/esp32c3/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ config SOC_ASSIST_DEBUG_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_40M
bool
default y
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32c3/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
#define SOC_BOD_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_ASSIST_DEBUG_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_40M 1
Expand Down
8 changes: 8 additions & 0 deletions components/soc/esp32c6/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ config SOC_ASSIST_DEBUG_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_40M
bool
default y
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32c6/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
#define SOC_ULP_LP_UART_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_ASSIST_DEBUG_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_40M 1
Expand Down
8 changes: 8 additions & 0 deletions components/soc/esp32h2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ config SOC_ASSIST_DEBUG_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_32M
bool
default y
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32h2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#define SOC_PAU_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_ASSIST_DEBUG_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_32M 1
Expand Down
12 changes: 12 additions & 0 deletions components/soc/esp32p4/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ config SOC_EFUSE_KEY_PURPOSE_FIELD
bool
default y

config SOC_EFUSE_SUPPORTED
bool
default y

config SOC_RTC_FAST_MEM_SUPPORTED
bool
default y
Expand Down Expand Up @@ -127,6 +131,14 @@ config SOC_PSRAM_DMA_CAPABLE
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_40M
bool
default y
Expand Down
4 changes: 3 additions & 1 deletion components/soc/esp32p4/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define SOC_SUPPORTS_SECURE_DL_MODE 1
// #define SOC_RISCV_COPROC_SUPPORTED 1
#define SOC_EFUSE_KEY_PURPOSE_FIELD 1
// #define SOC_EFUSE_SUPPORTED 1 //TODO: IDF-7512
#define SOC_EFUSE_SUPPORTED 1
#define SOC_RTC_FAST_MEM_SUPPORTED 1
#define SOC_RTC_MEM_SUPPORTED 1
#define SOC_RMT_SUPPORTED 1
Expand Down Expand Up @@ -81,6 +81,8 @@
// #define SOC_SDMMC_HOST_SUPPORTED 1 //TODO: IDF-6502
// #define SOC_CLK_TREE_SUPPORTED 1 //TODO: IDF-7526
// #define SOC_ASSIST_DEBUG_SUPPORTED 1 //TODO: IDF-7565
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_40M 1
Expand Down
12 changes: 12 additions & 0 deletions components/soc/esp32s2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ config SOC_CLK_TREE_SUPPORTED
bool
default y

config SOC_MPU_SUPPORTED
bool
default y

config SOC_WDT_SUPPORTED
bool
default y

config SOC_SPI_FLASH_SUPPORTED
bool
default y

config SOC_XTAL_SUPPORT_40M
bool
default y
Expand Down
3 changes: 3 additions & 0 deletions components/soc/esp32s2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
#define SOC_TOUCH_SENSOR_SUPPORTED 1
#define SOC_BOD_SUPPORTED 1
#define SOC_CLK_TREE_SUPPORTED 1
#define SOC_MPU_SUPPORTED 1
#define SOC_WDT_SUPPORTED 1
#define SOC_SPI_FLASH_SUPPORTED 1

/*-------------------------- XTAL CAPS ---------------------------------------*/
#define SOC_XTAL_SUPPORT_40M 1
Expand Down
Loading

0 comments on commit ca1cd88

Please sign in to comment.