Skip to content

Commit

Permalink
Some small fixes/improvements for pico_minimize_runtime (#1919)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kilograham authored Sep 10, 2024
1 parent b49d4ec commit 398ac2b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/host/pico_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ target_include_directories(pico_runtime_headers SYSTEM INTERFACE ${CMAKE_CURRENT

pico_mirrored_target_link_libraries(pico_runtime INTERFACE
pico_base
)
)

function(pico_minimize_runtime TARGET)
endfunction()
1 change: 1 addition & 0 deletions src/rp2_common/pico_platform_panic/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdarg.h>
#include <sys/cdefs.h>
#include <unistd.h>
#include "pico.h"
#include "pico/platform/panic.h"

#if LIB_PICO_PRINTF_PICO
Expand Down
29 changes: 28 additions & 1 deletion src/rp2_common/pico_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 398ac2b

Please sign in to comment.