Skip to content

pico-sdk: Switch to picolibc #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
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
7 changes: 7 additions & 0 deletions ChangeLog.zephyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Need to take care to not break these changes when updating pico-sdk.

## Patch List:
- [#10] pico-sdk: Switch to picolibc
- src/rp2040/boot_stage2/CMakeLists.txt
- src/rp2040/boot_stage2/boot_stage2.ld
- src/rp2350/boot_stage2/CMakeLists.txt
- src/rp2350/boot_stage2/boot_stage2.ld
- src/rp2_common/pico_runtime/CMakeLists.txt
- src/rp2_common/pico_standard_link/CMakeLists.txt
- [#9] pico-sdk: Disabling sanity check the IRQ status
- src/rp2_common/hardware_gpio/gpio.c
- [#8] pico-sdk: pico_platform_compiler: Do not redefine `__weak`
Expand Down
5 changes: 3 additions & 2 deletions src/rp2040/boot_stage2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ function(pico_define_boot_stage2 NAME SOURCES)
if (PICO_C_COMPILER_IS_CLANG)
target_link_options(${NAME} PRIVATE "-nostdlib")
elseif (PICO_C_COMPILER_IS_GNU)
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
target_compile_options(${NAME} PRIVATE "--specs=picolibc.specs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a history about this change to ChangeLog.zephyr.md.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

target_link_options(${NAME} PRIVATE "--specs=picolibc.specs")
target_link_options(${NAME} PRIVATE "-nostartfiles")
endif ()

# boot2_helpers include dir
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude)

target_link_libraries(${NAME} hardware_regs boot_stage2_headers)
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
target_link_options(${NAME} PRIVATE "-T${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a minor point, but I think long options are easier to read in scripts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picolibc's spec fragments only look for the -T version of this option, so we must use the short variant to prevent addition of the picolibc linker script here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I got it.
Thank you for your clarification.

set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)

pico_add_dis_output(${NAME})
Expand Down
4 changes: 2 additions & 2 deletions src/rp2040/boot_stage2/boot_stage2.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SECTIONS {
. = ORIGIN(SRAM);
.text : {
_start = .; /* make LLVM happy */
*(.entry)
*(.text)
KEEP(*(.entry))
KEEP(*(.text .text.*))
} >SRAM
}
4 changes: 2 additions & 2 deletions src/rp2350/boot_stage2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ function(pico_define_boot_stage2 NAME SOURCES)
if (PICO_C_COMPILER_IS_CLANG)
target_link_options(${NAME} PRIVATE "-nostdlib")
elseif (PICO_C_COMPILER_IS_GNU)
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
target_link_options(${NAME} PRIVATE "--specs=picolibc.specs")
target_link_options(${NAME} PRIVATE "-nostartfiles")
endif ()

# boot2_helpers include dir
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude)

target_link_libraries(${NAME} hardware_regs boot_stage2_headers)
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
target_link_options(${NAME} PRIVATE "-T${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)

pico_add_dis_output(${NAME})
Expand Down
4 changes: 2 additions & 2 deletions src/rp2350/boot_stage2/boot_stage2.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SECTIONS {
. = ORIGIN(SRAM);
.text : {
_start = .; /* make LLVM happy */
*(.entry)
*(.text)
KEEP(*(.entry .entry.*))
KEEP(*(.text .text.*))
} >SRAM
}
5 changes: 3 additions & 2 deletions src/rp2_common/pico_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ endforeach()

# todo is this correct/needed?
if (PICO_C_COMPILER_IS_GNU)
target_link_options(pico_runtime INTERFACE "--specs=nosys.specs")
target_compile_options(pico_runtime INTERFACE "--specs=picolibc.specs")
target_link_options(pico_runtime INTERFACE "--specs=picolibc.specs")
elseif (PICO_C_COMPILER_IS_CLANG)
# target_link_options(pico_runtime INTERFACE "-nostdlib")
endif()
Expand Down Expand Up @@ -144,4 +145,4 @@ function(pico_minimize_runtime TARGET)
if (NOT RUNTIME_INCLUDE_FPGA_CHECK)
target_compile_definitions(${TARGET} PRIVATE PICO_NO_FPGA_CHECK=1)
endif()
endfunction()
endfunction()
2 changes: 1 addition & 1 deletion src/rp2_common/pico_standard_link/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if (NOT TARGET pico_standard_link)
# if PICO_TARGET_BINARY_TYPE is set to foo on the target, otherwise ${CMAKE_CURRENT_LIST_DIR}/memmap_${PICO_DEFAULT_BINARY_TYPE).ld
set(_LINKER_SCRIPT_EXPRESSION "$<IF:$<BOOL:$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>>,$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>,${PICO_LINKER_SCRIPT_PATH}/memmap_$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>,>,${PICO_DEFAULT_BINARY_TYPE},$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>>.ld>")
target_link_options(pico_standard_link INTERFACE
"LINKER:--script=${_LINKER_SCRIPT_EXPRESSION}"
"-T${_LINKER_SCRIPT_EXPRESSION}"
)
pico_add_link_depend(pico_standard_link ${_LINKER_SCRIPT_EXPRESSION})
unset(_LINKER_SCRIPT_EXPRESSION)
Expand Down
Loading