From 398ac2baf97de465df8fac1965b53ee9002ac60c Mon Sep 17 00:00:00 2001 From: Graham Sanderson Date: Tue, 10 Sep 2024 18:45:25 -0500 Subject: [PATCH] Some small fixes/improvements for pico_minimize_runtime (#1919) * add PANIC and AUTO_INIT_MUTEX to pico_minimize_runtime; fix build with PICO_PANIC_FUNCTION= * add pico_minimize_runtime for host builds - does nothing * Add ALL option to pico_minimize_runtime --- src/host/pico_runtime/CMakeLists.txt | 5 +++- src/rp2_common/pico_platform_panic/panic.c | 1 + src/rp2_common/pico_runtime/CMakeLists.txt | 29 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/host/pico_runtime/CMakeLists.txt b/src/host/pico_runtime/CMakeLists.txt index da9a8a47e..dd4d67173 100644 --- a/src/host/pico_runtime/CMakeLists.txt +++ b/src/host/pico_runtime/CMakeLists.txt @@ -4,4 +4,7 @@ target_include_directories(pico_runtime_headers SYSTEM INTERFACE ${CMAKE_CURRENT pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_base -) \ No newline at end of file +) + +function(pico_minimize_runtime TARGET) +endfunction() \ No newline at end of file diff --git a/src/rp2_common/pico_platform_panic/panic.c b/src/rp2_common/pico_platform_panic/panic.c index 7d076da90..d3eca23ee 100644 --- a/src/rp2_common/pico_platform_panic/panic.c +++ b/src/rp2_common/pico_platform_panic/panic.c @@ -8,6 +8,7 @@ #include #include #include +#include "pico.h" #include "pico/platform/panic.h" #if LIB_PICO_PRINTF_PICO diff --git a/src/rp2_common/pico_runtime/CMakeLists.txt b/src/rp2_common/pico_runtime/CMakeLists.txt index 3665cd805..da329e695 100644 --- a/src/rp2_common/pico_runtime/CMakeLists.txt +++ b/src/rp2_common/pico_runtime/CMakeLists.txt @@ -65,7 +65,17 @@ endif() # FLOAT - support for single-precision floating point # DOUBLE - support for double-precision floating point # FPGA_CHECK - checks for FPGA which allows Raspberry Pi to run your binary on FPGA +# PANIC - default panic impl which brings in stdio +# AUTO_INIT_MUTEX - auto init mutexes; without this you get no printf mutex either - function(pico_minimize_runtime TARGET) + set(ALL_ITEMS + DEFAULT_ALARM_POOL + PRINTF + FLOAT + DOUBLE + FPGA_CHECK + PANIC + AUTO_INIT_MUTEX) cmake_parse_arguments(RUNTIME "" "" "INCLUDE;EXCLUDE" ${ARGN} ) foreach (INCL_EXCL IN ITEMS INCLUDE EXCLUDE) @@ -75,7 +85,13 @@ function(pico_minimize_runtime TARGET) set(VAL 0) endif() foreach(VAR IN LISTS RUNTIME_${INCL_EXCL}) - set(RUNTIME_INCLUDE_${VAR} ${VAL}) + if (VAR STREQUAL "ALL") + foreach(ITEM IN LISTS ALL_ITEMS) + set(RUNTIME_INCLUDE_${ITEM} ${VAL}) + endforeach () + else() + set(RUNTIME_INCLUDE_${VAR} ${VAL}) + endif() endforeach () endforeach () if (NOT RUNTIME_INCLUDE_DEFAULT_ALARM_POOL) @@ -114,6 +130,17 @@ function(pico_minimize_runtime TARGET) pico_set_printf_implementation(${TARGET} none) endif() + if (NOT RUNTIME_INCLUDE_PANIC) + target_compile_definitions(${TARGET} PRIVATE + PICO_PANIC_FUNCTION= #the default uses puts + ) + endif() + if (NOT RUNTIME_INCLUDE_AUTO_INIT_MUTEX) + target_compile_definitions(${TARGET} PRIVATE + PICO_RUNTIME_NO_INIT_MUTEX=1 + PICO_STDOUT_MUTEX=0 # currently pulls in mutex code otherwise + ) + endif() if (NOT RUNTIME_INCLUDE_FPGA_CHECK) target_compile_definitions(${TARGET} PRIVATE PICO_NO_FPGA_CHECK=1) endif()