Pure AVR Assembler programming

You can remove the framework = arduino line and it will use the _bare builder. Meaning it will just use avr-gcc -x assembler-with-cpp .. to compile stuff.

Example platformio.ini:

[env:attiny85]
platform = atmelavr
board = attiny85

src\main.S:

;hello.asm
;  turns on an LED which is connected to PB5 (digital out 13)

#define PORTB 0x18
#define DDRB 0x17

.global main

main:
	ldi r16,0b00100000
	out DDRB,r16
	out PORTB,r16
Start:
	rjmp Start

no other files are needed.

platformio -f -c eclipse run 
[..]
avr-gcc -x assembler-with-cpp -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=attiny85 -DF_CPU=8000000L -DPLATFORMIO=40000 -DARDUINO_AVR_ATTINYX5 -Isrc -Iinclude -c -o .pioenvs\attiny85\src\main.o src\main.S
avr-gcc -o .pioenvs\attiny85\firmware.elf -Os -mmcu=attiny85 -Wl,--gc-sections -flto -fuse-linker-plugin .pioenvs\attiny85\src\main.o -L.pioenvs\attiny85 -Wl,--start-group -lm -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pioenvs\attiny85\firmware.elf"])
avr-objcopy -O ihex -R .eeprom .pioenvs\attiny85\firmware.elf .pioenvs\attiny85\firmware.hex
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 0 bytes from 512 bytes)
PROGRAM: [          ]   0.7% (used 60 bytes from 8192 bytes)

Be careful with the assembler include files though, the tn85def.inc I found is apparently written in the assembler syntax for the Atmel Studio assembler and will cause syntax errors when compiled with avr-gcc/avr-as.

1 Like