AdaCore Blog

Mini SAM M4 Ada BSP

by Fabien Chouteau

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 pro­vide a pow­er­ful 120 Mhz Microchip SAMD51 Cortex‑M micro­con­troller, a cou­ple of LEDs and a user button.

A few weeks ago I wrote a Board Sup­port Pack­age (BSP) and an exam­ple project for the Mini SAM M4. They are avail­able from the Alire pack­age man­ag­er.

To build the exam­ple you will need a GNAT arm-elf cross com­pil­er, for instance from the GNAT Com­mu­ni­ty release.

Get the project and depen­den­cies from Alire:

$ alr get minisamd51_example

Go inside the project direc­to­ry and compile:

$ cd minisamd51_example*
$ alr build

To run the exam­ple on the board you first need to con­vert the ELF bina­ry file to an UF2 boot­loader com­pat­i­ble for­mat. I added a script to do that eas­i­ly, just run:

$ bash convert_to_uf2.sh

To pro­gram the Mini SAM you then have to con­nect the board to your com­put­er with a USB cable, and press the reset but­ton twice. The board will switch to boot­loader mode, which sim­u­lates a USB disk dri­ve. The last step is to drag and drop the minisamd51_example.uf2 into the USB dri­ve of the Mini SAM.

And you should have a blink­ing board:

This exam­ple uses a new tool called startup-gen to gen­er­ate link­er script and start­up code. You can learn more about startup-gen in this blog post.

Posted in

About Fabien Chouteau

Fabien Chouteau

Fabien joined AdaCore in 2010 after his engineering degree at the EPITA (Paris). He is involved in real-time, embedded and hardware simulation technology. Maker/DIYer in his spare time, his projects include electronics, music and woodworking.