| # Copyright 2022 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| import("//build_overrides/pi_pico.gni") |
| import("//build_overrides/pigweed.gni") |
| |
| import("$dir_pw_build/target_types.gni") |
| import("$dir_pw_docgen/docs.gni") |
| import("$dir_pw_system/system_target.gni") |
| import("$dir_pw_toolchain/arm_gcc/toolchains.gni") |
| import("$dir_pw_toolchain/generate_toolchain.gni") |
| |
| declare_args() { |
| pw_targets_ENABLE_RP2040_TEST_RUNNER = false |
| } |
| |
| if (current_toolchain != default_toolchain) { |
| pw_source_set("pre_init") { |
| remove_configs = [ "$dir_pw_build:strict_warnings" ] |
| |
| deps = [ |
| "$PICO_ROOT/src/common/pico_base", |
| "$PICO_ROOT/src/common/pico_stdlib", |
| "$PICO_ROOT/src/rp2_common/pico_malloc", |
| "$dir_pw_string", |
| "$dir_pw_system", |
| "$dir_pw_third_party/freertos", |
| ] |
| sources = [ "boot.cc" ] |
| } |
| |
| config("config_includes") { |
| include_dirs = [ "config" ] |
| } |
| |
| config("module_config_include") { |
| cflags = [ |
| "-include", |
| rebase_path("config/pigweed_module_config.h", root_build_dir), |
| ] |
| visibility = [ ":*" ] |
| } |
| |
| pw_source_set("module_config") { |
| public_configs = [ ":module_config_include" ] |
| } |
| |
| config("rp2040_hal_config") { |
| inputs = [ "config/rp2040_hal_config.h" ] |
| cflags = [ "-include" + |
| rebase_path("config/rp2040_hal_config.h", root_build_dir) ] |
| } |
| |
| pw_source_set("rp2040_freertos_config") { |
| public_configs = [ ":config_includes" ] |
| public_deps = [ "$dir_pw_third_party/freertos:config_assert" ] |
| public = [ "config/FreeRTOSConfig.h" ] |
| } |
| |
| pw_source_set("unit_test_app") { |
| sources = [ "unit_test_app.cc" ] |
| deps = [ |
| "$dir_pw_status", |
| "$dir_pw_system", |
| "$dir_pw_unit_test:rpc_service", |
| ] |
| } |
| |
| # We don't want this linked into the boot_stage2 binary, so make the printf |
| # float config a source set added to pw_build_LINK_DEPS (which is dropped on |
| # the boot_stage2 binary) rather than as a default_config. |
| pw_source_set("float_printf_adapter") { |
| all_dependent_configs = [ "$dir_pw_toolchain/arm_gcc:enable_float_printf" ] |
| } |
| } |
| |
| pw_system_target("rp2040") { |
| cpu = PW_SYSTEM_CPU.CORTEX_M0PLUS |
| scheduler = PW_SYSTEM_SCHEDULER.FREERTOS |
| use_pw_malloc = false |
| global_configs = [ ":rp2040_hal_config" ] |
| |
| build_args = { |
| pw_build_DEFAULT_MODULE_CONFIG = get_path_info(":module_config", "abspath") |
| pw_build_EXECUTABLE_TARGET_TYPE = "pico_executable" |
| pw_build_EXECUTABLE_TARGET_TYPE_FILE = |
| get_path_info("$dir_pigweed/targets/rp2040/pico_executable.gni", |
| "abspath") |
| |
| pw_log_BACKEND = dir_pw_log_tokenized |
| pw_log_tokenized_HANDLER_BACKEND = "$dir_pw_system:log_backend.impl" |
| |
| pw_third_party_freertos_CONFIG = |
| "$dir_pigweed/targets/rp2040:rp2040_freertos_config" |
| pw_third_party_freertos_PORT = "$dir_pw_third_party/freertos:arm_cm0" |
| |
| pw_sys_io_BACKEND = dir_pw_sys_io_stdio |
| pw_build_LINK_DEPS += [ |
| "$dir_pigweed/targets/rp2040:pre_init", |
| "$dir_pw_assert:impl", |
| "$dir_pw_log:impl", |
| get_path_info(":float_printf_adapter", "abspath"), |
| ] |
| |
| # ONLY RELEVANT FOR UNIT TESTS. |
| if (pw_targets_ENABLE_RP2040_TEST_RUNNER) { |
| _test_runner_script = |
| "//targets/rp2040/py/rp2040_utils/unit_test_client.py" |
| pw_unit_test_AUTOMATIC_RUNNER = |
| get_path_info(_test_runner_script, "abspath") |
| } |
| pw_unit_test_MAIN = "$dir_pigweed/targets/rp2040:unit_test_app" |
| } |
| } |
| |
| pw_doc_group("target_docs") { |
| sources = [ "target_docs.rst" ] |
| } |