← Back to context

Comment by mikepurvis

7 days ago

The pin mapping shenanigans are another annoying footgun with Arduino. Even in native development you're dealing with a physical pin number and the logical assignment (PA5, PA6, etc), but now Arduino maps that all again to an Arduino board pin number, and it's all shuffled to ensure the peripherals are in the right place to enable I2C, ADC, and PWM pins to function as expected.

Of course they did that. It's a HAL (hardware abstraction library).

That also means that simple projects are abstracted from the hardware. Means I can go across a dozen different CPU arch and board/pin layouts, and I change nothing in my source. I only change my target and it just works.

I did that when I went from a board operating at 16MHz/atmel to a STmicro running 50MHz. No change in my source. And that's really valuable in rapid prototyping.

Once I settled in on a board and everything, I could do it the "right way" aka the old waterfall-gile embedded approach and get things tweaked and optimized.

  • The problem is that a lot of this abstraction is done at runtime, not compile time. Your binaries become bloated, your application slow, and you end up using a microcontroller with three times the resources you actually need just to support all the dead weight.

  • A lot of firmware people consider HAL libraries as harmful. In general, microcontroller companies as pretty terrible at software.

Same deal exactly for the various ESP32 boards. With the added wrinkle that some of them (like T-Display) have had pins swapped in the doc at various stages.