Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtfm-app
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Karlsson
rtfm-app
Commits
aae6a171
Commit
aae6a171
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
bare3
parent
91c83a75
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/bare2.rs
+35
-0
35 additions, 0 deletions
examples/bare2.rs
examples/bare3.rs
+67
-3
67 additions, 3 deletions
examples/bare3.rs
with
102 additions
and
3 deletions
examples/bare2.rs
+
35
−
0
View file @
aae6a171
...
...
@@ -30,6 +30,41 @@ fn main() {
}
}
// 1. build and run the application (debug build)
// start ITM tracing to console *version 0.1.1*
// > itmdump /tmp/itm.log
// or alternatively *version 0.2.0*
// > mkfifo /tmp/itm.log
// > itmdump -f /tmp/itm.log -F
//
// start openocd (in my case...)
// > openocd -f interface/stlink.cfg -f target/stm32f4x.cfg
//
// what is the output in the ITM console
// ** your answer here **
//
// estimate the frequency of the output, give freq in hz
// ** your answer here **
//
// commit your answers (bare2_1)
//
// 2. rebuild and run in release mode
// estimate the frequency of the output, give freq in hz
// ** your answer here **
//
// estimate the ratio between debug/release optimized code
// (speedup)
// ** your answer here **
//
// commit your answers (bare2_2)
//
// 3. optional
// inspect the generated binaries, and try stepping through the code
// for both debug and release binaries. How do they differ
// ** your answer here **
//
// commit your answers (bare2_3)
// As we are not using interrupts, we just register a dummy catch all handler
#[link_section
=
".vector_table.interrupts"
]
#[used]
...
...
This diff is collapsed.
Click to expand it.
examples/bare3.rs
+
67
−
3
View file @
aae6a171
...
...
@@ -7,22 +7,86 @@
extern
crate
cortex_m
;
extern
crate
cortex_m_rt
;
use
core
::
str
;
#[macro_use]
extern
crate
cortex_m_debug
;
fn
main
()
{
let
s
=
"ABCD"
;
ipln!
(
"s = {:?}"
,
s
);
let
bs
=
s
.as_bytes
();
ipln!
(
"s = {}"
,
s
);
ipln!
(
"bs = {:?}"
,
bs
);
//
iterate over
the byte repr. of s
for
c
in
s
.as_bytes
()
{
ipln!
(
"
iterate over
slice"
);
for
c
in
b
s
{
ip!
(
"{},"
,
c
)
}
let
mut
a
=
[
65u8
;
4
];
//let mut a = [0u8; 4];
ipln!
();
ipln!
(
"iterate iterate uning (raw) indexing"
);
for
i
in
0
..
s
.len
()
{
ip!
(
"{},"
,
bs
[
i
]);
}
ipln!
();
ipln!
(
"a = {}"
,
str
::
from_utf8
(
&
a
)
.unwrap
());
loop
{}
}
// 1. build and run the application (debug build)
// start ITM tracing to console *version 0.1.1*
// > itmdump /tmp/itm.log
// or alternatively *version 0.2.0*
// > mkfifo /tmp/itm.log
// > itmdump -f /tmp/itm.log -F
//
// start openocd (in my case...)
// > openocd -f interface/stlink.cfg -f target/stm32f4x.cfg
//
// what is the output in the ITM console
// ** your answer here **
//
// what is the type of `s`
// ** your answer here **
//
// what is the type of `bs`
// ** your answer here **
//
// what is the type of `c`
// ** your answer here **
//
// what is the type of `a`
// ** your answer here **
//
// what is the type of `i`
// ** your answer here **
//
// commit your answers (bare3_1)
//
// 2. make types of `s`, `bs`, `c`, `a`, `i` explicit
//
// commit your answers (bare3_2)
//
// 3. uncomment line 28 (let mut a = [0u8; 4];)
// what happens and why
// ** your answer here **
//
// commit your answers (bare3_3)
//
// 4. alter the program so that the data from `bs` is copied byte by byte into `a`
// implement your solution
//
// commit your answers (bare3_4)
//
// 5. look for a way to make this copy done without a loop
// implement your solution
//
// commit your answers (bare3_5)
// As we are not using interrupts, we just register a dummy catch all handler
#[link_section
=
".vector_table.interrupts"
]
#[used]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment