Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Documentation/platforms/risc-v/esp32c6/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,9 @@ Makefile/CMake Variables for ULP Core Build:
- ``ULP_APP_C_SRCS``: Lists all C source files (.c) that need to be compiled for the ULP application.
- ``ULP_APP_ASM_SRCS``: Lists all assembly source files (.S or .s) to be assembled.
- ``ULP_APP_INCLUDES``: Specifies additional include directories for the compiler and assembler.
- ``ULP_CUSTOM_SECTIONS_LD``: Optional. Replaces the default ``${CHIP_SERIES}_lpcore_sections.ld`` linker template.
- ``ULP_EXTRA_DEFINES``: Optional. Extra compile definitions for the ULP firmware
- ``ULP_POST_LINK``: Optional (Make only). Commands run after linking.

Here is an Makefile example when using prebuilt binary for ULP core:

Expand Down
3 changes: 3 additions & 0 deletions Documentation/platforms/risc-v/esp32p4/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ Makefile/CMake Variables for ULP Core Build:
- ``ULP_APP_C_SRCS``: Lists all C source files (.c) that need to be compiled for the ULP application.
- ``ULP_APP_ASM_SRCS``: Lists all assembly source files (.S or .s) to be assembled.
- ``ULP_APP_INCLUDES``: Specifies additional include directories for the compiler and assembler.
- ``ULP_CUSTOM_SECTIONS_LD``: Optional. Replaces the default ``${CHIP_SERIES}_lpcore_sections.ld`` linker template.
- ``ULP_EXTRA_DEFINES``: Optional. Extra compile definitions for the ULP firmware
- ``ULP_POST_LINK``: Optional (Make only). Commands run after linking.

Here is an Makefile example when using prebuilt binary for ULP core:

Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/espressif/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
31 changes: 30 additions & 1 deletion arch/risc-v/src/common/espressif/esp_lp_mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <nuttx/debug.h>

#include "lp_core_mailbox.h"
#include "soc/soc_caps.h"

/****************************************************************************
* Pre-processor Definitions
Expand All @@ -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);
Expand All @@ -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 */
Expand All @@ -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
*
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
52 changes: 43 additions & 9 deletions arch/risc-v/src/common/espressif/esp_ulp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)

set(ULP_LPCORE_SECTIONS_LD
${ULP_BOARD_SCRIPTS_DIR}/${CHIP_SERIES}_lpcore_sections.ld)
if(ULP_CUSTOM_SECTIONS_LD)
set(ULP_LPCORE_SECTIONS_LD ${ULP_CUSTOM_SECTIONS_LD})
endif()
set(ULP_SECTIONS_LD ${ULP_FOLDER}/ulp_sections.ld)
set(ULP_MAPGEN_TOOL ${HAL}/components/ulp/esp32ulp_mapgen.py)

Expand Down Expand Up @@ -116,6 +119,8 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
${HAL}/components/esp_rom/${CHIP_SERIES}/include/${CHIP_SERIES}
${HAL}/components/hal/include
${HAL}/components/hal/platform_port/include
${HAL}/components/esp_hal_wdt/include
${HAL}/components/esp_hal_wdt/${CHIP_SERIES}/include
${HAL}/components/log
${HAL}/components/log/include
${HAL}/components/riscv/include
Expand Down Expand Up @@ -201,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
Expand All @@ -211,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()

# ############################################################################
Expand Down Expand Up @@ -311,17 +321,29 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
set(ULP_NUTTX_CONFIG_COPY ${ULP_FOLDER}/nuttx/config.h)

foreach(_ulp_csrc ${ULP_APP_C_SRCS})
list(APPEND ULP_APP_C_SOURCES ${ULP_APP_FOLDER}/${_ulp_csrc})
if(IS_ABSOLUTE "${_ulp_csrc}")
list(APPEND ULP_APP_C_SOURCES ${_ulp_csrc})
else()
list(APPEND ULP_APP_C_SOURCES ${ULP_APP_FOLDER}/${_ulp_csrc})
endif()
endforeach()

foreach(_ulp_asrc ${ULP_APP_ASM_SRCS})
list(APPEND ULP_APP_ASM_SOURCES ${ULP_APP_FOLDER}/${_ulp_asrc})
if(IS_ABSOLUTE "${_ulp_asrc}")
list(APPEND ULP_APP_ASM_SOURCES ${_ulp_asrc})
else()
list(APPEND ULP_APP_ASM_SOURCES ${ULP_APP_FOLDER}/${_ulp_asrc})
endif()
endforeach()

