Moving beyond Arduino, looking for a good HAL

Thread Starter

ppelleti

Joined Oct 16, 2020
4
I've been doing a bunch of microcontroller projects over the past few years, on a variety of different microcontrollers. I've primarily been using the Arduino environment to do so, but there are a large number of things that irritate me about Arduino, so I would prefer to move away from Arduino. However, I'm finding it difficult to do so, because Arduino supports many different microcontrollers, and has a wide variety of libraries available for interfacing with various peripherals.

Basically, what I'm looking for is a hardware abstraction layer of some sort. I don't mind delving into registers when I need to, but I'd prefer to have a common way of accessing things like timers, GPIO pins, SPI, and I2C regardless of which microcontroller I'm using.

Some things I'm looking for are:

  • Supports multiple architectures and manufacturers. I primarily use ATSAMD microcontrollers, but I'd like to also be able to use ARM Cortex-M microcontrollers from other vendors, and sometimes venture into RISC-V or ESP32.
  • Not too bloated. I want to be able to write code that fits on a SAMD11 with 16K of flash, but also scale up.
  • Writing code in a statically typed, systems programming language. It doesn't necessarily have to be C/C++, but I'm not looking for a dynamic language like MicroPython or Javascript.
  • A good ecosystem, with libraries and examples.
  • I don't necessarily object to an RTOS, but I don't need one. Just a single thread with interrupts is fine for me.
  • Easy to port to a new board.

A couple of possibilities I've looked at:

  • ARM mbed - Close to what I'm looking for. Seems well engineered. Version 5 seems to be moving more in the RTOS direction; I think version 2 was closer to what I was looking for. Downsides: ARM only. Each project uses a large amount (nearly a gigabyte, if I remember correctly) of disk space on the development system. I get the impression that adding support for a new board is not entirely trivial.
  • Rust - An interesting language with a number of features I like. Tends to be very verbose, though. Seems to support Cortex-M and RISC-V well, and ESP32 support is in development. Has a large number of libraries for many peripherals, although when I started to actually use them, I discovered they were not necessarily well-tested.

Are there other contenders I've overlooked? Thanks!
 

nsaspook

Joined Aug 27, 2009
7,723
My 2c

I think you're asking too much for multi-vendor micro-controller support at that hardware/software level.

IMO don't spend a lot of time with Rust as a possible C replacement until about 5 years have passed. ;) Rust doesn't have a specification Therefore all Rust code is undefined behavior
Do you want to solve problems by adding more language features using Rust (or other C++ type languages) or solve them with more language code programming in C? The people thinking using Rust are already writing (or at least thinking about it) safe C code so they really won't gain much from the Rust straightjacket.

It's a good idea but just about everything fun at the embedded area will be unsafe memory code that can't use some language feature static safety checks. A simpler memory safe low-level language is sadly, still in the future.
 
Last edited:

peterdeco

Joined Oct 8, 2019
250
My uC's of choice are PIC microcontrollers. I program them in Basic and have full access to all the bells and whistles on each I/O in the program without needing a library.
 

trebla

Joined Jun 29, 2019
215
I suggest you to try both the Cube IDE for STM32 and the MPLABX for SAMD. You can then evaluate both IDE environments for available sample programs and generated HAL code. Then you can decide which ecosystem to use for development in future. I use both.
 

Thread Starter

ppelleti

Joined Oct 16, 2020
4
Thanks for all the suggestions, although I'm not looking for a single-vendor solution. The appeal of Arduino is that Arduino programs are portable. I'm trying to find something similar, but more sophisticated.

Besides looking at mbed and Rust, I may also look at lightweight RTOSes like Simba and Zephyr.
 

trebla

Joined Jun 29, 2019
215
MikroElektronika has support for different MCU-s (AVR, PIC, dsPIC, PIC32, STM32, FT90x, NXP, TIVA) but they have different IDE-s for that and each compiler costs about $200-$300. On the other hand they have plenty of different libraries and porting code between different MCU-s is quite easy. Their new Necto IDE is trying to collect different compilers under one hood but today is there only ARM and PIC compilers. You can use trial versions for some limitations (3 months for Necto and code limitations for older IDE-s) and decide to buy or not to buy their licence. I personally do not like that some their libraries are provided only as binaries (legacy ones) and their open source SDK2.0 libraries are somewhat too abstract. Mikroe compilers
 

Thread Starter

ppelleti

Joined Oct 16, 2020
4
The reason your looking, is the very reason the Arduino environment came about,
vendors write tools for there chips.
Yes, but Arduino is really horrifying, from a software engineering standpoint. It would take a long time for me to list all my gripes. Some of my issues are with the Arduino build system, which could be fixed by going to PlatformIO, but some of my issues are with the Arduino API and ecosystem. I'd just prefer to have something which is better engineered than Arduino.
 

Thread Starter

ppelleti

Joined Oct 16, 2020
4
MikroElektronika has support for different MCU-s (AVR, PIC, dsPIC, PIC32, STM32, FT90x, NXP, TIVA) but they have different IDE-s for that and each compiler costs about $200-$300. On the other hand they have plenty of different libraries and porting code between different MCU-s is quite easy. Their new Necto IDE is trying to collect different compilers under one hood but today is there only ARM and PIC compilers. You can use trial versions for some limitations (3 months for Necto and code limitations for older IDE-s) and decide to buy or not to buy their licence. I personally do not like that some their libraries are provided only as binaries (legacy ones) and their open source SDK2.0 libraries are somewhat too abstract. Mikroe compilers
Thanks! That's useful to know.

I should probably add to my initial list of requirements, though, that I would prefer something open source.
 
Top