diff --git a/README.md b/README.md index d2356925439b1ef87f03f94b349ee1cdf831b5e0..13540edb73b6442c88239ead88524020935ba3d5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The course will be given as a self study course with a set of introductional sem Macro_rules/matching and expansion. Procedural macros (macros 2.0). Overview of the Rust RTFM implementation. -8. Building and debugginge embedded code in Rust +8. Building and debugging embedded code in Rust Hardware abstractions using svd2rust (autogenerated from vendor provided SVD specifications). Compiling using xargo. Setting up openocd and gdb. @@ -75,16 +75,147 @@ Seminars About the course. Scheduling further seminars. Introduction to the Rust [ecosystem](doc/Ecosystem.md), and basics of Rust programming. - We will cover the Rust book [Rustbook Second Edition](https://doc.rust-lang.org/book/second-edition.html) sections [Introduction](https://doc.rust-lang.org/book/second-edition/ch01-00-introduction.html) and [Guessing Game Tutorial](https://doc.rust-lang.org/book/second-edition/ch02-00-guessing-game-tutorial.html). + We will cover the Rust book [Rustbook Second Edition](https://doc.rust-lang.org/book/second-edition.html) sections + + * [1 - Introduction](https://doc.rust-lang.org/book/second-edition/ch01-00-introduction.html), + * [2 -Guessing Game Tutorial](https://doc.rust-lang.org/book/second-edition/ch02-00-guessing-game-tutorial.html), and + * [3 - Common Programming Concepts](https://doc.rust-lang.org/book/second-edition/ch03-00-common-programming-concepts.html). - * Assignment + * Assignment 1 Extend the guessing game application such to give an error message on ill formated input,(use the Restult::Err type). Add a counter to the number of tries and write the number of tries for each iteration and on "winning". - Make a github accound (if you don't have it). Make a github project whith your code, along with a README.md for usage instructions. + Make a github account (if you don't have it). Make a github project whith your code, along with a README.md for usage instructions. Prepare to present your development for the next seminar. +2. Basic Programming + + * Preparetion + + Solve and be prepared to present Assignment 1. + + + * Topic + + Using the Rust ownership model. + Data structures, structs, enums, String (relation to slices) etc. Containers, Vec, and HashSets/Maps. Iterators. Using the Rust module system. Handling errors. + + We will cover the Rust book [Rustbook Second Edition](https://doc.rust-lang.org/book/second-edition.html) sections + + * [4 - Understanding Ownership](https://doc.rust-lang.org/book/second-edition/ch04-00-understanding-ownership.html), + * [5 - Using Structs to Structure Related Data](https://doc.rust-lang.org/book/second-edition/ch05-00-structs.html), + * [6 - Enums and Pattern Matchings](https://doc.rust-lang.org/book/second-edition/ch06-00-enums.html), + + * [7 - Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html), + + * [8 - Common Collections](https://doc.rust-lang.org/book/second-edition/ch08-00-common-collections.html), and + + * [9 - Error Handling](https://doc.rust-lang.org/book/second-edition/ch09-00-error-handling.html). + + * Assignment 2 + + a. Extend the guessing game with a tuple holding `(u32, String)`, store each input `(counter, guess)` in a vector. Iterate ('for') to print the history at exiting. + + b. Instead of vector use a 'HashMap', with a key 'u32' and a value 'String'. Again iterate ('for') to print the history at exiting. (Explain the result.) + + c. Break out the line input into a function returning a `Result<Ok<u32>>, Err<String>>`. In case of a parsing error prepend the `Err<String>` with the text `"in parsing u32, "`. + + d. Optional, find a way to print the `HashMap` in a sorted way. + + Make three new branches (`2a, 2b, 2c`) whith your code, along with a README.md for usage instructions, and expected behavior. + + *During development you may want to limit the number of tries so you can test without having to bother with answering correctly (the game gets boring after a while.)* + + Prepare to present your development for the next seminar. + +3. The Rust Memory Model Revisited + + * Preparation + + Finish Assignment 2. + + * Topic + + In deapth discussion of underlying theory, linear types (relation to functional programming). The *Affine* type system of Rust, requirements on the programmer, and guarantees offered by the programmer. Lifetimes, of stack allocated and global variables. Relation to C++ `unique pointers`. + + * Assignment + + a. Recall the D0013E course lab2/4, where you decrypted an message in assembler (lab2) and C (lab 4). Now, let's re-implement the lab in Rust (base your development on group number [1's](www.sm.luth.se/csee/courses/smd/D0013E/labs/lab1underlag/grupp_01.lab1_underlag.s ) lab assignment). + + You have to be careful about the signed/unsigned operations and use `wrapping` arithmetics to avoid panics due to unsigned *carry* and signed *overflow*. + + Use borrowed array slices as arguments to `decode`. + + The `seed`, `abc`,`coded` and `plain` should be stack allocated. The decoded string should be printed when decryption is finished. + + b. Make the `seed`, `abc`,`coded` and `plain` heap allocated. Accessing those will require some `unsafe` code. (Keep the unsafe blocks as local as possible.) + + c. Safety analysis. Provoke the implementation, by omitting the `'\0'` (null termintation). Observe the result and motivate the behavior in terms of your understanding of the Rust memory model. Under which circumpstances do you consider 3a and 3b to have same/different memory safety. + + Update your git with two new branches (`3a, 3b`), and update docmentation to cover usage and analysis (`3c`). + +4. Cortex-M, are we embedded yet + + * Prepration + + Finish assignment 3. Bring a USB mini cable. + + * Topic + + Embedded programming in Rust. + + * xargo for building non-`std` (bare metal) systems + * [cortex-m-quickstart] + * [cortex-m] + * ([bluepill/nucleo] crates) + + * Building and debugging your first application. + + * Assignment + + a. Backport assignment `3b` to your choosen target. Use semihosting in order to `write` the resulting string to the host. You may need to use `--release` for decoding the long (`coded`) message, as being deeply recursive unoptimized code may run out of stack memory. + + b. Discuss from a memory safety perspective the outcome. + + c. Compare for the short message (`abc`), the number of cycles required for `decode` in `--dev` vs. `--release`. As a comparison my straightforword C implementation took 2200 cycles in best optimized mode using `gcc` (-o3), while my (transation) to Rust code took 1780 cycles. (Both executed on a bluepill board at 8MHz with flash memory wait states). + + Make a new git for your embedded development. Make three branches (`3a, 3b, 3c`) with updated documentation according to the above. + + +5. Advanced Rust Concepts + + * Prepration + + Bring a USB mini cable and your dev board. Be prepared to present the progress on assignment 3. + + * Topic + + Advanced Rust features, trait system and closures. + + * [10 - Generic Types, Traits, and Lifetimes](https://doc.rust-lang.org/book/second-edition/ch10-00-generics.html), and + * [13 - Functional Language Features in Rust](https://doc.rust-lang.org/book/second-edition/ch13-00-functional-features.html). + + * Assignment + + Continue working on assignment 3. + +6. Memory Safe Concrreny + + Preparation + + * Finish lab 3 and be prepared to show your solution. + + Topic + + * UnsafeCell, and synchronization in the RTFM model. + + *Requirements for Stack Resource Policy (SRP) based single-core scheduling. + +The RTFM-core (task and resource model) + + * +