Commit 3e654c73 authored by olesaa's avatar olesaa

Initial commit

parents
Pipeline #286 failed with stages
in 1 minute and 25 seconds
# This is a Makefile for AVR KURS,
# attempting to provide support for compiling and flashing AtMega4809 Curiosity from MacOS (2019-03-01)
# Author: ole.sivert@aarhaug.com
# Special thanks: magne.hov@gmail.com and richard.bman@gmail.com
#
# Guide for programming AVR AtMega4809 in MacOS
# To compile for AVR AtMega4809 we need some utilities for AVR, install these:
# The ones in your repos may or may not be up to date, let's save ourselves
# the trouble and go straight to the source.
# 1) Run 'make install', which will execute install_toolchain.sh. It is always wise to
# read the contents of scripts before running them.
# 2) The chip acts as a USB storage device! It should automount the path given below
# 3) Done! You can now cp the Makefile to wherever the main.c file you're working on is,
# and run 'make'. Note that uploading to the chip requires sudo priviledges, so you
# you will be asked for your password when uploading
# ###
# Dependency directories and binaries
CHIP_DIR = /Volumes/CURIOSITY/
TOOL_CHAIN_URL = "https://omegav.no/files/avrkurs/MacOS/install_toolchain.sh"
DFP_DIR = $(HOME)/Library/avr-atpack/
AVR-GCC = avr-gcc
AVR-OBJCOPY = avr-objcopy
# ####
# Project files and flags
#Source files, add more files to SRC if needed: main.c uart.c ...
SRC = main.c
OBJ = $(SRC:.c=.o)
#Target name
TARGET = out
#Compiler and Linker flags
MCU = atmega4809
CFLAGS = -B $(DFP_DIR)gcc/dev/atmega4809 -I $(DFP_DIR)include -mmcu=$(MCU) -Os
LDFLAGS = -B $(DFP_DIR)gcc/dev/atmega4809 -I $(DFP_DIR)include -mmcu=$(MCU) #-Wl,-Map=$(TARGET).map
# ####
# Make rules
all: build flash clean
build: $(TARGET).hex
flash:
cp $(TARGET).hex $(CHIP_DIR) && sync $(CHIP_DIR)$(TARGET).hex
clean:
rm -f $(OBJ) $(TARGET).{elf,hex}
install:
curl $(TOOL_CHAIN_URL) > install_toolchain.sh
chmod +x install_toolchain.sh
./install_toolchain.sh
rm install_toolchain.sh
# ####
# Compiler rules
%.hex: %.elf
$(AVR-OBJCOPY) -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
%.elf: $(OBJ)
$(AVR-GCC) $^ $(LDFLAGS) -o $@
%.o : %.c
$(AVR-GCC) $(CFLAGS) -o $@ -c $<
# Title: AVR toolchain installer macOS
# Author: Ole Sivert Aarhaug aka OS aka root 2019
# The toolchainurl might not last. Latest version can be found under https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers
TOOLCHAINURL="http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-osx-3.6.2.503-darwin.any.x86_64.tar.gz"
ATPACK="http://packs.download.atmel.com/Atmel.ATmega_DFP.1.3.300.atpack"
CURRENTDIR=$PWD
function downloadAvr {
if [ -d "$TMPDIR/avrkurs" ]; then
rm -R $TMPDIR/avrkurs
fi
mkdir $TMPDIR/avrkurs/
echo "Downloading...."
curl $TOOLCHAINURL > $TMPDIR/avrkurs/toolchain.tar.gz
cd $TMPDIR/avrkurs
curl $ATPACK > atpack.zip
gunzip -c toolchain.tar.gz | tar xopf -
echo "Installing....."
if [ -d "$HOME/Library/avr-toolchain" ]; then
rm -R $HOME/Library/avr-toolchain
fi
if [ -d "$HOME/Library/avr-atpack" ]; then
rm -R $HOME/Library/avr-atpack
fi
mkdir $HOME/Library/avr-atpack
unzip $TMPDIR/avrkurs/atpack.zip -d $HOME/Library/avr-atpack/
mv avr8-gnu-toolchain-darwin_x86_64/ $HOME/Library/avr-toolchain
echo "export PATH="$HOME/Library/avr-toolchain/bin:\$PATH"" >> $HOME/.bash_profile
rm -R $TMPDIR/avrkurs
echo "Done!"
}
echo " ___ _ _______ _ __ "
echo " / _ \| | | | ___ \ | | / / "
echo "/ /_\ \ | | | |_/ /_____| |/ / _ _ _ __ ___ "
echo "| _ | | | | /______| \| | | | '__/ __| "
echo "| | | \ \_/ / |\ \ | |\ \ |_| | | \__ \ "
echo "\_| |_/\___/\_| \_| \_| \_/\__,_|_| |___/ "
echo " "
echo " "
echo "___ ___ _____ _ _ _ "
echo "| \/ | |_ _| | | | | | "
echo "| | __ _ ___ | | _ __ ___| |_ __ _| | | ___ _ __ "
echo "| |\/| |/ _ |/ __| | || '_ \/ __| __/ _ | | |/ _ \ '__|"
echo "| | | | (_| | (__ _| || | | \__ \ || (_| | | | __/ | "
echo "\_| |_/\__,_|\___| \___/_| |_|___/\__\__,_|_|_|\___|_| "
echo "-----------------------------------------------------------"
echo "This installer will download, install and add to path the AVR-8bit toolchain for MacOS 64-bit"
printf "Do you want to continue? [Y/n] "
read ANS
if [ "$ANS" == 'Y' ] || [ "$ANS" == '' ]; then
downloadAvr
else
exit 0
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment