Bläddra i källkod

Initial import.

Mathias Gottschlag 5 år sedan
incheckning
6879a79e7c

+ 2
- 0
.gitignore Visa fil

@@ -0,0 +1,2 @@
1
+.*.swp
2
+/hackamp/firmware/target

Binär
hackamp/firmware/.Cargo.toml.swp Visa fil


+ 8
- 0
hackamp/firmware/.cargo/config Visa fil

@@ -0,0 +1,8 @@
1
+[target.thumbv7em-none-eabihf]
2
+runner = "arm-none-eabi-gdb -x openocd.gdb"
3
+rustflags = [
4
+  "-C", "link-arg=-Tlink.x",
5
+]
6
+
7
+[build]
8
+target = "thumbv7em-none-eabihf"

+ 422
- 0
hackamp/firmware/Cargo.lock Visa fil

@@ -0,0 +1,422 @@
1
+# This file is automatically @generated by Cargo.
2
+# It is not intended for manual editing.
3
+[[package]]
4
+name = "aligned"
5
+version = "0.3.4"
6
+source = "registry+https://github.com/rust-lang/crates.io-index"
7
+checksum = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf"
8
+dependencies = [
9
+ "as-slice",
10
+]
11
+
12
+[[package]]
13
+name = "as-slice"
14
+version = "0.1.4"
15
+source = "registry+https://github.com/rust-lang/crates.io-index"
16
+checksum = "bb4d1c23475b74e3672afa8c2be22040b8b7783ad9b461021144ed10a46bb0e6"
17
+dependencies = [
18
+ "generic-array 0.12.3",
19
+ "generic-array 0.13.2",
20
+ "generic-array 0.14.4",
21
+ "stable_deref_trait",
22
+]
23
+
24
+[[package]]
25
+name = "autocfg"
26
+version = "1.0.1"
27
+source = "registry+https://github.com/rust-lang/crates.io-index"
28
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
29
+
30
+[[package]]
31
+name = "bare-metal"
32
+version = "0.2.5"
33
+source = "registry+https://github.com/rust-lang/crates.io-index"
34
+checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
35
+dependencies = [
36
+ "rustc_version",
37
+]
38
+
39
+[[package]]
40
+name = "bitfield"
41
+version = "0.13.2"
42
+source = "registry+https://github.com/rust-lang/crates.io-index"
43
+checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
44
+
45
+[[package]]
46
+name = "byteorder"
47
+version = "1.3.4"
48
+source = "registry+https://github.com/rust-lang/crates.io-index"
49
+checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
50
+
51
+[[package]]
52
+name = "cast"
53
+version = "0.2.3"
54
+source = "registry+https://github.com/rust-lang/crates.io-index"
55
+checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
56
+dependencies = [
57
+ "rustc_version",
58
+]
59
+
60
+[[package]]
61
+name = "cortex-m"
62
+version = "0.6.4"
63
+source = "registry+https://github.com/rust-lang/crates.io-index"
64
+checksum = "88cdafeafba636c00c467ded7f1587210725a1adfab0c24028a7844b87738263"
65
+dependencies = [
66
+ "aligned",
67
+ "bare-metal",
68
+ "bitfield",
69
+ "volatile-register",
70
+]
71
+
72
+[[package]]
73
+name = "cortex-m-rt"
74
+version = "0.6.13"
75
+source = "registry+https://github.com/rust-lang/crates.io-index"
76
+checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb"
77
+dependencies = [
78
+ "cortex-m-rt-macros",
79
+ "r0",
80
+]
81
+
82
+[[package]]
83
+name = "cortex-m-rt-macros"
84
+version = "0.1.8"
85
+source = "registry+https://github.com/rust-lang/crates.io-index"
86
+checksum = "4717562afbba06e760d34451919f5c3bf3ac15c7bb897e8b04862a7428378647"
87
+dependencies = [
88
+ "proc-macro2",
89
+ "quote",
90
+ "syn",
91
+]
92
+
93
+[[package]]
94
+name = "cortex-m-rtic"
95
+version = "0.5.5"
96
+source = "registry+https://github.com/rust-lang/crates.io-index"
97
+checksum = "b30efcb6b7920d9016182c485687f0012487032a14c415d2fce6e9862ef8260e"
98
+dependencies = [
99
+ "cortex-m",
100
+ "cortex-m-rt",
101
+ "cortex-m-rtic-macros",
102
+ "heapless",
103
+ "rtic-core",
104
+ "version_check",
105
+]
106
+
107
+[[package]]
108
+name = "cortex-m-rtic-macros"
109
+version = "0.5.2"
110
+source = "registry+https://github.com/rust-lang/crates.io-index"
111
+checksum = "9a1a6a4c9550373038c0e21a78d44d529bd697c25bbf6b8004bddc6e63b119c7"
112
+dependencies = [
113
+ "proc-macro2",
114
+ "quote",
115
+ "rtic-syntax",
116
+ "syn",
117
+]
118
+
119
+[[package]]
120
+name = "cortex-m-semihosting"
121
+version = "0.3.5"
122
+source = "registry+https://github.com/rust-lang/crates.io-index"
123
+checksum = "113ef0ecffee2b62b58f9380f4469099b30e9f9cbee2804771b4203ba1762cfa"
124
+dependencies = [
125
+ "cortex-m",
126
+]
127
+
128
+[[package]]
129
+name = "embedded-hal"
130
+version = "0.2.4"
131
+source = "registry+https://github.com/rust-lang/crates.io-index"
132
+checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb"
133
+dependencies = [
134
+ "nb 0.1.3",
135
+ "void",
136
+]
137
+
138
+[[package]]
139
+name = "generic-array"
140
+version = "0.12.3"
141
+source = "registry+https://github.com/rust-lang/crates.io-index"
142
+checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
143
+dependencies = [
144
+ "typenum",
145
+]
146
+
147
+[[package]]
148
+name = "generic-array"
149
+version = "0.13.2"
150
+source = "registry+https://github.com/rust-lang/crates.io-index"
151
+checksum = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd"
152
+dependencies = [
153
+ "typenum",
154
+]
155
+
156
+[[package]]
157
+name = "generic-array"
158
+version = "0.14.4"
159
+source = "registry+https://github.com/rust-lang/crates.io-index"
160
+checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
161
+dependencies = [
162
+ "typenum",
163
+ "version_check",
164
+]
165
+
166
+[[package]]
167
+name = "hackamp-firmware"
168
+version = "0.1.0"
169
+dependencies = [
170
+ "cortex-m",
171
+ "cortex-m-rt",
172
+ "cortex-m-rtic",
173
+ "embedded-hal",
174
+ "panic-semihosting",
175
+ "stm32f4xx-hal",
176
+]
177
+
178
+[[package]]
179
+name = "hash32"
180
+version = "0.1.1"
181
+source = "registry+https://github.com/rust-lang/crates.io-index"
182
+checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc"
183
+dependencies = [
184
+ "byteorder",
185
+]
186
+
187
+[[package]]
188
+name = "hashbrown"
189
+version = "0.9.1"
190
+source = "registry+https://github.com/rust-lang/crates.io-index"
191
+checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
192
+
193
+[[package]]
194
+name = "heapless"
195
+version = "0.5.6"
196
+source = "registry+https://github.com/rust-lang/crates.io-index"
197
+checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1"
198
+dependencies = [
199
+ "as-slice",
200
+ "generic-array 0.13.2",
201
+ "hash32",
202
+ "stable_deref_trait",
203
+]
204
+
205
+[[package]]
206
+name = "indexmap"
207
+version = "1.6.0"
208
+source = "registry+https://github.com/rust-lang/crates.io-index"
209
+checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
210
+dependencies = [
211
+ "autocfg",
212
+ "hashbrown",
213
+]
214
+
215
+[[package]]
216
+name = "nb"
217
+version = "0.1.3"
218
+source = "registry+https://github.com/rust-lang/crates.io-index"
219
+checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
220
+dependencies = [
221
+ "nb 1.0.0",
222
+]
223
+
224
+[[package]]
225
+name = "nb"
226
+version = "1.0.0"
227
+source = "registry+https://github.com/rust-lang/crates.io-index"
228
+checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
229
+
230
+[[package]]
231
+name = "panic-semihosting"
232
+version = "0.5.4"
233
+source = "registry+https://github.com/rust-lang/crates.io-index"
234
+checksum = "aed16eb761d0ee9161dd1319cb38c8007813b20f9720a5a682b283e7b8cdfe58"
235
+dependencies = [
236
+ "cortex-m",
237
+ "cortex-m-semihosting",
238
+]
239
+
240
+[[package]]
241
+name = "proc-macro2"
242
+version = "1.0.24"
243
+source = "registry+https://github.com/rust-lang/crates.io-index"
244
+checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
245
+dependencies = [
246
+ "unicode-xid",
247
+]
248
+
249
+[[package]]
250
+name = "quote"
251
+version = "1.0.7"
252
+source = "registry+https://github.com/rust-lang/crates.io-index"
253
+checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
254
+dependencies = [
255
+ "proc-macro2",
256
+]
257
+
258
+[[package]]
259
+name = "r0"
260
+version = "0.2.2"
261
+source = "registry+https://github.com/rust-lang/crates.io-index"
262
+checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
263
+
264
+[[package]]
265
+name = "rand_core"
266
+version = "0.5.1"
267
+source = "registry+https://github.com/rust-lang/crates.io-index"
268
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
269
+
270
+[[package]]
271
+name = "rtic-core"
272
+version = "0.3.0"
273
+source = "registry+https://github.com/rust-lang/crates.io-index"
274
+checksum = "ab51fe832317e805f869b3d859f91aadf855c2c3da51f9b84bc645c201597158"
275
+
276
+[[package]]
277
+name = "rtic-syntax"
278
+version = "0.4.0"
279
+source = "registry+https://github.com/rust-lang/crates.io-index"
280
+checksum = "8152fcaa845720d61e6cc570548b89144c2c307f18a480bbd97e55e9f6eeff04"
281
+dependencies = [
282
+ "indexmap",
283
+ "proc-macro2",
284
+ "syn",
285
+]
286
+
287
+[[package]]
288
+name = "rustc_version"
289
+version = "0.2.3"
290
+source = "registry+https://github.com/rust-lang/crates.io-index"
291
+checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
292
+dependencies = [
293
+ "semver",
294
+]
295
+
296
+[[package]]
297
+name = "semver"
298
+version = "0.9.0"
299
+source = "registry+https://github.com/rust-lang/crates.io-index"
300
+checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
301
+dependencies = [
302
+ "semver-parser",
303
+]
304
+
305
+[[package]]
306
+name = "semver-parser"
307
+version = "0.7.0"
308
+source = "registry+https://github.com/rust-lang/crates.io-index"
309
+checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
310
+
311
+[[package]]
312
+name = "stable_deref_trait"
313
+version = "1.2.0"
314
+source = "registry+https://github.com/rust-lang/crates.io-index"
315
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
316
+
317
+[[package]]
318
+name = "stm32f4"
319
+version = "0.11.0"
320
+source = "registry+https://github.com/rust-lang/crates.io-index"
321
+checksum = "11460b4de3a84f072e2cf6e76306c64d27f405a0e83bace0a726f555ddf4bf33"
322
+dependencies = [
323
+ "bare-metal",
324
+ "cortex-m",
325
+ "vcell",
326
+]
327
+
328
+[[package]]
329
+name = "stm32f4xx-hal"
330
+version = "0.8.3"
331
+source = "registry+https://github.com/rust-lang/crates.io-index"
332
+checksum = "b3a2f044469d1e3aff2cd02bee8b2724f3d5d91f3175e5d1ec99770320d16192"
333
+dependencies = [
334
+ "bare-metal",
335
+ "cast",
336
+ "cortex-m",
337
+ "cortex-m-rt",
338
+ "embedded-hal",
339
+ "nb 0.1.3",
340
+ "rand_core",
341
+ "stm32f4",
342
+ "synopsys-usb-otg",
343
+ "void",
344
+]
345
+
346
+[[package]]
347
+name = "stm32ral"
348
+version = "0.3.1"
349
+source = "registry+https://github.com/rust-lang/crates.io-index"
350
+checksum = "8665561cb3422ddf54d257bf6cb3c5432ba0684f6937c4ad987bad16aa6ca496"
351
+dependencies = [
352
+ "bare-metal",
353
+ "cortex-m",
354
+]
355
+
356
+[[package]]
357
+name = "syn"
358
+version = "1.0.48"
359
+source = "registry+https://github.com/rust-lang/crates.io-index"
360
+checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
361
+dependencies = [
362
+ "proc-macro2",
363
+ "quote",
364
+ "unicode-xid",
365
+]
366
+
367
+[[package]]
368
+name = "synopsys-usb-otg"
369
+version = "0.1.0"
370
+source = "registry+https://github.com/rust-lang/crates.io-index"
371
+checksum = "6bcd2ca4e946cd2f33dfe2b0485f6b3c306721a035699f44f576d69e45b38db0"
372
+dependencies = [
373
+ "cortex-m",
374
+ "stm32ral",
375
+ "usb-device",
376
+ "vcell",
377
+]
378
+
379
+[[package]]
380
+name = "typenum"
381
+version = "1.12.0"
382
+source = "registry+https://github.com/rust-lang/crates.io-index"
383
+checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
384
+
385
+[[package]]
386
+name = "unicode-xid"
387
+version = "0.2.1"
388
+source = "registry+https://github.com/rust-lang/crates.io-index"
389
+checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
390
+
391
+[[package]]
392
+name = "usb-device"
393
+version = "0.2.7"
394
+source = "registry+https://github.com/rust-lang/crates.io-index"
395
+checksum = "849eed9b4dc61a1f17ba1d7a5078ceb095b9410caa38a506eb281ed5eff12fbd"
396
+
397
+[[package]]
398
+name = "vcell"
399
+version = "0.1.2"
400
+source = "registry+https://github.com/rust-lang/crates.io-index"
401
+checksum = "876e32dcadfe563a4289e994f7cb391197f362b6315dc45e8ba4aa6f564a4b3c"
402
+
403
+[[package]]
404
+name = "version_check"
405
+version = "0.9.2"
406
+source = "registry+https://github.com/rust-lang/crates.io-index"
407
+checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
408
+
409
+[[package]]
410
+name = "void"
411
+version = "1.0.2"
412
+source = "registry+https://github.com/rust-lang/crates.io-index"
413
+checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
414
+
415
+[[package]]
416
+name = "volatile-register"
417
+version = "0.2.0"
418
+source = "registry+https://github.com/rust-lang/crates.io-index"
419
+checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286"
420
+dependencies = [
421
+ "vcell",
422
+]

+ 18
- 0
hackamp/firmware/Cargo.toml Visa fil

@@ -0,0 +1,18 @@
1
+[package]
2
+name = "hackamp-firmware"
3
+version = "0.1.0"
4
+authors = ["Mathias Gottschlag <mgottschlag@gmail.com>"]
5
+edition = "2018"
6
+
7
+[dependencies]
8
+cortex-m = "0.6"
9
+cortex-m-rt = "0.6"
10
+cortex-m-rtic = "0.5.3"
11
+embedded-hal = "0.2.3"
12
+panic-semihosting = "0.5"
13
+stm32f4xx-hal = { version = "0.8.3", features = ["stm32f429", "usb_hs"] }
14
+
15
+[profile]
16
+[profile.release]
17
+debug = true
18
+lto = true

+ 15
- 0
hackamp/firmware/build.rs Visa fil

@@ -0,0 +1,15 @@
1
+use std::env;
2
+use std::fs;
3
+use std::io::Write;
4
+use std::path::PathBuf;
5
+
6
+fn main() {
7
+    // Put the linker script somewhere the linker can find it
8
+    let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
9
+    fs::File::create(out_dir.join("memory.x"))
10
+        .unwrap()
11
+        .write_all(include_bytes!("memory.x"))
12
+        .unwrap();
13
+    println!("cargo:rustc-link-search={}", out_dir.display());
14
+    println!("cargo:rerun-if-changed=memory.x");
15
+}

+ 7
- 0
hackamp/firmware/memory.x Visa fil

@@ -0,0 +1,7 @@
1
+
2
+/* Linker script for building examples for the STM32F429ZI */
3
+MEMORY
4
+{
5
+  FLASH : ORIGIN = 0x08000000, LENGTH = 2048K
6
+  RAM : ORIGIN = 0x20000000, LENGTH = 192K
7
+}

+ 5
- 0
hackamp/firmware/openocd.cfg Visa fil

@@ -0,0 +1,5 @@
1
+source [find interface/stlink.cfg]
2
+source [find target/stm32f4x.cfg]
3
+targets
4
+# reset halt
5
+# halt

+ 24
- 0
hackamp/firmware/openocd.gdb Visa fil

@@ -0,0 +1,24 @@
1
+set history save on
2
+set confirm off
3
+target extended-remote :3333
4
+monitor arm semihosting enable
5
+monitor reset halt
6
+
7
+# print demangled symbols
8
+set print asm-demangle on
9
+
10
+# set backtrace limit to not have infinite backtrace loops
11
+set backtrace limit 32
12
+
13
+# detect unhandled exceptions, hard faults and panics
14
+break DefaultHandler
15
+break HardFault
16
+#break rust_begin_unwind
17
+
18
+#break main
19
+
20
+load
21
+continue
22
+# monitor verify
23
+# monitor reset
24
+# quit

+ 1
- 0
hackamp/firmware/rustfmt.toml Visa fil

@@ -0,0 +1 @@
1
+edition = "2018"

+ 22
- 0
hackamp/firmware/src/main.rs Visa fil

@@ -0,0 +1,22 @@
1
+//! Firmware for the HackAmp.
2
+#![no_main]
3
+#![no_std]
4
+
5
+use panic_semihosting as _;
6
+
7
+#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true)]
8
+const APP: () = {
9
+    struct Resources {}
10
+
11
+    #[init]
12
+    fn init(_ctx: init::Context) {
13
+        // TODO
14
+    }
15
+
16
+    #[idle(resources = [])]
17
+    fn idle(_ctx: idle::Context) -> ! {
18
+        loop {
19
+            // TODO
20
+        }
21
+    }
22
+};

Loading…
Avbryt
Spara