mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
loader: add asm binary and ix build script to pick ARM asm and link.x
This commit is contained in:
parent
1867f6cf1a
commit
306fdee180
3 changed files with 36 additions and 3 deletions
BIN
loader/bin/armv7a-unknown-xous-elf.a
Normal file
BIN
loader/bin/armv7a-unknown-xous-elf.a
Normal file
Binary file not shown.
15
loader/bin/assemble.sh
Executable file
15
loader/bin/assemble.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 Foundation Devices, Inc <hello@foundationdevices.com>
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
rm -f arm*.a
|
||||
|
||||
crate=loader
|
||||
|
||||
arm-none-eabi-gcc -ggdb3 -mfpu=vfpv4-d16 -mfloat-abi=hard -c -march=armv7-a ../src/platform/atsama5d27/asm.S -o $crate.o
|
||||
ar crs armv7a-unknown-xous-elf.a $crate.o
|
||||
|
||||
rm $crate.o
|
||||
|
|
@ -8,15 +8,33 @@ fn main() {
|
|||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("riscv") {
|
||||
let linker_file_path = if target.starts_with("riscv") {
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
}
|
||||
|
||||
PathBuf::from("link.x")
|
||||
} else if target.starts_with("armv7a") {
|
||||
let name = env::var("CARGO_PKG_NAME").unwrap();
|
||||
|
||||
fs::copy(
|
||||
format!("bin/{}.a", target),
|
||||
out_dir.join(format!("lib{}.a", name)),
|
||||
).expect("copy arm assembly binary");
|
||||
|
||||
println!("cargo:rustc-link-lib=static={}", name);
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rerun-if-changed=bin/{}.a", target);
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
|
||||
PathBuf::from("src/platform/atsama5d27/link.x")
|
||||
} else {
|
||||
unreachable!("unsupported target");
|
||||
};
|
||||
|
||||
// Put the linker script somewhere the linker can find it
|
||||
fs::File::create(out_dir.join("link.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("link.x"))
|
||||
.write_all(fs::read_to_string(linker_file_path).expect("linker file read").as_bytes())
|
||||
.unwrap();
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue