From 3261d95eee7f75545153d49dcf8fdb283745dcbf Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 11 Apr 2020 20:19:39 +0800 Subject: [PATCH] add hello world firmware --- .cargo/config | 10 ++++ Cargo.lock | 121 +++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 14 +++++ armv7-none-eabihf.json | 28 ++++++++++ link.x | 64 ++++++++++++++++++++++ runtime/Cargo.toml | 15 +++++ runtime/src/main.rs | 19 +++++++ 7 files changed, 271 insertions(+) create mode 100644 .cargo/config create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 armv7-none-eabihf.json create mode 100644 link.x create mode 100644 runtime/Cargo.toml create mode 100644 runtime/src/main.rs diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 00000000..56064f83 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,10 @@ +[target.armv7-none-eabihf] +runner = "./runner.sh" +rustflags = [ + "-C", "link-arg=-Tlink.x", + "-C", "target-feature=a9,armv7-a,neon", + "-C", "target-cpu=cortex-a9", +] + +[build] +target = "armv7-none-eabihf.json" diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..4dc9b248 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,121 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bit_field" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "compiler_builtins" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036b035e9ebcd705affece16319223d19f229e2358be6e3b7b094e57193312e6" + +[[package]] +name = "libboard_zynq" +version = "0.0.0" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#526cfe7577c189687ed1fdca512120dd1460bb80" +dependencies = [ + "bit_field", + "libcortex_a9", + "libregister", + "smoltcp", + "volatile-register", +] + +[[package]] +name = "libcortex_a9" +version = "0.0.0" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#526cfe7577c189687ed1fdca512120dd1460bb80" +dependencies = [ + "bit_field", + "libregister", +] + +[[package]] +name = "libregister" +version = "0.0.0" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#526cfe7577c189687ed1fdca512120dd1460bb80" +dependencies = [ + "bit_field", + "vcell", + "volatile-register", +] + +[[package]] +name = "libsupport_zynq" +version = "0.0.0" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#526cfe7577c189687ed1fdca512120dd1460bb80" +dependencies = [ + "compiler_builtins", + "libboard_zynq", + "libcortex_a9", + "libregister", + "linked_list_allocator", + "r0", +] + +[[package]] +name = "linked_list_allocator" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1070ea54beccbfd3a3987aca6440f94cc1e0b447c2d979d8c7f761e265417e4" + +[[package]] +name = "managed" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdcec5e97041c7f0f1c5b7d93f12e57293c831c646f4cc7a5db59460c7ea8de6" + +[[package]] +name = "r0" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211" + +[[package]] +name = "runtime" +version = "0.1.0" +dependencies = [ + "libboard_zynq", + "libsupport_zynq", +] + +[[package]] +name = "smoltcp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fe46639fd2ec79eadf8fe719f237a7a0bd4dac5d957f1ca5bbdbc1c3c39e53a" +dependencies = [ + "bitflags", + "byteorder", + "managed", +] + +[[package]] +name = "vcell" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876e32dcadfe563a4289e994f7cb391197f362b6315dc45e8ba4aa6f564a4b3c" + +[[package]] +name = "volatile-register" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" +dependencies = [ + "vcell", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..37e84fbd --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[workspace] +members = ["runtime"] + +[profile.dev] +panic = "abort" +lto = false + +[profile.release] +panic = "abort" +debug = true +# Link-Time Optimization: +# turn off if you get unusable debug symbols. +lto = true +opt-level = 'z' # Optimize for size. diff --git a/armv7-none-eabihf.json b/armv7-none-eabihf.json new file mode 100644 index 00000000..4fc452f6 --- /dev/null +++ b/armv7-none-eabihf.json @@ -0,0 +1,28 @@ +{ + "abi-blacklist": [ + "stdcall", + "fastcall", + "vectorcall", + "thiscall", + "win64", + "sysv64" + ], + "arch": "arm", + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "env": "", + "executables": true, + "features": "+v7,+vfp3,-d32,+thumb2,-neon", + "is-builtin": false, + "linker": "rust-lld", + "linker-flavor": "ld.lld", + "llvm-target": "armv7-unknown-none-eabihf", + "max-atomic-width": 32, + "os": "none", + "panic-strategy": "abort", + "relocation-model": "static", + "target-c-int-width": "32", + "target-endian": "little", + "target-pointer-width": "32", + "vendor": "" +} diff --git a/link.x b/link.x new file mode 100644 index 00000000..bc6bebe7 --- /dev/null +++ b/link.x @@ -0,0 +1,64 @@ +ENTRY(_boot_cores); + +STACK_SIZE = 0x8000; + +/* Provide some defaults */ +PROVIDE(Reset = _boot_cores); +PROVIDE(UndefinedInstruction = Reset); +PROVIDE(SoftwareInterrupt = Reset); +PROVIDE(PrefetchAbort = Reset); +PROVIDE(DataAbort = Reset); +PROVIDE(ReservedException = Reset); +PROVIDE(IRQ = Reset); +PROVIDE(FIQ = Reset); + +MEMORY +{ + /* 256 kB On-Chip Memory */ + OCM : ORIGIN = 0, LENGTH = 0x30000 + OCM3 : ORIGIN = 0xFFFF0000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : + { + KEEP(*(.text.exceptions)); + *(.text.boot); + *(.text .text.*); + } > OCM + + .rodata : ALIGN(4) + { + *(.rodata .rodata.*); + } > OCM + + .data : ALIGN(4) + { + *(.data .data.*); + } > OCM + + .bss (NOLOAD) : ALIGN(0x4000) + { + /* Aligned to 16 kB */ + KEEP(*(.bss.l1_table)); + *(.bss .bss.*); + . = ALIGN(4); + } > OCM + __bss_start = ADDR(.bss); + __bss_end = ADDR(.bss) + SIZEOF(.bss); + + .stack (NOLOAD) : ALIGN(0x1000) { + . += STACK_SIZE; + } > OCM + __stack_end = ADDR(.stack); + __stack_start = ADDR(.stack) + SIZEOF(.stack); + + /DISCARD/ : + { + /* Unused exception related info that only wastes space */ + *(.ARM.exidx); + *(.ARM.exidx.*); + *(.ARM.extab.*); + } +} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml new file mode 100644 index 00000000..0c72a011 --- /dev/null +++ b/runtime/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "runtime" +description = "ARTIQ runtime on Zynq" +version = "0.1.0" +authors = ["Sebastien Bourdeauducq "] +edition = "2018" + +[features] +target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706"] +target_cora_z7_10 = ["libboard_zynq/target_cora_z7_10", "libsupport_zynq/target_cora_z7_10"] +default = ["target_zc706"] + +[dependencies] +libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zc706.git" } +libsupport_zynq = { git = "https://git.m-labs.hk/M-Labs/zc706.git" } diff --git a/runtime/src/main.rs b/runtime/src/main.rs new file mode 100644 index 00000000..bf7e1edf --- /dev/null +++ b/runtime/src/main.rs @@ -0,0 +1,19 @@ +#![no_std] +#![no_main] + +extern crate alloc; + +use libboard_zynq::println; +use libsupport_zynq::ram; + +#[no_mangle] +pub fn main_core0() { + println!("hello world 000"); + loop {} +} + +#[no_mangle] +pub fn main_core1() { + println!("hello world 111"); + loop {} +}