You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2023/02/22 15:35:15 UTC

[nuttx] 02/04: risc-v/espressif: Update ESP HAL to v5.0

This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch feature/sync_hal_5
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e568b6e82b457f8d9cd77b2f218aff062989e09a
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Feb 9 10:06:55 2023 -0300

    risc-v/espressif: Update ESP HAL to v5.0
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/risc-v/src/espressif/.gitignore       |   2 +-
 arch/risc-v/src/espressif/Make.defs        |  65 +--------------
 arch/risc-v/src/espressif/esp_libc_stubs.c | 124 ++++++++++++++---------------
 arch/risc-v/src/espressif/esp_lowputc.c    |  10 +--
 arch/risc-v/src/espressif/esp_serial.c     |   8 +-
 arch/risc-v/src/espressif/esp_start.c      |   2 +-
 arch/risc-v/src/espressif/esp_timerisr.c   |  35 ++++++--
 arch/risc-v/src/espressif/hal_esp32c3.mk   |  93 ++++++++++++++++++++++
 8 files changed, 200 insertions(+), 139 deletions(-)

diff --git a/arch/risc-v/src/espressif/.gitignore b/arch/risc-v/src/espressif/.gitignore
index 13204eef46..53497953f8 100644
--- a/arch/risc-v/src/espressif/.gitignore
+++ b/arch/risc-v/src/espressif/.gitignore
@@ -1,4 +1,4 @@
 /esp-wireless-drivers-3rdparty
 /esp-nuttx-bootloader
 /*.zip
-/hal_espressif
+/esp-hal-component
diff --git a/arch/risc-v/src/espressif/Make.defs b/arch/risc-v/src/espressif/Make.defs
index 5144c6d13f..4f1b589043 100644
--- a/arch/risc-v/src/espressif/Make.defs
+++ b/arch/risc-v/src/espressif/Make.defs
@@ -40,10 +40,10 @@ CHIP_CSRCS += esp_timerisr.c esp_wdt.c
 
 # Fetch Espressif HAL source files and add them to build
 
-HAL_ESPRESSIF_UNPACK = hal_espressif
-HAL_ESPRESSIF_ID     = 4ea8960de
+HAL_ESPRESSIF_UNPACK = esp-hal-component
+HAL_ESPRESSIF_ID     = c5160ae3
 HAL_ESPRESSIF_ZIP    = $(HAL_ESPRESSIF_ID).zip
-HAL_ESPRESSIF_URL    = https://github.com/gustavonihei/hal_espressif/archive
+HAL_ESPRESSIF_URL    = https://github.com/gustavonihei/esp-hal-component/archive
 
 $(HAL_ESPRESSIF_ZIP):
 	$(Q) echo "Downloading: HAL Espressif"
@@ -64,64 +64,7 @@ CFLAGS += -Wno-undef -Wno-unused-variable
 
 CHIP_SERIES = $(patsubst "%",%,$(CONFIG_ESPRESSIF_CHIP_SERIES))
 
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/bootloader_support/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/driver/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/private_include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/private_include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_common/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/include/soc)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES))
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/private_include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/include/$(CHIP_SERIES))
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES))
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/public_compat)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/platform_port/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/$(CHIP_SERIES)/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/log)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/log/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/riscv/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/include)
-INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/nuttx/$(CHIP_SERIES)/include)
-
-ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.ld
-ifeq ($(CONFIG_ESPRESSIF_ESP32C3),y)
-	ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.eco3.ld
-endif
-ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.api.ld
-ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.newlib.ld
-ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/ld/$(CHIP_SERIES).peripherals.ld
-
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/driver/periph_ctrl.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/src/esp_efuse_api.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/src/esp_efuse_utility.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_fields.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_table.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_utility.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/esp_clk.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/regi2c_ctrl.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/cpu_util_$(CHIP_SERIES).c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_clk.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_init.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_sleep.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_time.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/brownout.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/clk.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/uart_hal.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/uart_hal_iram.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/systimer_hal.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/wdt_hal_iram.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/$(CHIP_SERIES)/brownout_hal.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/log/log.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/log/log_noos.c
-CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/gpio_periph.c
+include chip/hal_${CHIP_SERIES}.mk
 
 context:: chip/$(HAL_ESPRESSIF_UNPACK)
 
diff --git a/arch/risc-v/src/espressif/esp_libc_stubs.c b/arch/risc-v/src/espressif/esp_libc_stubs.c
index 979d96aab1..95fd4d9cf5 100644
--- a/arch/risc-v/src/espressif/esp_libc_stubs.c
+++ b/arch/risc-v/src/espressif/esp_libc_stubs.c
@@ -27,10 +27,10 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/times.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <unistd.h>
 
 #include <nuttx/mutex.h>
@@ -50,13 +50,17 @@
  * Private Types
  ****************************************************************************/
 
