Guidance or links for cross compiling toolchain for microcontrollers

Hi Everyone,

Like a lot of hackers, I have outgrown the Arduino IDE, the project i'm working on now demands that I learn how to properly cross compile for my hardware so that I have the full range of debugging and compile tools that are usually available when creating c++ applications.

I have been searching for a solution, and it has brought me to the understanding that the Arduino environment is not so easy to separate from, which is why all of the current solutions focus on maintaining compatibility with the arduino core libraries.

When I attempt to delve deeper into how to actually program for microcontrollers I run into a rather large barrier to entry. There isn't any tutorials or documentation that I can find, It seems everyone keeps trying to take away the pain of developing for bare metal by hiding all of the details, which ends up hurting my ability to learn.

Does anyone know of any resources that will help me overcome the barrier to entry?

My ideal scenario would be a detailed explanation with tutorial on:

  • how to compile extremely simple code using command line optionally with makefile examples
  • how to define a toolchain for make or cmake. should be straight forward after the above item.

What I don't really need.

  • howto upload to the hardware with a programmer.
  • how to use platformio, arduino-cli, etc, etc.
  • Compatibility with arduino core.

I'm trying to understand the fundamentals.

I want to be able to compile my program for my primary operating system, and with a change of toolchain and some flags compile it for any arduino or microcontroller I have cretaed support for. Run the static analysis and linters from gcc and clang that help with so many errors and problems. compile using the latest standards available etc.

As I understand it, a microcontroller is not fundamentally different than any other platform except by what the entry point is, and what libraries are available, c and c++ still gets compiled to assembler and does its thing.

If anyone knows of any resources which might help, or is willing to mentor me a little that would be fantastic.

Also as a bit of a rant, why in hell the Arduino organisation is creating yet another bespoke build tool and package manager instead of using things like cmake and conan is beyond me.. there is an xkcd comic about competing standards.. Instead of lowering the barrier to entry, they have simply shifted the barrier around.

Arduino is just on top of gcc-avr.

Either you go the Windows way with AtmelStudio on M$, or WInAVR, on M$, or you go the easy road with linux and the usul tools including make and avr-gcc. There's lots of documentation out there.

You say there is loads of documentation out there but for some reason i can't find it. My current search efforts are all clogged up with platformio, arduinocmake project, or just basic arduino studio tutorials. I stated as much in my original post - "There isn't any tutorials or documentation that I can find".

If you have any resources that you can point me to other than 'just google it' that would be helpful.

Sorry, this one is german, but you can run it through goole translator:
https://www.mikrocontroller.net/articles/AVR-GCC-Tutorial
https://www.nongnu.org/avr-libc/user-manual/group__demo__project.html