diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel index 84eac746e..56b39e4a1 100644 --- a/bazel/config/BUILD.bazel +++ b/bazel/config/BUILD.bazel @@ -217,10 +217,22 @@ string_flag( build_setting_default = "Debug", ) -# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link +# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_TYPE, The default binary type to use, type=string, default=default, group=build +string_flag( + name = "PICO_DEFAULT_BINARY_TYPE", + build_setting_default = "default", + values = [ + "default", + "no_flash", + "copy_to_ram", + "blocked_ram", + ], +) + +# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_standard_link:default_linker_script, group=pico_standard_link label_flag( name = "PICO_DEFAULT_LINKER_SCRIPT", - build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script", + build_setting_default = "//src/rp2_common/pico_standard_link:default_linker_script", ) # PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build diff --git a/bazel/constraint/BUILD.bazel b/bazel/constraint/BUILD.bazel index acd112469..de2154473 100644 --- a/bazel/constraint/BUILD.bazel +++ b/bazel/constraint/BUILD.bazel @@ -273,3 +273,18 @@ config_setting( name = "pico_compilation_no_fastbuild_args_set", flag_values = {"//bazel/config:PICO_COMPILATION_NO_FASTBUILD_ARGS": "True"}, ) + +config_setting( + name = "pico_binary_type_no_flash", + flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "no_flash"}, +) + +config_setting( + name = "pico_binary_type_copy_to_ram", + flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "copy_to_ram"}, +) + +config_setting( + name = "pico_binary_type_blocked_ram", + flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "blocked_ram"}, +) diff --git a/bazel/util/pico_linker_scripts.bzl b/bazel/util/pico_linker_scripts.bzl new file mode 100644 index 000000000..8bdc18e9c --- /dev/null +++ b/bazel/util/pico_linker_scripts.bzl @@ -0,0 +1,38 @@ +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "use_cpp_toolchain") + +def _linker_scripts_impl(ctx): + link_flags = [] + for script in ctx.attr.include_scripts: + link_include_dir = script.label.package + if ctx.label.workspace_root: + link_include_dir = "/".join((ctx.label.workspace_root, link_include_dir)) + link_flag = "-L" + str(link_include_dir) + if not (link_flag in link_flags): + link_flags.append(link_flag) + + for script in ctx.files.link_scripts: + link_flags.append("-T" + str(script.path)) + + all_scripts = ctx.files.link_scripts + ctx.files.include_scripts + + linking_inputs = cc_common.create_linker_input( + owner = ctx.label, + user_link_flags = depset( + direct = link_flags, + ), + additional_inputs = depset(direct = all_scripts), + ) + return [ + DefaultInfo(files = depset(direct = all_scripts)), + CcInfo(linking_context = cc_common.create_linking_context(linker_inputs = depset(direct = [linking_inputs]))), + ] + +linker_scripts = rule( + implementation = _linker_scripts_impl, + attrs = { + "link_scripts": attr.label_list(allow_files = [".ld"], doc = "List of scripts to explicitly link"), + "include_scripts": attr.label_list(allow_files = [".incl"], doc = "List of scripts to include"), + }, + toolchains = use_cpp_toolchain(), + fragments = ["cpp"], +) diff --git a/bazel/util/transition.bzl b/bazel/util/transition.bzl index d01046358..396fbeeec 100644 --- a/bazel/util/transition.bzl +++ b/bazel/util/transition.bzl @@ -167,3 +167,33 @@ extra_copts_for_all_deps = declare_transtion( "//command_line_option:copt": "extra_copts", }, ) + +# This transition sets the binary type +pico_set_binary_type = declare_transtion( + attrs = { + "binary_type": attr.string(), + # This could be shared, but we don't in order to make it clearer that + # a transition is in use. + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + flag_overrides = { + "@pico-sdk//bazel/config:PICO_DEFAULT_BINARY_TYPE": "binary_type", + }, +) + +# This transition sets the linker script +pico_set_linker_script = declare_transtion( + attrs = { + "linker_script": attr.string(), + # This could be shared, but we don't in order to make it clearer that + # a transition is in use. + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + flag_overrides = { + "@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT": "linker_script", + }, +) diff --git a/src/common/pico_base_headers/BUILD.bazel b/src/common/pico_base_headers/BUILD.bazel index d7058ee85..4a859a3f2 100644 --- a/src/common/pico_base_headers/BUILD.bazel +++ b/src/common/pico_base_headers/BUILD.bazel @@ -74,6 +74,11 @@ cc_library( "//bazel/constraint:rp2040": ["PICO_RP2040=1"], "//bazel/constraint:rp2350": ["PICO_RP2350=1"], "//conditions:default": [], + }) + select({ + "//bazel/constraint:pico_binary_type_no_flash": ["PICO_NO_FLASH=1"], + "//bazel/constraint:pico_binary_type_copy_to_ram": ["PICO_COPY_TO_RAM=1"], + "//bazel/constraint:pico_binary_type_blocked_ram": ["PICO_USE_BLOCKED_RAM=1"], + "//conditions:default": [], }), ) diff --git a/src/rp2040/pico_platform/BUILD.bazel b/src/rp2040/pico_platform/BUILD.bazel index dd4412b02..f32f300bb 100644 --- a/src/rp2040/pico_platform/BUILD.bazel +++ b/src/rp2040/pico_platform/BUILD.bazel @@ -54,3 +54,96 @@ cc_library( "//src/rp2_common/pico_standard_link", ], ) + +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +exports_files( + [ + "memmap_blocked_ram.ld", + "memmap_copy_to_ram.ld", + "memmap_default.ld", + "memmap_no_flash.ld", + ], +) + +linker_scripts( + name = "memmap_default", + link_scripts = ["memmap_default.ld"], +) + +linker_scripts( + name = "memmap_blocked_ram", + link_scripts = ["memmap_blocked_ram.ld"], +) + +linker_scripts( + name = "memmap_copy_to_ram", + link_scripts = ["memmap_copy_to_ram.ld"], +) + +linker_scripts( + name = "memmap_no_flash", + link_scripts = ["memmap_no_flash.ld"], +) + +cc_library( + name = "default_linker_script", + target_compatible_with = ["//bazel/constraint:rp2040"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2040/pico_platform/script_include:rp2040_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "//src/rp2_common/pico_standard_link:default_flash_region", + "memmap_default", + ], +) + +# PICO_BUILD_DEFINE: PICO_USE_BLOCKED_RAM, whether this is a 'blocked_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link +cc_library( + name = "blocked_ram_linker_script", + target_compatible_with = ["//bazel/constraint:rp2040"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2040/pico_platform/script_include:rp2040_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "//src/rp2_common/pico_standard_link:default_flash_region", + "memmap_blocked_ram", + ], +) + +# PICO_BUILD_DEFINE: PICO_COPY_TO_RAM, whether this is a 'copy_to_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link +cc_library( + name = "copy_to_ram_linker_script", + target_compatible_with = ["//bazel/constraint:rp2040"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2040/pico_platform/script_include:rp2040_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "//src/rp2_common/pico_standard_link:default_flash_region", + "memmap_copy_to_ram", + ], +) + +# PICO_BUILD_DEFINE: PICO_NO_FLASH, whether this is a 'no_flash' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link +cc_library( + name = "no_flash_linker_script", + target_compatible_with = ["//bazel/constraint:rp2040"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2040/pico_platform/script_include:rp2040_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "memmap_no_flash", + ], +) diff --git a/src/rp2040/pico_platform/CMakeLists.txt b/src/rp2040/pico_platform/CMakeLists.txt index 9c91df3ea..d43f96b91 100644 --- a/src/rp2040/pico_platform/CMakeLists.txt +++ b/src/rp2040/pico_platform/CMakeLists.txt @@ -22,6 +22,21 @@ if (NOT TARGET pico_platform) pico_platform_panic pico_platform_sections ) + + pico_register_common_scope_var(PICO_LINKER_SCRIPT_PATH) + if (NOT PICO_LINKER_SCRIPT_PATH) + set(PICO_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}) + endif() + + pico_register_common_scope_var(PICO_LINKER_DEFAULT_LOCATIONS_PATH) + if (NOT PICO_LINKER_DEFAULT_LOCATIONS_PATH) + set(PICO_LINKER_DEFAULT_LOCATIONS_PATH ${CMAKE_CURRENT_LIST_DIR}/script_include/default_locations.ld) + endif() + + pico_register_common_scope_var(PICO_LINKER_SCRIPT_INCLUDE_DIRS) + list(APPEND PICO_LINKER_SCRIPT_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/script_include) + + pico_promote_common_scope_vars() endif() function(pico_add_platform_library TARGET) diff --git a/src/rp2040/pico_platform/memmap_blocked_ram.ld b/src/rp2040/pico_platform/memmap_blocked_ram.ld new file mode 100644 index 000000000..26955f209 --- /dev/null +++ b/src/rp2040/pico_platform/memmap_blocked_ram.ld @@ -0,0 +1,4 @@ +/* Use blocked ram */ +RAM_ORIGIN = 0x21000000; + +INCLUDE "memmap_default.incl" diff --git a/src/rp2040/pico_platform/memmap_copy_to_ram.ld b/src/rp2040/pico_platform/memmap_copy_to_ram.ld new file mode 100644 index 000000000..f0eb74d9f --- /dev/null +++ b/src/rp2040/pico_platform/memmap_copy_to_ram.ld @@ -0,0 +1 @@ +INCLUDE "memmap_copy_to_ram.incl" diff --git a/src/rp2040/pico_platform/memmap_default.ld b/src/rp2040/pico_platform/memmap_default.ld new file mode 100644 index 000000000..ddb81aae3 --- /dev/null +++ b/src/rp2040/pico_platform/memmap_default.ld @@ -0,0 +1 @@ +INCLUDE "memmap_default.incl" diff --git a/src/rp2040/pico_platform/memmap_no_flash.ld b/src/rp2040/pico_platform/memmap_no_flash.ld new file mode 100644 index 000000000..cbc400e66 --- /dev/null +++ b/src/rp2040/pico_platform/memmap_no_flash.ld @@ -0,0 +1 @@ +INCLUDE "memmap_no_flash.incl" diff --git a/src/rp2040/pico_platform/script_include/BUILD.bazel b/src/rp2040/pico_platform/script_include/BUILD.bazel new file mode 100644 index 000000000..fd89a12a8 --- /dev/null +++ b/src/rp2040/pico_platform/script_include/BUILD.bazel @@ -0,0 +1,19 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +linker_scripts( + name = "rp2040_linker_script_includes", + link_scripts = ["default_locations.ld"], + include_scripts = glob(["*.incl"]), +) + +cc_library( + name = "rp2040_linker_scripts", + target_compatible_with = ["//bazel/constraint:rp2040"], + deps = [ + "rp2040_linker_script_includes", + ], +) \ No newline at end of file diff --git a/src/rp2040/pico_platform/script_include/default_locations.ld b/src/rp2040/pico_platform/script_include/default_locations.ld new file mode 100644 index 000000000..03144ea07 --- /dev/null +++ b/src/rp2040/pico_platform/script_include/default_locations.ld @@ -0,0 +1,8 @@ +RAM_ORIGIN_DEFAULT = 0x20000000; +RAM_LENGTH_DEFAULT = 256k; +SCRATCH_X_ORIGIN_DEFAULT = 0x20040000; +SCRATCH_X_LENGTH_DEFAULT = 4k; +SCRATCH_Y_ORIGIN_DEFAULT = 0x20041000; +SCRATCH_Y_LENGTH_DEFAULT = 4k; +XIP_RAM_ORIGIN_DEFAULT = 0x15000000; +XIP_RAM_LENGTH_DEFAULT = 16k; diff --git a/src/rp2040/pico_platform/script_include/section_boot2.incl b/src/rp2040/pico_platform/script_include/section_boot2.incl new file mode 100644 index 000000000..8a8a6bea7 --- /dev/null +++ b/src/rp2040/pico_platform/script_include/section_boot2.incl @@ -0,0 +1,16 @@ +SECTIONS +{ + /* Second stage bootloader is prepended to the image. It must be 256 bytes big + and checksummed. It is usually built by the boot_stage2 target + in the Raspberry Pi Pico SDK + */ + + .boot2 : { + __boot2_start__ = .; + KEEP (*(.boot2)) + __boot2_end__ = .; + } > TEXT_STORE + + ASSERT(__boot2_end__ - __boot2_start__ == 256, + "ERROR: Pico second stage bootloader must be exactly 256 bytes in size for RP2040") +} diff --git a/src/rp2040/pico_platform/script_include/section_no_flash_text.incl b/src/rp2040/pico_platform/script_include/section_no_flash_text.incl new file mode 100644 index 000000000..57cd4cfc3 --- /dev/null +++ b/src/rp2040/pico_platform/script_include/section_no_flash_text.incl @@ -0,0 +1,47 @@ +/* Defines the following symbols for use by code: + __logical_binary_start + __binary_info_header_end + __embedded_block_end + __reset_start, __reset_end +*/ + +SECTIONS +{ + /* Note in NO_FLASH builds the entry point for both the bootrom, and debugger + entry (ELF entry point), are *first* in the image, and the vector table + follows immediately afterward. This is because the bootrom enters RAM + binaries directly at their lowest address (preferring main RAM over XIP + cache-as-SRAM if both are used). + */ + + .text : { + __logical_binary_start = .; + __reset_start = .; + KEEP (*(.reset)) + __reset_end = .; + KEEP (*(.binary_info_header)) + __binary_info_header_end = .; + KEEP (*(.embedded_block)) + __embedded_block_end = .; + . = ALIGN(256); + KEEP (*(.vectors)) + *(.text*) + . = ALIGN(4); + *(.init) + *(.fini) + /* Pull all c'tors into .text */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* Followed by destructors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.eh_frame*) + } > RAM +} diff --git a/src/rp2040/pico_platform/script_include/section_platform_end.incl b/src/rp2040/pico_platform/script_include/section_platform_end.incl new file mode 100644 index 000000000..cccfc262d --- /dev/null +++ b/src/rp2040/pico_platform/script_include/section_platform_end.incl @@ -0,0 +1,4 @@ +SECTIONS +{ + ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") +} diff --git a/src/rp2040/pico_platform/script_include/sections_copy_to_ram_text.incl b/src/rp2040/pico_platform/script_include/sections_copy_to_ram_text.incl new file mode 100644 index 000000000..be47abb6f --- /dev/null +++ b/src/rp2040/pico_platform/script_include/sections_copy_to_ram_text.incl @@ -0,0 +1,11 @@ +/* This swaps section_boot2 and section_default_text, because RP2040 binaries must begin with boot2 */ + +INCLUDE "section_flash_begin.incl" +INCLUDE "section_boot2.incl" +INCLUDE "section_copy_to_ram_flashtext.incl" +INCLUDE "section_copy_to_ram_rodata.incl" +INCLUDE "sections_arm_ex.incl" +INCLUDE "section_binary_info.incl" +INCLUDE "section_ram_vector_table.incl" +INCLUDE "section_uninitialized_data.incl" +INCLUDE "section_copy_to_ram_text.incl" diff --git a/src/rp2040/pico_platform/script_include/sections_default_text.incl b/src/rp2040/pico_platform/script_include/sections_default_text.incl new file mode 100644 index 000000000..c00c93429 --- /dev/null +++ b/src/rp2040/pico_platform/script_include/sections_default_text.incl @@ -0,0 +1,8 @@ +/* This swaps section_boot2 and section_default_text, because RP2040 binaries must begin with boot2 */ + +INCLUDE "section_flash_begin.incl" +INCLUDE "section_boot2.incl" +INCLUDE "section_default_text.incl" +INCLUDE "section_default_rodata.incl" +INCLUDE "sections_arm_ex.incl" +INCLUDE "section_binary_info.incl" diff --git a/src/rp2350/pico_platform/BUILD.bazel b/src/rp2350/pico_platform/BUILD.bazel index f6182b90a..7a69d0004 100644 --- a/src/rp2350/pico_platform/BUILD.bazel +++ b/src/rp2350/pico_platform/BUILD.bazel @@ -54,3 +54,74 @@ cc_library( "//src/rp2_common/pico_standard_link", ], ) + +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +exports_files( + [ + "memmap_copy_to_ram.ld", + "memmap_default.ld", + "memmap_no_flash.ld", + ], +) + +linker_scripts( + name = "memmap_default", + link_scripts = ["memmap_default.ld"], +) + +linker_scripts( + name = "memmap_copy_to_ram", + link_scripts = ["memmap_copy_to_ram.ld"], +) + +linker_scripts( + name = "memmap_no_flash", + link_scripts = ["memmap_no_flash.ld"], +) + +cc_library( + name = "default_linker_script", + target_compatible_with = ["//bazel/constraint:rp2350"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2350/pico_platform/script_include:rp2350_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "//src/rp2_common/pico_standard_link:default_flash_region", + "memmap_default", + ], +) + +# PICO_BUILD_DEFINE: PICO_COPY_TO_RAM, whether this is a 'copy_to_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link +cc_library( + name = "copy_to_ram_linker_script", + target_compatible_with = ["//bazel/constraint:rp2350"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2350/pico_platform/script_include:rp2350_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "//src/rp2_common/pico_standard_link:default_flash_region", + "memmap_copy_to_ram", + ], +) + +# PICO_BUILD_DEFINE: PICO_NO_FLASH, whether this is a 'no_flash' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link +cc_library( + name = "no_flash_linker_script", + target_compatible_with = ["//bazel/constraint:rp2350"], + visibility = [ + "//src/rp2_common/pico_standard_link:__pkg__", + ], + deps = [ + "//src/rp2_common/pico_crt0:no_warn_rwx_flag", + "//src/rp2350/pico_platform/script_include:rp2350_linker_scripts", + "//src/rp2_common/pico_standard_link/script_include:rp2_linker_scripts", + "memmap_no_flash", + ], +) diff --git a/src/rp2350/pico_platform/CMakeLists.txt b/src/rp2350/pico_platform/CMakeLists.txt index 7f875bf32..636f3fe83 100644 --- a/src/rp2350/pico_platform/CMakeLists.txt +++ b/src/rp2350/pico_platform/CMakeLists.txt @@ -33,6 +33,21 @@ if (NOT TARGET pico_platform) if (PICO_RISCV) pico_mirrored_target_link_libraries(pico_platform INTERFACE hardware_hazard3) endif() + + pico_register_common_scope_var(PICO_LINKER_SCRIPT_PATH) + if (NOT PICO_LINKER_SCRIPT_PATH) + set(PICO_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}) + endif() + + pico_register_common_scope_var(PICO_LINKER_DEFAULT_LOCATIONS_PATH) + if (NOT PICO_LINKER_DEFAULT_LOCATIONS_PATH) + set(PICO_LINKER_DEFAULT_LOCATIONS_PATH ${CMAKE_CURRENT_LIST_DIR}/script_include/default_locations.ld) + endif() + + pico_register_common_scope_var(PICO_LINKER_SCRIPT_INCLUDE_DIRS) + list(APPEND PICO_LINKER_SCRIPT_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/script_include) + + pico_promote_common_scope_vars() endif() function(pico_add_platform_library TARGET) diff --git a/src/rp2350/pico_platform/memmap_copy_to_ram.ld b/src/rp2350/pico_platform/memmap_copy_to_ram.ld new file mode 100644 index 000000000..f0eb74d9f --- /dev/null +++ b/src/rp2350/pico_platform/memmap_copy_to_ram.ld @@ -0,0 +1 @@ +INCLUDE "memmap_copy_to_ram.incl" diff --git a/src/rp2350/pico_platform/memmap_default.ld b/src/rp2350/pico_platform/memmap_default.ld new file mode 100644 index 000000000..ddb81aae3 --- /dev/null +++ b/src/rp2350/pico_platform/memmap_default.ld @@ -0,0 +1 @@ +INCLUDE "memmap_default.incl" diff --git a/src/rp2350/pico_platform/memmap_no_flash.ld b/src/rp2350/pico_platform/memmap_no_flash.ld new file mode 100644 index 000000000..cbc400e66 --- /dev/null +++ b/src/rp2350/pico_platform/memmap_no_flash.ld @@ -0,0 +1 @@ +INCLUDE "memmap_no_flash.incl" diff --git a/src/rp2350/pico_platform/script_include/BUILD.bazel b/src/rp2350/pico_platform/script_include/BUILD.bazel new file mode 100644 index 000000000..543824c4a --- /dev/null +++ b/src/rp2350/pico_platform/script_include/BUILD.bazel @@ -0,0 +1,26 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +filegroup( + name = "rp2350_linker_script_incls", + srcs = glob([ + "*.incl", + ]), +) + +linker_scripts( + name = "rp2350_linker_script_includes", + link_scripts = ["default_locations.ld"], + include_scripts = glob(["*.incl"]), +) + +cc_library( + name = "rp2350_linker_scripts", + target_compatible_with = ["//bazel/constraint:rp2350"], + deps = [ + "rp2350_linker_script_includes", + ], +) \ No newline at end of file diff --git a/src/rp2350/pico_platform/script_include/default_locations.ld b/src/rp2350/pico_platform/script_include/default_locations.ld new file mode 100644 index 000000000..15ddc7374 --- /dev/null +++ b/src/rp2350/pico_platform/script_include/default_locations.ld @@ -0,0 +1,8 @@ +RAM_ORIGIN_DEFAULT = 0x20000000; +RAM_LENGTH_DEFAULT = 512k; +SCRATCH_X_ORIGIN_DEFAULT = 0x20080000; +SCRATCH_X_LENGTH_DEFAULT = 4k; +SCRATCH_Y_ORIGIN_DEFAULT = 0x20081000; +SCRATCH_Y_LENGTH_DEFAULT = 4k; +XIP_RAM_ORIGIN_DEFAULT = 0x13FFC000; +XIP_RAM_LENGTH_DEFAULT = 16k; diff --git a/src/rp2350/pico_platform/script_include/section_platform_end.incl b/src/rp2350/pico_platform/script_include/section_platform_end.incl new file mode 100644 index 000000000..9503fa173 --- /dev/null +++ b/src/rp2350/pico_platform/script_include/section_platform_end.incl @@ -0,0 +1,5 @@ +SECTIONS +{ + ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary") + ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary") +} diff --git a/src/rp2_common/pico_crt0/BUILD.bazel b/src/rp2_common/pico_crt0/BUILD.bazel index b47b9c6cf..99c9244bd 100644 --- a/src/rp2_common/pico_crt0/BUILD.bazel +++ b/src/rp2_common/pico_crt0/BUILD.bazel @@ -3,48 +3,13 @@ load("//bazel:defs.bzl", "compatible_with_rp2") package(default_visibility = ["//visibility:public"]) -alias( - name = "default_linker_script", - actual = select({ - "//bazel/constraint:rp2040": "//src/rp2_common/pico_crt0/rp2040:default_linker_script", - "//bazel/constraint:rp2350": "//src/rp2_common/pico_crt0/rp2350:default_linker_script", - "//conditions:default": "//bazel:incompatible_cc_lib", - }), -) - -alias( - name = "blocked_ram_linker_script", - actual = select({ - "//bazel/constraint:rp2040": "//src/rp2_common/pico_crt0/rp2040:blocked_ram_linker_script", - "//conditions:default": "//bazel:incompatible_cc_lib", - }), -) - -alias( - name = "copy_to_ram_linker_script", - actual = select({ - "//bazel/constraint:rp2040": "//src/rp2_common/pico_crt0/rp2040:copy_to_ram_linker_script", - "//bazel/constraint:rp2350": "//src/rp2_common/pico_crt0/rp2350:copy_to_ram_linker_script", - "//conditions:default": "//bazel:incompatible_cc_lib", - }), -) - -alias( - name = "no_flash_linker_script", - actual = select({ - "//bazel/constraint:rp2040": "//src/rp2_common/pico_crt0/rp2040:no_flash_linker_script", - "//bazel/constraint:rp2350": "//src/rp2_common/pico_crt0/rp2350:no_flash_linker_script", - "//conditions:default": "//bazel:incompatible_cc_lib", - }), -) - cc_library( name = "no_warn_rwx_flag", linkopts = select({ "//bazel/constraint:pico_toolchain_gcc_enabled": ["-Wl,--no-warn-rwx-segments"], "//conditions:default": [], }), - visibility = [":__subpackages__"], + visibility = ["//src:__subpackages__"], ) cc_library( diff --git a/src/rp2_common/pico_crt0/CMakeLists.txt b/src/rp2_common/pico_crt0/CMakeLists.txt index bd4156932..1bbbac742 100644 --- a/src/rp2_common/pico_crt0/CMakeLists.txt +++ b/src/rp2_common/pico_crt0/CMakeLists.txt @@ -11,9 +11,4 @@ if (NOT TARGET pico_crt0) target_link_libraries(pico_crt0 INTERFACE boot_picobin_headers pico_bootrom_headers) endif() -pico_register_common_scope_var(PICO_LINKER_SCRIPT_PATH) -if (NOT PICO_LINKER_SCRIPT_PATH) - set(PICO_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}/${PICO_CHIP}) -endif() - pico_promote_common_scope_vars() \ No newline at end of file diff --git a/src/rp2_common/pico_crt0/rp2040/BUILD.bazel b/src/rp2_common/pico_crt0/rp2040/BUILD.bazel deleted file mode 100644 index 44912f0c8..000000000 --- a/src/rp2_common/pico_crt0/rp2040/BUILD.bazel +++ /dev/null @@ -1,70 +0,0 @@ -load("@rules_cc//cc:cc_library.bzl", "cc_library") - -package(default_visibility = ["//visibility:public"]) - -exports_files( - [ - "memmap_blocked_ram.ld", - "memmap_copy_to_ram.ld", - "memmap_default.ld", - "memmap_no_flash.ld", - ], -) - -# It's possible to set linker scripts globally or on a per-binary basis. -# -# Setting globally: -# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT to point to your -# desired linker script. -# -# Setting per-binary: -# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT=@pico-sdk//bazel:empty_cc_lib -# * Manually add your desired linker script to each cc_binary. -cc_library( - name = "default_linker_script", - linkopts = ["-T$(location memmap_default.ld)"], - target_compatible_with = ["//bazel/constraint:rp2040"], - deps = [ - "memmap_default.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - "//src/rp2_common/pico_standard_link:default_flash_region", - ], -) - -# PICO_BUILD_DEFINE: PICO_USE_BLOCKED_RAM, whether this is a 'blocked_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link -cc_library( - name = "blocked_ram_linker_script", - defines = ["PICO_USE_BLOCKED_RAM=1"], - linkopts = ["-T$(location memmap_blocked_ram.ld)"], - target_compatible_with = ["//bazel/constraint:rp2040"], - deps = [ - "memmap_blocked_ram.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - "//src/rp2_common/pico_standard_link:default_flash_region", - ], -) - -# PICO_BUILD_DEFINE: PICO_COPY_TO_RAM, whether this is a 'copy_to_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link -cc_library( - name = "copy_to_ram_linker_script", - defines = ["PICO_COPY_TO_RAM=1"], - linkopts = ["-T$(location memmap_copy_to_ram.ld)"], - target_compatible_with = ["//bazel/constraint:rp2040"], - deps = [ - "memmap_copy_to_ram.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - "//src/rp2_common/pico_standard_link:default_flash_region", - ], -) - -# PICO_BUILD_DEFINE: PICO_NO_FLASH, whether this is a 'no_flash' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link -cc_library( - name = "no_flash_linker_script", - defines = ["PICO_NO_FLASH=1"], - linkopts = ["-T$(location memmap_no_flash.ld)"], - target_compatible_with = ["//bazel/constraint:rp2040"], - deps = [ - "memmap_no_flash.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - ], -) diff --git a/src/rp2_common/pico_crt0/rp2040/memmap_blocked_ram.ld b/src/rp2_common/pico_crt0/rp2040/memmap_blocked_ram.ld deleted file mode 100644 index 6f5000566..000000000 --- a/src/rp2_common/pico_crt0/rp2040/memmap_blocked_ram.ld +++ /dev/null @@ -1,286 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - INCLUDE "pico_flash_region.ld" - RAM(rwx) : ORIGIN = 0x21000000, LENGTH = 256k - SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* Second stage bootloader is prepended to the image. It must be 256 bytes big - and checksummed. It is usually built by the boot_stage2 target - in the Raspberry Pi Pico SDK - */ - - .flash_begin : { - __flash_binary_start = .; - } > FLASH - - .boot2 : { - __boot2_start__ = .; - KEEP (*(.boot2)) - __boot2_end__ = .; - } > FLASH - - ASSERT(__boot2_end__ - __boot2_start__ == 256, - "ERROR: Pico second stage bootloader must be 256 bytes in size") - - /* The second stage will always enter the image at the start of .text. - The debugger will use the ELF entry point, which is the _entry_point - symbol if present, otherwise defaults to start of .text. - This can be used to transfer control back to the bootrom on debugger - launches only, to perform proper flash setup. - */ - - .text : { - __logical_binary_start = .; - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - KEEP (*(.reset)) - /* TODO revisit this now memset/memcpy/float in ROM */ - /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from - * FLASH ... we will include any thing excluded here in .data below by default */ - *(.init) - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.eh_frame*) - . = ALIGN(4); - } > FLASH - - .rodata : { - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*) - . = ALIGN(4); - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > FLASH - __binary_info_end = .; - . = ALIGN(4); - - .ram_vector_table (NOLOAD): { - *(.ram_vector_table) - } > RAM - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - - .data : { - __data_start__ = .; - *(vtable) - - *(.time_critical*) - - /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */ - *(.text*) - . = ALIGN(4); - *(.rodata*) - . = ALIGN(4); - - *(.data*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - *(.jcr) - . = ALIGN(4); - } > RAM AT> FLASH - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM AT> FLASH - PROVIDE(__data_end__ = .); - - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss (NOLOAD) : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X AT > FLASH - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y AT > FLASH - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - .flash_end : { - KEEP(*(.embedded_end_block*)) - PROVIDE(__flash_binary_end = .); - } > FLASH - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2040/memmap_copy_to_ram.ld b/src/rp2_common/pico_crt0/rp2040/memmap_copy_to_ram.ld deleted file mode 100644 index 842ebfd3c..000000000 --- a/src/rp2_common/pico_crt0/rp2040/memmap_copy_to_ram.ld +++ /dev/null @@ -1,287 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - INCLUDE "pico_flash_region.ld" - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k - SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* Second stage bootloader is prepended to the image. It must be 256 bytes big - and checksummed. It is usually built by the boot_stage2 target - in the Raspberry Pi Pico SDK - */ - - .flash_begin : { - __flash_binary_start = .; - } > FLASH - - .boot2 : { - __boot2_start__ = .; - KEEP (*(.boot2)) - __boot2_end__ = .; - } > FLASH - - ASSERT(__boot2_end__ - __boot2_start__ == 256, - "ERROR: Pico second stage bootloader must be 256 bytes in size") - - /* The second stage will always enter the image at the start of .text. - The debugger will use the ELF entry point, which is the _entry_point - symbol if present, otherwise defaults to start of .text. - This can be used to transfer control back to the bootrom on debugger - launches only, to perform proper flash setup. - */ - - .flashtext : { - __logical_binary_start = .; - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - KEEP (*(.reset)) - } - - .rodata : { - /* segments not marked as .flashdata are instead pulled into .data (in RAM) to avoid accidental flash accesses */ - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > FLASH - __binary_info_end = .; - . = ALIGN(4); - - /* Vector table goes first in RAM, to avoid large alignment hole */ - .ram_vector_table (NOLOAD): { - *(.ram_vector_table) - } > RAM - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - - .text : { - __ram_text_start__ = .; - *(.init) - *(.text*) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.eh_frame*) - . = ALIGN(4); - __ram_text_end__ = .; - } > RAM AT> FLASH - __ram_text_source__ = LOADADDR(.text); - . = ALIGN(4); - - .data : { - __data_start__ = .; - *(vtable) - - *(.time_critical*) - - . = ALIGN(4); - *(.rodata*) - . = ALIGN(4); - - *(.data*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.jcr) - . = ALIGN(4); - } > RAM AT> FLASH - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM AT> FLASH - PROVIDE(__data_end__ = .); - - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X AT > FLASH - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y AT > FLASH - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - .flash_end : { - KEEP(*(.embedded_end_block*)) - PROVIDE(__flash_binary_end = .); - } > FLASH - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2040/memmap_default.ld b/src/rp2_common/pico_crt0/rp2040/memmap_default.ld deleted file mode 100644 index 51254012d..000000000 --- a/src/rp2_common/pico_crt0/rp2040/memmap_default.ld +++ /dev/null @@ -1,286 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - INCLUDE "pico_flash_region.ld" - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k - SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* Second stage bootloader is prepended to the image. It must be 256 bytes big - and checksummed. It is usually built by the boot_stage2 target - in the Raspberry Pi Pico SDK - */ - - .flash_begin : { - __flash_binary_start = .; - } > FLASH - - .boot2 : { - __boot2_start__ = .; - KEEP (*(.boot2)) - __boot2_end__ = .; - } > FLASH - - ASSERT(__boot2_end__ - __boot2_start__ == 256, - "ERROR: Pico second stage bootloader must be 256 bytes in size") - - /* The second stage will always enter the image at the start of .text. - The debugger will use the ELF entry point, which is the _entry_point - symbol if present, otherwise defaults to start of .text. - This can be used to transfer control back to the bootrom on debugger - launches only, to perform proper flash setup. - */ - - .text : { - __logical_binary_start = .; - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - KEEP (*(.reset)) - /* TODO revisit this now memset/memcpy/float in ROM */ - /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from - * FLASH ... we will include any thing excluded here in .data below by default */ - *(.init) - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.eh_frame*) - . = ALIGN(4); - } > FLASH - - .rodata : { - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*) - . = ALIGN(4); - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > FLASH - __binary_info_end = .; - . = ALIGN(4); - - .ram_vector_table (NOLOAD): { - *(.ram_vector_table) - } > RAM - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - - .data : { - __data_start__ = .; - *(vtable) - - *(.time_critical*) - - /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */ - *(.text*) - . = ALIGN(4); - *(.rodata*) - . = ALIGN(4); - - *(.data*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - *(.jcr) - . = ALIGN(4); - } > RAM AT> FLASH - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM AT> FLASH - PROVIDE(__data_end__ = .); - - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss (NOLOAD) : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X AT > FLASH - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y AT > FLASH - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - .flash_end : { - KEEP(*(.embedded_end_block*)) - PROVIDE(__flash_binary_end = .); - } > FLASH - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2040/memmap_no_flash.ld b/src/rp2_common/pico_crt0/rp2040/memmap_no_flash.ld deleted file mode 100644 index dbf006a8c..000000000 --- a/src/rp2_common/pico_crt0/rp2040/memmap_no_flash.ld +++ /dev/null @@ -1,249 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k - SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* Note in NO_FLASH builds the entry point for both the bootrom, and debugger - entry (ELF entry point), are *first* in the image, and the vector table - follows immediately afterward. This is because the bootrom enters RAM - binaries directly at their lowest address (preferring main RAM over XIP - cache-as-SRAM if both are used). - */ - - .text : { - __logical_binary_start = .; - __reset_start = .; - KEEP (*(.reset)) - __reset_end = .; - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - . = ALIGN(256); - KEEP (*(.vectors)) - *(.time_critical*) - *(.text*) - . = ALIGN(4); - *(.init) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.eh_frame*) - } > RAM - - .rodata : { - . = ALIGN(4); - *(.rodata*) - . = ALIGN(4); - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > RAM - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > RAM - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > RAM - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > RAM - __binary_info_end = .; - . = ALIGN(4); - - .data : { - __data_start__ = .; - *(vtable) - *(.data*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.jcr) - . = ALIGN(4); - } > RAM - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM - PROVIDE(__data_end__ = .); - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss (NOLOAD) : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2350/BUILD.bazel b/src/rp2_common/pico_crt0/rp2350/BUILD.bazel deleted file mode 100644 index b0f1ca7dd..000000000 --- a/src/rp2_common/pico_crt0/rp2350/BUILD.bazel +++ /dev/null @@ -1,56 +0,0 @@ -load("@rules_cc//cc:cc_library.bzl", "cc_library") - -package(default_visibility = ["//visibility:public"]) - -exports_files( - [ - "memmap_copy_to_ram.ld", - "memmap_default.ld", - "memmap_no_flash.ld", - ], -) - -# It's possible to set linker scripts globally or on a per-binary basis. -# -# Setting globally: -# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT to point to your -# desired linker script. -# -# Setting per-binary: -# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT=@pico-sdk//bazel:empty_cc_lib -# * Manually add your desired linker script to each cc_binary. -cc_library( - name = "default_linker_script", - linkopts = ["-T$(location memmap_default.ld)"], - target_compatible_with = ["//bazel/constraint:rp2350"], - deps = [ - "memmap_default.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - "//src/rp2_common/pico_standard_link:default_flash_region", - ], -) - -# PICO_BUILD_DEFINE: PICO_COPY_TO_RAM, whether this is a 'copy_to_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link -cc_library( - name = "copy_to_ram_linker_script", - defines = ["PICO_COPY_TO_RAM=1"], - linkopts = ["-T$(location memmap_copy_to_ram.ld)"], - target_compatible_with = ["//bazel/constraint:rp2350"], - deps = [ - "memmap_copy_to_ram.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - "//src/rp2_common/pico_standard_link:default_flash_region", - ], -) - -# PICO_BUILD_DEFINE: PICO_NO_FLASH, whether this is a 'no_flash' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link -cc_library( - name = "no_flash_linker_script", - defines = ["PICO_NO_FLASH=1"], - linkopts = ["-T$(location memmap_no_flash.ld)"], - target_compatible_with = ["//bazel/constraint:rp2350"], - deps = [ - "memmap_no_flash.ld", - "//src/rp2_common/pico_crt0:no_warn_rwx_flag", - ], -) diff --git a/src/rp2_common/pico_crt0/rp2350/memmap_copy_to_ram.ld b/src/rp2_common/pico_crt0/rp2350/memmap_copy_to_ram.ld deleted file mode 100644 index 44c69f3b9..000000000 --- a/src/rp2_common/pico_crt0/rp2350/memmap_copy_to_ram.ld +++ /dev/null @@ -1,309 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - INCLUDE "pico_flash_region.ld" - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k - SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* On Arm, the bootrom expects a VT at the start of the - image by default; on RISC-V, the default is to enter the image at its - lowest address, so an IMAGE_DEF item is required to specify the - nondefault entry point. */ - - .flash_begin : { - __flash_binary_start = .; - } > FLASH - - /* The bootrom will enter the image at the point indicated in your - IMAGE_DEF, which is usually the reset handler of your vector table. - - The debugger will use the ELF entry point, which is the _entry_point - symbol, and in our case is *different from the bootrom's entry point.* - This is used to go back through the bootrom on debugger launches only, - to perform the same initial flash setup that would be performed on a - cold boot. - */ - - .flashtext : { - __logical_binary_start = .; - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - KEEP (*(.reset)) - . = ALIGN(4); - } > FLASH - - /* Note the boot2 section is optional, and should be discarded if there is - no reference to it *inside* the binary, as it is not called by the - bootrom. (The bootrom performs a simple best-effort XIP setup and - leaves it to the binary to do anything more sophisticated.) However - there is still a size limit of 256 bytes, to ensure the boot2 can be - stored in boot RAM. - - Really this is a "XIP setup function" -- the name boot2 is historic and - refers to its dual-purpose on RP2040, where it also handled vectoring - from the bootrom into the user image. - */ - - .boot2 : { - __boot2_start__ = .; - *(.boot2) - __boot2_end__ = .; - } > FLASH - - ASSERT(__boot2_end__ - __boot2_start__ <= 256, - "ERROR: Pico second stage bootloader must be no more than 256 bytes in size") - - .rodata : { - /* segments not marked as .flashdata are instead pulled into .data (in RAM) to avoid accidental flash accesses */ - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > FLASH - __binary_info_end = .; - . = ALIGN(4); - - /* Vector table goes first in RAM, to avoid large alignment hole */ - .ram_vector_table (NOLOAD): { - *(.ram_vector_table) - } > RAM - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - - .text : { - __ram_text_start__ = .; - *(.init) - *(.text*) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.eh_frame*) - . = ALIGN(4); - __ram_text_end__ = .; - } > RAM AT> FLASH - __ram_text_source__ = LOADADDR(.text); - . = ALIGN(4); - - .data : { - __data_start__ = .; - *(vtable) - - *(.time_critical*) - - . = ALIGN(4); - *(.rodata*) - *(.srodata*) - . = ALIGN(4); - - *(.data*) - *(.sdata*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.jcr) - . = ALIGN(4); - } > RAM AT> FLASH - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM AT> FLASH - PROVIDE(__data_end__ = .); - - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - PROVIDE(__global_pointer$ = . + 2K); - *(.sbss*) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X AT > FLASH - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y AT > FLASH - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - .flash_end : { - KEEP(*(.embedded_end_block*)) - PROVIDE(__flash_binary_end = .); - } > FLASH =0xaa - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary") - ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary") - - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2350/memmap_default.ld b/src/rp2_common/pico_crt0/rp2350/memmap_default.ld deleted file mode 100644 index bce316d14..000000000 --- a/src/rp2_common/pico_crt0/rp2350/memmap_default.ld +++ /dev/null @@ -1,302 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - INCLUDE "pico_flash_region.ld" - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k - SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - .flash_begin : { - __flash_binary_start = .; - } > FLASH - - /* The bootrom will enter the image at the point indicated in your - IMAGE_DEF, which is usually the reset handler of your vector table. - - The debugger will use the ELF entry point, which is the _entry_point - symbol, and in our case is *different from the bootrom's entry point.* - This is used to go back through the bootrom on debugger launches only, - to perform the same initial flash setup that would be performed on a - cold boot. - */ - - .text : { - __logical_binary_start = .; - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - KEEP (*(.reset)) - /* TODO revisit this now memset/memcpy/float in ROM */ - /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from - * FLASH ... we will include any thing excluded here in .data below by default */ - *(.init) - *libgcc.a:cmse_nonsecure_call.o - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.eh_frame*) - . = ALIGN(4); - } > FLASH - - /* Note the boot2 section is optional, and should be discarded if there is - no reference to it *inside* the binary, as it is not called by the - bootrom. (The bootrom performs a simple best-effort XIP setup and - leaves it to the binary to do anything more sophisticated.) However - there is still a size limit of 256 bytes, to ensure the boot2 can be - stored in boot RAM. - - Really this is a "XIP setup function" -- the name boot2 is historic and - refers to its dual-purpose on RP2040, where it also handled vectoring - from the bootrom into the user image. - */ - - .boot2 : { - __boot2_start__ = .; - *(.boot2) - __boot2_end__ = .; - } > FLASH - - ASSERT(__boot2_end__ - __boot2_start__ <= 256, - "ERROR: Pico second stage bootloader must be no more than 256 bytes in size") - - .rodata : { - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*) - *(.srodata*) - . = ALIGN(4); - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > FLASH - __binary_info_end = .; - . = ALIGN(4); - - .ram_vector_table (NOLOAD): { - *(.ram_vector_table) - } > RAM - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - - .data : { - __data_start__ = .; - *(vtable) - - *(.time_critical*) - - /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */ - *(.text*) - . = ALIGN(4); - *(.rodata*) - . = ALIGN(4); - - *(.data*) - *(.sdata*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - *(.jcr) - . = ALIGN(4); - } > RAM AT> FLASH - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM AT> FLASH - PROVIDE(__data_end__ = .); - - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss (NOLOAD) : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - PROVIDE(__global_pointer$ = . + 2K); - *(.sbss*) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X AT > FLASH - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y AT > FLASH - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - .flash_end : { - KEEP(*(.embedded_end_block*)) - PROVIDE(__flash_binary_end = .); - } > FLASH =0xaa - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary") - ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary") - - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld b/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld deleted file mode 100644 index 5bedf6d21..000000000 --- a/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld +++ /dev/null @@ -1,256 +0,0 @@ -/* Based on GCC ARM embedded samples. - Defines the following symbols for use by code: - __exidx_start - __exidx_end - __etext - __data_start__ - __preinit_array_start - __preinit_array_end - __init_array_start - __init_array_end - __fini_array_start - __fini_array_end - __data_end__ - __bss_start__ - __bss_end__ - __end__ - end - __HeapLimit - __StackLimit - __StackTop - __stack (== StackTop) -*/ - -MEMORY -{ - RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k - SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k - SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k -} - -ENTRY(_entry_point) - -SECTIONS -{ - /* Note unlike RP2040, we start the image with a vector table even for - NO_FLASH builds. On Arm, the bootrom expects a VT at the start of the - image by default; on RISC-V, the default is to enter the image at its - lowest address, so an IMAGE_DEF item is required to specify the - nondefault entry point. */ - - .text : { - __logical_binary_start = .; - /* Vectors require 512-byte alignment on v8-M when >48 IRQs are used, - so we would waste RAM if the vector table were not at the - start. */ - KEEP (*(.vectors)) - KEEP (*(.binary_info_header)) - __binary_info_header_end = .; - KEEP (*(.embedded_block)) - __embedded_block_end = .; - __reset_start = .; - KEEP (*(.reset)) - __reset_end = .; - *(.time_critical*) - *(.text*) - . = ALIGN(4); - *(.init) - *(.fini) - /* Pull all c'tors into .text */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - /* Followed by destructors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.eh_frame*) - } > RAM - - .rodata : { - . = ALIGN(4); - *(.rodata*) - *(.srodata*) - . = ALIGN(4); - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) - . = ALIGN(4); - } > RAM - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > RAM - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > RAM - __exidx_end = .; - - /* Machine inspectable binary information */ - . = ALIGN(4); - __binary_info_start = .; - .binary_info : - { - KEEP(*(.binary_info.keep.*)) - *(.binary_info.*) - } > RAM - __binary_info_end = .; - . = ALIGN(4); - - .data : { - __data_start__ = .; - *(vtable) - *(.data*) - *(.sdata*) - - . = ALIGN(4); - *(.after_data.*) - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__mutex_array_start = .); - KEEP(*(SORT(.mutex_array.*))) - KEEP(*(.mutex_array)) - PROVIDE_HIDDEN (__mutex_array_end = .); - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(SORT(.preinit_array.*))) - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) - PROVIDE_HIDDEN (__fini_array_end = .); - - *(.jcr) - . = ALIGN(4); - } > RAM - - .tdata : { - . = ALIGN(4); - *(.tdata .tdata.* .gnu.linkonce.td.*) - /* All data end */ - __tdata_end = .; - } > RAM - PROVIDE(__data_end__ = .); - - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ - __etext = LOADADDR(.data); - - .tbss (NOLOAD) : { - . = ALIGN(4); - __bss_start__ = .; - __tls_base = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - - __tls_end = .; - } > RAM - - .bss (NOLOAD) : { - . = ALIGN(4); - __tbss_end = .; - - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) - *(COMMON) - PROVIDE(__global_pointer$ = . + 2K); - *(.sbss*) - . = ALIGN(4); - __bss_end__ = .; - } > RAM - - .heap (NOLOAD): - { - __end__ = .; - end = __end__; - KEEP(*(.heap*)) - } > RAM - /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however - to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ - __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); - - /* Start and end symbols must be word-aligned */ - .scratch_x : { - __scratch_x_start__ = .; - *(.scratch_x.*) - . = ALIGN(4); - __scratch_x_end__ = .; - } > SCRATCH_X - __scratch_x_source__ = LOADADDR(.scratch_x); - - .scratch_y : { - __scratch_y_start__ = .; - *(.scratch_y.*) - . = ALIGN(4); - __scratch_y_end__ = .; - } > SCRATCH_Y - __scratch_y_source__ = LOADADDR(.scratch_y); - - /* .stack*_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later - * - * stack1 section may be empty/missing if platform_launch_core1 is not used */ - - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. - */ - .stack1_dummy (NOLOAD): - { - *(.stack1*) - } > SCRATCH_X - .stack_dummy (NOLOAD): - { - KEEP(*(.stack*)) - } > SCRATCH_Y - - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - - /* picolibc and LLVM */ - PROVIDE (__heap_start = __end__); - PROVIDE (__heap_end = __HeapLimit); - PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); - PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); - PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); - - /* llvm-libc */ - PROVIDE (_end = __end__); - PROVIDE (__llvm_libc_heap_limit = __HeapLimit); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - - ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary") - ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary") - - /* todo assert on extra code */ -} - diff --git a/src/rp2_common/pico_standard_link/BUILD.bazel b/src/rp2_common/pico_standard_link/BUILD.bazel index 4c8ff249a..7f345bb8a 100644 --- a/src/rp2_common/pico_standard_link/BUILD.bazel +++ b/src/rp2_common/pico_standard_link/BUILD.bazel @@ -18,6 +18,56 @@ generated_pico_flash_region( }), ) +# It's possible to set linker scripts globally or on a per-binary basis. +# +# Setting globally to a custom linker script: +# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT to point to your +# custom linker script - do not use this for SDK linker scripts, you must +# use PICO_DEFAULT_BINARY_TYPE instead +# +# Setting per-binary to a custom linker script: +# * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT=@pico-sdk//bazel:empty_cc_lib +# * Manually add your desired linker script to each cc_binary. +alias( + name = "default_linker_script", + actual = select({ + # Handle selection based on PICO_DEFAULT_BINARY_TYPE here + "//bazel/constraint:pico_binary_type_no_flash": "//src/rp2_common/pico_standard_link:no_flash_linker_script", + "//bazel/constraint:pico_binary_type_copy_to_ram": "//src/rp2_common/pico_standard_link:copy_to_ram_linker_script", + "//bazel/constraint:pico_binary_type_blocked_ram": "//src/rp2_common/pico_standard_link:blocked_ram_linker_script", + # Then for the default type + "//bazel/constraint:rp2040": "//src/rp2040/pico_platform:default_linker_script", + "//bazel/constraint:rp2350": "//src/rp2350/pico_platform:default_linker_script", + "//conditions:default": "//bazel:incompatible_cc_lib", + }), +) + +alias( + name = "blocked_ram_linker_script", + actual = select({ + "//bazel/constraint:rp2040": "//src/rp2040/pico_platform:blocked_ram_linker_script", + "//conditions:default": "//bazel:incompatible_cc_lib", + }), +) + +alias( + name = "copy_to_ram_linker_script", + actual = select({ + "//bazel/constraint:rp2040": "//src/rp2040/pico_platform:copy_to_ram_linker_script", + "//bazel/constraint:rp2350": "//src/rp2350/pico_platform:copy_to_ram_linker_script", + "//conditions:default": "//bazel:incompatible_cc_lib", + }), +) + +alias( + name = "no_flash_linker_script", + actual = select({ + "//bazel/constraint:rp2040": "//src/rp2040/pico_platform:no_flash_linker_script", + "//bazel/constraint:rp2350": "//src/rp2350/pico_platform:no_flash_linker_script", + "//conditions:default": "//bazel:incompatible_cc_lib", + }), +) + cc_library( name = "pico_standard_link", target_compatible_with = compatible_with_rp2(), diff --git a/src/rp2_common/pico_standard_link/CMakeLists.txt b/src/rp2_common/pico_standard_link/CMakeLists.txt index c16968bba..6ebcd4d3d 100644 --- a/src/rp2_common/pico_standard_link/CMakeLists.txt +++ b/src/rp2_common/pico_standard_link/CMakeLists.txt @@ -5,6 +5,11 @@ if (NOT TARGET pico_standard_link) target_link_libraries(pico_standard_link INTERFACE boot_stage2_headers) endif() + pico_register_common_scope_var(PICO_LINKER_SCRIPT_INCLUDE_DIRS) + + # add the default linker script include directories + list(APPEND PICO_LINKER_SCRIPT_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/script_include) + # pico_add_link_depend(TARGET dependency) # \brief\ Add a link time dependency to the target # @@ -70,6 +75,32 @@ if (NOT TARGET pico_standard_link) set_target_properties(${TARGET} PROPERTIES PICO_TARGET_LINKER_SCRIPT ${LDSCRIPT}) endfunction() + # pico_set_linker_script_var(TARGET NAME VALUE) + # \brief\ Set the linker script for the target + # + # \param\ NAME Name of variable to set + # \param\ VALUE Value of variable to set + function(pico_set_linker_script_var TARGET NAME VALUE) + set_property(TARGET ${TARGET} APPEND PROPERTY PICO_TARGET_LINKER_SCRIPT_VARS "${NAME}=${VALUE}") + endfunction() + + # pico_add_linker_script_override_path(TARGET PATH) + # \brief\ Add an override linker script path to the target + # + # This can be used to override default linker script files with custom versions. + # + # For example, to use custom files in ${CMAKE_CURRENT_LIST_DIR}/extra_scripts instead of the default ones, + # call pico_add_linker_script_override_path(TARGET ${CMAKE_CURRENT_LIST_DIR}/extra_scripts). This will + # include the custom files first, overriding the default ones. + # + # It will not override prior paths set by pico_add_linker_script_override_path. + # + # \param\ TARGET The target to add the linker script override path to + # \param\ PATH The path containing the overriding linker scripts + function(pico_add_linker_script_override_path TARGET PATH) + set_property(TARGET ${TARGET} APPEND PROPERTY PICO_TARGET_LINKER_SCRIPT_OVERRIDE_PATHS "${PATH}") + endfunction() + # pico_set_binary_type(TARGET TYPE) # \brief\ Set the binary type for the target # @@ -78,6 +109,7 @@ if (NOT TARGET pico_standard_link) set_target_properties(${TARGET} PROPERTIES PICO_TARGET_BINARY_TYPE ${TYPE}) endfunction() + # PICO_CMAKE_CONFIG: PICO_DEFAULT_BINARY_TYPE, The default binary type to use, type=string, default=default, group=build # slightly messy as we support both the preferred PICO_DEFAULT_BINARY_TYPE and the individual variables if (NOT PICO_DEFAULT_BINARY_TYPE) if (PICO_NO_FLASH) @@ -124,8 +156,23 @@ if (NOT TARGET pico_standard_link) #math(EXPR PICO_FLASH_SIZE_BYTES_STRING "${PICO_FLASH_SIZE_BYTES}" OUTPUT_FORMAT HEXADECIMAL) set(PICO_FLASH_SIZE_BYTES_STRING "${PICO_FLASH_SIZE_BYTES}") configure_file(${CMAKE_CURRENT_LIST_DIR}/pico_flash_region.template.ld ${CMAKE_BINARY_DIR}/pico_flash_region.ld) - # add include path for linker scripts - target_link_options(pico_standard_link INTERFACE "LINKER:-L${CMAKE_BINARY_DIR}") + # add include path for linker scripts to find it + list(APPEND PICO_LINKER_SCRIPT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}) + pico_promote_common_scope_vars() + + # add override paths from PICO_TARGET_LINKER_SCRIPT_OVERRIDE_PATHS + target_link_options(pico_standard_link INTERFACE "LINKER:$<$>:-L$,,-L>>") + + # add include paths from PICO_LINKER_SCRIPT_INCLUDE_DIRS + foreach(DIR IN LISTS PICO_LINKER_SCRIPT_INCLUDE_DIRS) + target_link_options(pico_standard_link INTERFACE "LINKER:-L${DIR}") + endforeach() + + # add default locations script, so they can be referenced by pico_set_linker_script_var variables + target_link_options(pico_standard_link INTERFACE "LINKER:--script=${PICO_LINKER_DEFAULT_LOCATIONS_PATH}") + + # add variables set by pico_set_linker_script_var function + target_link_options(pico_standard_link INTERFACE "LINKER:$<$>:--defsym=$,,--defsym=>>") # LINKER script will be PICO_TARGET_LINKER_SCRIPT if set on target, or ${CMAKE_CURRENT_LIST_DIR}/memmap_foo.ld # if PICO_TARGET_BINARY_TYPE is set to foo on the target, otherwise ${CMAKE_CURRENT_LIST_DIR}/memmap_${PICO_DEFAULT_BINARY_TYPE).ld diff --git a/src/rp2_common/pico_standard_link/script_include/BUILD.bazel b/src/rp2_common/pico_standard_link/script_include/BUILD.bazel new file mode 100644 index 000000000..0cc69e0d6 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/BUILD.bazel @@ -0,0 +1,18 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("//bazel:defs.bzl", "compatible_with_rp2") +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +package(default_visibility = ["//visibility:public"]) + +linker_scripts( + name = "rp2_linker_script_includes", + include_scripts = glob(["*.incl"]), +) + +cc_library( + name = "rp2_linker_scripts", + target_compatible_with = compatible_with_rp2(), + deps = [ + "rp2_linker_script_includes", + ], +) \ No newline at end of file diff --git a/src/rp2_common/pico_standard_link/script_include/default_rodata_excludes.incl b/src/rp2_common/pico_standard_link/script_include/default_rodata_excludes.incl new file mode 100644 index 000000000..920e30383 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/default_rodata_excludes.incl @@ -0,0 +1 @@ +*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib*_a-mem*.o *libm.a:) .rodata*) \ No newline at end of file diff --git a/src/rp2_common/pico_standard_link/script_include/default_text_excludes.incl b/src/rp2_common/pico_standard_link/script_include/default_text_excludes.incl new file mode 100644 index 000000000..e81ae31bf --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/default_text_excludes.incl @@ -0,0 +1 @@ +*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib*_a-mem*.o *libm.a:) .text*) \ No newline at end of file diff --git a/src/rp2_common/pico_standard_link/script_include/memmap_copy_to_ram.incl b/src/rp2_common/pico_standard_link/script_include/memmap_copy_to_ram.incl new file mode 100644 index 000000000..f54a3e833 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memmap_copy_to_ram.incl @@ -0,0 +1,18 @@ +/* Include platform memory locations */ +INCLUDE "set_memory_locations.incl" + +/* Include memory regions used */ +INCLUDE "memory_flash.incl" +INCLUDE "memory_ram.incl" +INCLUDE "memory_scratch.incl" +INCLUDE "memory_generated.incl" +INCLUDE "memory_extra.incl" + +/* Include aliases for storage memory regions */ +INCLUDE "memory_aliases_flash.incl" + +/* Define entry point symbol */ +ENTRY(_entry_point) + +/* Include default sections */ +INCLUDE "sections_copy_to_ram.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/memmap_default.incl b/src/rp2_common/pico_standard_link/script_include/memmap_default.incl new file mode 100644 index 000000000..4f3233509 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memmap_default.incl @@ -0,0 +1,18 @@ +/* Include platform memory locations */ +INCLUDE "set_memory_locations.incl" + +/* Include memory regions used */ +INCLUDE "memory_flash.incl" +INCLUDE "memory_ram.incl" +INCLUDE "memory_scratch.incl" +INCLUDE "memory_generated.incl" +INCLUDE "memory_extra.incl" + +/* Include aliases for storage memory regions */ +INCLUDE "memory_aliases_flash.incl" + +/* Define entry point symbol */ +ENTRY(_entry_point) + +/* Include default sections */ +INCLUDE "sections_default.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/memmap_no_flash.incl b/src/rp2_common/pico_standard_link/script_include/memmap_no_flash.incl new file mode 100644 index 000000000..c043470e9 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memmap_no_flash.incl @@ -0,0 +1,17 @@ +/* Include platform memory locations */ +INCLUDE "set_memory_locations.incl" + +/* Include memory regions used */ +INCLUDE "memory_ram.incl" +INCLUDE "memory_scratch.incl" +INCLUDE "memory_generated.incl" +INCLUDE "memory_extra.incl" + +/* Include aliases for no_flash storage memory regions (alias to themselves) */ +INCLUDE "memory_aliases_no_flash.incl" + +/* Define entry point symbol */ +ENTRY(_entry_point) + +/* Include no_flash sections */ +INCLUDE "sections_no_flash.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/memory_aliases_flash.incl b/src/rp2_common/pico_standard_link/script_include/memory_aliases_flash.incl new file mode 100644 index 000000000..370b63ed1 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_aliases_flash.incl @@ -0,0 +1,6 @@ +/* Store everything in flash */ + +REGION_ALIAS("TEXT_STORE", FLASH); +REGION_ALIAS("RAM_STORE", FLASH); +REGION_ALIAS("SCRATCH_X_STORE", FLASH); +REGION_ALIAS("SCRATCH_Y_STORE", FLASH); diff --git a/src/rp2_common/pico_standard_link/script_include/memory_aliases_no_flash.incl b/src/rp2_common/pico_standard_link/script_include/memory_aliases_no_flash.incl new file mode 100644 index 000000000..258072736 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_aliases_no_flash.incl @@ -0,0 +1,6 @@ +/* Store everything where it came from (ram/scratch) */ + +REGION_ALIAS("TEXT_STORE", RAM); +REGION_ALIAS("RAM_STORE", RAM); +REGION_ALIAS("SCRATCH_X_STORE", SCRATCH_X); +REGION_ALIAS("SCRATCH_Y_STORE", SCRATCH_Y); diff --git a/src/rp2_common/pico_standard_link/script_include/memory_extra.incl b/src/rp2_common/pico_standard_link/script_include/memory_extra.incl new file mode 100644 index 000000000..cdd16166c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_extra.incl @@ -0,0 +1,17 @@ +/* Empty file + + This file can be overridden to add extra memory regions. + + For example, to add a PSRAM region, you would replace + this file with: + + MEMORY + { + PSRAM(rwx) : ORIGIN = 0x11000000, LENGTH = 8M + } + + Or to include a XIP_RAM region, you would replace + this file with: + + INCLUDE "memory_xip_ram.incl" +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/memory_flash.incl b/src/rp2_common/pico_standard_link/script_include/memory_flash.incl new file mode 100644 index 000000000..669fe00e3 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_flash.incl @@ -0,0 +1,4 @@ +MEMORY +{ + INCLUDE "pico_flash_region.ld" +} diff --git a/src/rp2_common/pico_standard_link/script_include/memory_generated.incl b/src/rp2_common/pico_standard_link/script_include/memory_generated.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_generated.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/memory_ram.incl b/src/rp2_common/pico_standard_link/script_include/memory_ram.incl new file mode 100644 index 000000000..2b8a88a06 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_ram.incl @@ -0,0 +1,4 @@ +MEMORY +{ + RAM(rwx) : ORIGIN = RAM_ORIGIN, LENGTH = RAM_LENGTH +} diff --git a/src/rp2_common/pico_standard_link/script_include/memory_scratch.incl b/src/rp2_common/pico_standard_link/script_include/memory_scratch.incl new file mode 100644 index 000000000..7ba5d2172 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_scratch.incl @@ -0,0 +1,5 @@ +MEMORY +{ + SCRATCH_X(rwx) : ORIGIN = SCRATCH_X_ORIGIN, LENGTH = SCRATCH_X_LENGTH + SCRATCH_Y(rwx) : ORIGIN = SCRATCH_Y_ORIGIN, LENGTH = SCRATCH_Y_LENGTH +} diff --git a/src/rp2_common/pico_standard_link/script_include/memory_xip_ram.incl b/src/rp2_common/pico_standard_link/script_include/memory_xip_ram.incl new file mode 100644 index 000000000..636e90137 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/memory_xip_ram.incl @@ -0,0 +1,4 @@ +MEMORY +{ + XIP_RAM(rwx) : ORIGIN = XIP_RAM_ORIGIN, LENGTH = XIP_RAM_LENGTH +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_binary_info.incl b/src/rp2_common/pico_standard_link/script_include/section_binary_info.incl new file mode 100644 index 000000000..7c76c03e9 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_binary_info.incl @@ -0,0 +1,17 @@ +/* Defines the following symbols for use by code: + __binary_info_start, __binary_info_end +*/ + +SECTIONS +{ + /* Machine inspectable binary information */ + . = ALIGN(4); + __binary_info_start = .; + .binary_info : + { + KEEP(*(.binary_info.keep.*)) + *(.binary_info.*) + } > TEXT_STORE + __binary_info_end = .; + . = ALIGN(4); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_boot2.incl b/src/rp2_common/pico_standard_link/script_include/section_boot2.incl new file mode 100644 index 000000000..7423819c4 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_boot2.incl @@ -0,0 +1,27 @@ +/* Defines the following symbols for use by code: + __boot2_start__, __boot2_end__ +*/ + +SECTIONS +{ + /* Note the boot2 section is optional, and should be discarded if there is + no reference to it *inside* the binary, as it is not called by the + bootrom. (The bootrom performs a simple best-effort XIP setup and + leaves it to the binary to do anything more sophisticated.) However + there is still a size limit of 256 bytes, to ensure the boot2 can be + stored in boot RAM. + + Really this is a "XIP setup function" -- the name boot2 is historic and + refers to its dual-purpose on RP2040, where it also handled vectoring + from the bootrom into the user image. + */ + + .boot2 : { + __boot2_start__ = .; + *(.boot2) + __boot2_end__ = .; + } > TEXT_STORE + + ASSERT(__boot2_end__ - __boot2_start__ <= 256, + "ERROR: Pico second stage bootloader must be no more than 256 bytes in size") +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_bss.incl b/src/rp2_common/pico_standard_link/script_include/section_bss.incl new file mode 100644 index 000000000..38de94018 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_bss.incl @@ -0,0 +1,31 @@ +/* Defines the following symbols for use by code: + __bss_start__, __bss_end__ + __tls_base, __tls_end + __tbss_end + __global_pointer$ +*/ + +SECTIONS +{ + .tbss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + __tls_base = .; + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + + __tls_end = .; + } > RAM + + .bss (NOLOAD) : { + . = ALIGN(4); + __tbss_end = .; + + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) + *(COMMON) + PROVIDE(__global_pointer$ = . + 2K); + *(.sbss*) + . = ALIGN(4); + __bss_end__ = .; + } > RAM +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_data.incl b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_data.incl new file mode 100644 index 000000000..60890c885 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_data.incl @@ -0,0 +1,71 @@ +/* Defines the following symbols for use by code: + __data_start__, __data_end__ + __mutex_array_start, __mutex_array_end + __preinit_array_start, __preinit_array_end + __init_array_start, __init_array_end + __fini_array_start, __fini_array_end + __tdata_end + __etext +*/ + +SECTIONS +{ + .data : { + __data_start__ = .; + *(vtable) + + *(.time_critical*) + + . = ALIGN(4); + *(.rodata*) + *(.srodata*) + . = ALIGN(4); + + *(.data*) + *(.sdata*) + + . = ALIGN(4); + *(.after_data.*) + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__mutex_array_start = .); + KEEP(*(SORT(.mutex_array.*))) + KEEP(*(.mutex_array)) + PROVIDE_HIDDEN (__mutex_array_end = .); + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(SORT(.preinit_array.*))) + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + *(SORT(.fini_array.*)) + *(.fini_array) + PROVIDE_HIDDEN (__fini_array_end = .); + + *(.jcr) + . = ALIGN(4); + } > RAM AT> RAM_STORE + + .tdata : { + . = ALIGN(4); + *(.tdata .tdata.* .gnu.linkonce.td.*) + /* All data end */ + __tdata_end = .; + } > RAM AT> RAM_STORE + PROVIDE(__data_end__ = .); + + /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ + __etext = LOADADDR(.data); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_flashtext.incl b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_flashtext.incl new file mode 100644 index 000000000..8c0792d0e --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_flashtext.incl @@ -0,0 +1,31 @@ +/* Defines the following symbols for use by code: + __logical_binary_start + __binary_info_header_end + __embedded_block_end +*/ + +SECTIONS +{ + /* The bootrom will enter the image at the entry point indicated in your + IMAGE_DEF, which is usually the reset handler of your vector table. + If there is no entry point indicated in the IMAGE_DEF, it expects a VT + at the start of the image, and will use the entry point from that. + + The debugger will use the ELF entry point, which is the _entry_point + symbol, and in our case is *different from the bootrom's entry point.* + This is used to go back through the bootrom on debugger launches only, + to perform the same initial flash setup that would be performed on a + cold boot. + */ + + .flashtext : { + __logical_binary_start = .; + KEEP (*(.vectors)) + KEEP (*(.binary_info_header)) + __binary_info_header_end = .; + KEEP (*(.embedded_block)) + __embedded_block_end = .; + KEEP (*(.reset)) + . = ALIGN(4); + } > TEXT_STORE +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_rodata.incl b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_rodata.incl new file mode 100644 index 000000000..a6de46efc --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_rodata.incl @@ -0,0 +1,8 @@ +SECTIONS +{ + .rodata : { + /* segments not marked as .flashdata are instead pulled into .data (in RAM) to avoid accidental flash accesses */ + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) + . = ALIGN(4); + } > TEXT_STORE +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_text.incl b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_text.incl new file mode 100644 index 000000000..a9e36bbb1 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_copy_to_ram_text.incl @@ -0,0 +1,31 @@ +/* Defines the following symbols for use by code: + __ram_text_start__, __ram_text_end__, __ram_text_source__ +*/ + +SECTIONS +{ + .text : { + __ram_text_start__ = .; + *(.init) + *(.text*) + *(.fini) + /* Pull all c'tors into .text */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* Followed by destructors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.eh_frame*) + . = ALIGN(4); + __ram_text_end__ = .; + } > RAM AT> RAM_STORE + __ram_text_source__ = LOADADDR(.text); + . = ALIGN(4); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_default_data.incl b/src/rp2_common/pico_standard_link/script_include/section_default_data.incl new file mode 100644 index 000000000..114b3c493 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_default_data.incl @@ -0,0 +1,47 @@ +/* Defines the following symbols for use by code: + __data_start__, __data_end__ + __mutex_array_start, __mutex_array_end + __etext +*/ + +SECTIONS +{ + .data : { + __data_start__ = .; + *(vtable) + + *(.time_critical*) + + /* remaining .text and .rodata; i.e. stuff we exclude in ..._excludes files because we want it in RAM */ + *(.text*) + . = ALIGN(4); + *(.rodata*) + . = ALIGN(4); + + *(.data*) + *(.sdata*) + + . = ALIGN(4); + *(.after_data.*) + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__mutex_array_start = .); + KEEP(*(SORT(.mutex_array.*))) + KEEP(*(.mutex_array)) + PROVIDE_HIDDEN (__mutex_array_end = .); + + *(.jcr) + . = ALIGN(4); + } > RAM AT> RAM_STORE + + .tdata : { + . = ALIGN(4); + *(.tdata .tdata.* .gnu.linkonce.td.*) + /* All data end */ + __tdata_end = .; + } > RAM AT> RAM_STORE + PROVIDE(__data_end__ = .); + + /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ + __etext = LOADADDR(.data); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_default_rodata.incl b/src/rp2_common/pico_standard_link/script_include/section_default_rodata.incl new file mode 100644 index 000000000..2df23bbf2 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_default_rodata.incl @@ -0,0 +1,10 @@ +SECTIONS +{ + .rodata : { + INCLUDE "default_rodata_excludes.incl" + *(.srodata*) + . = ALIGN(4); + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) + . = ALIGN(4); + } > TEXT_STORE +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_default_text.incl b/src/rp2_common/pico_standard_link/script_include/section_default_text.incl new file mode 100644 index 000000000..911cafab2 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_default_text.incl @@ -0,0 +1,76 @@ +/* Defines the following symbols for use by code: + __logical_binary_start + __binary_info_header_end + __embedded_block_end + __preinit_array_start, __preinit_array_end + __init_array_start, __init_array_end + __fini_array_start, __fini_array_end +*/ + +SECTIONS +{ + /* The bootrom will enter the image at the entry point indicated in your + IMAGE_DEF, which is usually the reset handler of your vector table. + If there is no entry point indicated in the IMAGE_DEF, it expects a VT + at the start of the image, and will use the entry point from that. + + The debugger will use the ELF entry point, which is the _entry_point + symbol, and in our case is *different from the bootrom's entry point.* + This is used to go back through the bootrom on debugger launches only, + to perform the same initial flash setup that would be performed on a + cold boot. + */ + + .text : { + __logical_binary_start = .; + KEEP (*(.vectors)) + KEEP (*(.binary_info_header)) + __binary_info_header_end = .; + KEEP (*(.embedded_block)) + __embedded_block_end = .; + KEEP (*(.reset)) + /* TODO revisit this now memset/memcpy/float in ROM */ + /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from + * FLASH ... we will include any thing excluded here in .data below by default */ + *(.init) + *libgcc.a:cmse_nonsecure_call.o + INCLUDE "default_text_excludes.incl" + *(.fini) + /* Pull all c'tors into .text */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* Followed by destructors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(SORT(.preinit_array.*))) + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + *(SORT(.fini_array.*)) + *(.fini_array) + PROVIDE_HIDDEN (__fini_array_end = .); + + *(.eh_frame*) + . = ALIGN(4); + } > TEXT_STORE +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_end.incl b/src/rp2_common/pico_standard_link/script_include/section_end.incl new file mode 100644 index 000000000..3ffddcabd --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_end.incl @@ -0,0 +1,33 @@ +/* Defines the following symbols for use by code: + __StackLimit + __StackOneTop, __StackOneBottom + __StackTop, __StackBottom + __stack (== __StackTop) + + Also defines additional symbols for other compilers/libcs +*/ + +SECTIONS +{ + /* stack limit is poorly named, but historically is maximum heap ptr */ + __StackLimit = ORIGIN(RAM) + LENGTH(RAM); + __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); + __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); + __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); + __StackBottom = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + /* picolibc and LLVM */ + PROVIDE (__heap_start = __end__); + PROVIDE (__heap_end = __HeapLimit); + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); + PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1)); + PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); + + /* llvm-libc */ + PROVIDE (_end = __end__); + PROVIDE (__llvm_libc_heap_limit = __HeapLimit); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_extra_post_data.incl b/src/rp2_common/pico_standard_link/script_include/section_extra_post_data.incl new file mode 100644 index 000000000..00360c637 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_extra_post_data.incl @@ -0,0 +1,6 @@ +/* Empty file + + This file is included between the end of data/bss and the start of the heap. + + It can be overridden to add extra sections into ram. +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_extra_post_end.incl b/src/rp2_common/pico_standard_link/script_include/section_extra_post_end.incl new file mode 100644 index 000000000..24a964de1 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_extra_post_end.incl @@ -0,0 +1,7 @@ +/* Empty file + + This file is included after the section_end file. + + It can be overridden to override any symbols provided by the linker scripts, + or to add custom asserts. +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_extra_post_platform_end.incl b/src/rp2_common/pico_standard_link/script_include/section_extra_post_platform_end.incl new file mode 100644 index 000000000..7be81fcd5 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_extra_post_platform_end.incl @@ -0,0 +1,9 @@ +/* Empty file + + This file is included after the section_platform_end file. + + It can be overridden to override any symbols provided by the linker scripts, + or to add custom asserts. + + It is intended to be used for platform specific overrides. +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_extra_post_scratch.incl b/src/rp2_common/pico_standard_link/script_include/section_extra_post_scratch.incl new file mode 100644 index 000000000..245c039ee --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_extra_post_scratch.incl @@ -0,0 +1,6 @@ +/* Empty file + + This file is included between the end of scratch and the start of the stack. + + It can be overridden to add extra sections in the scratch memory, before the stack. +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_extra_post_text.incl b/src/rp2_common/pico_standard_link/script_include/section_extra_post_text.incl new file mode 100644 index 000000000..e21811e4c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_extra_post_text.incl @@ -0,0 +1,6 @@ +/* Empty file + + This file is included between the end of text and the start of data. + + It can be overridden to add extra sections into flash. +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_flash_begin.incl b/src/rp2_common/pico_standard_link/script_include/section_flash_begin.incl new file mode 100644 index 000000000..48492a926 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_flash_begin.incl @@ -0,0 +1,10 @@ +/* Defines the following symbols for use by code: + __flash_binary_start +*/ + +SECTIONS +{ + .flash_begin : { + __flash_binary_start = .; + } > TEXT_STORE +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_flash_end.incl b/src/rp2_common/pico_standard_link/script_include/section_flash_end.incl new file mode 100644 index 000000000..38d3481d7 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_flash_end.incl @@ -0,0 +1,11 @@ +/* Defines the following symbols for use by code: + __flash_binary_end +*/ + +SECTIONS +{ + .flash_end : { + KEEP(*(.embedded_end_block*)) + PROVIDE(__flash_binary_end = .); + } > TEXT_STORE =0xaa +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_generated_post_data.incl b/src/rp2_common/pico_standard_link/script_include/section_generated_post_data.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_generated_post_data.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_generated_post_end.incl b/src/rp2_common/pico_standard_link/script_include/section_generated_post_end.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_generated_post_end.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_generated_post_platform_end.incl b/src/rp2_common/pico_standard_link/script_include/section_generated_post_platform_end.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_generated_post_platform_end.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_generated_post_scratch.incl b/src/rp2_common/pico_standard_link/script_include/section_generated_post_scratch.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_generated_post_scratch.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_generated_post_text.incl b/src/rp2_common/pico_standard_link/script_include/section_generated_post_text.incl new file mode 100644 index 000000000..2060e314c --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_generated_post_text.incl @@ -0,0 +1,4 @@ +/* DO NOT OVERRIDE THIS FILE + + This file is provided for the SDK to override +*/ diff --git a/src/rp2_common/pico_standard_link/script_include/section_heap.incl b/src/rp2_common/pico_standard_link/script_include/section_heap.incl new file mode 100644 index 000000000..240e118d4 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_heap.incl @@ -0,0 +1,16 @@ +/* Defines the following symbols for use by code: + __HeapLimit +*/ + +SECTIONS +{ + .heap DEFINED(HEAP_LOC) ? HEAP_LOC : . (NOLOAD): + { + __end__ = .; + end = __end__; + KEEP(*(.heap*)) + } > RAM + /* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however + to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */ + __HeapLimit = DEFINED(HEAP_LIMIT) ? HEAP_LIMIT : ORIGIN(RAM) + LENGTH(RAM); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_no_flash_data.incl b/src/rp2_common/pico_standard_link/script_include/section_no_flash_data.incl new file mode 100644 index 000000000..57c38782f --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_no_flash_data.incl @@ -0,0 +1,66 @@ +/* Defines the following symbols for use by code: + __data_start__, __data_end__ + __mutex_array_start, __mutex_array_end + __preinit_array_start, __preinit_array_end + __init_array_start, __init_array_end + __fini_array_start, __fini_array_end + __tdata_end + __etext +*/ + +SECTIONS +{ + .data : { + __data_start__ = .; + *(vtable) + + *(.time_critical*) + + *(.data*) + *(.sdata*) + + . = ALIGN(4); + *(.after_data.*) + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__mutex_array_start = .); + KEEP(*(SORT(.mutex_array.*))) + KEEP(*(.mutex_array)) + PROVIDE_HIDDEN (__mutex_array_end = .); + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(SORT(.preinit_array.*))) + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + *(SORT(.fini_array.*)) + *(.fini_array) + PROVIDE_HIDDEN (__fini_array_end = .); + + *(.jcr) + . = ALIGN(4); + } > RAM + + .tdata : { + . = ALIGN(4); + *(.tdata .tdata.* .gnu.linkonce.td.*) + /* All data end */ + __tdata_end = .; + } > RAM + PROVIDE(__data_end__ = .); + + /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ + __etext = LOADADDR(.data); +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_no_flash_rodata.incl b/src/rp2_common/pico_standard_link/script_include/section_no_flash_rodata.incl new file mode 100644 index 000000000..9e5ae119d --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_no_flash_rodata.incl @@ -0,0 +1,11 @@ +SECTIONS +{ + .rodata : { + . = ALIGN(4); + *(.rodata*) + *(.srodata*) + . = ALIGN(4); + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) + . = ALIGN(4); + } > RAM +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_no_flash_text.incl b/src/rp2_common/pico_standard_link/script_include/section_no_flash_text.incl new file mode 100644 index 000000000..e7ec24187 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_no_flash_text.incl @@ -0,0 +1,47 @@ +/* Defines the following symbols for use by code: + __logical_binary_start + __binary_info_header_end + __embedded_block_end + __reset_start, __reset_end +*/ + +SECTIONS +{ + /* On Arm, the bootrom expects a VT at the start of the image by default; + on RISC-V, the default is to enter the image at its lowest address, so + an IMAGE_DEF item is required to specify the nondefault entry point. + */ + + .text : { + __logical_binary_start = .; + /* Vectors require 512-byte alignment on v8-M when >48 IRQs are used, + so we would waste RAM if the vector table were not at the + start. */ + KEEP (*(.vectors)) + KEEP (*(.binary_info_header)) + __binary_info_header_end = .; + KEEP (*(.embedded_block)) + __embedded_block_end = .; + __reset_start = .; + KEEP (*(.reset)) + __reset_end = .; + *(.text*) + . = ALIGN(4); + *(.init) + *(.fini) + /* Pull all c'tors into .text */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* Followed by destructors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.eh_frame*) + } > RAM +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_ram_vector_table.incl b/src/rp2_common/pico_standard_link/script_include/section_ram_vector_table.incl new file mode 100644 index 000000000..1e5818110 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_ram_vector_table.incl @@ -0,0 +1,6 @@ +SECTIONS +{ + .ram_vector_table (NOLOAD): { + *(.ram_vector_table) + } > RAM +} diff --git a/src/rp2_common/pico_standard_link/script_include/section_uninitialized_data.incl b/src/rp2_common/pico_standard_link/script_include/section_uninitialized_data.incl new file mode 100644 index 000000000..6167314be --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/section_uninitialized_data.incl @@ -0,0 +1,7 @@ +SECTIONS +{ + .uninitialized_data (NOLOAD): { + . = ALIGN(4); + *(.uninitialized_data*) + } > RAM +} diff --git a/src/rp2_common/pico_standard_link/script_include/sections_arm_ex.incl b/src/rp2_common/pico_standard_link/script_include/sections_arm_ex.incl new file mode 100644 index 000000000..cf4cb4dee --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_arm_ex.incl @@ -0,0 +1,18 @@ +/* Defines the following symbols for use by code: + __exidx_start, __exidx_end +*/ + +SECTIONS +{ + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > TEXT_STORE + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > TEXT_STORE + __exidx_end = .; +} diff --git a/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram.incl b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram.incl new file mode 100644 index 000000000..0c3c7d42e --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram.incl @@ -0,0 +1,20 @@ +/* Main section list for copy_to_ram binaries */ + +INCLUDE "sections_copy_to_ram_text.incl" +INCLUDE "section_generated_post_text.incl" +INCLUDE "section_extra_post_text.incl" +INCLUDE "sections_copy_to_ram_data.incl" +INCLUDE "section_generated_post_data.incl" +INCLUDE "section_extra_post_data.incl" +INCLUDE "section_heap.incl" +INCLUDE "sections_scratch.incl" +INCLUDE "section_generated_post_scratch.incl" +INCLUDE "section_extra_post_scratch.incl" +INCLUDE "sections_stack.incl" +INCLUDE "section_flash_end.incl" +INCLUDE "section_end.incl" +INCLUDE "section_generated_post_end.incl" +INCLUDE "section_extra_post_end.incl" +INCLUDE "section_platform_end.incl" +INCLUDE "section_generated_post_platform_end.incl" +INCLUDE "section_extra_post_platform_end.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_data.incl b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_data.incl new file mode 100644 index 000000000..ff90005e1 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_data.incl @@ -0,0 +1,4 @@ +/* Sub-section list for read/write sections in copy_to_ram binaries */ + +INCLUDE "section_copy_to_ram_data.incl" +INCLUDE "section_bss.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_text.incl b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_text.incl new file mode 100644 index 000000000..7dcb9c1cf --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_copy_to_ram_text.incl @@ -0,0 +1,11 @@ +/* Sub-section list for read-only sections in copy_to_ram binaries */ + +INCLUDE "section_flash_begin.incl" +INCLUDE "section_copy_to_ram_flashtext.incl" +INCLUDE "section_boot2.incl" +INCLUDE "section_copy_to_ram_rodata.incl" +INCLUDE "sections_arm_ex.incl" +INCLUDE "section_binary_info.incl" +INCLUDE "section_ram_vector_table.incl" +INCLUDE "section_uninitialized_data.incl" +INCLUDE "section_copy_to_ram_text.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_default.incl b/src/rp2_common/pico_standard_link/script_include/sections_default.incl new file mode 100644 index 000000000..4e07b3968 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_default.incl @@ -0,0 +1,20 @@ +/* Main section list for default binaries */ + +INCLUDE "sections_default_text.incl" +INCLUDE "section_generated_post_text.incl" +INCLUDE "section_extra_post_text.incl" +INCLUDE "sections_default_data.incl" +INCLUDE "section_generated_post_data.incl" +INCLUDE "section_extra_post_data.incl" +INCLUDE "section_heap.incl" +INCLUDE "sections_scratch.incl" +INCLUDE "section_generated_post_scratch.incl" +INCLUDE "section_extra_post_scratch.incl" +INCLUDE "sections_stack.incl" +INCLUDE "section_flash_end.incl" +INCLUDE "section_end.incl" +INCLUDE "section_generated_post_end.incl" +INCLUDE "section_extra_post_end.incl" +INCLUDE "section_platform_end.incl" +INCLUDE "section_generated_post_platform_end.incl" +INCLUDE "section_extra_post_platform_end.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_default_data.incl b/src/rp2_common/pico_standard_link/script_include/sections_default_data.incl new file mode 100644 index 000000000..cfa77cb2f --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_default_data.incl @@ -0,0 +1,6 @@ +/* Sub-section list for read/write sections in default binaries */ + +INCLUDE "section_ram_vector_table.incl" +INCLUDE "section_uninitialized_data.incl" +INCLUDE "section_default_data.incl" +INCLUDE "section_bss.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_default_text.incl b/src/rp2_common/pico_standard_link/script_include/sections_default_text.incl new file mode 100644 index 000000000..cc1985309 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_default_text.incl @@ -0,0 +1,8 @@ +/* Sub-section list for read-only sections in default binaries */ + +INCLUDE "section_flash_begin.incl" +INCLUDE "section_default_text.incl" +INCLUDE "section_boot2.incl" +INCLUDE "section_default_rodata.incl" +INCLUDE "sections_arm_ex.incl" +INCLUDE "section_binary_info.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_no_flash.incl b/src/rp2_common/pico_standard_link/script_include/sections_no_flash.incl new file mode 100644 index 000000000..e9ba353df --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_no_flash.incl @@ -0,0 +1,19 @@ +/* Main section list for no_flash binaries */ + +INCLUDE "sections_no_flash_text.incl" +INCLUDE "section_generated_post_text.incl" +INCLUDE "section_extra_post_text.incl" +INCLUDE "sections_no_flash_data.incl" +INCLUDE "section_generated_post_data.incl" +INCLUDE "section_extra_post_data.incl" +INCLUDE "section_heap.incl" +INCLUDE "sections_scratch.incl" +INCLUDE "section_generated_post_scratch.incl" +INCLUDE "section_extra_post_scratch.incl" +INCLUDE "sections_stack.incl" +INCLUDE "section_end.incl" +INCLUDE "section_generated_post_end.incl" +INCLUDE "section_extra_post_end.incl" +INCLUDE "section_platform_end.incl" +INCLUDE "section_generated_post_platform_end.incl" +INCLUDE "section_extra_post_platform_end.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_no_flash_data.incl b/src/rp2_common/pico_standard_link/script_include/sections_no_flash_data.incl new file mode 100644 index 000000000..6a55a1481 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_no_flash_data.incl @@ -0,0 +1,5 @@ +/* Sub-section list for read/write sections in no_flash binaries */ + +INCLUDE "section_no_flash_data.incl" +INCLUDE "section_uninitialized_data.incl" +INCLUDE "section_bss.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_no_flash_text.incl b/src/rp2_common/pico_standard_link/script_include/sections_no_flash_text.incl new file mode 100644 index 000000000..0217b33c5 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_no_flash_text.incl @@ -0,0 +1,6 @@ +/* Sub-section list for read-only sections in no_flash binaries */ + +INCLUDE "section_no_flash_text.incl" +INCLUDE "section_no_flash_rodata.incl" +INCLUDE "sections_arm_ex.incl" +INCLUDE "section_binary_info.incl" diff --git a/src/rp2_common/pico_standard_link/script_include/sections_scratch.incl b/src/rp2_common/pico_standard_link/script_include/sections_scratch.incl new file mode 100644 index 000000000..7505ca627 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_scratch.incl @@ -0,0 +1,24 @@ +/* Defines the following symbols for use by code: + __scratch_x_start__, __scratch_x_end__, __scratch_x_source__ + __scratch_y_start__, __scratch_y_end__, __scratch_y_source__ +*/ + +SECTIONS +{ + /* Start and end symbols must be word-aligned */ + .scratch_x : { + __scratch_x_start__ = .; + *(.scratch_x.*) + . = ALIGN(4); + __scratch_x_end__ = .; + } > SCRATCH_X AT> SCRATCH_X_STORE + __scratch_x_source__ = LOADADDR(.scratch_x); + + .scratch_y : { + __scratch_y_start__ = .; + *(.scratch_y.*) + . = ALIGN(4); + __scratch_y_end__ = .; + } > SCRATCH_Y AT> SCRATCH_Y_STORE + __scratch_y_source__ = LOADADDR(.scratch_y); +} diff --git a/src/rp2_common/pico_standard_link/script_include/sections_stack.incl b/src/rp2_common/pico_standard_link/script_include/sections_stack.incl new file mode 100644 index 000000000..15aaa8572 --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/sections_stack.incl @@ -0,0 +1,20 @@ +SECTIONS +{ + /* .stack*_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later + * + * stack1 section may be empty/missing if platform_launch_core1 is not used */ + + /* by default we put core 0 stack at the end of scratch Y, so that if core 1 + * stack is not used then all of SCRATCH_X is free. + */ + .stack1_dummy (NOLOAD): + { + *(.stack1*) + } > SCRATCH_X + .stack_dummy (NOLOAD): + { + KEEP(*(.stack*)) + } > SCRATCH_Y +} diff --git a/src/rp2_common/pico_standard_link/script_include/set_memory_locations.incl b/src/rp2_common/pico_standard_link/script_include/set_memory_locations.incl new file mode 100644 index 000000000..a2341f42a --- /dev/null +++ b/src/rp2_common/pico_standard_link/script_include/set_memory_locations.incl @@ -0,0 +1,10 @@ +/* Set memory locations either to the already defined value, or to the default value from default_locations.ld */ + +RAM_ORIGIN = DEFINED(RAM_ORIGIN) ? RAM_ORIGIN : RAM_ORIGIN_DEFAULT; +RAM_LENGTH = DEFINED(RAM_LENGTH) ? RAM_LENGTH : RAM_LENGTH_DEFAULT; +SCRATCH_X_ORIGIN = DEFINED(SCRATCH_X_ORIGIN) ? SCRATCH_X_ORIGIN : SCRATCH_X_ORIGIN_DEFAULT; +SCRATCH_X_LENGTH = DEFINED(SCRATCH_X_LENGTH) ? SCRATCH_X_LENGTH : SCRATCH_X_LENGTH_DEFAULT; +SCRATCH_Y_ORIGIN = DEFINED(SCRATCH_Y_ORIGIN) ? SCRATCH_Y_ORIGIN : SCRATCH_Y_ORIGIN_DEFAULT; +SCRATCH_Y_LENGTH = DEFINED(SCRATCH_Y_LENGTH) ? SCRATCH_Y_LENGTH : SCRATCH_Y_LENGTH_DEFAULT; +XIP_RAM_ORIGIN = DEFINED(XIP_RAM_ORIGIN) ? XIP_RAM_ORIGIN : XIP_RAM_ORIGIN_DEFAULT; +XIP_RAM_LENGTH = DEFINED(XIP_RAM_LENGTH) ? XIP_RAM_LENGTH : XIP_RAM_LENGTH_DEFAULT; diff --git a/test/kitchen_sink/BUILD.bazel b/test/kitchen_sink/BUILD.bazel index fd0dd5ef9..e4e9df23b 100644 --- a/test/kitchen_sink/BUILD.bazel +++ b/test/kitchen_sink/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("//bazel:defs.bzl", "compatible_with_rp2", "pico_generate_pio_header") -load("//bazel/util:transition.bzl", "kitchen_sink_test_binary") +load("//bazel:defs.bzl", "compatible_with_rp2", "pico_generate_pio_header", "incompatible_with_config") +load("//bazel/util:transition.bzl", "kitchen_sink_test_binary", "pico_set_binary_type", "pico_set_linker_script") package(default_visibility = ["//visibility:public"]) @@ -108,6 +108,107 @@ cc_binary( deps = [":kitchen_sink_common"], ) +cc_binary( + name = "kitchen_sink_copy_to_ram_actual", + testonly = True, + srcs = ["kitchen_sink.c"], + tags = ["manual"], # Built via kitchen_sink_copy_to_ram + deps = [":kitchen_sink_common"], +) + +cc_binary( + name = "kitchen_sink_no_flash_actual", + testonly = True, + srcs = ["kitchen_sink.c"], + tags = ["manual"], # Built via kitchen_sink_no_flash + deps = [":kitchen_sink_common"], +) + +cc_binary( + name = "kitchen_sink_blocked_ram_actual", + testonly = True, + srcs = ["kitchen_sink.c"], + tags = ["manual"], # Built via kitchen_sink_blocked_ram + deps = [":kitchen_sink_common"], +) + +pico_set_binary_type( + name = "kitchen_sink_copy_to_ram", + testonly = True, + src = ":kitchen_sink_copy_to_ram_actual", + binary_type = "copy_to_ram", + target_compatible_with = compatible_with_rp2(), +) + +pico_set_binary_type( + name = "kitchen_sink_no_flash", + testonly = True, + src = ":kitchen_sink_no_flash_actual", + binary_type = "no_flash", + target_compatible_with = compatible_with_rp2(), +) + +pico_set_binary_type( + name = "kitchen_sink_blocked_ram", + testonly = True, + src = ":kitchen_sink_blocked_ram_actual", + binary_type = "blocked_ram", + target_compatible_with = ["//bazel/constraint:rp2040"], +) + +cc_binary( + name = "kitchen_sink_ram_section_actual", + testonly = True, + srcs = ["kitchen_sink.c"], + tags = ["manual"], # Built via kitchen_sink_ram_section + deps = [":kitchen_sink_common"], + defines = ["EXTRA_DATA_SECTION=1"] +) + +cc_library( + name = "kitchen_sink_ram_section_linker_script", + deps = [ + "//test/kitchen_sink/kitchen_sink_ram_section_scripts:kitchen_sink_ram_section_scripts", + "//test/kitchen_sink/kitchen_sink_extra_end_scripts:kitchen_sink_extra_end_scripts", + "//src/rp2_common/pico_standard_link:default_linker_script", + ], +) + +pico_set_linker_script( + name = "kitchen_sink_ram_section", + testonly = True, + src = ":kitchen_sink_ram_section_actual", + linker_script = "//test/kitchen_sink:kitchen_sink_ram_section_linker_script", + target_compatible_with = compatible_with_rp2(), +) + +cc_binary( + name = "kitchen_sink_simple_overlay_actual", + testonly = True, + srcs = ["kitchen_sink.c"], + tags = ["manual"], # Built via kitchen_sink_simple_overlay + deps = [":kitchen_sink_common"], + defines = ["EXTRA_DATA_SECTION=2"] +) + +cc_library( + name = "kitchen_sink_simple_overlay_linker_script", + deps = [ + "//test/kitchen_sink/kitchen_sink_simple_overlay_scripts:kitchen_sink_simple_overlay_scripts", + "//test/kitchen_sink/kitchen_sink_extra_end_scripts:kitchen_sink_extra_end_scripts", + "//src/rp2_common/pico_standard_link:default_linker_script", + ], +) + +pico_set_linker_script( + name = "kitchen_sink_simple_overlay", + testonly = True, + src = ":kitchen_sink_simple_overlay_actual", + linker_script = "//test/kitchen_sink:kitchen_sink_simple_overlay_linker_script", + # Clang does not support overlay sections + target_compatible_with = compatible_with_rp2() + incompatible_with_config("//bazel/constraint:pico_toolchain_clang_enabled"), +) + cc_binary( name = "kitchen_sink_lwip_poll_actual", testonly = True, diff --git a/test/kitchen_sink/CMakeLists.txt b/test/kitchen_sink/CMakeLists.txt index 1d6110f4c..ed039d87e 100644 --- a/test/kitchen_sink/CMakeLists.txt +++ b/test/kitchen_sink/CMakeLists.txt @@ -214,6 +214,35 @@ if (NOT KITCHEN_SINK_NO_BINARY_TYPE_VARIANTS) pico_add_extra_outputs(kitchen_sink_blocked_ram) target_compile_definitions(kitchen_sink_blocked_ram PRIVATE KITCHEN_SINK_ID="blocked-ram binary") endif() + + add_executable(kitchen_sink_ram_custom ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + # Have ram start from 0x20020000 length 128k, and heap start from 0x20030000 + pico_set_linker_script_var(kitchen_sink_ram_custom RAM_ORIGIN 0x20020000) + pico_set_linker_script_var(kitchen_sink_ram_custom RAM_LENGTH 128k) + pico_set_linker_script_var(kitchen_sink_ram_custom HEAP_LOC 0x20030000) + # Also swap scratch x and scratch y, to test using defaults + pico_set_linker_script_var(kitchen_sink_ram_custom SCRATCH_X_ORIGIN SCRATCH_Y_ORIGIN_DEFAULT) + pico_set_linker_script_var(kitchen_sink_ram_custom SCRATCH_Y_ORIGIN SCRATCH_X_ORIGIN_DEFAULT) + target_link_libraries(kitchen_sink_ram_custom kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_ram_custom) + target_compile_definitions(kitchen_sink_ram_custom PRIVATE KITCHEN_SINK_ID="custom ram binary") + + add_executable(kitchen_sink_ram_section ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + pico_add_linker_script_override_path(kitchen_sink_ram_section ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_ram_section_scripts) + pico_add_linker_script_override_path(kitchen_sink_ram_section ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_extra_end_scripts) + target_link_libraries(kitchen_sink_ram_section kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_ram_section) + target_compile_definitions(kitchen_sink_ram_section PRIVATE KITCHEN_SINK_ID="ram section binary" EXTRA_DATA_SECTION=1) + + if (NOT PICO_C_COMPILER_IS_CLANG) + # Clang does not support overlay sections + add_executable(kitchen_sink_simple_overlay ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + pico_add_linker_script_override_path(kitchen_sink_simple_overlay ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_simple_overlay_scripts) + pico_add_linker_script_override_path(kitchen_sink_simple_overlay ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_extra_end_scripts) + target_link_libraries(kitchen_sink_simple_overlay kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_simple_overlay) + target_compile_definitions(kitchen_sink_simple_overlay PRIVATE KITCHEN_SINK_ID="simple overlay binary" EXTRA_DATA_SECTION=2) + endif() endif() add_executable(kitchen_sink_cpp ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_cpp.cpp) diff --git a/test/kitchen_sink/kitchen_sink.c b/test/kitchen_sink/kitchen_sink.c index 7bc2bcd11..0b712a220 100644 --- a/test/kitchen_sink/kitchen_sink.c +++ b/test/kitchen_sink/kitchen_sink.c @@ -5,6 +5,7 @@ */ #include +#include #ifndef KITCHEN_SINK_INCLUDE_HEADER // provided for backwards compatibility for non CMake build systems - just includes enough to compile @@ -85,6 +86,44 @@ int main(void) { hard_assert(recursive_mutex_try_enter(&recursive_mutex, NULL)); hard_assert(recursive_mutex_try_enter(&recursive_mutex, NULL)); printf("%f\n", foox(1.3f, 2.6f)); +#ifdef EXTRA_DATA_SECTION + extern uint32_t __extra_end_variable__; + printf("__extra_end_variable__ = %p\n", (void *)&__extra_end_variable__); +#if EXTRA_DATA_SECTION > 1 + extern uint32_t __overlays_start__; + uint32_t stored_words; + + static int overlay_first __attribute__((section(".overlay_first"))) = 12345678; + printf("overlay_first before load = %d\n", overlay_first); + static int overlay_second_one __attribute__((section(".overlay_second"))) = 34567890; + static int overlay_second_two __attribute__((section(".overlay_second"))) = 56789012; + printf("overlay_second before load = %d, %d\n", overlay_second_one, overlay_second_two); + + extern uint32_t __load_start_overlay_second; + extern uint32_t __load_stop_overlay_second; + stored_words = (uint32_t)(&__load_stop_overlay_second - &__load_start_overlay_second); + memcpy(&__overlays_start__, &__load_start_overlay_second, 4 * stored_words); + printf("overlay_second after load = %d, %d\n", overlay_second_one, overlay_second_two); + + extern uint32_t __load_start_overlay_first; + extern uint32_t __load_stop_overlay_first; + stored_words = (uint32_t)(&__load_stop_overlay_first - &__load_start_overlay_first); + memcpy(&__overlays_start__, &__load_start_overlay_first, 4 * stored_words); + printf("overlay_first after load = %d\n", overlay_first); + printf("overlay_second after overlay_first load = %d, %d\n", overlay_second_one, overlay_second_two); +#else + static int extra_data __attribute__((section(".extra_data"))) = 12345678; + printf("extra_data before load = %d\n", extra_data); + + extern uint32_t __extra_data_source__; + extern uint32_t __extra_data_start__; + extern uint32_t __extra_data_end__; + uint32_t stored_words = (uint32_t)(&__extra_data_end__ - &__extra_data_start__); + memcpy(&__extra_data_start__, &__extra_data_source__, 4 * stored_words); + + printf("extra_data after load = %d\n", extra_data); +#endif +#endif #ifndef __riscv // this should compile as we are Cortex M0+ pico_default_asm ("SVC #3"); diff --git a/test/kitchen_sink/kitchen_sink_extra_end_scripts/BUILD.bazel b/test/kitchen_sink/kitchen_sink_extra_end_scripts/BUILD.bazel new file mode 100644 index 000000000..9c83da183 --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_extra_end_scripts/BUILD.bazel @@ -0,0 +1,8 @@ +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +package(default_visibility = ["//test/kitchen_sink:__pkg__"]) + +linker_scripts( + name = "kitchen_sink_extra_end_scripts", + include_scripts = glob(["*.incl"]), +) diff --git a/test/kitchen_sink/kitchen_sink_extra_end_scripts/section_extra_post_end.incl b/test/kitchen_sink/kitchen_sink_extra_end_scripts/section_extra_post_end.incl new file mode 100644 index 000000000..52fe92ddd --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_extra_end_scripts/section_extra_post_end.incl @@ -0,0 +1,4 @@ +SECTIONS +{ + PROVIDE(__extra_end_variable__ = 4M); +} diff --git a/test/kitchen_sink/kitchen_sink_ram_section_scripts/BUILD.bazel b/test/kitchen_sink/kitchen_sink_ram_section_scripts/BUILD.bazel new file mode 100644 index 000000000..584890b69 --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_ram_section_scripts/BUILD.bazel @@ -0,0 +1,8 @@ +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +package(default_visibility = ["//test/kitchen_sink:__pkg__"]) + +linker_scripts( + name = "kitchen_sink_ram_section_scripts", + include_scripts = glob(["*.incl"]), +) diff --git a/test/kitchen_sink/kitchen_sink_ram_section_scripts/section_extra_post_data.incl b/test/kitchen_sink/kitchen_sink_ram_section_scripts/section_extra_post_data.incl new file mode 100644 index 000000000..458bd6b26 --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_ram_section_scripts/section_extra_post_data.incl @@ -0,0 +1,10 @@ +SECTIONS +{ + .extra_data : { + __extra_data_start__ = .; + *(.extra_data*) + . = ALIGN(4); + __extra_data_end__ = .; + } > RAM AT> RAM_STORE + __extra_data_source__ = LOADADDR(.extra_data); +} diff --git a/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/BUILD.bazel b/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/BUILD.bazel new file mode 100644 index 000000000..6bb2e84dd --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/BUILD.bazel @@ -0,0 +1,8 @@ +load("//bazel/util:pico_linker_scripts.bzl", "linker_scripts") + +package(default_visibility = ["//test/kitchen_sink:__pkg__"]) + +linker_scripts( + name = "kitchen_sink_simple_overlay_scripts", + include_scripts = glob(["*.incl"]), +) diff --git a/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/section_extra_post_data.incl b/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/section_extra_post_data.incl new file mode 100644 index 000000000..d5b3d95bd --- /dev/null +++ b/test/kitchen_sink/kitchen_sink_simple_overlay_scripts/section_extra_post_data.incl @@ -0,0 +1,15 @@ +SECTIONS +{ + PROVIDE(__overlays_start__ = .); + OVERLAY : { + .overlay_first { + KEEP (*(.first*)) + . = ALIGN(4); + } + .overlay_second { + KEEP (*(.second*)) + . = ALIGN(4); + } + } > RAM AT> RAM_STORE + PROVIDE(__overlays_end__ = .); +} diff --git a/tools/bazel_build.py b/tools/bazel_build.py index 522f28310..e2177b44f 100755 --- a/tools/bazel_build.py +++ b/tools/bazel_build.py @@ -37,8 +37,13 @@ "//test/hardware_sync_spin_lock_test:hardware_sync_spin_lock_test", "//test/kitchen_sink:kitchen_sink", "//test/kitchen_sink:kitchen_sink_cpp", + "//test/kitchen_sink:kitchen_sink_copy_to_ram", + "//test/kitchen_sink:kitchen_sink_no_flash", + "//test/kitchen_sink:kitchen_sink_blocked_ram", "//test/kitchen_sink:kitchen_sink_lwip_poll", "//test/kitchen_sink:kitchen_sink_lwip_background", + "//test/kitchen_sink:kitchen_sink_ram_section", + "//test/kitchen_sink:kitchen_sink_simple_overlay", "//test/pico_divider_test:pico_divider_test", "//test/pico_divider_test:pico_divider_nesting_test", "//test/pico_float_test:pico_double_test", @@ -84,6 +89,8 @@ "//test/kitchen_sink:kitchen_sink_lwip_background", # Host only. "//test/pico_float_test:hazard3_test_gen", + # RP2040 only + "//test/kitchen_sink:kitchen_sink_blocked_ram", # TODO: RISC-V support. "//test/pico_float_test:pico_float_test_hazard3", ) @@ -106,6 +113,8 @@ "//test/pico_float_test:pico_float_test_hazard3", # hardware_sha256 doesn't appear to work on RP2040. "//test/pico_sha256_test:pico_sha256_test", + # not supported by clang + "//test/kitchen_sink:kitchen_sink_simple_overlay", ) ), }, @@ -122,8 +131,12 @@ "//test/kitchen_sink:kitchen_sink_lwip_background", # Host only. "//test/pico_float_test:hazard3_test_gen", + # RP2040 only + "//test/kitchen_sink:kitchen_sink_blocked_ram", # TODO: RISC-V support. "//test/pico_float_test:pico_float_test_hazard3", + # not supported by clang + "//test/kitchen_sink:kitchen_sink_simple_overlay", ) ), }, @@ -156,7 +169,9 @@ ( # Host only. "//test/pico_float_test:hazard3_test_gen", - # No RISC-V on RP2040. + # RP2040 only + "//test/kitchen_sink:kitchen_sink_blocked_ram", + # TODO: RISC-V support. "//test/pico_float_test:pico_float_test_hazard3", ) ),