Microcontroller Kit Overview
We sell a complete kit containing all necessary components on the Amiga shop website: farm-ng microcontroller kit
Feather M4 Can device setup
This device can be used for rapid prototyping of applications that interact with farm-ng's Amiga platform.
The Feather M4 board front and back, where to solder the connector, and the resistor that must be cut:
The connected Feather M4 and which wire to screw into high and low sides and where the reset button is:
The male M12 CAN bus connector whose white (high) and blue (low) connectors are screwed into the Feather M4 and the male CAN bus connector is attached to the CAN bus:
Flashing the UF2 firmware on the M4 device
We run CircuitPython on the microcontrollers, as it is well supported, well documented, and recommended by Adafruit for their microcontrollers.
CircuitPython is installed by flashing the microcontroller with the correct UF2 file, and you can tell if CircuitPython is installed if the microcontroller is mounted as a directory called CIRCUITPY
whenever you connect it.
On first connection
The following instructions summarize the CircuitPython on Feather M4 CAN instructions. You can also check out the more generic Adafruit Installing CircuitPython instructions.
- Connect your feather to your computer through the USB-C port on the feather
Check that the large LED is green or randomly varying colored. If it is red, you are most likely using a charge only USB-C cable.
-
Double click the reset button to enter
BOOTLOADER
mode, allowing you to flash the microcontroller with a Microsoft standard flash format uf2 file. The Feather should automatically remount and show up asFTHRCANBOOT
orFEATHERBOOT
tipThe timing of the double click can be a little tricky, so if it mounts as
CIRCUITPY
, just try again until it mounts asAMIGA
. If you cannot get the double click timing correct, you can enter BOOTLOADER mode with the following advanced user steps:-
Open a serial console connected to the dashboard (see: Adafruit connecting to the serial console)
-
Pause the program with
ctrl+C
-
Enter the following commands in the REPL
import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
microcontroller.reset() -
-
You can now flash the drive with the correct CircuitPython version, with either the drag & drop or the command line method.
-
After the flashing, feather should automatically update, reboot with the newly loaded firmware, and remount as
CIRCUITPY
Flash by drag & drop
-
Download the correct UF2 file
- From our repo: Download CircuitPython 7.3.2 - Feather M4 CAN
- Directly from Adafruit: Download CircuitPython 7.3.3 - Feather M4 CAN
-
Copy (drag & drop) the UF2 file onto the feather mounted in
BOOTLOADER
mode. -
It should automatically update and remount as
CIRCUITPY
Flash UF2 by command line
These instructions show how to copy (flash) the UF2 file onto the Feather
from the cloned amiga-dev-kit
repo, for each OS.
- Linux
- MacOs
- WSL
From a terminal, use the command line:
cd ~/<to_your_base_directory>/amiga-dev-kit
cp circuitpy/feather_m4_can/uf2s/adafruit-circuitpython-feather_m4_can-en_US-7.3.2.uf2 \
/media/$USERNAME/FTHRCANBOOT/
In your system (or PyCharm) terminal, use the command line:
cd ~/<to_your_base_directory>/amiga-dev-kit
cp circuitpy/feather_m4_can/uf2s/adafruit-circuitpython-feather_m4_can-en_US-7.3.2.uf2 \
/Volumes/FTHRCANBOOT
From a terminal, use the command line:
cd ~/<to_your_base_directory>/amiga-dev-kit
# mount the feather in wsl with 'd', assuming the feather is presenting as the D: drive on windows.
# Use the corresponding letter to the mounted drive.
sudo ./mnt_feather_wsl.sh d
cp circuitpy/feather_m4_can/uf2s/adafruit-circuitpython-feather_m4_can-en_US-7.3.2.uf2 /mnt/d/
On subsequent connection
When attaching a previously flashed Feather M4 device, it should automatically mount as CIRCUITPY
.
You can always check the our farm-ng adk uf2 dir or the Feather M4 CAN UF2 page for future stable & experimental releases.
Loading code on the Feather
Now that you have a flashed Feather, time to load some code:
-
Copy the
lib/
folder fromamiga-dev-kit/circuitpy/
to the root of the Feather. The contents oflib/
are automatically added to your python path on the microcontroller. -
Attach a serial terminal to the feather, so you can see std out.
- Linux
- MacOs
screen /dev/ttyACM0
tipUse autocomplete to get the correct usb modem
.../tty.usb[tab_for_autocomplete]
screen /dev/tty./dev/tty.usbmodem14201
tipMu is the recommended serial console program by adafruit on their CircuitPython serial console page. Mu has a built in plotter for tuples printed to the serial console (print statements in the python code on your microcontroller).
However, we've found that Mu can be a little unstable and freezes occasionally, so we'd recommend checking out their links for the "advanced" serial console:
-
Now add a
code.py
file to the root of the Feather drive. Try one of the examples found in the Examples index, such as the Hello Main Loop example.
The feather should automatically reload when you drop any new code onto it.
The feather automatically runs the file named code.py
and adds the contents of the lib/
directory to the python path.
You can also reload through the serial console by:
- Cancelling the current execution with
crtl+C
- Reloading with
ctrl+D