-static mutex_t g_nxlock_common;
-static mutex_t g_nxlock_recursive;
-
 /* Forward declaration */
 
 struct _reent;
 
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static mutex_t g_nxlock_common;
+static mutex_t g_nxlock_recursive;
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -81,8 +85,7 @@ int _kill_r(struct _reent *r, int pid, int sig)
   return kill(pid, sig);
 }
 
-int _link_r(struct _reent *r, const char *oldpath,
-                      const char *newpath)
+int _link_r(struct _reent *r, const char *oldpath, const char *newpath)
 {
   /* TODO */
 
@@ -94,8 +97,7 @@ int lseek_r(struct _reent *r, int fd, int offset, int whence)
   return lseek(fd, offset, whence);
 }
 
-int _open_r(struct _reent *r, const char *pathname,
-                      int flags, int mode)
+int _open_r(struct _reent *r, const char *pathname, int flags, int mode)
 {
   return open(pathname, flags, mode);
 }
@@ -105,8 +107,7 @@ int read_r(struct _reent *r, int fd, void *buf, int count)
   return read(fd, buf, count);
 }
 
-int _rename_r(struct _reent *r, const char *oldpath,
-                        const char *newpath)
+int _rename_r(struct _reent *r, const char *oldpath, const char *newpath)
 {
   return rename(oldpath, newpath);
 }
@@ -119,8 +120,7 @@ void *_sbrk_r(struct _reent *r, ptrdiff_t increment)
   return (void *) -1;
 }
 
-int _stat_r(struct _reent *r, const char *pathname,
-                      struct stat *statbuf)
+int _stat_r(struct _reent *r, const char *pathname, struct stat *statbuf)
 {
   return stat(pathname, statbuf);
 }
