rust-embedded/discovery

This guide probably only works for Linux

tieje opened this issue · 6 comments

tieje commented

I tried using an M1 Mac and a Windows laptop to complete this tutorial.
Neither worked.
MacOS uses LLDB instead of GDB. LLDB breaks immediately when connecting to the GDB server:
thread #1, stop reason = signal SIGTRAP

Windows can't even connect to the GDB server using:
arm-none-eabi-gdb ../../target/thumbv7em-none-eabihf/debug/led-roulette

I have not tried on Linux yet but it probably only works there.

It should work fine on WIndows and MacOS. On MacOS you'll need to use gdb rather than lldb, but you can install arm-none-eabi-gdb or gdb-multiarch on MacOS. On Windows what error are you getting?

Have you followed the "Setting up a development environment" part of the book? here for the STM32 version or here for the nRF version. It has different instructions for Linux, Windows, and MacOS.

If there is some error in the description of how to get set up on one of those operating systems, that's a bug that we'll need to fix - it should work on all three.

tieje commented

Mac doesn't use GDB anymore. Apple prefers LLDB now.
https://stackoverflow.com/questions/19436460/gdb-debugging-in-terminal-os-x-10-8-5-with-zsh
You can't build GDB on mac anymore: brew install gdb

$ 05-led-roulette % rustc -V
rustc 1.71.1 (eb26296b5 2023-08-03)

$ 05-led-roulette % rustup component add llvm-tools-preview
info: component 'llvm-tools' for target 'aarch64-apple-darwin' is up to date

$ 05-led-roulette % cargo install cargo-binutils --vers 0.3.3
     Ignored package `cargo-binutils v0.3.3` is already installed, use --force to override

$ 05-led-roulette % cargo size --version
cargo-size 0.3.3

$ 05-led-roulette % cargo install cargo-embed --vers 0.18.0
    Updating crates.io index
error: binary `cargo-embed` already exists in destination as part of `probe-rs v0.20.0`
Add --force to overwrite

$ 05-led-roulette % brew install --cask gcc-arm-embedded                      
Warning: Not upgrading gcc-arm-embedded, the latest version is already installed

$ 05-led-roulette % brew install minicom
Warning: minicom 2.8 is already installed and up-to-date.



$ 05-led-roulette % cargo embed --features v2 --target thumbv7em-none-eabihf
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
      Config default
      Target /Users/tieje/Documents/discovery/microbit/target/thumbv7em-none-eabihf/debug/led-roulette
        WARN probe_rs::config::target > Using custom sequence for nRF52
     Erasing sectors ✔ [00:00:00] [#####################] 4.00 KiB/4.00 KiB @ 29.01 KiB/s (eta 0s )
 Programming pages   ✔ [00:00:00] [#####################] 4.00 KiB/4.00 KiB @ 15.29 KiB/s (eta 0s )    Finished flashing in 0.434s
    GDB stub listening at 127.0.0.1:1337


[In another terminal]


$ ~ % cd Documents/discovery/microbit/src/05-led-roulette 
$ 05-led-roulette % gdb target/thumbv7em-none-eabihf/debug/led-roulette
zsh: command not found: gdb
$ 05-led-roulette % brew install gdb
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
gdb: The x86_64 architecture is required for this software.
Error: gdb: An unsatisfied requirement failed this build.

For Windows 11, I run into different problems, but we can solve those later.

On macOS with Apple Silicon (M1, M2 etc.), one needs to install architecture specific gdb.
Therefore, you will need to install arm-none-eabi-gdb speifically.

Details are at its formula:
https://formulae.brew.sh/formula/arm-none-eabi-gdb#default
For quick ref:
brew install arm-none-eabi-gdb

tieje commented

Thank you, this worked. layout asm looks different but that's probably due to the architecture.
Should I create a PR or do you want to handle it?

05-led-roulette % arm-none-eabi-gdb target/thumbv7em-none-eabihf/debug/led-roulette
(gdb) target remote :1337
Remote debugging using :1337
0x00000100 in nrf52833_pac::{impl#280}::fmt (self=0xb7f40fbc, f=0x24d0ee32)
at src/lib.rs:163
163 #[derive(Copy, Clone, Debug, PartialEq, Eq)]

Glad it helped. Sure I will update and raise a PR. Thanks.

Should be fixed after #541. Thank you everybody!