if(ULP_APP_INCLUDES)
foreach(_ulp_incl ${ULP_APP_INCLUDES})
get_filename_component(_ulp_incl_dir ${_ulp_incl} DIRECTORY)
list(APPEND ULP_APP_INCLUDE_DIRS ${_ulp_incl_dir})
if(IS_DIRECTORY "${_ulp_incl}")
list(APPEND ULP_APP_INCLUDE_DIRS ${_ulp_incl})
else()
get_filename_component(_ulp_incl_dir ${_ulp_incl} DIRECTORY)
list(APPEND ULP_APP_INCLUDE_DIRS ${_ulp_incl_dir})
endif()
endforeach()
list(REMOVE_DUPLICATES ULP_APP_INCLUDE_DIRS)
list(APPEND ULP_INCLUDE_DIRS ${ULP_APP_INCLUDE_DIRS})
Expand Down Expand Up @@ -375,6 +397,10 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
target_include_directories(${ULP_FIRMWARE_TARGET}
PRIVATE ${ULP_INCLUDE_DIRS})
target_compile_definitions(${ULP_FIRMWARE_TARGET} PRIVATE IS_ULP_COCPU)
if(ULP_EXTRA_DEFINES)
target_compile_definitions(${ULP_FIRMWARE_TARGET}
PRIVATE ${ULP_EXTRA_DEFINES})
endif()
target_compile_options(
${ULP_FIRMWARE_TARGET}
PRIVATE ${ULP_COMPILE_OPTS}
Expand All @@ -399,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]=]
)
Expand All @@ -408,7 +441,7 @@ if(CONFIG_ESPRESSIF_USE_LP_CORE)
_ulp_postprocess_aliases "${_ulp_postprocess_aliases}")

set(_ulp_postprocess_var_map
[=[if ! grep -q "struct ulp_var_map_s ulp_var_map" "@ULP_VAR_MAP_HEADER@"; then printf '%s\n' '#include "nuttx/symtab.h"' '#include "ulp/ulp_vars.h"' '' 'struct ulp_var_map_s' '{' ' struct symtab_s sym;' ' size_t size;' '};' '' 'struct ulp_var_map_s ulp_var_map[] =' '{ };' > "@ULP_VAR_MAP_HEADER@"; fi; sed -i "/@ULP_PREFIX@/d" "@ULP_VAR_MAP_HEADER@"; flock -x "@ULP_LOCKFILE@" -c 'grep "@ULP_PREFIX@" "@ULP_MAIN_HEADER@" | while IFS= read -r line; do var=$(echo "$line" | grep -oP "@ULP_PREFIX@\w+(?=[;\[])" ); if [ -n "$var" ]; then size=$(echo "$line" | grep -oP "\[\d+\]" | grep -oP "\d+"); if [ -n "$size" ]; then size=$(( size * 4 )); else size=4; fi; sed -i "s/ };//" "@ULP_VAR_MAP_HEADER@"; echo -ne " { .sym.sym_name = \"${var}\", .sym.sym_value = &${var}, .size = ${size}},\n };" >> "@ULP_VAR_MAP_HEADER@"; fi; done']=]
[=[if ! grep -q "struct ulp_var_map_s ulp_var_map" "@ULP_VAR_MAP_HEADER@"; then printf '%s\n' '#include "nuttx/symtab.h"' '#include "ulp/ulp_vars.h"' '' 'struct ulp_var_map_s' '{' ' struct symtab_s sym;' ' size_t size;' '};' '' 'struct ulp_var_map_s ulp_var_map[] =' '{ };' > "@ULP_VAR_MAP_HEADER@"; fi; sed -i "/@ULP_PREFIX@/d" "@ULP_VAR_MAP_HEADER@"; flock -x "@ULP_LOCKFILE@" -c 'grep "@ULP_PREFIX@" "@ULP_MAIN_HEADER@" | while IFS= read -r line; do var=$(echo "$line" | grep -oP "@ULP_PREFIX@\w+(?=[;\[])" ); if [ -n "$var" ]; then size=$(echo "$line" | grep -oP "\[\d+\]" | grep -oP "\d+"); if [ -n "$size" ]; then size=$(( size * 4 )); else size=4; fi; sed -i "s/ };//" "@ULP_VAR_MAP_HEADER@"; printf " { .sym.sym_name = \"%s\", .sym.sym_value = &%s, .size = %s},\n };" "${var}" "${var}" "${size}" >> "@ULP_VAR_MAP_HEADER@"; fi; done']=]
)
string(REPLACE "@ULP_VAR_MAP_HEADER@" "${ULP_VAR_MAP_HEADER}"
_ulp_postprocess_var_map "${_ulp_postprocess_var_map}")
Expand All @@ -427,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
Expand Down
38 changes: 32 additions & 6 deletions arch/risc-v/src/common/espressif/esp_ulp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)c
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)platform_port$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_wdt$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_wdt$(DELIM)$(CHIP_SERIES)$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)include
ULP_INCLUDES += $(INCDIR_PREFIX)$(CHIP)$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)riscv$(DELIM)include
Expand Down Expand Up @@ -141,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
Expand All @@ -159,8 +163,8 @@ else
ULP_BIN_FILE = $(ULP_FOLDER)$(DELIM)ulp.bin
ULP_BIN_FILE_PATH = $(ULP_BIN_FILE)

