Editorial changes

This commit is contained in:
wagiminator
2022-12-13 16:40:38 +01:00
parent 0bf76a6b75
commit e1635009fa
37 changed files with 53 additions and 59 deletions

View File

@@ -61,7 +61,7 @@ The following microcontrollers can be used: ATtiny204, 214, 404, 414, 804, 814,
## If using the makefile (Linux/Mac)
- Connect your [programmer](https://github.com/wagiminator/AVR-Programmer) to your PC and to the UPDI header on the board. Make sure the programmer works with 3.3V.
- Download [AVR 8-bit Toolchain](https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers) and extract the sub-folders (avr, bin, include, ...) to /software/tools/avr-gcc. To do this, you have to register for free with Microchip on the download site.
- Make sure you have installed the latest [avr-gcc toolchain](http://maxembedded.com/2015/06/setting-up-avr-gcc-toolchain-on-linux-and-mac-os-x/).
- Open a terminal.
- Navigate to the folder with the makefile and the sketch.
- Run `DEVICE=attiny814 PROGRMR=serialupdi PORT=/dev/ttyUSB0 make install` to compile, burn the fuses and upload the firmware (change DEVICE, PROGRMR and PORT accordingly).

View File

@@ -1,18 +1,17 @@
# ===================================================================================
# Project: USB PD Adapter
# Author: Stefan Wagner
# Year: 2022
# URL: https://github.com/wagiminator
#
# Download AVR 8-bit Toolchain:
# https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers
# and extract to ./tools/avr-gcc
# ===================================================================================
# Type "make help" in the command line.
# ===================================================================================
# Input and Output File Names
SKETCH = USB_PD_Adapter.ino
TARGET = usb_pd_adapter
# Microcontroller Options
# Microcontroller Settings
DEVICE ?= attiny814
CLOCK = 1000000
FUSE0 = 0x00
@@ -24,27 +23,27 @@ FUSE6 = 0x04
FUSE7 = 0x00
FUSE8 = 0x00
# Programmer Options (serialupdi or jtag2updi)
# Programmer Settings
PROGRMR ?= serialupdi
PORT ?= /dev/ttyUSB0
# Paths
GCCPATH = ./tools/avr-gcc
DFPPATH = ./tools/dfp
PYMPATH = ./tools/pymcuprog
ADCPATH = ./tools/avrdude
# Commands
DFPINCL = -B $(DFPPATH)/gcc/dev/$(DEVICE)/ -I $(DFPPATH)/include/
COMPILE = $(GCCPATH)/bin/avr-gcc $(DFPINCL) -flto -Wall -Os -mmcu=$(DEVICE) -DF_CPU=$(CLOCK)UL -x c++ $(SKETCH)
PYPROG = python3 -u $(PYMPATH)/prog.py -t uart -u $(PORT) -b 230400 -d $(DEVICE)
AVRDUDE = avrdude -C $(ADCPATH)/avrdude.conf -c jtag2updi -P $(PORT) -p $(DEVICE)
# Toolchain
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
PYPROG = python3 -u ./tools/pymcuprog/prog.py -t uart -u $(PORT) -b 230400 -d $(DEVICE)
AVRDUDE = avrdude -C ./tools/avrdude/avrdude.conf -c $(PROGRMR) -P $(PORT) -p $(DEVICE)
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d
# Compiler Flags
CFLAGS = -w -flto -Os -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++
CFLAGS += -B include/dev/$(DEVICE) -I include
# Symbolic Targets
help:
@echo "Use the following commands:"
@echo "make all compile and build $(TARGET).bin/.hex/.asm for $(DEVICE)"
@echo "make all compile and build $(TARGET).elf/.bin/.hex/.asm for $(DEVICE)"
@echo "make hex compile and build $(TARGET).hex for $(DEVICE)"
@echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)"
@echo "make bin compile and build $(TARGET).bin for $(DEVICE)"
@@ -53,22 +52,32 @@ help:
@echo "make install compile, upload and burn fuses for $(DEVICE)"
@echo "make clean remove all build files"
all: buildbin buildhex buildasm removetemp size
all: buildelf buildbin buildhex buildasm removetemp size
bin: buildbin removetemp size
elf: buildelf removetemp size
hex: buildbin buildhex removetemp size removebin
bin: buildelf buildbin removetemp size removeelf
asm: buildbin buildasm removetemp size removebin
hex: buildelf buildhex removetemp size removeelf
install: fuses upload
asm: buildelf buildasm removetemp size removeelf
flash: install
install: hex
@echo "Installing $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
ifeq ($(PROGRMR),serialupdi)
@$(PYPROG) --fuses 0:$(FUSE0) 1:$(FUSE1) 2:$(FUSE2) 4:$(FUSE4) 5:$(FUSE5) 6:$(FUSE6) 7:$(FUSE7) 8:$(FUSE8) -f $(TARGET).hex -a write
else
@$(AVRDUDE) -Ufuse0:w:$(FUSE0):m -Ufuse1:w:$(FUSE1):m -Ufuse2:w:$(FUSE2):m -Ufuse4:w:$(FUSE4):m -Ufuse5:w:$(FUSE5):m -Ufuse6:w:$(FUSE6):m -Ufuse7:w:$(FUSE7):m -Ufuse8:w:$(FUSE8):m -U flash:w:$(TARGET).hex:i
endif
upload: hex
@echo "Uploading to $(DEVICE) ..."
@echo "Uploading $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
ifeq ($(PROGRMR),serialupdi)
@$(PYPROG) --fuses 2:$(FUSE2) 6:$(FUSE6) 8:$(FUSE8) -f $(TARGET).hex -a write
@$(PYPROG) -f $(TARGET).hex -a write
else
@$(AVRDUDE) -U fuse2:w:$(FUSE2):m -U fuse6:w:$(FUSE6):m -U fuse8:w:$(FUSE8):m -U flash:w:$(TARGET).hex:i
@$(AVRDUDE) -U flash:w:$(TARGET).hex:i
endif
fuses:
@@ -82,28 +91,34 @@ endif
clean:
@echo "Cleaning all up ..."
@$(CLEAN)
@rm -f $(TARGET).bin $(TARGET).hex $(TARGET).asm
@rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(TARGET).asm
buildelf:
@echo "Compiling $(SKETCH) for $(DEVICE) @ $(CLOCK)Hz ..."
@$(CC) $(CFLAGS) $(SKETCH) -o $(TARGET).elf
buildbin:
@echo "Building $(TARGET).bin for $(DEVICE) @ $(CLOCK)Hz ..."
@$(COMPILE) -o $(TARGET).bin
@echo "Building $(TARGET).bin ..."
@$(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin
buildhex:
@echo "Building $(TARGET).hex ..."
@$(GCCPATH)/bin/avr-objcopy -O ihex -R .eeprom $(TARGET).bin $(TARGET).hex
@$(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
buildasm:
@echo "Disassembling to $(TARGET).asm ..."
@$(GCCPATH)/bin/avr-objdump -d $(TARGET).bin > $(TARGET).asm
@$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm
size:
@echo "FLASH: $(shell $(GCCPATH)/bin/avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$1 + $$2}') bytes"
@echo "SRAM: $(shell $(GCCPATH)/bin/avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$2 + $$3}') bytes"
@echo "------------------"
@echo "FLASH: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$1 + $$2}') bytes"
@echo "SRAM: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$2 + $$3}') bytes"
@echo "------------------"
removetemp:
@echo "Removing temporary files ..."
@$(CLEAN)
removebin:
@echo "Removing $(TARGET).bin ..."
@rm -f $(TARGET).bin
removeelf:
@echo "Removing $(TARGET).elf ..."
@rm -f $(TARGET).elf

View File

@@ -1,4 +0,0 @@
Download AVR 8-bit Toolchain:
https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers
To do this, you have to register for free with Microchip on the site.
Extract the sub-folders (avr, bin, include, ...) here.

View File

@@ -1,17 +0,0 @@
Description: Atmel ATtiny Series Device Support (1.10.348)
Source: http://packs.download.atmel.com/
Copyright (c) 2020 Microchip Technology Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the Licence at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.