@@ -319,59 +319,59 @@ void _cleanup_r(struct _reent *r)
 
 static const struct syscall_stub_table g_stub_table =
 {
-    .__getreent = &__getreent,
-    ._malloc_r = &_malloc_r,
-    ._free_r = &_free_r,
-    ._realloc_r = &_realloc_r,
-    ._calloc_r = &_calloc_r,
-    ._abort = &_abort,
-    ._system_r = &_system_r,
-    ._rename_r = &_rename_r,
-    ._times_r = &_times_r,
-    ._gettimeofday_r = &_gettimeofday_r,
-    ._raise_r = &_raise_r,
-    ._unlink_r = &_unlink_r,
-    ._link_r = &_link_r,
-    ._stat_r = &_stat_r,
-    ._fstat_r = &_fstat_r,
-    ._sbrk_r = &_sbrk_r,
-    ._getpid_r = &_getpid_r,
-    ._kill_r = &_kill_r,
-    ._exit_r = NULL,
-    ._close_r = &_close_r,
-    ._open_r = &_open_r,
-    ._write_r = &write_r,
-    ._lseek_r = &lseek_r,
-    ._read_r = &read_r,
+  .__getreent = &__getreent,
+  ._malloc_r = &_malloc_r,
+  ._free_r = &_free_r,
+  ._realloc_r = &_realloc_r,
+  ._calloc_r = &_calloc_r,
+  ._abort = &_abort,
+  ._system_r = &_system_r,
+  ._rename_r = &_rename_r,
+  ._times_r = &_times_r,
+  ._gettimeofday_r = &_gettimeofday_r,
+  ._raise_r = &_raise_r,
+  ._unlink_r = &_unlink_r,
+  ._link_r = &_link_r,
+  ._stat_r = &_stat_r,
+  ._fstat_r = &_fstat_r,
+  ._sbrk_r = &_sbrk_r,
+  ._getpid_r = &_getpid_r,
+  ._kill_r = &_kill_r,
+  ._exit_r = NULL,
+  ._close_r = &_close_r,
+  ._open_r = &_open_r,
+  ._write_r = &write_r,
+  ._lseek_r = &lseek_r,
+  ._read_r = &read_r,
 #if ESP_ROM_HAS_RETARGETABLE_LOCKING
-    ._retarget_lock_init = &__retarget_lock_init,
-    ._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
-    ._retarget_lock_close = &__retarget_lock_close,
-    ._retarget_lock_close_recursive = &__retarget_lock_close_recursive,
-    ._retarget_lock_acquire = &__retarget_lock_acquire,
-    ._retarget_lock_acquire_recursive = &__retarget_lock_acquire_recursive,
-    ._retarget_lock_try_acquire = &__retarget_lock_try_acquire,
-    ._retarget_lock_try_acquire_recursive =
-      &__retarget_lock_try_acquire_recursive,
-    ._retarget_lock_release = &__retarget_lock_release,
-    ._retarget_lock_release_recursive = &__retarget_lock_release_recursive,
+  ._retarget_lock_init = &__retarget_lock_init,
+  ._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
+  ._retarget_lock_close = &__retarget_lock_close,
+  ._retarget_lock_close_recursive = &__retarget_lock_close_recursive,
+  ._retarget_lock_acquire = &__retarget_lock_acquire,
+  ._retarget_lock_acquire_recursive = &__retarget_lock_acquire_recursive,
+  ._retarget_lock_try_acquire = &__retarget_lock_try_acquire,
+  ._retarget_lock_try_acquire_recursive =
+    &__retarget_lock_try_acquire_recursive,
+  ._retarget_lock_release = &__retarget_lock_release,
+  ._retarget_lock_release_recursive = &__retarget_lock_release_recursive,
 #else
-    ._lock_init = &_lock_init,
-    ._lock_init_recursive = &_lock_init_recursive,
-    ._lock_close = &_lock_close,
-    ._lock_close_recursive = &_lock_close_recursive,
-    ._lock_acquire = &_lock_acquire,
-    ._lock_acquire_recursive = &_lock_acquire_recursive,
-    ._lock_try_acquire = &_lock_try_acquire,
-    ._lock_try_acquire_recursive = &_lock_try_acquire_recursive,
-    ._lock_release = &_lock_release,
-    ._lock_release_recursive = &_lock_release_recursive,
+  ._lock_init = &_lock_init,
+  ._lock_init_recursive = &_lock_init_recursive,
+  ._lock_close = &_lock_close,
+  ._lock_close_recursive = &_lock_close_recursive,
+  ._lock_acquire = &_lock_acquire,
+  ._lock_acquire_recursive = &_lock_acquire_recursive,
+  ._lock_try_acquire = &_lock_try_acquire,
+  ._lock_try_acquire_recursive = &_lock_try_acquire_recursive,
+  ._lock_release = &_lock_release,
+  ._lock_release_recursive = &_lock_release_recursive,
 #endif
-    ._printf_float = NULL,
-    ._scanf_float = NULL,
-    .__assert_func = &__assert_func,
-    .__sinit = (void *)abort,
-    ._cleanup_r = &_cleanup_r,
+  ._printf_float = NULL,
+  ._scanf_float = NULL,
+  .__assert_func = &__assert_func,
+  .__sinit = (void *)abort,
+  ._cleanup_r = &_cleanup_r
 };
 
 /****************************************************************************
diff --git a/arch/risc-v/src/espressif/esp_lowputc.c b/arch/risc-v/src/espressif/esp_lowputc.c
index 688d242659..4f1ef3eb8b 100644
--- a/arch/risc-v/src/espressif/esp_lowputc.c
+++ b/arch/risc-v/src/espressif/esp_lowputc.c
@@ -44,8 +44,8 @@
 #include "esp_irq.h"
 #include "esp_lowputc.h"
 
-#include "driver/periph_ctrl.h"
 #include "hal/uart_hal.h"
+#include "periph_ctrl.h"
 #include "soc/gpio_sig_map.h"
 
 /****************************************************************************
@@ -262,16 +262,16 @@ void esp_lowputc_config_pins(const struct esp_uart_s *priv)
 {
   /* Configure the pins */
 
+  esp_configgpio(priv->txpin, OUTPUT);
   esp_gpio_matrix_out(priv->txpin, priv->txsig, 0, 0);
-  esp_configgpio(priv->txpin, OUTPUT_FUNCTION_1);
 
-  esp_configgpio(priv->rxpin, INPUT_FUNCTION_1);
+  esp_configgpio(priv->rxpin, INPUT | PULLUP);
   esp_gpio_matrix_in(priv->rxpin, priv->rxsig, 0);
 
 #ifdef CONFIG_SERIAL_IFLOWCONTROL
   if (priv->iflow)
     {
-      esp_configgpio(priv->rtspin, OUTPUT_FUNCTION_1);
+      esp_configgpio(priv->rtspin, OUTPUT);
       esp_gpio_matrix_out(priv->rtspin, priv->rtssig, 0, 0);
     }
 
@@ -279,7 +279,7 @@ void esp_lowputc_config_pins(const struct esp_uart_s *priv)
 #ifdef CONFIG_SERIAL_OFLOWCONTROL
   if (priv->oflow)
     {
-      esp_configgpio(priv->ctspin, INPUT_FUNCTION_1);
+      esp_configgpio(priv->ctspin, INPUT | PULLUP);
       esp_gpio_matrix_in(priv->ctspin, priv->ctssig, 0);
     }
 #endif
diff --git a/arch/risc-v/src/espressif/esp_serial.c b/arch/risc-v/src/espressif/esp_serial.c
index e7162998e3..6d024dacd0 100644
--- a/arch/risc-v/src/espressif/esp_serial.c
+++ b/arch/risc-v/src/espressif/esp_serial.c
@@ -47,7 +47,9 @@
 #include "esp_irq.h"
 #include "esp_lowputc.h"
 
+#include "clk_tree.h"
 #include "hal/uart_hal.h"
+#include "soc/clk_tree_defs.h"
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -361,6 +363,7 @@ static void esp_serial_set_stop_length(const struct esp_uart_s *priv)
 static int esp_setup(uart_dev_t *dev)
 {
   struct esp_uart_s *priv = dev->priv;
+  uint32_t sclk_freq;
 
   uart_hal_init(priv->hal, priv->id);
 
@@ -397,7 +400,10 @@ static int esp_setup(uart_dev_t *dev)
   esp_lowputc_enable_sysclk(priv);
 
   uart_hal_set_sclk(priv->hal, UART_SCLK_APB);
-  uart_hal_set_baudrate(priv->hal, priv->baud);
+  clk_tree_src_get_freq_hz(SOC_MOD_CLK_APB,
+                           CLK_TREE_SRC_FREQ_PRECISION_CACHED,
+                           &sclk_freq);
+  uart_hal_set_baudrate(priv->hal, priv->baud, sclk_freq);
   uart_hal_set_parity(priv->hal, priv->parity);
   uart_hal_set_tx_idle_num(priv->hal, 0);
 
diff --git a/arch/risc-v/src/espressif/esp_start.c b/arch/risc-v/src/espressif/esp_start.c
index b75f41e466..73fc0dff5c 100644
--- a/arch/risc-v/src/espressif/esp_start.c
+++ b/arch/risc-v/src/espressif/esp_start.c
@@ -37,7 +37,7 @@
 
 #include "brownout.h"
 #include "esp_clk_internal.h"
-#include "soc/cpu.h"
+#include "esp_cpu.h"
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/arch/risc-v/src/espressif/esp_timerisr.c b/arch/risc-v/src/espressif/esp_timerisr.c
index bfbf631689..b6a4baddc0 100644
--- a/arch/risc-v/src/espressif/esp_timerisr.c
+++ b/arch/risc-v/src/espressif/esp_timerisr.c
@@ -36,6 +36,8 @@
 
 #include "hal/systimer_hal.h"
 #include "hal/systimer_ll.h"
+#include "periph_ctrl.h"
+#include "systimer.h"
 
 /****************************************************************************
  * Private Data
@@ -65,7 +67,7 @@ static systimer_hal_context_t systimer_hal;
 static int systimer_irq_handler(int irq, void *context, void *arg)
 {
   systimer_ll_clear_alarm_int(systimer_hal.dev,
-                              SYSTIMER_LL_ALARM_OS_TICK_CORE0);
+                              SYSTIMER_ALARM_OS_TICK_CORE0);
 
   /* Process timer interrupt */
 
@@ -95,22 +97,39 @@ static int systimer_irq_handler(int irq, void *context, void *arg)
 
 void up_timer_initialize(void)
 {
+  periph_module_enable(PERIPH_SYSTIMER_MODULE);
   systimer_hal_init(&systimer_hal);
+  systimer_hal_tick_rate_ops_t ops =
+    {
+      .ticks_to_us = systimer_ticks_to_us,
+      .us_to_ticks = systimer_us_to_ticks,
+    };
+
+  systimer_hal_set_tick_rate_ops(&systimer_hal, &ops);
+  systimer_ll_set_counter_value(systimer_hal.dev,
+                                SYSTIMER_COUNTER_OS_TICK,
+                                0);
+  systimer_ll_apply_counter_value(systimer_hal.dev,
+                                  SYSTIMER_COUNTER_OS_TICK);
+  systimer_hal_counter_can_stall_by_cpu(&systimer_hal,
+                                        SYSTIMER_COUNTER_OS_TICK, 0,
+                                        false);
+
   systimer_hal_connect_alarm_counter(&systimer_hal,
-                                     SYSTIMER_LL_ALARM_OS_TICK_CORE0,
-                                     SYSTIMER_LL_COUNTER_OS_TICK);
+                                     SYSTIMER_ALARM_OS_TICK_CORE0,
+                                     SYSTIMER_COUNTER_OS_TICK);
   systimer_hal_set_alarm_period(&systimer_hal,
-                                SYSTIMER_LL_ALARM_OS_TICK_CORE0,
+                                SYSTIMER_ALARM_OS_TICK_CORE0,
                                 CONFIG_USEC_PER_TICK);
   systimer_hal_select_alarm_mode(&systimer_hal,
-                                 SYSTIMER_LL_ALARM_OS_TICK_CORE0,
+                                 SYSTIMER_ALARM_OS_TICK_CORE0,
                                  SYSTIMER_ALARM_MODE_PERIOD);
   systimer_hal_counter_can_stall_by_cpu(&systimer_hal,
-                                        SYSTIMER_LL_COUNTER_OS_TICK, 0,
+                                        SYSTIMER_COUNTER_OS_TICK, 0,
                                         true);
   systimer_hal_enable_alarm_int(&systimer_hal,
-                                SYSTIMER_LL_ALARM_OS_TICK_CORE0);
-  systimer_hal_enable_counter(&systimer_hal, SYSTIMER_LL_COUNTER_OS_TICK);
+                                SYSTIMER_ALARM_OS_TICK_CORE0);
+  systimer_hal_enable_counter(&systimer_hal, SYSTIMER_COUNTER_OS_TICK);
 
   esp_setup_irq(ESP_PERIPH_SYSTIMER_T0, ESP_IRQ_PRIORITY_DEFAULT,
                 ESP_IRQ_TRIGGER_LEVEL);
