This repository was archived by the owner on Nov 30, 2022. It is now read-only.
File tree 6 files changed +181
-0
lines changed
6 files changed +181
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Test Embedded
2
+
3
+ on :
4
+ push :
5
+
6
+ jobs :
7
+ build :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ -
11
+ name : Checkout
12
+ uses : actions/checkout@v2
13
+ - name : Checkout Toolchain
14
+ uses : actions-rs/toolchain@v1
15
+ with :
16
+ profile : minimal
17
+ toolchain : stable
18
+ override : true
19
+ components : rust-src
20
+ target : thumbv7m-none-eabi
21
+ -
22
+ name : Build
23
+ run : cd embedded && cargo build
Original file line number Diff line number Diff line change
1
+ [target.thumbv7m-none-eabi]
2
+ # uncomment this to make `cargo run` execute programs on QEMU
3
+ runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
4
+
5
+ rustflags = [
6
+ # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
7
+ # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
8
+ "-C", "link-arg=--nmagic",
9
+
10
+ # LLD (shipped with the Rust toolchain) is used as the default linker
11
+ "-C", "link-arg=-Tlink.x",
12
+
13
+ # if you run into problems with LLD switch to the GNU linker by commenting out
14
+ # this line
15
+ # "-C", "linker=arm-none-eabi-ld",
16
+
17
+ # if you need to link to pre-compiled C libraries provided by a C toolchain
18
+ # use GCC as the linker by commenting out both lines above and then
19
+ # uncommenting the three lines below
20
+ # "-C", "linker=arm-none-eabi-gcc",
21
+ # "-C", "link-arg=-Wl,-Tlink.x",
22
+ # "-C", "link-arg=-nostartfiles",
23
+ ]
24
+
25
+ [build]
26
+ target = "thumbv7m-none-eabi" # Cortex-M3
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ authors = [
" Riccardo Casatta <[email protected] >" ]
3
+ edition = " 2018"
4
+ readme = " README.md"
5
+ name = " embedded"
6
+ version = " 0.1.0"
7
+
8
+ [dependencies ]
9
+ cortex-m = " 0.6.0"
10
+ cortex-m-rt = " 0.6.10"
11
+ cortex-m-semihosting = " 0.3.3"
12
+ panic-halt = " 0.2.0"
13
+ bitcoin_hashes = { path =" ../" , default-features = false }
14
+
15
+ # Uncomment for the panic example.
16
+ # panic-itm = "0.4.1"
17
+
18
+ # Uncomment for the allocator example.
19
+ # alloc-cortex-m = "0.4.0"
20
+
21
+ # Uncomment for the device example.
22
+ # Update `memory.x`, set target to `thumbv7em-none-eabihf` in `.cargo/config`,
23
+ # and then use `cargo build --examples device` to build it.
24
+ # [dependencies.stm32f3]
25
+ # features = ["stm32f303", "rt"]
26
+ # version = "0.7.1"
27
+
28
+ # this lets you use `cargo fix`!
29
+ [[bin ]]
30
+ name = " embedded"
31
+ test = false
32
+ bench = false
33
+
34
+ [profile .release ]
35
+ codegen-units = 1 # better optimizations
36
+ debug = true # symbols are nice and they don't increase the size on Flash
37
+ lto = true # better optimizations
Original file line number Diff line number Diff line change
1
+ //! This build script copies the `memory.x` file from the crate root into
2
+ //! a directory where the linker can always find it at build time.
3
+ //! For many projects this is optional, as the linker always searches the
4
+ //! project root directory -- wherever `Cargo.toml` is. However, if you
5
+ //! are using a workspace or have a more complicated build setup, this
6
+ //! build script becomes required. Additionally, by requesting that
7
+ //! Cargo re-run the build script whenever `memory.x` is changed,
8
+ //! updating `memory.x` ensures a rebuild of the application with the
9
+ //! new memory settings.
10
+
11
+ use std:: env;
12
+ use std:: fs:: File ;
13
+ use std:: io:: Write ;
14
+ use std:: path:: PathBuf ;
15
+
16
+ fn main ( ) {
17
+ // Put `memory.x` in our output directory and ensure it's
18
+ // on the linker search path.
19
+ let out = & PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) ;
20
+ File :: create ( out. join ( "memory.x" ) )
21
+ . unwrap ( )
22
+ . write_all ( include_bytes ! ( "memory.x" ) )
23
+ . unwrap ( ) ;
24
+ println ! ( "cargo:rustc-link-search={}" , out. display( ) ) ;
25
+
26
+ // By default, Cargo will re-run a build script whenever
27
+ // any file in the project changes. By specifying `memory.x`
28
+ // here, we ensure the build script is only re-run when
29
+ // `memory.x` is changed.
30
+ println ! ( "cargo:rerun-if-changed=memory.x" ) ;
31
+ }
Original file line number Diff line number Diff line change
1
+ MEMORY
2
+ {
3
+ /* NOTE 1 K = 1 KiBi = 1024 bytes */
4
+ /* TODO Adjust these memory regions to match your device memory layout */
5
+ /* These values correspond to the LM3S6965, one of the few devices QEMU can emulate */
6
+ FLASH : ORIGIN = 0x00000000, LENGTH = 256K
7
+ RAM : ORIGIN = 0x20000000, LENGTH = 64K
8
+ }
9
+
10
+ /* This is where the call stack will be allocated. */
11
+ /* The stack is of the full descending type. */
12
+ /* You may want to use this variable to locate the call stack and static
13
+ variables in different memory regions. Below is shown the default value */
14
+ /* _stack_start = ORIGIN (RAM) + LENGTH (RAM); */
15
+
16
+ /* You can use this symbol to customize the location of the .text section */
17
+ /* If omitted the .text section will be placed right after the .vector_table
18
+ section */
19
+ /* This is required only on microcontrollers that store some configuration right
20
+ after the vector table */
21
+ /* _stext = ORIGIN (FLASH) + 0x400; */
22
+
23
+ /* Example of putting non-initialized variables into custom RAM locations. */
24
+ /* This assumes you have defined a region RAM2 above, and in the Rust
25
+ sources added the attribute `#[link_section = ".ram2bss"]` to the data
26
+ you want to place there. */
27
+ /* Note that the section will not be zero-initialized by the runtime! */
28
+ /* SECTIONS {
29
+ .ram2bss (NOLOAD) : ALIGN (4) {
30
+ *(.ram2bss);
31
+ . = ALIGN (4);
32
+ } > RAM2
33
+ } INSERT AFTER .bss;
34
+ */
Original file line number Diff line number Diff line change
1
+ #![ no_std]
2
+ #![ no_main]
3
+
4
+ #[ macro_use]
5
+ extern crate bitcoin_hashes;
6
+
7
+ // pick a panicking behavior
8
+ use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
9
+ // use panic_abort as _; // requires nightly
10
+ // use panic_itm as _; // logs messages over ITM; requires ITM support
11
+ // use panic_semihosting as _; // logs messages to the host stderr; requires a debugger
12
+
13
+ use cortex_m_rt:: entry;
14
+ use cortex_m_semihosting:: { debug, hprintln} ;
15
+ use bitcoin_hashes:: sha256;
16
+ use core:: str:: FromStr ;
17
+ use bitcoin_hashes:: Hash ;
18
+
19
+ hash_newtype ! ( TestType , sha256:: Hash , 32 , doc="test" ) ;
20
+
21
+ #[ entry]
22
+ fn main ( ) -> ! {
23
+ hprintln ! ( "Hello world!" ) . unwrap ( ) ;
24
+
25
+ debug:: exit ( debug:: EXIT_SUCCESS ) ;
26
+
27
+ loop {
28
+ // your code goes here
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments