Skip to main content
2 of 3
Mention importance of -F and -V (the busybee)
glibg10b
  • 317
  • 1
  • 7
  1. Create a new file called Makefile in your project directory. Populate it with the following contents:
TEMPDIR := $(shell mktemp -d)

all:
    avr-g++ -DF_CPU=<CLK> -D__AVR_<PART>__ -DARDUINO=<ID> -DARDUINO_AVR_<DEVICE> -DARDUINO_ARCH_AVR -mmcu=<PARTNO> -fno-threadsafe-statics -O3 -flto -std=c++23 -isystem/usr/avr/include -lm -fuse-linker-plugin -Wl,--gc-sections *.cpp -o ${TEMPDIR}/a.elf

    avr-objcopy -O ihex -R .eeprom ${TEMPDIR}/a.elf ${TEMPDIR}/a.hex
    avrdude -F -V -p<PARTNO> -carduino -P/dev/tty<SERIAL_PORT> -b<BAUD> -D -Uflash:w:${TEMPDIR}/a.hex

    rm ${TEMPDIR}/a.elf ${TEMPDIR}/a.hex
    rm -d ${TEMPDIR}
  1. In the Arduino IDE, press Ctrl+, and enable verbose output during compilation and uploading
  2. Start uploading with Ctrl+U. Fill in the values in Makefile with the values in the Arduino IDE's build output
  3. Run make

-lm links in the AVR math library. *.cpp refers to your c++ source files. -F skips avrdude's signature check and -V prevents it from reading back the flash contents and verifying it -- both of these options save time by bypassing important safety features, but you may want to disable them while diagnosing problems.

glibg10b
  • 317
  • 1
  • 7