AdaCore / Ada_Drivers_Library

Ada source code and complete sample GNAT projects for selected bare-board platforms supported by GNAT.
BSD 3-Clause "New" or "Revised" License
248 stars 144 forks source link

Support for Adafruit Feather M0 board #390

Closed faelys closed 3 years ago

faelys commented 3 years ago

Hello,

I own an Adafruit Feather M0 board (the one with embedded ATWINC1500 wifi chip), and I was hoping to program it with Ada.

When I bought it, I thought that the MicroBit had a SAMD21 chip too, but it seems I was mistaken (maybe I got confused and mixed Cortex M0 and SAMD21), so maybe I underestimated the task.

I think I read somewhere (but I can't remember where) that there was some weirdness with register mapping on the SAMD21, but it might be well beyond my depth, considering I'm not even sure I understand what these words mean exactly.

Is there any hope for an ADL newbie like me to add Feather M0 support? If so, would you have any specific advice for this hardware, or should I just proceed with reading the general documentation and starting from the MicroBit support? Is there anybody else interested in this board who would spend time to work with me on this?

Fabien-Chouteau commented 3 years ago

Hi @faelys

Is there any hope for an ADL newbie like me to add Feather M0 support?

There is hope :) It is indeed not an easy task, but you can do it.

I strongly recommend getting a good debugger setup, and for this the Feather M0 is not the best since there is no Cortex-M debug connector on the board. The METRO M0 Express would be a better option: https://www.adafruit.com/product/3505

For the debugger you can either get a SEGGER J-Link EDU Mini (https://www.adafruit.com/product/3571) or Black Magic Probe (open source, open hardare): https://www.adafruit.com/product/3839 .

If so, would you have any specific advice for this hardware, or should I just proceed with reading the general documentation and > starting from the MicroBit support?

Nowadays I would look at what is done for the samd51 (myself) and the rp2040 (Jeremy Grosser) in the Alire ecosystem.

I started to write some instructions for you but it quickly turned in to a blog post. So stay tuned on AdaCore blog because I will post the instructions there ASAP.

Is there anybody else interested in this board who would spend time to work with me on this?

In theory I am, and I will help you as best as I can for the drivers. But I don't have much time available at the moment.

JeremyGrosser commented 3 years ago

https://github.com/JeremyGrosser/clock3/tree/master/src

Before the RP2040 came out, I was working on drivers for the samd21 as a part of another project. It's in very rough shape and there are a lot of things in this repo not relevant to the samd21, but I figured I'd push what I have if it might be useful to others. Much of this code is incomplete or broken, but it does work well enough to use the UART and some I2C peripherals.

I was going for more of an Arduino-like experience with the Board package, rather than building drivers that implement the HAL interfaces. If you're developing a reusable set of drivers for this chip, a HAL compatible interface is definitely the way to go.

Fabien-Chouteau commented 3 years ago

Hello @faelys,

The blog post is here: https://blog.adacore.com/starting-micro-controller-ada-drivers-in-the-alire-ecosystem

I hope this will help you getting started. I will close the issue for now. but don't hesitate to ask follow-up questions.