feat(lp-core): Added ability to print from LP ROM on the LP core

This commit adds the ability to use LP ROM functions from the LP core.
This allows the LP core code to utilize standard functions such as those
for printing from the LP ROM and therefore help reduce the code size on
the LP core.
pull/13306/head
Sudeep Mohanty 2024-03-11 12:15:09 +01:00
rodzic 26fd843376
commit b90a279587
5 zmienionych plików z 40 dodań i 1 usunięć

Wyświetl plik

@ -80,4 +80,16 @@ menu "Ultra Low Power (ULP) Co-processor"
Size of the shared memory defined in ulp_lp_core_memory_shared.c.
Size should be kept in-sync with the size of the struct defined there.
config ULP_ROM_PRINT_ENABLE
depends on ULP_COPROC_TYPE_LP_CORE && ESP_ROM_HAS_LP_ROM
bool
prompt "Enable print utilities from LP ROM"
default "y"
help
Set this option to enable printf functionality from LP ROM. This option
can help reduce the LP core binary size by not linking printf functionality
from RAM code.
Note: For LP ROM prints to work properly, make sure that the LP core boots
from the LP ROM.
endmenu # Ultra Low Power (ULP) Co-processor

Wyświetl plik

@ -54,6 +54,7 @@ target_link_options(${ULP_APP_NAME} PRIVATE SHELL:-T ${CMAKE_CURRENT_BINARY_DIR}
# To avoid warning "Manually-specified variables were not used by the project"
set(bypassWarning "${IDF_TARGET}")
set(bypassWarning "${CONFIG_ESP_ROM_HAS_LP_ROM}")
if(ULP_COCPU_IS_RISCV)
#risc-v ulp uses extra files for building:
list(APPEND ULP_S_SOURCES

Wyświetl plik

@ -1,8 +1,9 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
/**
* @brief Print from the LP core
@ -14,4 +15,21 @@
* @param ... variable argument list
*
*/
#if CONFIG_ULP_ROM_PRINT_ENABLE
extern int ets_printf(const char* format, ...);
int (*lp_core_printf)(const char* format, ...) = ets_printf;
#else
//TODO: Change return type from void to int in IDF 6.0
void lp_core_printf(const char* format, ...);
#endif /* CONFIG_ULP_ROM_PRINT_ENABLE */
#if CONFIG_ULP_ROM_PRINT_ENABLE
/**
* @brief Install LP ROM UART printf function as standard putc handler to enable prints
*
* @note This function must be called before printing anything when the LP core boots from LP ROM but does not install
* putc handler. This is possible when the LP ROM is instructed so by setting bit#1 in the LP_SYSTEM_REG_LP_STORE9_REG register.
*/
extern void ets_install_uart_printf(void);
void (*lp_core_install_uart_printf)(void) = ets_install_uart_printf;
#endif /* CONFIG_ULP_ROM_PRINT_ENABLE */

Wyświetl plik

@ -6,6 +6,8 @@
#include <stdarg.h>
#include "ulp_lp_core_uart.h"
#if !CONFIG_ULP_ROM_PRINT_ENABLE
#define LP_UART_PORT_NUM LP_UART_NUM_0
#define BINARY_SUPPORT 1
@ -271,3 +273,5 @@ int lp_core_printf(const char* format, ...)
return ret;
}
#endif /* !CONFIG_ULP_ROM_PRINT_ENABLE */

Wyświetl plik

@ -49,6 +49,9 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE)
set(TOOLCHAIN_FLAG ${idf_path}/components/ulp/cmake/toolchain-lp-core-riscv.cmake)
set(ULP_IS_LP_CORE_RISCV ON)
if(CONFIG_ESP_ROM_HAS_LP_ROM)
set(CONFIG_ESP_ROM_HAS_LP_ROM ON)
endif()
endif()
externalproject_add(${app_name}
@ -67,6 +70,7 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
-DPYTHON=${python}
-DULP_COCPU_IS_RISCV=${ULP_IS_RISCV}
-DULP_COCPU_IS_LP_CORE=${ULP_IS_LP_CORE_RISCV}
-DCONFIG_ESP_ROM_HAS_LP_ROM=${CONFIG_ESP_ROM_HAS_LP_ROM}
${extra_cmake_args}
BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${app_name} --target build
BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources}