Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2019
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Henrik Theolin
e7020e_2019
Compare revisions
student to 8c4a3c34930f3615624be3f765e4da68737bdcef
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
Henrik/e7020e_2019
Select target project
No results found
8c4a3c34930f3615624be3f765e4da68737bdcef
Select Git revision
Branches
student
1 result
Swap
Target
pln/e7020e_2019
Select target project
pln/e7020e_2019
Henrik/e7020e_2019
wijk/e7020e_2019
sheepwall/e7020e_2019
Tiberg/e7020e_2019
Tyllstrom/e7020e_2019
Ridgep/e7020e_2019
7 results
student
Select Git revision
Branches
nrf52
student
2 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (7)
bare0_1
· eb1afad4
Henrik Theolin
authored
6 years ago
eb1afad4
bare0_1
· 4019e38c
Henrik Theolin
authored
6 years ago
4019e38c
bare0_2
· dbe09940
Henrik Theolin
authored
6 years ago
dbe09940
bare0_3
· 16f16fd0
Henrik Theolin
authored
6 years ago
16f16fd0
bare0_4
· c71fedfb
Henrik Theolin
authored
6 years ago
c71fedfb
bare0_3 fix and bare0_5
· c08dd88b
Henrik Theolin
authored
6 years ago
c08dd88b
bare0_6
· 8c4a3c34
Henrik Theolin
authored
6 years ago
8c4a3c34
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.vscode/launch.json
+24
-24
24 additions, 24 deletions
.vscode/launch.json
examples/bare0.rs
+37
-19
37 additions, 19 deletions
examples/bare0.rs
openocd.cfg
+1
-1
1 addition, 1 deletion
openocd.cfg
with
62 additions
and
44 deletions
.vscode/launch.json
View file @
8c4a3c34
...
...
@@ -59,7 +59,7 @@
"preLaunchTask"
:
"cargo build --example itm"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/itm"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -89,7 +89,7 @@
"preLaunchTask"
:
"cargo build --example panic"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/panic"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -119,7 +119,7 @@
"preLaunchTask"
:
"cargo build --example exception_itm --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/exception_itm"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -145,7 +145,7 @@
"preLaunchTask"
:
"cargo build --example exception_itm_raw"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/exception_itm_raw"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -302,7 +302,7 @@
"preLaunchTask"
:
"cargo build --example bare0"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare0"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -331,7 +331,7 @@
]
},
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -360,7 +360,7 @@
]
},
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -389,7 +389,7 @@
]
},
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -418,7 +418,7 @@
]
},
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -434,7 +434,7 @@
"monitor arm semihosting enable"
],
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -450,7 +450,7 @@
"monitor arm semihosting enable"
],
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -466,7 +466,7 @@
"monitor arm semihosting enable"
],
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -482,7 +482,7 @@
"monitor arm semihosting enable"
],
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -495,7 +495,7 @@
"preLaunchTask"
:
"cargo build --example bare6"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare6"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -524,7 +524,7 @@
"preLaunchTask"
:
"cargo build --example bare6"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare6"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -585,7 +585,7 @@
"preLaunchTask"
:
"cargo build --example bare7"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare7"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -616,7 +616,7 @@
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare7"
,
//
uses
local
config
files
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -646,7 +646,7 @@
"preLaunchTask"
:
"cargo build --example bare8"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare8"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -673,7 +673,7 @@
"preLaunchTask"
:
"cargo build --example bare9"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare9"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -700,7 +700,7 @@
"preLaunchTask"
:
"cargo build --example bare9 --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/bare9"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -727,7 +727,7 @@
"preLaunchTask"
:
"cargo build --example bare10 --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/bare10"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -759,7 +759,7 @@
"preLaunchTask"
:
"cargo build --example bare10"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/bare10"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -791,7 +791,7 @@
"preLaunchTask"
:
"cargo build --example marcus --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/marcus"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
@@ -823,7 +823,7 @@
"preLaunchTask"
:
"cargo build --example equivalence --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/equivalence"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"swoConfig"
:
{
...
...
This diff is collapsed.
Click to expand it.
examples/bare0.rs
View file @
8c4a3c34
...
...
@@ -18,26 +18,43 @@ extern crate panic_halt;
// Minimal runtime / startup for Cortex-M microcontrollers
use
cortex_m_rt
::
entry
;
use
core
::
cell
::
UnsafeCell
;
struct
U32
{
data
:
UnsafeCell
<
u32
>
,
}
// a constant (cannot be changed at run-time)
const
X_INIT
:
u32
=
1
0
;
const
X_INIT
:
u32
=
0
xffffffff
;
// global mutabale variables (changed using unsafe code)
static
mut
X
:
u32
=
X_INIT
;
static
mut
Y
:
u32
=
0
;
static
X
:
U32
=
U32
{
data
:
UnsafeCell
::
new
(
X_INIT
),
};
static
Y
:
U32
=
U32
{
data
:
UnsafeCell
::
new
(
0
),
};
unsafe
impl
Sync
for
U32
{}
#[entry]
fn
main
()
->
!
{
// local mutabale variable (changed in safe code)
let
mut
x
=
unsafe
{
X
}
;
let
mut
x
=
read_u32
(
&
X
)
;
loop
{
x
+=
1
;
// <- place breakpoint here (3)
unsafe
{
X
+=
1
;
Y
=
X
;
assert!
(
x
==
X
&&
X
==
Y
);
x
=
x
.wrapping_add
(
1
);
// <- place breakpoint here (3)
write_u32
(
&
X
,
read_u32
(
&
X
)
.wrapping_add
(
1
)
);
write_u32
(
&
Y
,
read_u32
(
&
X
));
assert!
(
x
==
read_u32
(
&
X
)
&&
read_u32
(
&
X
)
==
read_u32
(
&
Y
)
);
}
}
fn
read_u32
(
uint
:
&
U32
)
->
u32
{
return
unsafe
{
*
uint
.data
.get
()};
}
fn
write_u32
(
write_to
:
&
U32
,
value
:
u32
)
{
unsafe
{
*
write_to
.data
.get
()
=
value
};
}
// 0. Compile/build the example in debug (dev) mode.
...
...
@@ -48,25 +65,26 @@ fn main() -> ! {
// 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.
//
// **
your answer here
**
// **
* x: 962669 *
**
//
// In the Expressions (WATCH -vscode) view add X and Y
// what do you find
//
// ** your answer here **
// *** Watch X and Y didn't work, added watch to 'bare0::X::h2583a8be644794f3' and 'bare0::Y::hef3986a5288bec08' to be able to read the variables
// X = 962669, Y = 962668 ***
//
// Step through one complete iteration of the loop
// and see how the (Local) Variables are updated
// can you foresee what will eventually happen?
//
// **
place your answer here
**
// **
* x is incremented. Eventually x will wrap. *
**
//
// Commit your answers (bare0_1)
//
// 2. Alter the constant X_INIT so that `x += 1` directly causes `x` to wrap
// what happens when `x` wraps
//
// **
your answer h
er
e
**
// **
We end up in the panic handl
er **
//
// Commit your answers (bare0_2)
//
...
...
@@ -74,10 +92,10 @@ fn main() -> ! {
//
// Change (both) += opertions to use wrapping_add
// load and run the progam, what happens
// **
your answer her
e **
// **
x value wraps around u32 max 4294967295 and get valu
e
0
**
//
// Now continue exectution, what happens
// **
your answer here
**
// **
X,Y and x is incremented and wraps around max
**
//
// Commit your answers (bare0_3)
//
...
...
@@ -86,7 +104,7 @@ fn main() -> ! {
//
// 4. Change the asserion to `assert!(x == X && X == Y + 1)`, what happens?
//
// **
place your answer h
er
e
**
// **
The assert fails and we go into panic handl
er **
//
// Commit your answers (bare0_4)
//
...
...
This diff is collapsed.
Click to expand it.
openocd.cfg
View file @
8c4a3c34
...
...
@@ -3,6 +3,6 @@
# Depending on the hardware revision you got you'll have to pick ONE of these
# interfaces. At any time only one interface should be commented out.
source
[find interface/stlink.cfg]
source
[find interface/stlink
-v2-1
.cfg]
source
[find target/stm32f4x.cfg]
This diff is collapsed.
Click to expand it.