mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/risc-v/espressif: Add SW LP Mailbox support
Add software lp mailbox support Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
This commit is contained in:
parent
50a7831e49
commit
9c96d876d1
6 changed files with 66 additions and 7 deletions
|
|
@ -1732,7 +1732,7 @@ config ESPRESSIF_ANA_COMPR1
|
|||
config ESPRESSIF_LP_MAILBOX
|
||||
bool "LP Mailbox"
|
||||
default n
|
||||
depends on ARCH_CHIP_ESP32P4 && ESPRESSIF_USE_LP_CORE
|
||||
depends on ESPRESSIF_USE_LP_CORE
|
||||
---help---
|
||||
Enable lp mailbox support for data passing between cores.
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <nuttx/debug.h>
|
||||
|
||||
#include "lp_core_mailbox.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
|
@ -52,6 +53,7 @@ struct esp_lp_mailbox_priv_s
|
|||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int esp_lp_mailbox_open(struct file *filep);
|
||||
static int esp_lp_mailbox_read(struct file *filep,
|
||||
char *buffer,
|
||||
size_t buflen);
|
||||
|
|
@ -68,7 +70,7 @@ static int esp_lp_mailbox_ioctl(struct file *filep,
|
|||
|
||||
static const struct file_operations g_esp_lp_mailbox_fops =
|
||||
{
|
||||
.open = NULL, /* open */
|
||||
.open = esp_lp_mailbox_open, /* open */
|
||||
.close = NULL, /* close */
|
||||
.read = esp_lp_mailbox_read, /* read */
|
||||
.write = esp_lp_mailbox_write, /* write */
|
||||
|
|
@ -91,6 +93,31 @@ struct esp_lp_mailbox_priv_s esp_lp_mailbox_priv =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_lp_mailbox_open
|
||||
*
|
||||
* Description:
|
||||
* Handler for the LP Mailbox initializer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* filep - Pointer to the file structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int esp_lp_mailbox_open(struct file *filep)
|
||||
{
|
||||
int ret = OK;
|
||||
#ifndef SOC_LP_MAILBOX_SUPPORTED
|
||||
ret = lp_core_mailbox_init(&esp_lp_mailbox_priv.mailbox,
|
||||
&esp_lp_mailbox_priv.config);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_lp_mailbox_rcv_callback
|
||||
*
|
||||
|
|
@ -312,6 +339,7 @@ static int esp_lp_mailbox_ioctl(struct file *filep,
|
|||
|
||||
int esp_lp_mailbox_init(void)
|
||||
{
|
||||
#ifdef SOC_LP_MAILBOX_SUPPORTED
|
||||
int ret = lp_core_mailbox_init(&esp_lp_mailbox_priv.mailbox,
|
||||
&esp_lp_mailbox_priv.config);
|
||||
|
||||
|
|
@ -320,6 +348,7 @@ int esp_lp_mailbox_init(void)
|
|||
ferr("Failed to initialize LP Mailbox driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
register_driver("/dev/lp_mailbox", esp_lp_mailbox_priv.ops,
|
||||
0600, (void *)&esp_lp_mailbox_priv);
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
|
|||
${HAL}/components/ulp/lp_core/lp_core/lp_core_startup.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_utils.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_uart.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_mailbox.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_print.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_panic.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_interrupt.c
|
||||
|
|
@ -216,10 +217,14 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
|
|||
)
|
||||
|
||||
if(CONFIG_ARCH_CHIP_ESP32P4)
|
||||
list(
|
||||
APPEND ULP_CSOURCES ${HAL}/components/ulp/lp_core/lp_core/lp_core_touch.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_hw.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_mailbox.c)
|
||||
list(APPEND ULP_CSOURCES
|
||||
${HAL}/components/ulp/lp_core/lp_core/lp_core_touch.c
|
||||
${HAL}/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_hw.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARCH_CHIP_ESP32C6)
|
||||
list(APPEND ULP_CSOURCES
|
||||
${HAL}/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_sw.c)
|
||||
endif()
|
||||
|
||||
# ############################################################################
|
||||
|
|
@ -420,6 +425,13 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
|
|||
COMMENT "Linking ULP firmware"
|
||||
VERBATIM)
|
||||
|
||||
set(_ulp_postprocess_sw_mailbox_alias
|
||||
[=[if grep -q 'g_lp_core_mailbox_impl_sw_ctx' "@ULP_MAIN_LD@"; then addr=$(grep 'g_lp_core_mailbox_impl_sw_ctx' "@ULP_MAIN_LD@" | head -1 | sed -E 's/.*=[[:space:]]*([0x0-9a-fA-F]+);.*/\1/'); if ! grep -qE '^[[:space:]]*ulp_g_lp_core_mailbox_impl_sw_ctx[[:space:]]*=' "@ULP_MAIN_LD@"; then echo "ulp_g_lp_core_mailbox_impl_sw_ctx = ${addr};" >> "@ULP_MAIN_LD@"; fi; fi]=]
|
||||
)
|
||||
string(REPLACE "@ULP_MAIN_LD@" "${ULP_MAIN_LD}"
|
||||
_ulp_postprocess_sw_mailbox_alias
|
||||
"${_ulp_postprocess_sw_mailbox_alias}")
|
||||
|
||||
set(_ulp_postprocess_aliases
|
||||
[=[grep -E '^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]*=[[:space:]]*[0x]*[0-9a-fA-F]+;' "@ULP_MAIN_LD@" | while IFS= read -r line; do var_name=$(echo "$line" | sed -E 's/^[[:space:]]*([a-zA-Z_][a-zA-Z0-9_]*).*/\1/'); existing_line=$(grep -E "^[[:space:]]*${var_name}[[:space:]]*=" "@ULP_ALIASES_LD@" 2>/dev/null || true); if [ -n "$existing_line" ]; then if [ "$existing_line" != "$line" ]; then sed -i "/${existing_line}/c\\${line}" "@ULP_ALIASES_LD@"; fi; else echo "$line" >> "@ULP_ALIASES_LD@"; fi; done]=]
|
||||
)
|
||||
|
|
@ -448,6 +460,7 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
|
|||
COMMAND ${ULP_READELF} -sW ${ULP_ELF_FILE} > ${ULP_SYM_FILE}
|
||||
COMMAND ${Python3_EXECUTABLE} ${ULP_MAPGEN_TOOL} -s ${ULP_SYM_FILE} -o
|
||||
${ULP_FOLDER}/ulp_main --base ${ULP_BASE} --prefix ${ULP_PREFIX}
|
||||
COMMAND bash -c "${_ulp_postprocess_sw_mailbox_alias}"
|
||||
COMMAND bash -c "${_ulp_postprocess_aliases}"
|
||||
COMMAND sed -i "/${ULP_PREFIX}/d" ${ULP_VARS_HEADER}
|
||||
COMMAND
|
||||
|
|
|
|||
|
|
@ -143,10 +143,12 @@ ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM
|
|||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_lp_adc_shared.c
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_lp_vad_shared.c
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_critical_section_shared.c
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core$(DELIM)lp_core_mailbox.c
|
||||
ifeq ($(CONFIG_ARCH_CHIP_ESP32P4),y)
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core$(DELIM)lp_core_touch.c
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core$(DELIM)port$(DELIM)lp_core_mailbox_impl_hw.c
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core$(DELIM)lp_core_mailbox.c
|
||||
else
|
||||
ULP_CSOURCES += $(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core$(DELIM)port$(DELIM)lp_core_mailbox_impl_sw.c
|
||||
endif
|
||||
|
||||
# Add ULP app source files and directories
|
||||
|
|
@ -305,6 +307,13 @@ ifneq ($(suffix $(ULP_APP_BIN)),.bin)
|
|||
$(Q) $(OBJCOPY) -O binary $(ULP_ELF_FILE) $(ULP_BIN_FILE)
|
||||
$(Q) $(ULP_READELF) -sW $(ULP_ELF_FILE) > $(ULP_SYM_FILE)
|
||||
$(Q) python3 $(ULP_MAPGEN_TOOL_PATH) -s $(ULP_SYM_FILE) -o $(ULP_FOLDER)$(DELIM)ulp_main --base $(ULP_BASE) --prefix $(ULP_PREFIX)
|
||||
$(Q) if grep -q 'g_lp_core_mailbox_impl_sw_ctx' $(ULP_FOLDER)$(DELIM)ulp_main.ld; then \
|
||||
addr=$$(grep 'g_lp_core_mailbox_impl_sw_ctx' $(ULP_FOLDER)$(DELIM)ulp_main.ld | head -1 | \
|
||||
sed -E 's/.*=[[:space:]]*([0x0-9a-fA-F]+);.*/\1/'); \
|
||||
if ! grep -qE '^[[:space:]]*ulp_g_lp_core_mailbox_impl_sw_ctx[[:space:]]*=' $(ULP_FOLDER)$(DELIM)ulp_main.ld; then \
|
||||
echo "ulp_g_lp_core_mailbox_impl_sw_ctx = $$addr;" >> $(ULP_FOLDER)$(DELIM)ulp_main.ld; \
|
||||
fi; \
|
||||
fi
|
||||
# Checking ULP linker script output and adding/changing related lines on common linker for HP core to access ULP core variables on HP core.
|
||||
$(Q) grep -E '^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]*=[[:space:]]*[0x]*[0-9a-fA-F]+;' $(ULP_FOLDER)$(DELIM)ulp_main.ld | while IFS= read -r line; do \
|
||||
out_file=$(BOARD)$(DELIM)scripts$(DELIM)ulp_aliases.ld; \
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ list(
|
|||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/mac_addr.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/modem_clock.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/periph_ctrl.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/pmu_share_hw.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/regi2c_ctrl.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/rtc_module.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/sleep_console.c
|
||||
|
|
@ -504,6 +505,9 @@ list(
|
|||
HAL_SRCS
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/lp_core_i2c.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/lp_core.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/lp_core_mailbox.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/lp_core_mailbox_impl_sw.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/shared/ulp_lp_core_critical_section_shared.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/shared/ulp_lp_core_memory_shared.c
|
||||
${ESP_HAL_3RDPARTY_REPO}/components/ulp/lp_core/shared/ulp_lp_core_lp_timer_shared.c
|
||||
)
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)mac_addr.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)modem_clock.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)periph_ctrl.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)pmu_share_hw.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)regi2c_ctrl.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)rtc_module.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)sleep_console.c
|
||||
|
|
@ -364,6 +365,9 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_flash$(DELIM)cache_utils.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core_i2c.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core_mailbox.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)lp_core_mailbox_impl_sw.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_critical_section_shared.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_memory_shared.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)ulp$(DELIM)lp_core$(DELIM)shared$(DELIM)ulp_lp_core_lp_timer_shared.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src$(DELIM)rmt_common.c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue