diff --git a/boards/acd52832/Cargo.toml b/boards/acd52832/Cargo.toml index fd489a00f9..0f2227e3ce 100644 --- a/boards/acd52832/Cargo.toml +++ b/boards/acd52832/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/acd52832/layout.ld b/boards/acd52832/layout.ld index 9f56cf4afa..b3013bbbec 100644 --- a/boards/acd52832/layout.ld +++ b/boards/acd52832/layout.ld @@ -12,4 +12,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/apollo3/lora_things_plus/Cargo.toml b/boards/apollo3/lora_things_plus/Cargo.toml index 1e7066581d..74c3c25c66 100644 --- a/boards/apollo3/lora_things_plus/Cargo.toml +++ b/boards/apollo3/lora_things_plus/Cargo.toml @@ -20,6 +20,9 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/apollo3/lora_things_plus/Makefile b/boards/apollo3/lora_things_plus/Makefile index 152f7c5cab..3d023c939a 100644 --- a/boards/apollo3/lora_things_plus/Makefile +++ b/boards/apollo3/lora_things_plus/Makefile @@ -45,13 +45,9 @@ flash-app: .PHONY: test test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release .PHONY: test-atecc508a test-atecc508a: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release --features atecc508a diff --git a/boards/apollo3/lora_things_plus/layout.ld b/boards/apollo3/lora_things_plus/layout.ld index 47f8e81def..6f2748d6ce 100644 --- a/boards/apollo3/lora_things_plus/layout.ld +++ b/boards/apollo3/lora_things_plus/layout.ld @@ -20,4 +20,4 @@ _lkv_data = LENGTH(kv_data); PAGE_SIZE = 8K; -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/apollo3/redboard_artemis_atp/Cargo.toml b/boards/apollo3/redboard_artemis_atp/Cargo.toml index 3254d4b14c..2e1b5a3ae4 100644 --- a/boards/apollo3/redboard_artemis_atp/Cargo.toml +++ b/boards/apollo3/redboard_artemis_atp/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/apollo3/redboard_artemis_atp/Makefile b/boards/apollo3/redboard_artemis_atp/Makefile index ba9c32c40b..2a6c2ff0ff 100644 --- a/boards/apollo3/redboard_artemis_atp/Makefile +++ b/boards/apollo3/redboard_artemis_atp/Makefile @@ -45,6 +45,4 @@ flash-app: .PHONY: test test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/apollo3/redboard_artemis_atp/layout.ld b/boards/apollo3/redboard_artemis_atp/layout.ld index a2e4bbdd4d..152c7e0d86 100644 --- a/boards/apollo3/redboard_artemis_atp/layout.ld +++ b/boards/apollo3/redboard_artemis_atp/layout.ld @@ -15,4 +15,4 @@ MEMORY PAGE_SIZE = 8K; -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/apollo3/redboard_artemis_nano/Cargo.toml b/boards/apollo3/redboard_artemis_nano/Cargo.toml index f7acdf24d9..e6335ba5ff 100644 --- a/boards/apollo3/redboard_artemis_nano/Cargo.toml +++ b/boards/apollo3/redboard_artemis_nano/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/apollo3/redboard_artemis_nano/Makefile b/boards/apollo3/redboard_artemis_nano/Makefile index 3f6828d6f6..de8d303edc 100644 --- a/boards/apollo3/redboard_artemis_nano/Makefile +++ b/boards/apollo3/redboard_artemis_nano/Makefile @@ -45,6 +45,4 @@ flash-app: .PHONY: test test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/apollo3/redboard_artemis_nano/layout.ld b/boards/apollo3/redboard_artemis_nano/layout.ld index a2e4bbdd4d..152c7e0d86 100644 --- a/boards/apollo3/redboard_artemis_nano/layout.ld +++ b/boards/apollo3/redboard_artemis_nano/layout.ld @@ -15,4 +15,4 @@ MEMORY PAGE_SIZE = 8K; -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/arty_e21/Cargo.toml b/boards/arty_e21/Cargo.toml index 8a6f7eeb5f..4b32b89326 100644 --- a/boards/arty_e21/Cargo.toml +++ b/boards/arty_e21/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/arty_e21/layout.ld b/boards/arty_e21/layout.ld index 2a1f31fa67..4af6345199 100644 --- a/boards/arty_e21/layout.ld +++ b/boards/arty_e21/layout.ld @@ -9,4 +9,4 @@ MEMORY ram (rwx) : ORIGIN = 0x80000000, LENGTH = 64K } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/build.rs b/boards/build.rs index 0a29ee2a54..e1c1b3c3ed 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -13,69 +13,9 @@ //! # ... //! build = "../path/to/build.rs" //! ``` - -use std::fs; -use std::path::Path; - -const LINKER_SCRIPT: &str = "layout.ld"; +//! +//! Out-of-tree boards are recommended to copy this file into their board crate. fn main() { - if !Path::new(LINKER_SCRIPT).exists() { - panic!("Boards must provide a `layout.ld` link script file"); - } - - // The `RUSTFLAGS` that the Tock config files set can be easily overridden - // by command line flags. The build will still succeed but the resulting - // binary may be invalid as it was not built with the intended flags. This - // check seeks to prevent that. Our approach is we set a sentinel flag in - // our configuration file and then check that it is set here. If it isn't, - // the flags were overwritten and the build will be invalid. - // - // We only do this check if we are actually building for an embedded target - // (i.e., the TARGET is not the same as the HOST). This avoids a false - // positive when running tools like `cargo clippy`. - // - // If you are intentionally not using the standard Tock config files, set - // `cfg-tock-buildflagssentinel` in your cargo config to prevent this - // error. - if std::env::var("HOST") != std::env::var("TARGET") { - let rust_flags = std::env::var("CARGO_ENCODED_RUSTFLAGS"); - if !rust_flags - .iter() - .any(|f| f.contains("cfg_tock_buildflagssentinel")) - { - panic!( - "Incorrect build configuration. Verify you are using unstable cargo and have not unintentionally set the RUSTFLAGS environment variable." - ); - } - } - - // Include the folder where the board's Cargo.toml is in the linker file - // search path. - println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); - // `-Tlayout.ld`: Use the linker script `layout.ld` all boards must provide. - println!("cargo:rustc-link-arg=-T{}", LINKER_SCRIPT); - - track_linker_script(LINKER_SCRIPT); -} - -/// Track the given linker script and all of its `INCLUDE`s so that the build -/// is rerun when any of them change. -fn track_linker_script>(path: P) { - let path = path.as_ref(); - - assert!(path.is_file(), "expected path {path:?} to be a file"); - - println!("cargo:rerun-if-changed={}", path.display()); - - // Find all the `INCLUDE ` lines in the linker script. - let link_script = fs::read_to_string(path).expect("failed to read {path:?}"); - let includes = link_script - .lines() - .filter_map(|line| line.strip_prefix("INCLUDE").map(str::trim)); - - // Recursively track included linker scripts. - for include in includes { - track_linker_script(include); - } + tock_build_scripts::default_linker_script(); } diff --git a/boards/build_scripts/Cargo.toml b/boards/build_scripts/Cargo.toml new file mode 100644 index 0000000000..b10760eefd --- /dev/null +++ b/boards/build_scripts/Cargo.toml @@ -0,0 +1,10 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +[package] +name = "tock_build_scripts" +description = """Helper functions for compiling Tock boards.""" +version.workspace = true +authors.workspace = true +edition.workspace = true diff --git a/boards/build_scripts/README.md b/boards/build_scripts/README.md new file mode 100644 index 0000000000..3221e675ff --- /dev/null +++ b/boards/build_scripts/README.md @@ -0,0 +1,43 @@ +Tock Build Scripts Support Crate +================================ + +This crate provides helpers for building Tock boards. + +Out-of-tree Tock kernel configurations (i.e., Tock boards) can optionally +include this crate as a dependency to use the +[build.rs](https://doc.rust-lang.org/cargo/reference/build-scripts.html) +functionality provided by the kernel. + +This crate also packages the default `tock_kernel_layout.ld` linker script. + +Usage +----- + +There are three general steps to use this crate. + +1. This crate should be included as a build dependency in the boards's + Cargo.toml file: + + ```toml + # Cargo.toml + + # ...Existing Cargo.toml contents... + + [build-dependencies] + tock_build_scripts = { git = "https://github.com/tock/tock"} + ``` + + This will ensure the crate and the build scripts are available for the board + build. + +2. This crate provides a helper function which can used from the board's + build.rs file. In the common case, you just call the provided function from + the build.rs file in your crate's root: + + ```rs + // build.rs + + fn main() { + tock_build_scripts::default_linker_script(); + } + ``` diff --git a/boards/build_scripts/src/default.rs b/boards/build_scripts/src/default.rs new file mode 100644 index 0000000000..1332458f2b --- /dev/null +++ b/boards/build_scripts/src/default.rs @@ -0,0 +1,104 @@ +// Licensed under the Apache License, Version 2.0 or the MIT License. +// SPDX-License-Identifier: Apache-2.0 OR MIT +// Copyright Tock Contributors 2024. + +//! Provide helpers for building Tock boards that match the default conventions. + +use std::fs; +use std::path::Path; + +const LINKER_SCRIPT: &str = "layout.ld"; + +/// Setup the Tock board to build with a board-provided linker script called +/// `layout.ld`. +/// +/// The board linker script (i.e., `layout.ld`) should end with the command: +/// +/// ``` +/// INCLUDE tock_kernel_layout.ld +/// ``` +/// +/// This function will ensure that the linker's search path is configured to +/// find `tock_kernel_layout.ld`. +pub fn default_linker_script() { + if !Path::new(LINKER_SCRIPT).exists() { + panic!("Boards must provide a `layout.ld` link script file"); + } + + // The `RUSTFLAGS` that the Tock config files set can be easily overridden + // by command line flags. The build will still succeed but the resulting + // binary may be invalid as it was not built with the intended flags. This + // check seeks to prevent that. Our approach is we set a sentinel flag in + // our configuration file and then check that it is set here. If it isn't, + // the flags were overwritten and the build will be invalid. + // + // We only do this check if we are actually building for an embedded target + // (i.e., the TARGET is not the same as the HOST). This avoids a false + // positive when running tools like `cargo clippy`. + // + // If you are intentionally not using the standard Tock config files, set + // `cfg-tock-buildflagssentinel` in your cargo config to prevent this + // error. + if std::env::var("HOST") != std::env::var("TARGET") { + let rust_flags = std::env::var("CARGO_ENCODED_RUSTFLAGS"); + if !rust_flags + .iter() + .any(|f| f.contains("cfg_tock_buildflagssentinel")) + { + panic!( + "Incorrect build configuration. Verify you are using unstable cargo and have not unintentionally set the RUSTFLAGS environment variable." + ); + } + } + + // Include the folder where this build_script crate's Cargo.toml is in the + // linker file search path for `tock_kernel_layout.ld`. + println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); + // Directive to rebuild if the linker script in this crate is changed. + println!( + "cargo:rerun-if-changed={}", + Path::new(std::env!("CARGO_MANIFEST_DIR")) + .join("tock_kernel_layout.ld") + .to_string_lossy() + ); + + // Include the folder where the board's Cargo.toml is in the linker file + // search path. + println!( + "cargo:rustc-link-arg=-L{}", + std::env::var("CARGO_MANIFEST_DIR").unwrap() + ); + // `-Tlayout.ld`: Use the linker script `layout.ld` all boards must provide. + println!("cargo:rustc-link-arg=-T{}", LINKER_SCRIPT); + + track_linker_script(LINKER_SCRIPT); +} + +/// Track the given linker script and all of its `INCLUDE`s so that the build +/// is rerun when any of them change. +fn track_linker_script>(path: P) { + let path = path.as_ref(); + + // Skip the default Tock linker script as we have manually added the + // containing directory to the linker search path and we do not know the + // path to add the rerun directive here. Instead, we add the rerun directory + // for the default Tock linker script manually before calling this function. + if path.to_str() == Some("tock_kernel_layout.ld") { + return; + } + + assert!(path.is_file(), "expected path {path:?} to be a file"); + + println!("cargo:rerun-if-changed={}", path.display()); + + // Find all the `INCLUDE ` lines in the linker script. + let link_script = fs::read_to_string(path).expect("failed to read {path:?}"); + let includes = link_script + .lines() + .filter_map(|line| line.strip_prefix("INCLUDE").map(str::trim)); + + // Recursively track included linker scripts. + for include in includes { + track_linker_script(include); + } +} diff --git a/boards/build_scripts/src/lib.rs b/boards/build_scripts/src/lib.rs new file mode 100644 index 0000000000..a7233780cc --- /dev/null +++ b/boards/build_scripts/src/lib.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 or the MIT License. +// SPDX-License-Identifier: Apache-2.0 OR MIT +// Copyright Tock Contributors 2024. + +mod default; + +pub use default::default_linker_script; diff --git a/boards/kernel_layout.ld b/boards/build_scripts/tock_kernel_layout.ld similarity index 100% rename from boards/kernel_layout.ld rename to boards/build_scripts/tock_kernel_layout.ld diff --git a/boards/clue_nrf52840/Cargo.toml b/boards/clue_nrf52840/Cargo.toml index 11b6ba7262..32ecdba741 100644 --- a/boards/clue_nrf52840/Cargo.toml +++ b/boards/clue_nrf52840/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/clue_nrf52840/layout.ld b/boards/clue_nrf52840/layout.ld index 155ce70074..bef96ea7ae 100644 --- a/boards/clue_nrf52840/layout.ld +++ b/boards/clue_nrf52840/layout.ld @@ -21,4 +21,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Cargo.toml b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Cargo.toml index 9142694943..56c495c0cf 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Cargo.toml +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../../../capsules/core" } capsules-extra = { path = "../../../../capsules/extra" } capsules-system = { path = "../../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../../build_scripts" } + [lints] workspace = true diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/layout.ld b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/layout.ld index 417a58fe7d..51025ae38d 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/layout.ld +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../../../nordic/nrf52840_chip_layout.ld -INCLUDE ../../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Cargo.toml b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Cargo.toml index 009af4d495..4b2796d31b 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Cargo.toml +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../../../capsules/core" } capsules-extra = { path = "../../../../capsules/extra" } capsules-system = { path = "../../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../../build_scripts" } + [lints] workspace = true diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/layout.ld b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/layout.ld index 417a58fe7d..51025ae38d 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/layout.ld +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../../../nordic/nrf52840_chip_layout.ld -INCLUDE ../../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Cargo.toml b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Cargo.toml index 8ca48bf492..a6e8da641b 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Cargo.toml +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../../../capsules/core" } capsules-extra = { path = "../../../../capsules/extra" } capsules-system = { path = "../../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../../build_scripts" } + [lints] workspace = true diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/layout.ld b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/layout.ld index 417a58fe7d..51025ae38d 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/layout.ld +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../../../nordic/nrf52840_chip_layout.ld -INCLUDE ../../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/esp32-c3-devkitM-1/Cargo.toml b/boards/esp32-c3-devkitM-1/Cargo.toml index 7bf47d9dd9..9e012c7e8e 100644 --- a/boards/esp32-c3-devkitM-1/Cargo.toml +++ b/boards/esp32-c3-devkitM-1/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/esp32-c3-devkitM-1/Makefile b/boards/esp32-c3-devkitM-1/Makefile index 1eab05692e..0d9e8e2a7e 100644 --- a/boards/esp32-c3-devkitM-1/Makefile +++ b/boards/esp32-c3-devkitM-1/Makefile @@ -26,6 +26,4 @@ endif test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ - $(Q)cp ../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/ $(Q)$(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/esp32-c3-devkitM-1/layout.ld b/boards/esp32-c3-devkitM-1/layout.ld index 817a10501d..24d5747c04 100644 --- a/boards/esp32-c3-devkitM-1/layout.ld +++ b/boards/esp32-c3-devkitM-1/layout.ld @@ -9,4 +9,4 @@ MEMORY prog (rx) : ORIGIN = 0x403B0000, LENGTH = 0x30000 } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/hail/Cargo.toml b/boards/hail/Cargo.toml index 51154beb57..7b2eabebd1 100644 --- a/boards/hail/Cargo.toml +++ b/boards/hail/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/hail/layout.ld b/boards/hail/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/hail/layout.ld +++ b/boards/hail/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/hifive1/Cargo.toml b/boards/hifive1/Cargo.toml index b95ba670e1..74145bbaa6 100644 --- a/boards/hifive1/Cargo.toml +++ b/boards/hifive1/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/hifive1/layout.ld b/boards/hifive1/layout.ld index 4be3945554..eb649cc764 100644 --- a/boards/hifive1/layout.ld +++ b/boards/hifive1/layout.ld @@ -15,4 +15,4 @@ MEMORY ram (rwx) : ORIGIN = 0x80000000, LENGTH = 0x4000 } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/hifive_inventor/Cargo.toml b/boards/hifive_inventor/Cargo.toml index 775a0ec4da..a3aa476119 100644 --- a/boards/hifive_inventor/Cargo.toml +++ b/boards/hifive_inventor/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/hifive_inventor/layout.ld b/boards/hifive_inventor/layout.ld index dd16de43aa..b05f697b46 100644 --- a/boards/hifive_inventor/layout.ld +++ b/boards/hifive_inventor/layout.ld @@ -14,4 +14,4 @@ MEMORY MPU_MIN_ALIGN = 1K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/imix/Cargo.toml b/boards/imix/Cargo.toml index bd7558bbc1..1e4dc4d472 100644 --- a/boards/imix/Cargo.toml +++ b/boards/imix/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/imix/layout.ld b/boards/imix/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/imix/layout.ld +++ b/boards/imix/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/imxrt1050-evkb/Cargo.toml b/boards/imxrt1050-evkb/Cargo.toml index 497de8a5ab..5386241ad7 100644 --- a/boards/imxrt1050-evkb/Cargo.toml +++ b/boards/imxrt1050-evkb/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/imxrt1050-evkb/layout.ld b/boards/imxrt1050-evkb/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/imxrt1050-evkb/layout.ld +++ b/boards/imxrt1050-evkb/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/litex/arty/Cargo.toml b/boards/litex/arty/Cargo.toml index 9d7e5da9ff..9b61a2972e 100644 --- a/boards/litex/arty/Cargo.toml +++ b/boards/litex/arty/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/litex/arty/layout.ld b/boards/litex/arty/layout.ld index f9a3511b7c..fbe41beee1 100644 --- a/boards/litex/arty/layout.ld +++ b/boards/litex/arty/layout.ld @@ -24,4 +24,4 @@ SECTIONS { _esram = ORIGIN(ram) + LENGTH(ram); } -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/litex/sim/Cargo.toml b/boards/litex/sim/Cargo.toml index 5b100e1e2c..8da4f200e7 100644 --- a/boards/litex/sim/Cargo.toml +++ b/boards/litex/sim/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/litex/sim/layout.ld b/boards/litex/sim/layout.ld index 0fe2382257..6e59ac96a1 100644 --- a/boards/litex/sim/layout.ld +++ b/boards/litex/sim/layout.ld @@ -24,4 +24,4 @@ SECTIONS { _esram = ORIGIN(ram) + LENGTH(ram); } -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/makepython-nrf52840/Cargo.toml b/boards/makepython-nrf52840/Cargo.toml index a657aafc77..5f7e5f2270 100644 --- a/boards/makepython-nrf52840/Cargo.toml +++ b/boards/makepython-nrf52840/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/makepython-nrf52840/layout.ld b/boards/makepython-nrf52840/layout.ld index d5950e39c4..0bc886e980 100644 --- a/boards/makepython-nrf52840/layout.ld +++ b/boards/makepython-nrf52840/layout.ld @@ -11,4 +11,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/microbit_v2/Cargo.toml b/boards/microbit_v2/Cargo.toml index 498aaf0c04..64f85fd865 100644 --- a/boards/microbit_v2/Cargo.toml +++ b/boards/microbit_v2/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/microbit_v2/layout.ld b/boards/microbit_v2/layout.ld index b9b80d64d0..e5ef626253 100644 --- a/boards/microbit_v2/layout.ld +++ b/boards/microbit_v2/layout.ld @@ -14,4 +14,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/msp_exp432p401r/Cargo.toml b/boards/msp_exp432p401r/Cargo.toml index c9679a49dc..9cb09b2243 100644 --- a/boards/msp_exp432p401r/Cargo.toml +++ b/boards/msp_exp432p401r/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/msp_exp432p401r/layout.ld b/boards/msp_exp432p401r/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/msp_exp432p401r/layout.ld +++ b/boards/msp_exp432p401r/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nano33ble/Cargo.toml b/boards/nano33ble/Cargo.toml index dcce7834e2..01084a2594 100644 --- a/boards/nano33ble/Cargo.toml +++ b/boards/nano33ble/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/nano33ble/layout.ld b/boards/nano33ble/layout.ld index d5950e39c4..0bc886e980 100644 --- a/boards/nano33ble/layout.ld +++ b/boards/nano33ble/layout.ld @@ -11,4 +11,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nano33ble_rev2/Cargo.toml b/boards/nano33ble_rev2/Cargo.toml index c766df9871..15358a46e4 100644 --- a/boards/nano33ble_rev2/Cargo.toml +++ b/boards/nano33ble_rev2/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/nano33ble_rev2/layout.ld b/boards/nano33ble_rev2/layout.ld index d5950e39c4..0bc886e980 100644 --- a/boards/nano33ble_rev2/layout.ld +++ b/boards/nano33ble_rev2/layout.ld @@ -11,4 +11,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nano_rp2040_connect/Cargo.toml b/boards/nano_rp2040_connect/Cargo.toml index 633f9954ba..88b63d8498 100644 --- a/boards/nano_rp2040_connect/Cargo.toml +++ b/boards/nano_rp2040_connect/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/nano_rp2040_connect/layout.ld b/boards/nano_rp2040_connect/layout.ld index 75b23a9d07..9277a44c9f 100644 --- a/boards/nano_rp2040_connect/layout.ld +++ b/boards/nano_rp2040_connect/layout.ld @@ -26,7 +26,7 @@ SECTIONS { { KEEP (*(.flash_bootloader)); . = ALIGN (256); - } > rom + } > rom } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nordic/nrf52840_dongle/Cargo.toml b/boards/nordic/nrf52840_dongle/Cargo.toml index 184d0f0a12..418f8c7abb 100644 --- a/boards/nordic/nrf52840_dongle/Cargo.toml +++ b/boards/nordic/nrf52840_dongle/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/nordic/nrf52840_dongle/layout.ld b/boards/nordic/nrf52840_dongle/layout.ld index 3eccbaa12d..1bb3f0fb79 100644 --- a/boards/nordic/nrf52840_dongle/layout.ld +++ b/boards/nordic/nrf52840_dongle/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../nrf52840_chip_layout.ld -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nordic/nrf52840dk/Cargo.toml b/boards/nordic/nrf52840dk/Cargo.toml index 7bc8d1d05b..7f7a6c4d8c 100644 --- a/boards/nordic/nrf52840dk/Cargo.toml +++ b/boards/nordic/nrf52840dk/Cargo.toml @@ -28,5 +28,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/nordic/nrf52840dk/layout.ld b/boards/nordic/nrf52840dk/layout.ld index 3eccbaa12d..1bb3f0fb79 100644 --- a/boards/nordic/nrf52840dk/layout.ld +++ b/boards/nordic/nrf52840dk/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../nrf52840_chip_layout.ld -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nordic/nrf52dk/Cargo.toml b/boards/nordic/nrf52dk/Cargo.toml index ac5952f268..cc23243c24 100644 --- a/boards/nordic/nrf52dk/Cargo.toml +++ b/boards/nordic/nrf52dk/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../../capsules/core" } capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/nordic/nrf52dk/layout.ld b/boards/nordic/nrf52dk/layout.ld index 0142c25b8a..a76f22a889 100644 --- a/boards/nordic/nrf52dk/layout.ld +++ b/boards/nordic/nrf52dk/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../nrf52832_chip_layout.ld -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nucleo_f429zi/Cargo.toml b/boards/nucleo_f429zi/Cargo.toml index b2091b9db1..54ff6040fd 100644 --- a/boards/nucleo_f429zi/Cargo.toml +++ b/boards/nucleo_f429zi/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/nucleo_f429zi/layout.ld b/boards/nucleo_f429zi/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/nucleo_f429zi/layout.ld +++ b/boards/nucleo_f429zi/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/nucleo_f446re/Cargo.toml b/boards/nucleo_f446re/Cargo.toml index 104ed244c9..a037d8b888 100644 --- a/boards/nucleo_f446re/Cargo.toml +++ b/boards/nucleo_f446re/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/nucleo_f446re/layout.ld b/boards/nucleo_f446re/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/nucleo_f446re/layout.ld +++ b/boards/nucleo_f446re/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/opentitan/earlgrey-cw310/Cargo.toml b/boards/opentitan/earlgrey-cw310/Cargo.toml index 2e1d2bf6f4..9c1d00711c 100644 --- a/boards/opentitan/earlgrey-cw310/Cargo.toml +++ b/boards/opentitan/earlgrey-cw310/Cargo.toml @@ -22,6 +22,9 @@ capsules-extra = { path = "../../../capsules/extra" } capsules-aes-gcm = { path = "../../../capsules/aes_gcm" } capsules-system = { path = "../../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [features] default = ["fpga_cw310"] diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index 0f73d8463c..2be8982928 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -110,17 +110,14 @@ ifneq ($(OPENTITAN_TREE),) endif mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} QEMU_ENTRY_POINT=${QEMU_ENTRY_POINT} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release test-hardware: ot-check mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests test-verilator: ot-check mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld - $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ $(Q)VERILATOR="yes" OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests,sim_verilator diff --git a/boards/opentitan/earlgrey-cw310/layout.ld b/boards/opentitan/earlgrey-cw310/layout.ld index 868a66beae..870b8b7b4d 100644 --- a/boards/opentitan/earlgrey-cw310/layout.ld +++ b/boards/opentitan/earlgrey-cw310/layout.ld @@ -63,4 +63,4 @@ SECTIONS { } > rom } ASSERT (((_etext - _manifest) > 0), "Error: PMP and Flash protection setup assumes _etext follows _manifest"); -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/opentitan/earlgrey-cw310/test_layout.ld b/boards/opentitan/earlgrey-cw310/test_layout.ld index fbeb1739f6..9569ae07a3 100644 --- a/boards/opentitan/earlgrey-cw310/test_layout.ld +++ b/boards/opentitan/earlgrey-cw310/test_layout.ld @@ -69,4 +69,4 @@ SECTIONS { } > rom } ASSERT (((_etext - _manifest) > 0), "Error: PMP and Flash protection setup assumes _etext follows _manifest"); -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/particle_boron/Cargo.toml b/boards/particle_boron/Cargo.toml index 1232fc610e..d9ae0f9e4d 100644 --- a/boards/particle_boron/Cargo.toml +++ b/boards/particle_boron/Cargo.toml @@ -25,5 +25,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/particle_boron/layout.ld b/boards/particle_boron/layout.ld index 89d8ab00fc..f34d7b03de 100644 --- a/boards/particle_boron/layout.ld +++ b/boards/particle_boron/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../nordic/nrf52840_chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/pico_explorer_base/Cargo.toml b/boards/pico_explorer_base/Cargo.toml index bcaaeb1d7a..eb2c7db0b3 100644 --- a/boards/pico_explorer_base/Cargo.toml +++ b/boards/pico_explorer_base/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/pico_explorer_base/layout.ld b/boards/pico_explorer_base/layout.ld index ce99f68d6d..0851ffc33f 100644 --- a/boards/pico_explorer_base/layout.ld +++ b/boards/pico_explorer_base/layout.ld @@ -26,7 +26,7 @@ SECTIONS { { KEEP (*(.flash_bootloader)); . = ALIGN (256); - } > rom + } > rom } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/qemu_rv32_virt/Cargo.toml b/boards/qemu_rv32_virt/Cargo.toml index d8460e259a..059aae3f58 100644 --- a/boards/qemu_rv32_virt/Cargo.toml +++ b/boards/qemu_rv32_virt/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/qemu_rv32_virt/layout.ld b/boards/qemu_rv32_virt/layout.ld index 6c477a76ae..bc6115f16a 100644 --- a/boards/qemu_rv32_virt/layout.ld +++ b/boards/qemu_rv32_virt/layout.ld @@ -30,4 +30,4 @@ SECTIONS { _esram = ORIGIN(ram) + LENGTH(ram); } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/raspberry_pi_pico/Cargo.toml b/boards/raspberry_pi_pico/Cargo.toml index d38acf1ce0..9f4abea94c 100644 --- a/boards/raspberry_pi_pico/Cargo.toml +++ b/boards/raspberry_pi_pico/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/raspberry_pi_pico/layout.ld b/boards/raspberry_pi_pico/layout.ld index ce99f68d6d..0851ffc33f 100644 --- a/boards/raspberry_pi_pico/layout.ld +++ b/boards/raspberry_pi_pico/layout.ld @@ -26,7 +26,7 @@ SECTIONS { { KEEP (*(.flash_bootloader)); . = ALIGN (256); - } > rom + } > rom } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/redboard_redv/Cargo.toml b/boards/redboard_redv/Cargo.toml index 62215335f0..33f8a82073 100644 --- a/boards/redboard_redv/Cargo.toml +++ b/boards/redboard_redv/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/redboard_redv/layout.ld b/boards/redboard_redv/layout.ld index ec098cebcb..fdaf6122fa 100644 --- a/boards/redboard_redv/layout.ld +++ b/boards/redboard_redv/layout.ld @@ -14,4 +14,4 @@ MEMORY ram (rwx) : ORIGIN = 0x80000000, LENGTH = 16K } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/sma_q3/Cargo.toml b/boards/sma_q3/Cargo.toml index 4813d48c74..55968e92e1 100644 --- a/boards/sma_q3/Cargo.toml +++ b/boards/sma_q3/Cargo.toml @@ -25,5 +25,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/sma_q3/layout.ld b/boards/sma_q3/layout.ld index 89d8ab00fc..f34d7b03de 100644 --- a/boards/sma_q3/layout.ld +++ b/boards/sma_q3/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../nordic/nrf52840_chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/stm32f3discovery/Cargo.toml b/boards/stm32f3discovery/Cargo.toml index 85bdda5dce..0e4ddc4296 100644 --- a/boards/stm32f3discovery/Cargo.toml +++ b/boards/stm32f3discovery/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/stm32f3discovery/layout.ld b/boards/stm32f3discovery/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/stm32f3discovery/layout.ld +++ b/boards/stm32f3discovery/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/stm32f412gdiscovery/Cargo.toml b/boards/stm32f412gdiscovery/Cargo.toml index ad53dd58d2..affdf29117 100644 --- a/boards/stm32f412gdiscovery/Cargo.toml +++ b/boards/stm32f412gdiscovery/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/stm32f412gdiscovery/layout.ld b/boards/stm32f412gdiscovery/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/stm32f412gdiscovery/layout.ld +++ b/boards/stm32f412gdiscovery/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/stm32f429idiscovery/Cargo.toml b/boards/stm32f429idiscovery/Cargo.toml index a0b25541f5..205c720b64 100644 --- a/boards/stm32f429idiscovery/Cargo.toml +++ b/boards/stm32f429idiscovery/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/stm32f429idiscovery/layout.ld b/boards/stm32f429idiscovery/layout.ld index 6814c00acd..c13ac43bca 100644 --- a/boards/stm32f429idiscovery/layout.ld +++ b/boards/stm32f429idiscovery/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ./chip_layout.ld -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/teensy40/Cargo.toml b/boards/teensy40/Cargo.toml index b58b74e07e..1f2fc540c4 100644 --- a/boards/teensy40/Cargo.toml +++ b/boards/teensy40/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/teensy40/layout.ld b/boards/teensy40/layout.ld index 954fb11fd3..fa1f38ade5 100644 --- a/boards/teensy40/layout.ld +++ b/boards/teensy40/layout.ld @@ -25,7 +25,7 @@ MEMORY SECTIONS { - .boot : + .boot : { /* FlexSPI Configuration Block (defined in source) */ KEEP(*(.fcb)); @@ -71,4 +71,4 @@ SECTIONS } > rom } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/Cargo.toml b/boards/tutorials/nrf52840dk-hotp-tutorial/Cargo.toml index 57b4e2e6c2..1623376aee 100644 --- a/boards/tutorials/nrf52840dk-hotp-tutorial/Cargo.toml +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/Cargo.toml @@ -23,5 +23,8 @@ capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } components = { path = "../../components" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/layout.ld b/boards/tutorials/nrf52840dk-hotp-tutorial/layout.ld index 52d52ab3ac..e87005fd9e 100644 --- a/boards/tutorials/nrf52840dk-hotp-tutorial/layout.ld +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2024. */ INCLUDE ../../nordic/nrf52840_chip_layout.ld -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/Cargo.toml b/boards/tutorials/nrf52840dk-thread-tutorial/Cargo.toml index cdadcc88dd..a51b88671d 100644 --- a/boards/tutorials/nrf52840dk-thread-tutorial/Cargo.toml +++ b/boards/tutorials/nrf52840dk-thread-tutorial/Cargo.toml @@ -23,5 +23,8 @@ capsules-extra = { path = "../../../capsules/extra" } capsules-system = { path = "../../../capsules/system" } components = { path = "../../components" } +[build-dependencies] +tock_build_scripts = { path = "../../build_scripts" } + [lints] workspace = true diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/layout.ld b/boards/tutorials/nrf52840dk-thread-tutorial/layout.ld index ece13c78e4..8924ae11fe 100644 --- a/boards/tutorials/nrf52840dk-thread-tutorial/layout.ld +++ b/boards/tutorials/nrf52840dk-thread-tutorial/layout.ld @@ -3,4 +3,4 @@ /* Copyright Tock Contributors 2023. */ INCLUDE ../../nordic/nrf52840_chip_layout.ld -INCLUDE ../../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/veer_el2_sim/Cargo.toml b/boards/veer_el2_sim/Cargo.toml index 014781c163..ad163b8b37 100644 --- a/boards/veer_el2_sim/Cargo.toml +++ b/boards/veer_el2_sim/Cargo.toml @@ -20,5 +20,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/veer_el2_sim/layout.ld b/boards/veer_el2_sim/layout.ld index 9bed370cc7..ac16f27045 100644 --- a/boards/veer_el2_sim/layout.ld +++ b/boards/veer_el2_sim/layout.ld @@ -9,4 +9,4 @@ MEMORY ram (rwx) : ORIGIN = 0x20600000, LENGTH = 0x300000 } -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/weact_f401ccu6/Cargo.toml b/boards/weact_f401ccu6/Cargo.toml index 8a725d66fa..4c2c66c4fc 100644 --- a/boards/weact_f401ccu6/Cargo.toml +++ b/boards/weact_f401ccu6/Cargo.toml @@ -19,5 +19,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/weact_f401ccu6/layout.ld b/boards/weact_f401ccu6/layout.ld index e7affc0fff..d9cf1b4f12 100644 --- a/boards/weact_f401ccu6/layout.ld +++ b/boards/weact_f401ccu6/layout.ld @@ -17,4 +17,4 @@ MEMORY PAGE_SIZE = 2K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/boards/wm1110dev/Cargo.toml b/boards/wm1110dev/Cargo.toml index af5bb32503..db764aa3c5 100644 --- a/boards/wm1110dev/Cargo.toml +++ b/boards/wm1110dev/Cargo.toml @@ -21,5 +21,8 @@ capsules-core = { path = "../../capsules/core" } capsules-extra = { path = "../../capsules/extra" } capsules-system = { path = "../../capsules/system" } +[build-dependencies] +tock_build_scripts = { path = "../build_scripts" } + [lints] workspace = true diff --git a/boards/wm1110dev/layout.ld b/boards/wm1110dev/layout.ld index a6f358c41c..2a2667603b 100644 --- a/boards/wm1110dev/layout.ld +++ b/boards/wm1110dev/layout.ld @@ -13,4 +13,4 @@ MEMORY PAGE_SIZE = 4K; -INCLUDE ../kernel_layout.ld +INCLUDE tock_kernel_layout.ld diff --git a/doc/OutOfTree.md b/doc/OutOfTree.md index 78e6ce2e77..139f7fad1a 100644 --- a/doc/OutOfTree.md +++ b/doc/OutOfTree.md @@ -1,8 +1,8 @@ Out of Tree Tock ================ -This guide covers best practices for maintaining subsytems not in the -Tock master repository. +This guide covers best practices for maintaining subsytems not in the main Tock +repository. _It is a work in progress. Comments and pull requests are appreciated!_ @@ -25,13 +25,13 @@ Tock aims to maintain a stable syscall ABI, but does not guarantee stability of kernel interfaces. There are two primary channels to stay abreast of Tock development: - - [tock-dev mailing list](https://groups.google.com/forum/#!forum/tock-dev): - Any major Tock changes will be announced via this list. The list - also support general Tock development, however it is relatively low - traffic (<1 email/day on average). - - [Tock GitHub](https://github.com/tock/tock/): All Tock - changes go through Pull Requests. Non-trivial changes will generally - wait at least one week to merge to allow for feedback. +- [tock-dev mailing list](https://lists.tockos.org/postorius/lists/): Any major + Tock changes will be announced via this list. The list also supports general + Tock development, however, it is relatively low traffic (<1 email/day on + average). +- [Tock GitHub](https://github.com/tock/tock/): All Tock changes go through Pull + Requests. Non-trivial changes will generally wait at least one week to merge + to allow for feedback. Finally, please don't hesitate to [ask for help](https://github.com/tock/tock/#keep-up-to-date). @@ -40,112 +40,135 @@ Finally, please don't hesitate to Structure --------- -Usually it is easiest to keep a -[submodule](https://git-scm.com/docs/git-submodule) of Tock in your -project. - -We then suggest generally mirroring the Tock directory structure, -something like: +We suggest generally mirroring the Tock directory structure within your +repository. This looks something like: $ tree . . ├── boards - │   └── my_board - │   ├── Cargo.toml - │   ├── Makefile - │   ├── layout.ld - │   └── src - │   └── main.rs - ├── my_drivers - │   ├── Cargo.toml - │   └── src - │   ├── my_radio.rs - │   └── my_sensor.rs - └── tock # Where this is a git submodule - │   ├── ... + │ └── my_board + │ ├── Cargo.toml + │ ├── Makefile + │ ├── layout.ld + │ └── src + │ └── main.rs + ├── capsules + │ ├── Cargo.toml + │ └── src + │ ├── my_radio.rs + │ └── my_sensor.rs + +Your code is then in individual Cargo crates. This is important because you can +then use Cargo to include dependencies (including the upstream Tock kernel +crates). Boards ------ -Your board's Makefile will need to set a `PLATFORM` variable, specifying -the name of this platform, and include the primary Tock Makefile. We -also strongly suggest defining `program` and `flash` targets that -specify how the kernel is loaded onto your board. - - ```make - PLATFORM = my_board - - # Include Tock build rules - include ../../tock/boards/Makefile.common - - # Rules for loading via bootloader or other simple, direct connection - program: - ... - - # Rules for loading via JTAG or other external programmer - flash: - ... - ``` - -Your board's Cargo.toml will need to express how to find all the -components that your board uses. Most of these will likely be references -to elements of Tock. - - ```toml - [package] - name = "my_board" - version = "0.1.0" - authors = ["Example Developer "] - build = "../../tock/boards/build.rs" - - [profile.dev] - panic = "abort" - lto = true - opt-level = 0 - debug = true - - [profile.release] - panic = "abort" - lto = true - - [dependencies] - cortexm4 = { path = "../../tock/arch/cortex-m4" } - capsules = { path = "../../tock/capsules" } - sam4l = { path = "../../tock/chips/sam4l" } - kernel = { path = "../../tock/kernel" } - my_drivers = { path = "../../my_drivers" } - ``` - -If using a linker script named `layout.ld`, your board crate can make use of the -Tock submodule's `build.rs` script to ensure it rebuilds when any linker scripts -change. +Boards are likely to start with a copy of an existing Tock board. + +You can build a Tock board using Cargo commands (i.e., `cargo build --release`). +If you prefer to have the option to use Make you will need to copy the +`Makefile.common` makefile from the Tock repository and then include a Makefile +in your board's directory. + +Your board's Makefile will need to include the primary Tock Makefile. We also +strongly suggest defining `program` and `flash` targets that specify how the +kernel is loaded onto your board. + +```make +# Include Tock build rules +include ../Makefile.common + +# Rules for loading via bootloader or other simple, direct connection +program: + ... + +# Rules for loading via JTAG or other external programmer +flash: + ... +``` + +Your board's Cargo.toml will need to express how to find all the components that +your board uses. Most of these will likely be references to elements of Tock. + +```toml +[package] +name = "my_board" +version = "0.1.0" +authors = ["Example Developer "] +build = "build.rs" + +[profile.dev] +panic = "abort" +lto = true +opt-level = "z" +debug = true + +[profile.release] +panic = "abort" +lto = true +opt-level = "z" +debug = true +codegen-units = 1 + +[dependencies] +cortexm4 = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +capsules = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +sam4l = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +kernel = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +my_drivers = { path = "../../my_drivers" } + +[build-dependencies] +tock_build_scripts = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +``` + +You will need to create a `build.rs` file that simply calls into the generic +build script provided in the Tock repository: + +```rust +// build.rs +// +fn main() { + tock_build_scripts::default_linker_script(); +} +``` + +You can use the default Tock linker script by creating a `layout.ld` file, +specifying the memory map, and then including the linker script +`tock_kernel_layout.ld`. + +```ld +/* layout.ld */ + +... + +INCLUDE tock_kernel_layout.ld +``` Everything Else --------------- -Custom chips, drivers, or other components should only require a -Cargo.toml. - - ```toml - [package] - name = "my_drivers" - version = "0.1.0" - authors = ["Example Developer "] +Custom chips, drivers, or other components should only require a Cargo.toml. - [dependencies] - kernel = { path = "../tock/kernel" } - ``` +```toml +[package] +name = "my_drivers" +version = "0.1.0" +authors = ["Example Developer "] +[dependencies] +kernel = { git = "https://github.com/tock/tock", rev = "0c1b63b49" } +``` Examples -------- - - Several of the Tock core developers also work on the - [Signpost project](https://github.com/lab11/signpost-software). - The project includes - [seven boards (and growing!)](https://github.com/lab11/signpost-software/tree/master/signpost/kernel/boards) - that run Tock. - - New chips and boards often begin life out of tree. A current effort - is [the STM32 port](https://github.com/tock/tock-stm32). +- Several of the Tock core developers also work on the [Signpost + project](https://github.com/lab11/signpost-software). The project includes + [seven boards](https://github.com/lab11/signpost-software/tree/master/signpost/kernel/boards) + that run Tock. +- New chips and boards often begin life out of tree. A current effort is [the + STM32 port](https://github.com/tock/tock-stm32). diff --git a/tools/check_boards_readme.py b/tools/check_boards_readme.py index f42ee16099..82e17a9d8f 100755 --- a/tools/check_boards_readme.py +++ b/tools/check_boards_readme.py @@ -13,6 +13,7 @@ import sys SKIP = [ + "boards/build_scripts", "boards/components", "boards/nordic/nrf52_components", "boards/configurations",