build script

This commit is contained in:
Christoph J. Scherr 2023-10-27 10:57:47 +02:00
parent 6515ff4c97
commit 089eb27c89
7 changed files with 47 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
src/blink/build src/blink/build
blink/build blink/build
blink/build blink/build
**/build/**

21
beep/main.c Normal file
View File

@ -0,0 +1,21 @@
#define F_CPU 16000000UL
#define __AVR_ATmega328P__
#include <avr/io.h>
int main(void) {
DDRB = 0xff;
DDRD = 0;
PORTD |= (1 << PORTD2) | (1 << PORTD3);
PORTB = 0;
while (1) {
if (!(PIND & (1 << PIND2))) {
PORTB |= (1 << PORTB5);
}
if (!(PIND & (1 << PIND3))) {
PORTB &= ~(1 << PORTB5);
}
}
}

View File

@ -1,17 +0,0 @@
#!/bin/bash
set -e
TDIR=$(mktemp -d)
BUILD=./build
mkdir -p $BUILD
avr-gcc -mmcu=atmega328p -DF_CPU=16000000L \
-DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR \
-I/usr/avr/include \
main.c -o $BUILD/main.elf
avr-objcopy -O ihex -R .eeprom $BUILD/main.elf $BUILD/main.hex
avr-size -A $BUILD/main.elf
avrdude \
"-C/home/plex/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V \
-patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D \
-Uflash:w:$BUILD/main.hex:i

25
build.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
if [ -z "$1" ]
then
echo "specify which directory to build and flash"
else
cd $1
TDIR=$(mktemp -d)
BUILD=../build
mkdir -p $BUILD
avr-gcc -mmcu=atmega328p -DF_CPU=16000000L \
-DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR \
-I/usr/avr/include \
main.c -o $BUILD/main.elf
avr-objcopy -O ihex -R .eeprom $BUILD/main.elf $BUILD/main.hex
avr-size -A $BUILD/main.elf
avrdude \
"-C/home/plex/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V \
-patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D \
-Uflash:w:$BUILD/main.hex:i
fi

View File

@ -1,17 +0,0 @@
#!/bin/bash
set -e
TDIR=$(mktemp -d)
BUILD=./build
mkdir -p $BUILD
avr-gcc -mmcu=atmega328p -DF_CPU=16000000L \
-DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR \
-I/usr/avr/include \
main.c -o $BUILD/main.elf
avr-objcopy -O ihex -R .eeprom $BUILD/main.elf $BUILD/main.hex
avr-size -A $BUILD/main.elf
avrdude \
"-C/home/plex/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V \
-patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D \
-Uflash:w:$BUILD/main.hex:i

Binary file not shown.

View File

@ -1,18 +0,0 @@
:100000000C9434000C943E000C943E000C943E0082
:100010000C943E000C943E000C943E000C943E0068
:100020000C943E000C943E000C943E000C943E0058
:100030000C943E000C943E000C943E000C943E0048
:100040000C943E000C943E000C943E000C943E0038
:100050000C943E000C943E000C943E000C943E0028
:100060000C943E000C943E0011241FBECFEFD8E04C
:10007000DEBFCDBF0E9440000C9481000C940000B4
:10008000CF93DF93CDB7DEB784E290E02FEFFC0192
:1000900020838AE290E0FC0110828BE290E0FC0178
:1000A00020818BE290E02C60FC01208385E290E0CF
:1000B000FC01108289E290E0FC018081882F90E0B1
:1000C00084709927009749F485E290E0FC01208133
:1000D00085E290E02062FC01208389E290E0FC014F
:1000E0008081882F90E088709927009719F785E222
:1000F00090E0FC01208185E290E02F7DFC012083CF
:06010000D9CFF894FFCFF7
:00000001FF