diff --git a/arch/risc-v/src/espressif/hal_esp32c3.mk b/arch/risc-v/src/espressif/hal_esp32c3.mk
new file mode 100644
index 0000000000..0da54d663a
--- /dev/null
+++ b/arch/risc-v/src/espressif/hal_esp32c3.mk
@@ -0,0 +1,93 @@
+############################################################################
+# arch/risc-v/src/espressif/esp32c3.mk
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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.
+#
+############################################################################
+
+# Include header paths
+
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/driver/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/private_include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/private_include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_common/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/include/esp_private
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/include/soc
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/private_include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/include/$(CHIP_SERIES)
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/include/private/esp_private
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/public_compat
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/$(CHIP_SERIES)/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/platform_port/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/log
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/log/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/riscv/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/nuttx/$(CHIP_SERIES)/include
+
+# Linker scripts
+
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.ld
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.eco3.ld
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.api.ld
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.newlib.ld
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_rom/$(CHIP_SERIES)/ld/$(CHIP_SERIES).rom.version.ld
+ARCHSCRIPT += $(ARCH_SRCDIR)/chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/ld/$(CHIP_SERIES).peripherals.ld
+
+# Source files
+
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/src/esp_efuse_api.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/src/esp_efuse_utility.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_fields.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_table.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/efuse/$(CHIP_SERIES)/esp_efuse_utility.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/cpu.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/esp_clk.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/periph_ctrl.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/regi2c_ctrl.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/clk_tree_common.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/clk_tree.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_clk.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_init.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_sleep.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/rtc_time.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/sar_periph_ctrl.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/systimer.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/brownout.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/clk.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/brownout_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/efuse_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/systimer_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/uart_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/uart_hal_iram.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/wdt_hal_iram.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/$(CHIP_SERIES)/clk_tree_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/hal/$(CHIP_SERIES)/efuse_hal.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/log/log.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/log/log_noos.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/riscv/interrupt.c
+CHIP_CSRCS += chip/$(HAL_ESPRESSIF_UNPACK)/components/soc/$(CHIP_SERIES)/gpio_periph.c