ULP_C_SRCS = $(addprefix $(ULP_APP_FOLDER)/,$(sort $(ULP_APP_C_SRCS)))
ULP_ASM_SRCS = $(addprefix $(ULP_APP_FOLDER)/,$(sort $(ULP_APP_ASM_SRCS)))
ULP_C_SRCS = $(foreach s,$(sort $(ULP_APP_C_SRCS)),$(if $(filter /%,$(s)),$(s),$(ULP_APP_FOLDER)/$(s)))
ULP_ASM_SRCS = $(foreach s,$(sort $(ULP_APP_ASM_SRCS)),$(if $(filter /%,$(s)),$(s),$(ULP_APP_FOLDER)/$(s)))

ULP_APP_OBJS = $(ULP_ASM_SRCS:.S=_ulp.o)
ULP_APP_OBJS += $(ULP_C_SRCS:.c=_ulp.o)
Expand Down Expand Up @@ -250,6 +254,17 @@ ULP_LDFLAGS := \
-Xlinker -Map=$(ULP_MAP_FILE) \
$(ULP_LDINCLUDES)

# Optional compile defines (e.g. -DNUTTX_ESP_BIST_MODULE) — after := above
ULP_CFLAGS += $(ULP_EXTRA_DEFINES)
ULP_ASFLAGS += $(ULP_EXTRA_DEFINES)

# Default LP sections linker template; apps may override with ULP_CUSTOM_SECTIONS_LD
ifeq ($(ULP_CUSTOM_SECTIONS_LD),)
ULP_SECTIONS_TEMPLATE = $(BOARD)$(DELIM)scripts$(DELIM)${CHIP_SERIES}_lpcore_sections.ld
else
ULP_SECTIONS_TEMPLATE = $(ULP_CUSTOM_SECTIONS_LD)
endif

# Build rules

.PHONY: context depend
Expand All @@ -261,22 +276,26 @@ checkpython3:
exit 1; \
fi

%_ulp.o: %.c $(ULP_NUTTX_CONFIG)
%_ulp.o: %.c $(ULP_NUTTX_CONFIG) $(ULP_FOLDER)$(DELIM)ulp_sections.ld
$(Q) echo "Compiling $< for ULP"
$(Q) $(CC) $(ULP_CFLAGS) -c $< -o $@
$(Q) $(CC) $(ULP_INCLUDES) -E -P -xc -o $(ULP_FOLDER)$(DELIM)ulp_sections.ld $(BOARD)$(DELIM)scripts$(DELIM)${CHIP_SERIES}_lpcore_sections.ld

%_ulp.o: %.S $(ULP_NUTTX_CONFIG)
$(Q) echo "Compiling $< for ULP"
$(Q) $(CC) $(ULP_ASFLAGS) -c $< -o $@

$(ULP_FOLDER)$(DELIM)ulp_sections.ld: $(ULP_NUTTX_CONFIG) $(ULP_SECTIONS_TEMPLATE)
$(Q) echo "Preprocessing ULP linker sections from $(ULP_SECTIONS_TEMPLATE)"
$(Q) $(CC) $(ULP_INCLUDES) -E -P -xc -o $@ $(ULP_SECTIONS_TEMPLATE)

$(ULP_NUTTX_CONFIG): $(ULP_FOLDER)
$(Q) echo "Copying nuttx$(DELIM)config.h into $(ULP_FOLDER)$(DELIM)nuttx"
$(Q) cp $(TOPDIR)$(DELIM)include$(DELIM)nuttx$(DELIM)config.h $(ULP_FOLDER)$(DELIM)nuttx

$(ULP_ELF_FILE): $(ULP_OBJS)
$(Q) echo "Linking for ULP"
$(Q) $(CC) $(ULP_LDFLAGS) $(ULP_OBJS) -o $@
$(ULP_POST_LINK)

$(ULP_BIN_FILE): $(ULP_ELF_FILE) checkpython3
$(Q) \
Expand All @@ -288,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; \
Expand Down Expand Up @@ -317,7 +343,7 @@ ifneq ($(suffix $(ULP_APP_BIN)),.bin)
size=4; \
fi; \
sed -i "s/ };//" $(ULP_VAR_MAP_HEADER); \
echo -ne " { .sym.sym_name = \"$${var}\", .sym.sym_value = &$${var}, .size = $${size}},\n };" >> $(ULP_VAR_MAP_HEADER); \
printf " { .sym.sym_name = \"%s\", .sym.sym_value = &%s, .size = %s},\n };" "$${var}" "$${var}" "$${size}" >> $(ULP_VAR_MAP_HEADER); \
fi; \
done'
endif
Expand Down
4 changes: 4 additions & 0 deletions arch/risc-v/src/esp32c6/hal_esp32c6.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
Loading
Loading