Skip to content

avr-devel

avr-devel is the 8-bit AVR counterpart of esp32-devel: the avr cross toolchain, the build rules, the flashing and a blink template.

PayloadWhat it provides
toolchains/avrthe avr cross toolchain of the selected board
rules/appbuilds the flashable image, reports the firmware size, flashes on xmake install
includes/boardthe board options and the avr-gcc / avrdude package definitions
templates/c/avr.blinkxmake create -t avr.blink
modules/*the board table, the image builder, the flasher and the tool finders

Supported boards: uno, nano (ATmega328P) and mega2560 (ATmega2560).

The toolchain comes from the packages the addon ships, so nothing has to be installed by hand: avr-gcc brings avr-libc, the startup code and the device linker scripts — the entry point is a plain int main(void) — and avrdude writes the image over the serial bootloader of the board, no programmer needed.

Install

sh
$ xmake addon --install avr-devel

Create and build a project

sh
$ xmake create -t avr.blink -l c blink
$ cd blink
$ xmake f --board=uno
$ xmake
[ 38%]: linking.release blink.elf
[ 56%]: generating.release blink.hex

AVR Memory Usage
----------------
Device: atmega328p

Program:     296 bytes (0.9% Full)
Data:         50 bytes (2.4% Full)

Flash and monitor

sh
$ xmake install                    # flash it, the serial port is auto-detected
$ xmake run                        # flash it and then watch the serial output
$ xmake f --port=/dev/ttyUSB0 --baud=57600

Use it in your own project

lua
add_addons("avr-devel")
includes("@addon/avr-devel/board")

target("blink")
    add_rules("@addon/avr-devel/app")
    add_files("src/*.c")
OptionDefaultDescription
--boardunouno, nano or mega2560
--f_cputhe frequency of the boardthe cpu frequency in Hz, e.g. 8000000
--portauto-detectedthe serial port
--baudthe bootloader rate of the boardthe flashing baud rate
--monitor_baud9600the serial monitor baud rate

Known gaps

Only the serial bootloader is supported, an ISP programmer is not. The prebuilt toolchain has no macOS arm64 build, it runs under Rosetta.