If you don’t know the Mini SAM yet, get ready to meet the cutest PCB ever designed (yes PCBs can be cute). The Mini SAM boards have the same size and shape as the famous Lego “minifigs”.
Beyond the great look, the boards provide a powerful 120 Mhz Microchip SAMD51 Cortex‑M microcontroller, a couple of LEDs and a user button.
A few weeks ago I wrote a Board Support Package (BSP) and an example project for the Mini SAM M4. They are available from the Alire package manager.
To build the example you will need a GNAT arm-elf cross compiler, for instance from the GNAT Community release.
Get the project and dependencies from Alire:
$ alr get minisamd51_example
Go inside the project directory and compile:
$ cd minisamd51_example* $ alr build
To run the example on the board you first need to convert the ELF binary file to an UF2 bootloader compatible format. I added a script to do that easily, just run:
$ bash convert_to_uf2.sh
To program the Mini SAM you then have to connect the board to your computer with a USB cable, and press the reset button twice. The board will switch to bootloader mode, which simulates a USB disk drive. The last step is to drag and drop the
minisamd51_example.uf2 into the USB drive of the Mini SAM.
And you should have a blinking board:
This example uses a new tool called
startup-gen to generate linker script and startup code. You can learn more about
startup-gen in this blog post.