diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e524d79 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ +build/ diff --git a/README.md b/README.md index cc03025..740bc1d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,19 @@ # Arduino C -Programming the Arduino in pure C. +Programming the Arduino in pure C on Linux. + +## Requirements + +* arvdude +* arv-gcc +* avr-libc ## Compile and upload Run using the following command (example port): ``` -sudo ./compile /dev/ttyUSB0 +sudo ./compile.sh /dev/ttyUSB0 ``` + +The port can be found by looking inside `/dev`, the system file `ll /sys/class/tty/ttyUSB*`, or by running `lsusb`. diff --git a/compile b/compile.sh similarity index 91% rename from compile rename to compile.sh index 02ae63d..d8ba68f 100755 --- a/compile +++ b/compile.sh @@ -14,17 +14,19 @@ echo "BAUD set to $BAUD" rm -rf build || true mkdir build +# compile files avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/servo.o -Wall servo/servo.c - avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/rf24.o -Wall rf24/rf24.c - avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/util.o -Wall ard/util.c avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/serial.o -Wall ard/serial.c avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/pins.o -Wall ard/pins.c avr-gcc -Os -DF_CPU=16000000UL -mmcu=$MMCU -c -o build/main.o -Wall main.c +# compile binary avr-gcc -mmcu=$MMCU build/*.o -o build/main -avr-objcopy -O ihex -R .eeprom build/main build/main.hex -avrdude -F -V -c arduino -p $AVR_TYPE -P $1 -b $BAUD -U flash:w:build/main.hex -rm -r build +# create file to upload to arduino +avr-objcopy -O ihex -R .eeprom build/main build/main.hex + +# upload to arduino +avrdude -F -V -c arduino -p $AVR_TYPE -P $1 -b $BAUD -U flash:w:build/main.hex