aboutsummaryrefslogtreecommitdiff
path: root/justfile
diff options
context:
space:
mode:
Diffstat (limited to 'justfile')
-rw-r--r--justfile44
1 files changed, 44 insertions, 0 deletions
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..567f3c6
--- /dev/null
+++ b/justfile
@@ -0,0 +1,44 @@
+set export
+# set unstable
+
+default:
+ echo -
+
+AVR_LIBC := env("AVR_LIBC", "/usr/lib/avr")
+# F_CPU := "32768"
+MCU := "attiny84a"
+MCU_PART := "attiny84"
+SRCS := "src/main.c src/display.c"
+OUTDIR := "./out"
+PROGRAMMER := "arduino"
+UPLOAD_SPEED := "19200"
+SERIAL_PORT := "/dev/ttyUSB0"
+
+CFLAGS := f"-g -Os -std=gnu99 -Isrc -mmcu={{MCU}} \
+-I{{AVR_LIBC}}/avr/include -L{{AVR_LIBC}}/avr/lib \
+-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall"
+
+AVRDUDE := f"avrdude -v -p {{MCU_PART}} -c {{PROGRAMMER}} -b {{UPLOAD_SPEED}}"
+
+build: compile-flags
+ mkdir -p {{OUTDIR}}
+ avr-gcc {{CFLAGS}} {{SRCS}} -o {{OUTDIR}}/out.elf
+ avr-objcopy -O ihex -R .eeprom {{OUTDIR}}/out.elf {{OUTDIR}}/out.hex
+ du -bh "{{OUTDIR}}/out.hex"
+
+write: build flash
+
+flash port=SERIAL_PORT: check-hexfile-exists
+ {{AVRDUDE}} -P {{port}} -F -U "flash:w:{{OUTDIR}}/out.hex:i"
+
+clean:
+ rm -rf {{OUTDIR}}
+
+format:
+ find src/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
+
+@check-hexfile-exists:
+ [ -f "{{OUTDIR}}/out.hex" ] || (echo "No out.hex. Run build first"; exit 1);
+
+@compile-flags:
+ echo '{{CFLAGS}}' | tr ' ' '\n' > ./compile_flags.txt