Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtic_f4xx_nucleo
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Ruben Asplund
rtic_f4xx_nucleo
Commits
98208c34
Commit
98208c34
authored
4 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
rtt_timing
parent
3e259b43
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.cargo/config
+2
-2
2 additions, 2 deletions
.cargo/config
examples/rtt_timing.rs
+11
-10
11 additions, 10 deletions
examples/rtt_timing.rs
with
13 additions
and
12 deletions
.cargo/config
+
2
−
2
View file @
98208c34
...
@@ -5,10 +5,10 @@
...
@@ -5,10 +5,10 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# which option to pick depends on your system
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
#
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
#
runner = "probe-run --chip STM32F411RETx"
runner = "probe-run --chip STM32F411RETx"
rustflags = [
rustflags = [
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
...
...
This diff is collapsed.
Click to expand it.
examples/rtt_timing.rs
+
11
−
10
View file @
98208c34
...
@@ -125,7 +125,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -125,7 +125,7 @@ fn timed_loop() -> (u32, u32) {
//
//
// Open the file in you editor and search for the `timed_loop`.
// Open the file in you editor and search for the `timed_loop`.
//
//
// [Assembly for function here]
// [Assembly for function
`timed_loop`
here]
//
//
// Locate the loop body, and verify that it makes sense
// Locate the loop body, and verify that it makes sense
// based on the information from the technical documentation:
// based on the information from the technical documentation:
...
@@ -158,7 +158,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -158,7 +158,7 @@ fn timed_loop() -> (u32, u32) {
//
//
// Now add a breakpoint at `timed_loop`.
// Now add a breakpoint at `timed_loop`.
// (gdb) break timed_loop
// (gdb) break timed_loop
// Breakpoint 5 at 0x800023e: file examples/rtt_timing.rs, line 4
5
.
// Breakpoint 5 at 0x800023e: file examples/rtt_timing.rs, line 4
6
.
//
//
// Now we can continue (first break will be at `init`)
// Now we can continue (first break will be at `init`)
// (gdb) continue
// (gdb) continue
...
@@ -170,7 +170,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -170,7 +170,7 @@ fn timed_loop() -> (u32, u32) {
// unsafe { intrinsics::volatile_load(src) }
// unsafe { intrinsics::volatile_load(src) }
//
//
// Now we are inside the `timed_loop`.
// Now we are inside the `timed_loop`.
// disassemble
//
(gdb)
disassemble
// Dump of assembler code for function _ZN10rtt_timing10timed_loop17h4a445e5f592f3304E:
// Dump of assembler code for function _ZN10rtt_timing10timed_loop17h4a445e5f592f3304E:
// 0x08000232 <+0>: movw r1, #4100 ; 0x1004
// 0x08000232 <+0>: movw r1, #4100 ; 0x1004
// 0x08000236 <+4>: movw r2, #10000 ; 0x2710
// 0x08000236 <+4>: movw r2, #10000 ; 0x2710
...
@@ -202,7 +202,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -202,7 +202,7 @@ fn timed_loop() -> (u32, u32) {
//
//
// We can now set a breakpoint exactly at the `nop`.
// We can now set a breakpoint exactly at the `nop`.
//
//
// (gdb) break *0x800024
0
// (gdb) break *0x800024
2
//
//
// And continue execution to the breakpoint:
// And continue execution to the breakpoint:
// (gdb) continue
// (gdb) continue
...
@@ -260,7 +260,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -260,7 +260,7 @@ fn timed_loop() -> (u32, u32) {
// for which write is marked "unsafe".
// for which write is marked "unsafe".
//
//
// Figure out the way to access the register through:
// Figure out the way to access the register through:
// `cx.
cx.
core.DWT.cyccnt.write(0)`.
// `cx.core.DWT.cyccnt.write(0)`.
// And add that to the code just before calling `timed_loop`.
// And add that to the code just before calling `timed_loop`.
//
//
// (Remember to comment out #![deny(unsafe_code)])
// (Remember to comment out #![deny(unsafe_code)])
...
@@ -285,6 +285,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -285,6 +285,7 @@ fn timed_loop() -> (u32, u32) {
// The ram requirement for the application amounts only to
// The ram requirement for the application amounts only to
// to the buffers (allocated for RTT), and the stack
// to the buffers (allocated for RTT), and the stack
// for the functions (which is in this case 0 for the `timed_loop`).
// for the functions (which is in this case 0 for the `timed_loop`).
// (Look at the code, there is no pushing/popping, no local stack.)
//
//
// Let's have a look at the code footprint (flash).
// Let's have a look at the code footprint (flash).
//
//
...
@@ -307,12 +308,12 @@ fn timed_loop() -> (u32, u32) {
...
@@ -307,12 +308,12 @@ fn timed_loop() -> (u32, u32) {
// handler by `panic_halt`, but besides that it should still
// handler by `panic_halt`, but besides that it should still
// measure time (debugging in gdb of `timed_loop` must still work).
// measure time (debugging in gdb of `timed_loop` must still work).
//
//
// > cargo size
// > cargo size
--example rtt_timing --release --features nightly
//
//
// [Your answer here]
// [Your answer here]
//
//
// I was able to get down to:
// I was able to get down to:
// cargo size --example rtt_timing --release --features nightly
//
>
cargo size --example rtt_timing --release --features nightly
// Compiling app v0.1.0 (/home/pln/courses/e7020e/app)
// Compiling app v0.1.0 (/home/pln/courses/e7020e/app)
// Finished release [optimized + debuginfo] target(s) in 0.32s
// Finished release [optimized + debuginfo] target(s) in 0.32s
// text data bss dec hex filename
// text data bss dec hex filename
...
@@ -324,14 +325,14 @@ fn timed_loop() -> (u32, u32) {
...
@@ -324,14 +325,14 @@ fn timed_loop() -> (u32, u32) {
//
//
// - You have confirmed that RTIC is extremely light weight
// - You have confirmed that RTIC is extremely light weight
// (zero-cost in release build).
// (zero-cost in release build).
// Applications can be be less than 1k flash.
// Applications can be be less than 1k flash.
Ideal for IoT!
//
//
// - You have seen that RTIC applications are easy to trace using RTT
// - You have seen that RTIC applications are easy to trace using RTT
// If more details are required, you have learned to use gdb.
// If more details are required, you have learned to use gdb.
//
//
// - You have confirmed that Rust generates:
// - You have confirmed that Rust generates:
// really, really, bad code in debug build.
// really, really, bad code in debug build
(beware!)
.
// really, really, really good code in release build
.
// really, really, really good code in release build
!
//
//
// - You have setup timing measurements which are
// - You have setup timing measurements which are
// Cycle accurate (0.000 000 01s at 100MHz).
// Cycle accurate (0.000 000 01s at 100MHz).
...
...
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