4 Comments

With all that bare metal no libs from the start, I am getting impression you used gcc and some makefile scripts instead of vendor IDE.

If so, I wonder what programming utility have you used - what is st-util for SAMx?

BTW by cheap $15 programmer you mean pickit3 clone?

Expand full comment
author

The IDE from the vendor is free, so it's not a bad choice on Windows. But I talk about the build process here:

https://lcamtuf.coredump.cx/bob-the-cat/

TL;DR: If you want open-source tools, basically download ARM CMSIS + Microchip DFP (they provide a bunch of .h files with register names and some other macros, plus a linker script) + arm-none-eabi-newlib (some subset of standard C library functions), then use arm-none-eabi-gcc (the latter two usually provided by Linux distros).

For programming, the tool is OpenOCD, and I give an example of calling it to program this particular chip.

Programmers - anything that is CMSIS-DAP compliant and supports SWD should do for OpenOCD. There's stuff like this: https://github.com/wagiminator/CH552-picoDAP

Expand full comment

You mentioned ready-made breakout boards in passing, but it seems like buying a board from a vendor like Teensy or Adafruit and using Arduino or PlatformIO would be the most common way to approach this for hobbyists? Certainly there’s no reason to spend $250 when these boards go for $6-30. (Whether an Arduino implementation counts as an OS is debatable, but it does handle booting and some device drivers for you, sort of like MS-DOS did.)

My recent projects have used Raspberry Pi Picos after a friend gave me a few. The most difficult part of getting started was deciding among the many ways of writing a program for it. Settled on this one: https://github.com/earlephilhower/arduino-pico

When programming at this level of abstraction, the complexity of 32-bit microcontrollers is hidden and they can be had at similar prices to 8-bit boards, so I don’t see any reason not to use 32-bit MCU’s all the time.

Expand full comment
author
Feb 1, 2023·edited Feb 1, 2023Author

I don't think Arduino or Raspberry Pi Pico are the targets of my critique. These are basically nearly-bare microcontrollers where somebody else did the job of soldering the chip to a breakout board, maybe adding a couple of minor accessories like a voltage regulator, and then provided a lightweight set of libraries / macros that sprinkle some syntactic sugar on top of what's essentially a bare MCU environment.

I think it's reasonable to pay for that and I don't think you're gonna see worse outcomes. Just don't fall for the illusion that your life is radically easier. On Raspberry Pi Pico, you might be doing:

gpio_set_dir(LED_PIN, GPIO_OUT);

...and on an Arduino, you might be doing:

pinMode(LED_BUILTIN, OUTPUT);

...and on a bare microcontroller, you might be doing:

PORTA.DIR = _BV(MY_LED_PIN);

...but you're doing the same thing, with the same amount of effort. Now, it's not hurting anyone, so you know - live and let live.

Anyway - in the series, I'm trying to make two other points:

1) That most of the time, you don't need a Linux-based "whole computer" board, such as the "big" Raspberry Pi, Beaglebone, or whatever. They are not exactly cheap, they are fairly power-hungry, and they add unexpected complications to many projects. It's not that you should never use them, but it's good to know the alternatives.

2) That there is an industry of overpriced evaluation boards - not Raspberry Pi Pico or Arduino! - that capitalize specifically on people thinking "geez, I want to build something with an ARM Cortex chip, but there's no way I could get it running without this complex-looking board!". I mean stuff like this:

https://www.mouser.com/ProductDetail/Microchip-Technology/DM320210?qs=sGAEpiMZZMuqBwn8WqcFUj1SFkunHY10T%252BGvFJNlLp1VnI2IcD96KA%3D%3D

I updated the text a bit to clarify. Raspberry Pi Pico is actually really cool!

Expand full comment