This repository was archived by the owner on Nov 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +108
-0
lines changed
Expand file tree Collapse file tree 5 files changed +108
-0
lines changed Original file line number Diff line number Diff line change 8080 DO_FEATURE_MATRIX : true
8181 run : ./contrib/test.sh
8282
83+ Embedded :
84+ runs-on : ubuntu-latest
85+ steps :
86+ - name : Checkout
87+ uses : actions/checkout@v2
88+ - name : Set up QEMU
89+ run : sudo apt install qemu-system-arm
90+ - name : Checkout Toolchain
91+ uses : actions-rs/toolchain@v1
92+ with :
93+ profile : minimal
94+ toolchain : nightly
95+ override : true
96+ components : rust-src
97+ target : thumbv7m-none-eabi
98+ - name : Run
99+ env :
100+ RUSTFLAGS : " -C link-arg=-Tlink.x"
101+ CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER : " qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
102+ run : cd embedded && cargo run --target thumbv7m-none-eabi
103+
104+
Original file line number Diff line number Diff line change @@ -8,4 +8,7 @@ Cargo.lock
88fuzz /hfuzz_target
99fuzz /hfuzz_workspace
1010
11+ # embedded
12+ embedded /.cargo
13+
1114* ~
Original file line number Diff line number Diff line change 1+ [package ]
2+ authors = [" Riccardo Casatta <riccardo@casatta.it>" ]
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+ alloc-cortex-m = " 0.4.1"
14+ bitcoin_hashes = { path =" ../" , default-features = false }
15+
16+ [[bin ]]
17+ name = " embedded"
18+ test = false
19+ bench = false
20+
21+ [profile .release ]
22+ codegen-units = 1 # better optimizations
23+ debug = true # symbols are nice and they don't increase the size on Flash
24+ lto = true # better optimizations
Original file line number Diff line number Diff line change 1+ MEMORY
2+ {
3+ FLASH : ORIGIN = 0x00000000 , LENGTH = 256 K
4+ RAM : ORIGIN = 0x20000000 , LENGTH = 64 K
5+ }
Original file line number Diff line number Diff line change 1+ #![ feature( alloc_error_handler) ]
2+ #![ no_std]
3+ #![ no_main]
4+
5+ #[ macro_use]
6+ extern crate bitcoin_hashes;
7+
8+ extern crate alloc;
9+
10+ use alloc_cortex_m:: CortexMHeap ;
11+ use bitcoin_hashes:: { sha256, Hash , HashEngine } ;
12+ use core:: alloc:: Layout ;
13+ use core:: str:: FromStr ;
14+ use cortex_m:: asm;
15+ use cortex_m_rt:: entry;
16+ use cortex_m_semihosting:: { debug, hprintln} ;
17+ use panic_halt as _;
18+
19+ hash_newtype ! ( TestType , sha256:: Hash , 32 , doc = "test" ) ;
20+
21+ // this is the allocator the application will use
22+ #[ global_allocator]
23+ static ALLOCATOR : CortexMHeap = CortexMHeap :: empty ( ) ;
24+
25+ const HEAP_SIZE : usize = 1024 ; // in bytes
26+
27+ #[ entry]
28+ fn main ( ) -> ! {
29+ unsafe { ALLOCATOR . init ( cortex_m_rt:: heap_start ( ) as usize , HEAP_SIZE ) }
30+
31+ let mut engine = TestType :: engine ( ) ;
32+ engine. input ( b"abc" ) ;
33+ let hash = TestType :: from_engine ( engine) ;
34+
35+ let hash_check =
36+ TestType :: from_str ( "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" )
37+ . unwrap ( ) ;
38+ hprintln ! ( "hash:{} hash_check:{}" , hash, hash_check) . unwrap ( ) ;
39+ if hash == hash_check {
40+ debug:: exit ( debug:: EXIT_SUCCESS ) ;
41+ } else {
42+ debug:: exit ( debug:: EXIT_FAILURE ) ;
43+ }
44+
45+ loop { }
46+ }
47+
48+ // define what happens in an Out Of Memory (OOM) condition
49+ #[ alloc_error_handler]
50+ fn alloc_error ( _layout : Layout ) -> ! {
51+ asm:: bkpt ( ) ;
52+
53+ loop { }
54+ }
You can’t perform that action at this time.
0 commit comments