Skip to content
Snippets Groups Projects
Commit 9d2bdec8 authored by August Svensson's avatar August Svensson
Browse files

merge

parents 35abd50c a5dcb243
Branches
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"preLaunchTask": "cargo build --example hello", "preLaunchTask": "cargo build --example hello",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/hello", "executable": "./target/thumbv7em-none-eabihf/debug/examples/hello",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"preLaunchTask": "cargo build --example itm", "preLaunchTask": "cargo build --example itm",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/itm", "executable": "./target/thumbv7em-none-eabihf/debug/examples/itm",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
"preLaunchTask": "cargo build --example panic", "preLaunchTask": "cargo build --example panic",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/panic", "executable": "./target/thumbv7em-none-eabihf/debug/examples/panic",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
"preLaunchTask": "cargo build --example exception_itm --release", "preLaunchTask": "cargo build --example exception_itm --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/exception_itm", "executable": "./target/thumbv7em-none-eabihf/release/examples/exception_itm",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
"preLaunchTask": "cargo build --example exception_itm_raw", "preLaunchTask": "cargo build --example exception_itm_raw",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/exception_itm_raw", "executable": "./target/thumbv7em-none-eabihf/debug/examples/exception_itm_raw",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
"preLaunchTask": "cargo build --example crash --release", "preLaunchTask": "cargo build --example crash --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/crash", "executable": "./target/thumbv7em-none-eabihf/release/examples/crash",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
"executable": "./target/thumbv7em-none-eabihf/debug/examples/device", "executable": "./target/thumbv7em-none-eabihf/debug/examples/device",
// uses local config files // uses local config files
"configFiles": [ "configFiles": [
"./stlink.cfg", "./stlink-v2-1.cfg",
"./stm32f4x.cfg" "./stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
"executable": "./target/thumbv7em-none-eabihf/debug/examples/rtfm_blinky", "executable": "./target/thumbv7em-none-eabihf/debug/examples/rtfm_blinky",
// uses local config files // uses local config files
"configFiles": [ "configFiles": [
"./stlink.cfg", "./stlink-v2-1.cfg",
"./stm32f4x.cfg" "./stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -302,7 +302,7 @@ ...@@ -302,7 +302,7 @@
"preLaunchTask": "cargo build --example bare0", "preLaunchTask": "cargo build --example bare0",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare0", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare0",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -331,7 +331,7 @@ ...@@ -331,7 +331,7 @@
] ]
}, },
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -360,7 +360,7 @@ ...@@ -360,7 +360,7 @@
] ]
}, },
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -389,7 +389,7 @@ ...@@ -389,7 +389,7 @@
] ]
}, },
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -418,7 +418,7 @@ ...@@ -418,7 +418,7 @@
] ]
}, },
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
"monitor arm semihosting enable" "monitor arm semihosting enable"
], ],
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -450,7 +450,7 @@ ...@@ -450,7 +450,7 @@
"monitor arm semihosting enable" "monitor arm semihosting enable"
], ],
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -466,7 +466,7 @@ ...@@ -466,7 +466,7 @@
"monitor arm semihosting enable" "monitor arm semihosting enable"
], ],
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -482,7 +482,7 @@ ...@@ -482,7 +482,7 @@
"monitor arm semihosting enable" "monitor arm semihosting enable"
], ],
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
...@@ -495,7 +495,7 @@ ...@@ -495,7 +495,7 @@
"preLaunchTask": "cargo build --example bare6", "preLaunchTask": "cargo build --example bare6",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -524,7 +524,7 @@ ...@@ -524,7 +524,7 @@
"preLaunchTask": "cargo build --example bare6", "preLaunchTask": "cargo build --example bare6",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -585,7 +585,7 @@ ...@@ -585,7 +585,7 @@
"preLaunchTask": "cargo build --example bare7", "preLaunchTask": "cargo build --example bare7",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare7", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare7",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -616,7 +616,7 @@ ...@@ -616,7 +616,7 @@
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare7", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare7",
// uses local config files // uses local config files
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"postLaunchCommands": [ "postLaunchCommands": [
...@@ -646,7 +646,7 @@ ...@@ -646,7 +646,7 @@
"preLaunchTask": "cargo build --example bare8", "preLaunchTask": "cargo build --example bare8",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare8", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare8",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -673,7 +673,7 @@ ...@@ -673,7 +673,7 @@
"preLaunchTask": "cargo build --example bare9", "preLaunchTask": "cargo build --example bare9",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare9", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare9",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -700,7 +700,7 @@ ...@@ -700,7 +700,7 @@
"preLaunchTask": "cargo build --example bare9 --release", "preLaunchTask": "cargo build --example bare9 --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/bare9", "executable": "./target/thumbv7em-none-eabihf/release/examples/bare9",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -727,7 +727,7 @@ ...@@ -727,7 +727,7 @@
"preLaunchTask": "cargo build --example bare10 --release", "preLaunchTask": "cargo build --example bare10 --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/bare10", "executable": "./target/thumbv7em-none-eabihf/release/examples/bare10",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -759,7 +759,7 @@ ...@@ -759,7 +759,7 @@
"preLaunchTask": "cargo build --example bare10", "preLaunchTask": "cargo build --example bare10",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare10", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare10",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -791,7 +791,7 @@ ...@@ -791,7 +791,7 @@
"preLaunchTask": "cargo build --example marcus --release", "preLaunchTask": "cargo build --example marcus --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/marcus", "executable": "./target/thumbv7em-none-eabihf/release/examples/marcus",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
...@@ -823,7 +823,7 @@ ...@@ -823,7 +823,7 @@
"preLaunchTask": "cargo build --example equivalence --release", "preLaunchTask": "cargo build --example equivalence --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/equivalence", "executable": "./target/thumbv7em-none-eabihf/release/examples/equivalence",
"configFiles": [ "configFiles": [
"interface/stlink.cfg", "interface/stlink-v2-1.cfg",
"target/stm32f4x.cfg" "target/stm32f4x.cfg"
], ],
"swoConfig": { "swoConfig": {
......
...@@ -34,13 +34,13 @@ version = "0.5.8" ...@@ -34,13 +34,13 @@ version = "0.5.8"
# alloc-cortex-m = "0.3.5" # alloc-cortex-m = "0.3.5"
[dependencies.stm32f4] [dependencies.stm32f4]
version = "0.5.0" version = "0.6.0"
features = ["stm32f413", "rt"] features = ["stm32f413", "rt"]
optional = true optional = true
[dependencies.stm32f4xx-hal] [dependencies.stm32f4xx-hal]
git = "https://github.com/stm32-rs/stm32f4xx-hal.git" git = "https://github.com/stm32-rs/stm32f4xx-hal.git"
version = "0.2.8" version = "0.3.0"
features = ["stm32f413", "rt"] features = ["stm32f413", "rt"]
optional = true optional = true
......
...@@ -19,7 +19,7 @@ extern crate panic_halt; ...@@ -19,7 +19,7 @@ extern crate panic_halt;
use cortex_m_rt::entry; use cortex_m_rt::entry;
// a constant (cannot be changed at run-time) // a constant (cannot be changed at run-time)
const X_INIT: u32 = 10; const X_INIT: u32 = u32::max_value();
// global mutabale variables (changed using unsafe code) // global mutabale variables (changed using unsafe code)
static mut X: u32 = X_INIT; static mut X: u32 = X_INIT;
...@@ -27,17 +27,36 @@ static mut Y: u32 = 0; ...@@ -27,17 +27,36 @@ static mut Y: u32 = 0;
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// local mutabale variable (changed in safe code) // local mutable variable (changed in safe code)
let mut x = unsafe { X }; let mut x = read_x();
let mut x_tmp: u32;
loop { loop {
x += 1; // <- place breakpoint here (3) x = x.wrapping_add(1u32);
unsafe {
X += 1; // I assume that there was a point in not setting X = x directly since the assert is there;
Y = X; // hence the x_tmp variable.
assert!(x == X && X == Y); x_tmp = read_x();
x_tmp = x_tmp.wrapping_add(1u32);
write_x(x_tmp);
write_y(read_x());
}
}
fn write_x(x: u32) {
unsafe { X = x; }
} }
fn write_y(y: u32) {
unsafe { Y = y; }
} }
fn read_x() -> u32 {
unsafe { X }
}
fn read_y() -> u32 {
unsafe { Y }
} }
// 0. Compile/build the example in debug (dev) mode. // 0. Compile/build the example in debug (dev) mode.
...@@ -48,45 +67,46 @@ fn main() -> ! { ...@@ -48,45 +67,46 @@ fn main() -> ! {
// 1. Run the program in the debugger, let the program run for a while and // 1. Run the program in the debugger, let the program run for a while and
// then press pause. Look in the (Local -vscode) Variables view what do you find. // then press pause. Look in the (Local -vscode) Variables view what do you find.
// //
// ** your answer here ** // * x: 540217
// //
// In the Expressions (WATCH -vscode) view add X and Y // In the Expressions (WATCH -vscode) view add X and Y
// what do you find // what do you find
// //
// ** your answer here ** // * X: 540217
// * Y: 540217
// //
// Step through one complete iteration of the loop // Step through one complete iteration of the loop
// and see how the (Local) Variables are updated // and see how the (Local) Variables are updated
// can you foresee what will eventually happen? // can you foresee what will eventually happen?
// //
// ** place your answer here ** // * It will increase x, X and Y. After a while, x will overflow and go to 0.
// //
// Commit your answers (bare0_1) // Commit your answers (bare0_1)
// //
// 2. Alter the constant X_INIT so that `x += 1` directly causes `x` to wrap // 2. Alter the constant X_INIT so that `x += 1` directly causes `x` to wrap
// what happens when `x` wraps // what happens when `x` wraps
// //
// ** your answer here ** // * Changed to 4294967295 (2^32 - 1). The program runs and ends up in a panic.
// //
// Commit your answers (bare0_2) // Commit your answers (bare0_2)
// //
// 3. Place a breakpoint at `x += 1` // 3. Place a breakpoint at `x += 1`
// //
// Change (both) += opertions to use wrapping_add // Change (both) += opertions to use wrapping_add
// load and run the progam, what happens // load and run the program, what happens
// ** your answer here ** // * x, X, and Y start over at 0 again.
// //
// Now continue exectution, what happens // Now continue exectution, what happens
// ** your answer here ** // * The program runs as it normally did.
// //
// Commit your answers (bare0_3) // Commit your answers (bare0_3)
// //
// (If the program did not succeed back to the breakpoint // (If the program did not succeed back to the breakpoint
// you have some fault in the program and go back to 3.) // you have some fault in the program and go back to 3.)
// //
// 4. Change the asserion to `assert!(x == X && X == Y + 1)`, what happens? // 4. Change the assertion to `assert!(x == X && X == Y + 1)`, what happens?
// //
// ** place your answer here ** // * The program enters a panic loop.
// //
// Commit your answers (bare0_4) // Commit your answers (bare0_4)
// //
......
...@@ -22,6 +22,6 @@ fn main() -> ! { ...@@ -22,6 +22,6 @@ fn main() -> ! {
let mut p = Peripherals::take().unwrap(); let mut p = Peripherals::take().unwrap();
let stim = &mut p.ITM.stim[0]; let stim = &mut p.ITM.stim[0];
iprintln!(stim, "Hello, again!"); iprintln!(stim, "Hello, again! {:x}", 10);
loop {} loop {}
} }
...@@ -6,8 +6,13 @@ ...@@ -6,8 +6,13 @@
interface hla interface hla
hla_layout stlink hla_layout stlink
hla_device_desc "ST-LINK" hla_device_desc "ST-LINK"
<<<<<<< HEAD
hla_vid_pid 0x0483 0x374b hla_vid_pid 0x0483 0x374b
#0x0483 0x3744 0x0483 0x3748 #0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 #0x0483 0x3744 0x0483 0x3748 #0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753
=======
hla_vid_pid 0x0483 0x374b
# 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753
>>>>>>> a5dcb24301e873baabb9c0d623d99325bac0a32c
# Optionally specify the serial number of ST-LINK/V2 usb device. ST-LINK/V2 # Optionally specify the serial number of ST-LINK/V2 usb device. ST-LINK/V2
# devices seem to have serial numbers with unreadable characters. ST-LINK/V2 # devices seem to have serial numbers with unreadable characters. ST-LINK/V2
......
...@@ -56,7 +56,7 @@ flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME ...@@ -56,7 +56,7 @@ flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
# bit more to be on the safe side. Perhaps superstition, but if are # bit more to be on the safe side. Perhaps superstition, but if are
# running off a crystal, we can run closer to the limit. Note # running off a crystal, we can run closer to the limit. Note
# that there can be a pretty wide band where things are more or less stable. # that there can be a pretty wide band where things are more or less stable.
adapter_khz 2000 adapter_khz 1800
adapter_nsrst_delay 100 adapter_nsrst_delay 100
if {[using_jtag]} { if {[using_jtag]} {
...@@ -103,5 +103,5 @@ $_TARGETNAME configure -event reset-init { ...@@ -103,5 +103,5 @@ $_TARGETNAME configure -event reset-init {
$_TARGETNAME configure -event reset-start { $_TARGETNAME configure -event reset-start {
# Reduce speed since CPU speed will slow down to 16MHz with the reset # Reduce speed since CPU speed will slow down to 16MHz with the reset
adapter_khz 2000 adapter_khz 1800
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment