From Gentoo Wiki
Jump to: navigation, search

Alternative: Write plain C or C++ code keeping the hardware compatible

Instead of using the Arduino IDE or one of the plenty wrappers in form of makefiles, cmake files, IDE plugins etc. all using the same C++-alike Arduino language you can directly program the AVR microcontroller inside your arduino, while still using the bootloader which is used for Arduino sketches.

This means you can always switch from the Arduino software world to plain C and back without any need to re-flash a bootloader.

Setup the toolchain

Just setup the toolchain with crossdev as described above.


1. Put a note into the toolchain setup part when I confirmed that this actually works:

[ebuild N ] cross-avr/binutils-2.33.1:2.33::crossdev USE="plugins -default-gold -doc -gold -multitarget -nls -static-libs -test" 0 KiB [ebuild N ] cross-avr/gcc-9.2.0-r2:9.2.0::crossdev USE="cxx (-altivec) -d -debug -doc (-fixed-point) -fortran -go -graphite -hardened -jit -libssp -lto (-multilib) -nls -nptl -objc -objc++ -objc-gc -openmp (-pch) -pgo (-pie) -sanitize (-ssp*) -systemtap -test -vanilla -vtv" 0 KiB [ebuild N ] cross-avr/avr-libc-2.0.0::crossdev USE="-doc -headers-only" 0 KiB

2. add this link to external references:

Install necessary packages

root #emerge --ask sys-devel/make dev-embedded/avrdude

Use a custom Makefile

Write a basic blink example

Use data sheets from the vendor

To get information about register, pins, timings and so on you should look into the vendor's datasheets.

You can find them by searching directly or via the arduino company's website via the following steps:

1. Search your specific arduino mode, e.g. Arduino Uno Rev. 3.

2. Scroll down to the bar Overview|Tech Specs|Documentation.

3. Click at Tech Specs.

4. Click at the green-ish marked name of the microcontroller, i.e. the first entry. This one links to the specific data sheet as as PDF.

Note that the mentioned steps require javascript, so some PDFs will be linked in the external ressources section below.

External references