Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update the microbit part of the book #575

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

nikgul
Copy link
Contributor

@nikgul nikgul commented Jun 19, 2024

This is currently a work in progress.

Update the crate versions to the latest versions as I work my way through the book.

I plan on squasing the commits into one per chapter when this is ready.

@nikgul nikgul requested a review from a team as a code owner June 19, 2024 04:43
@nikgul nikgul marked this pull request as draft June 19, 2024 04:44
nikgul added 14 commits June 20, 2024 09:03
Updated to mention the 2021 edition in stead of 2018
Cargo.toml:
  * edition             2018 -> 2021
  * cortex-m            0.7.3 -> 0.7.7, added feature `critical-section-single-core`
  * cortex-m-rt         0.7.0 -> 0.7.3
  * rtt-target          0.3.1 -> 0.5.0, removed feature `cortex-m`
  * panic-rtt-target    0.1.2 -> 0.1.3, removed feature `cortex-m`

src/main.rs:
  * To prevent a link error regarding undefined symbols
    (`_critical_section_1_0_acquire` and `_critical_section_1_0_release`)
    I have added `use cortex_m as _;`

The code compiles, and I see the RTT output from cargo embed.
Cargo.toml
  * edition             2018 -> 2021
  * microbit-v2         0.12.0 -> 0.14.0
  * microbit            0.12.0 -> 0.14.0
  * cortex-m            0.7.3 -> 0.7.7, added feature `critical-section-single-core`
  * cortex-m-rt         0.7.0 -> 0.7.3
  * rtt-target          0.3.1 -> 0.5.0, removed feature `cortex-m`
  * panic-rtt-target    0.1.2 -> 0.1.3, removed feature `cortex-m`
The microbit crate apparently don't reexport the hal's OutputPin trail,
there for add embedded-hal as a dependency.
A new version of the microbit crates has been released.

Cargo.toml
  *  microbit-v2        0.14.0 -> 0.15.0
     Which updated HAL crates to version 0.18.0
  *  microbit           0.14.0 -> 0.15.0

In connection with this I moved all the examples in the book out of book
text and made them project examples, and used an include statement, like
it's done in `my-solution`, which makes checking the examples faster,
and I also cought a couple of typos I made when I updated the text,
which rust-analyser didn't like.

The examples can be run manually with commands like:
`cargo embed --target thumbv7em-none-eabihf --features v2 --example
it-blinks-1`

Don't know if this messes with any automatic tests yet.
Copy link
Member

@BartMassey BartMassey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks much for this careful review. These changes mostly look fantastic. In particular, the use of include over pasting for the code examples is just great.

@@ -45,22 +45,23 @@ $ gdb target/thumbv6m-none-eabi/debug/led-roulette
> as long as it does not crash, you are fine.

Next we will have to connect to the GDB stub. It runs on `localhost:1337` per default so in order to
connect to it run the following:
connect to it run the following on the gdb commandline (`(gdb)`):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing, I think. How about "on the gdb command line (that is, at the (gdb) prompt):"

@@ -2,28 +2,29 @@
name = "led-roulette"
version = "0.1.0"
authors = ["Henrik Böving <hargonix@gmail.com>"]
edition = "2018"
edition = "2021"

[dependencies.microbit-v2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the number corrections (version numbers, runtimes, entry points, sizes, etc) will change quickly as the ecosystem updates. A note to that effect should be put here somewhere, so that we aren't doing this on some regular basis. Probably should just freeze things at some point and make careful notes about the reference point, I guess? I don't know — it's a hard problem.

In a fantasy world, this kind of stuff would be done automatically in CI. But that sounds even harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants