Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2020
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
Gustav Hansson
e7020e_2020
Compare revisions
master to b06929c07255dadc84aed6101a6bc5782751d06c
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
97gushan/e7020e_2020
Select target project
No results found
b06929c07255dadc84aed6101a6bc5782751d06c
Select Git revision
Loading items
Swap
Target
pln/e7020e_2020
Select target project
pln/e7020e_2020
97gushan/e7020e_2020
markhakansson/e7020e_2020
Grumme2/e7020e_2020
Hammarkvast/e7020e_2020
5 results
master
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (4)
fix config issues
· 518e95cd
Gustav Hansson
authored
5 years ago
518e95cd
add debug for examples in launch.json
· b2d69e6d
Gustav Hansson
authored
5 years ago
b2d69e6d
bare0 0-5
· 1337defd
Gustav Hansson
authored
5 years ago
1337defd
bare1
· b06929c0
Gustav Hansson
authored
5 years ago
b06929c0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.vscode/launch.json
+27
-10
27 additions, 10 deletions
.vscode/launch.json
examples/bare0.rs
+49
-13
49 additions, 13 deletions
examples/bare0.rs
examples/bare1.rs
+64
-10
64 additions, 10 deletions
examples/bare1.rs
openocd.cfg
+2
-3
2 additions, 3 deletions
openocd.cfg
with
142 additions
and
36 deletions
.vscode/launch.json
View file @
b06929c0
...
...
@@ -4,6 +4,7 @@
//
For
more
information
,
visit:
https://go.microsoft.com/fwlink/?linkid=
830387
"version"
:
"0.2.0"
,
"configurations"
:
[
//
Launch
configuration
for
`app`
//
-
debug
//
-
semihosting
...
...
@@ -16,8 +17,28 @@
"preLaunchTask"
:
"cargo build"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/app"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
//
"interface/stlink-v2-1.cfg"
,
//
deprecated
setup
script
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
"monitor arm semihosting enable"
],
"runToMain"
:
true
,
"cwd"
:
"${workspaceRoot}"
},
//
Launch
configuration
for
`app`
//
-
debug
//
-
semihosting
//
-
run
to
main
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"examples (debug)"
,
"preLaunchTask"
:
"cargo build --examples"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/${fileBasenameNoExtension}"
,
"configFiles"
:
[
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -39,8 +60,7 @@
"preLaunchTask"
:
"cargo build --example"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/${fileBasenameNoExtension}"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
//
"interface/stlink-v2-1.cfg"
,
//
deprecated
setup
script
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -75,8 +95,7 @@
"preLaunchTask"
:
"cargo build --example"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/${fileBasenameNoExtension}"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
//
"interface/stlink-v2-1.cfg"
,
//
deprecated
setup
script
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -150,8 +169,7 @@
"preLaunchTask"
:
"cargo build --example --release"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/${fileBasenameNoExtension}"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
//
"interface/stlink-v2-1.cfg"
,
//
deprecated
setup
script
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
@@ -175,8 +193,7 @@
"preLaunchTask"
:
"cargo build --example --release --features stm32f4"
,
"executable"
:
"./target/thumbv7em-none-eabihf/release/examples/${fileBasenameNoExtension}"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
//
"interface/stlink-v2-1.cfg"
,
//
deprecated
setup
script
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
...
...
This diff is collapsed.
Click to expand it.
examples/bare0.rs
View file @
b06929c0
...
...
@@ -22,25 +22,49 @@ use panic_semihosting as _;
use
cortex_m_rt
::
entry
;
// a constant (cannot be changed at run-time)
const
X_INIT
:
u32
=
10
;
// const X_INIT: u32 = core::u32::MAX;
const
X_INIT
:
u32
=
core
::
u32
::
MAX
;
// global mutable variables (changed using unsafe code)
static
mut
X
:
u32
=
X_INIT
;
static
mut
Y
:
u32
=
0
;
fn
write_x
(
x
:
u32
,
i
:
u32
)
{
unsafe
{
X
=
x
.wrapping_add
(
i
);
}
}
fn
write_y
(
y
:
u32
)
{
unsafe
{
Y
=
y
;
}
}
fn
read_y
()
->
u32
{
unsafe
{
Y
}
}
fn
read_x
()
->
u32
{
unsafe
{
X
}
}
#[entry]
fn
main
()
->
!
{
// local mutable variable (changed in safe code)
let
mut
x
=
unsafe
{
X
}
;
let
mut
x
=
read_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_x
(
read_x
(),
1
)
;
write_y
(
read_x
())
;
assert!
(
x
==
read_x
()
&&
read_x
()
==
read_y
()
);
}
}
...
...
@@ -56,12 +80,14 @@ fn main() -> ! {
//
// Look under Variables/Local what do you find.
//
//
** your answer here **
//
x: 9389056
//
// In the Expressions (WATCH -vscode) view add X and Y
// what do you find
//
// ** your answer here **
// X: 9389055
// Y: <optimized out>
//
// Step through one complete iteration of the loop
// and see how the (Local) Variables are updated
...
...
@@ -69,6 +95,10 @@ fn main() -> ! {
//
// ** place your answer here **
//
// x will update to 9389057
// eventually x will overflow and if rust runs in debug mode then rust will panic and
// if it runs in release mode rust wont check for the overflow and just do a wrap the value
//
// Commit your answers (bare0_1)
//
// 2. Alter the constant X_INIT so that `x += 1` directly causes `x` to wrap.
...
...
@@ -76,6 +106,8 @@ fn main() -> ! {
// (Hint, look under OUTPUT/Adopter Output to see the `openocd` output.)
//
// ** your answer here **
// The program panics
// panicked at 'attempt to add with overflow', examples/bare0.rs:42:9
//
// Commit your answers (bare0_2)
//
...
...
@@ -84,10 +116,12 @@ fn main() -> ! {
// Change (both) += operations to use wrapping_add
// load and run the program, what happens
// ** your answer here **
//
// x wrapps around and become 0
// X does nothing
// Now continue execution, what happens
// ** your answer here **
//
// x continues to add up
// X still does nothing
// Commit your answers (bare0_3)
//
// (If the program did not succeed back to the breakpoint
...
...
@@ -96,6 +130,8 @@ fn main() -> ! {
// 4. Change the assertion to `assert!(x == X && X == Y + 1)`, what happens?
//
// ** place your answer here **
// panic because the assertion fails
// panicked at 'assertion failed: x == X && X == Y + 1', examples/bare0.rs:46:13
//
// Commit your answers (bare0_4)
//
...
...
This diff is collapsed.
Click to expand it.
examples/bare1.rs
View file @
b06929c0
...
...
@@ -59,10 +59,16 @@ fn main() -> ! {
// (passing 3 breakpoints)
//
// ** your answer here **
// The program hits the first breakpoint again with a callstack
// with a lot of elements in the callstack pointing to 0x08000424
// local x variable contains various values
//
// What is the `ITM` output.
//
// ** your answer here **
// Program
// received signal SIGTRAP, Trace/breakpoint trap.
// bare1::__cortex_m_rt_main () at examples/bare1.rs:22
// 22 cortex_m::asm::bkpt();
//
// Commit your answer (bare1_1)
//
...
...
@@ -74,16 +80,42 @@ fn main() -> ! {
// What is the output of:
// > disassemble
//
// ** your answer here **
// Please check OUTPUT tab (Adapter Output) for output from openocd
// disassemble
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x0800040a <+0>: sub sp, #8
// 0x0800040c <+2>: mvn.w r0, #1
// 0x08000410 <+6>: str r0, [sp, #4]
// 0x08000412 <+8>: bkpt 0x0000
// 0x08000414 <+10>: mov.w r0, #4294967295 ; 0xffffffff
// 0x08000418 <+14>: add r4, sp, #4
// 0x0800041a <+16>: str r0, [sp, #4]
// 0x0800041c <+18>: bkpt 0x0000
// 0x0800041e <+20>: mov r0, r4
// 0x08000420 <+22>: bl 0x8000400 <core::ptr::read_volatile>
// => 0x08000424 <+26>: bkpt 0x0000
// 0x08000426 <+28>: ldr r0, [sp, #4]
// 0x08000428 <+30>: adds r0, #1
// 0x0800042a <+32>: bcc.n 0x800041a <bare1::__cortex_m_rt_main+16>
// 0x0800042c <+34>: movw r0, #5984 ; 0x1760
// 0x08000430 <+38>: movt r0, #2048 ; 0x800
// 0x08000434 <+42>: movw r2, #5956 ; 0x1744
// 0x08000438 <+46>: movt r2, #2048 ; 0x800
// 0x0800043c <+50>: movs r1, #28
// 0x0800043e <+52>: bl 0x800053a <core::panicking::panic>
// 0x08000442 <+56>: udf #254 ; 0xfe
// End of assembler dump.
//
// How many instructions are in between the two `bkpt` instructions in the loop.
// Notice, the generated code may not be exactly what you expect :)
//
//
** your answer here **
//
THere are 6 instrucations inbetween
//
// Which instruction stores the local variable on the stack.
//
//
** your answer here **
//
0x0800041a <+16>: str r0, [sp, #4]
//
// Commit your answers (bare1_2)
//
...
...
@@ -99,15 +131,25 @@ fn main() -> ! {
// What is the output of:
// > disassemble
//
// ** your answer here **
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x08000406 <+0>: sub sp, #4
// 0x08000408 <+2>: mvn.w r0, #1
// 0x0800040c <+6>: str r0, [sp, #0]
// 0x0800040e <+8>: adds r0, #1
// 0x08000410 <+10>: bkpt 0x0000
// 0x08000412 <+12>: str r0, [sp, #0]
// => 0x08000414 <+14>: bkpt 0x0000
// 0x08000416 <+16>: ldr r0, [sp, #0]
// 0x08000418 <+18>: b.n 0x800040e <bare1::__cortex_m_rt_main+8>
// End of assembler dump.
//
// How many instructions are in between the two `bkpt` instructions.
//
//
** your answer here **
//
1
//
// Where is the local variable stored?
//
//
** your answer here **
//
0x08000412 <+12>: str r0, [sp, #0]
//
// Is there now any reference to the panic handler?
// If not, why is that the case?
...
...
@@ -172,9 +214,21 @@ fn main() -> ! {
//
// What is now the disassembly of the loop (in debug/dev mode):
//
// ** your answer here **
//
// commit your answers (bare1_5)
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x0800040a <+0>: sub sp, #8
// 0x0800040c <+2>: mvn.w r0, #1
// 0x08000410 <+6>: str r0, [sp, #4]
// 0x08000412 <+8>: add r4, sp, #4
// 0x08000414 <+10>: bkpt 0x0000
// 0x08000416 <+12>: ldr r0, [sp, #4]
// 0x08000418 <+14>: adds r0, #1
// 0x0800041a <+16>: str r0, [sp, #4]
// => 0x0800041c <+18>: bkpt 0x0000
// 0x0800041e <+20>: mov r0, r4
// 0x08000420 <+22>: bl 0x8000400 <core::ptr::read_volatile>
// 0x08000424 <+26>: b.n 0x8000414 <bare1::__cortex_m_rt_main+10>
// End of assembler dump.
// commit your answers (bare1_4)
//
// Now restore the `.cargo/config` to its original state.
//
...
...
This diff is collapsed.
Click to expand it.
openocd.cfg
View file @
b06929c0
source
[find interface/stlink.cfg]
# deprecated
# source [find interface/stlink-v2-1.cfg]
source
[find interface/stlink-v2-1.cfg]
transport
select
hla_swd
# increase working area to 64KB
...
...
This diff is collapsed.
Click to expand it.