Getting Started with Feather M0 (Solved)

Hello.

I have an Adafruit Feather M0, and would like to try using Rust to program it. I noticed that this specific board seemed to have support (GitHub - atsamd-rs/atsamd: Target atsamd microcontrollers using Rust).

I checked out that repo, and using the steps provided was able to get close. However, I could not get my device to be found, both with and without putting the board into bootloader mode.

~/repos/atsamd/boards/feather_m0 $ cargo hf2 --release --example blinky_basic
warning: unused import: `IntoFunction`
  --> src/lib.rs:17:29
   |
17 | use gpio::{Floating, Input, IntoFunction, PfC, Port};
   |                             ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

    Finished release [optimized + debuginfo] target(s) in 0.14s
    Searching for a connected device with known vid/pid pair.
thread 'main' panicked at 'Are you sure device is plugged in and in bootloader mode?', src/libcore/option.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

I can see the device in Mac's system report (I tried specifying the pid and vid, same issue). I am able to program the board normally using the Arduino IDE if I download Adafruit's board libraries, so the problem isn't hardware related.

I think the problem here is that hidapi's Mac implementation doesn't support devices like this (I compiled that library's test GUI, and sure enough the device is not found). So while this isn't an issue with rust specifically, I imagine this community might have been more likely to have also had a problem like this, and was hoping someone could provide insight. Either a way to work around this, or to explain if there is something important that I'm missing here.

Thanks

I think I have made some progress on this. One thing I noticed is that according to Adafruit, the Feather M0 does not seem to support HF2, however the Feather M0 Express does (or perhaps I just have an older Feather M0, and newer ones use HF2).

Either way, I stopped going down that route, and instead using bossac.

cargo build --release --example blinky_basic
arm-none-eabi-objcopy -O binary [snip]/blinky_basic [snip]/blinky_basic.bin
bossac -p /dev/cu.usbmodem1421 -e -w -v -R --offset=0x4000 [snip]/blinky_basic.bin

I do get what appears to be a successful response:

Erase flash

Done in 0.806 seconds
Write 1000 bytes to flash (16 pages)
[==============================] 100% (16/16 pages)
Done in 0.009 seconds
Verify 1000 bytes of flash
[==============================] 100% (16/16 pages)
Verify successful
Done in 0.062 seconds

The Feather then restarts. Unfortunately, the LED isn't blinking, it's just a solid red. So I'm still not quite there yet.

Ok, I realized my problem. The offset needed to be 0x2000, not 0x4000 (the Feather has a 8K bootloader in memory, but I copy and pasted from the Feather M4, which has a 16K).

Thus, here is what I was able to do to get it working.

1.) Compile

cargo build --release --example blinky_basic

2.) Create the .bin

arm-none-eabi-objcopy -O binary target/thumbv6m-none-eabi/release/examples/blinky_basic target/thumbv6m-none-eabi/release/examples/blinky_basic.bin

3.) Put device into bootloader mode (double-tap button on board).
4.) Flash:

bossac -p /dev/cu.usbmodem1421 -e -w -v -R --offset=0x2000 target/thumbv6m-none-eabi/release/examples/blinky_basic.bin

I downloaded and installed a version of bossac, but if you have the Arduino IDE installed it also has the bossac binary. It is located here:

/Users/mark/Library/Arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.