mirror of
https://github.com/wagiminator/ATtiny814-USB-PD-Adapter.git
synced 2025-08-06 12:47:16 +03:00
Editorial changes
This commit is contained in:
@@ -61,7 +61,7 @@ The following microcontrollers can be used: ATtiny204, 214, 404, 414, 804, 814,
|
|||||||
|
|
||||||
## If using the makefile (Linux/Mac)
|
## 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.
|
- 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.
|
- Open a terminal.
|
||||||
- Navigate to the folder with the makefile and the sketch.
|
- 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).
|
- 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).
|
||||||
|
@@ -1,18 +1,17 @@
|
|||||||
|
# ===================================================================================
|
||||||
# Project: USB PD Adapter
|
# Project: USB PD Adapter
|
||||||
# Author: Stefan Wagner
|
# Author: Stefan Wagner
|
||||||
# Year: 2022
|
# Year: 2022
|
||||||
# URL: https://github.com/wagiminator
|
# 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.
|
# Type "make help" in the command line.
|
||||||
|
# ===================================================================================
|
||||||
|
|
||||||
# Input and Output File Names
|
# Input and Output File Names
|
||||||
SKETCH = USB_PD_Adapter.ino
|
SKETCH = USB_PD_Adapter.ino
|
||||||
TARGET = usb_pd_adapter
|
TARGET = usb_pd_adapter
|
||||||
|
|
||||||
# Microcontroller Options
|
# Microcontroller Settings
|
||||||
DEVICE ?= attiny814
|
DEVICE ?= attiny814
|
||||||
CLOCK = 1000000
|
CLOCK = 1000000
|
||||||
FUSE0 = 0x00
|
FUSE0 = 0x00
|
||||||
@@ -24,27 +23,27 @@ FUSE6 = 0x04
|
|||||||
FUSE7 = 0x00
|
FUSE7 = 0x00
|
||||||
FUSE8 = 0x00
|
FUSE8 = 0x00
|
||||||
|
|
||||||
# Programmer Options (serialupdi or jtag2updi)
|
# Programmer Settings
|
||||||
PROGRMR ?= serialupdi
|
PROGRMR ?= serialupdi
|
||||||
PORT ?= /dev/ttyUSB0
|
PORT ?= /dev/ttyUSB0
|
||||||
|
|
||||||
# Paths
|
# Toolchain
|
||||||
GCCPATH = ./tools/avr-gcc
|
CC = avr-gcc
|
||||||
DFPPATH = ./tools/dfp
|
OBJCOPY = avr-objcopy
|
||||||
PYMPATH = ./tools/pymcuprog
|
OBJDUMP = avr-objdump
|
||||||
ADCPATH = ./tools/avrdude
|
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
|
||||||
|
|
||||||
# Commands
|
# Compiler Flags
|
||||||
DFPINCL = -B $(DFPPATH)/gcc/dev/$(DEVICE)/ -I $(DFPPATH)/include/
|
CFLAGS = -w -flto -Os -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++
|
||||||
COMPILE = $(GCCPATH)/bin/avr-gcc $(DFPINCL) -flto -Wall -Os -mmcu=$(DEVICE) -DF_CPU=$(CLOCK)UL -x c++ $(SKETCH)
|
CFLAGS += -B include/dev/$(DEVICE) -I include
|
||||||
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)
|
|
||||||
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d
|
|
||||||
|
|
||||||
# Symbolic Targets
|
# Symbolic Targets
|
||||||
help:
|
help:
|
||||||
@echo "Use the following commands:"
|
@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 hex compile and build $(TARGET).hex for $(DEVICE)"
|
||||||
@echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)"
|
@echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)"
|
||||||
@echo "make bin compile and build $(TARGET).bin 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 install compile, upload and burn fuses for $(DEVICE)"
|
||||||
@echo "make clean remove all build files"
|
@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
|
||||||
|
|
||||||
upload: hex
|
flash: install
|
||||||
@echo "Uploading to $(DEVICE) ..."
|
|
||||||
|
install: hex
|
||||||
|
@echo "Installing $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
|
||||||
ifeq ($(PROGRMR),serialupdi)
|
ifeq ($(PROGRMR),serialupdi)
|
||||||
@$(PYPROG) --fuses 2:$(FUSE2) 6:$(FUSE6) 8:$(FUSE8) -f $(TARGET).hex -a write
|
@$(PYPROG) --fuses 0:$(FUSE0) 1:$(FUSE1) 2:$(FUSE2) 4:$(FUSE4) 5:$(FUSE5) 6:$(FUSE6) 7:$(FUSE7) 8:$(FUSE8) -f $(TARGET).hex -a write
|
||||||
else
|
else
|
||||||
@$(AVRDUDE) -U fuse2:w:$(FUSE2):m -U fuse6:w:$(FUSE6):m -U fuse8:w:$(FUSE8):m -U flash:w:$(TARGET).hex:i
|
@$(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 $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
|
||||||
|
ifeq ($(PROGRMR),serialupdi)
|
||||||
|
@$(PYPROG) -f $(TARGET).hex -a write
|
||||||
|
else
|
||||||
|
@$(AVRDUDE) -U flash:w:$(TARGET).hex:i
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fuses:
|
fuses:
|
||||||
@@ -82,28 +91,34 @@ endif
|
|||||||
clean:
|
clean:
|
||||||
@echo "Cleaning all up ..."
|
@echo "Cleaning all up ..."
|
||||||
@$(CLEAN)
|
@$(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:
|
buildbin:
|
||||||
@echo "Building $(TARGET).bin for $(DEVICE) @ $(CLOCK)Hz ..."
|
@echo "Building $(TARGET).bin ..."
|
||||||
@$(COMPILE) -o $(TARGET).bin
|
@$(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin
|
||||||
|
|
||||||
buildhex:
|
buildhex:
|
||||||
@echo "Building $(TARGET).hex ..."
|
@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:
|
buildasm:
|
||||||
@echo "Disassembling to $(TARGET).asm ..."
|
@echo "Disassembling to $(TARGET).asm ..."
|
||||||
@$(GCCPATH)/bin/avr-objdump -d $(TARGET).bin > $(TARGET).asm
|
@$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm
|
||||||
|
|
||||||
size:
|
size:
|
||||||
@echo "FLASH: $(shell $(GCCPATH)/bin/avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$1 + $$2}') bytes"
|
@echo "------------------"
|
||||||
@echo "SRAM: $(shell $(GCCPATH)/bin/avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$2 + $$3}') bytes"
|
@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:
|
removetemp:
|
||||||
@echo "Removing temporary files ..."
|
@echo "Removing temporary files ..."
|
||||||
@$(CLEAN)
|
@$(CLEAN)
|
||||||
|
|
||||||
removebin:
|
removeelf:
|
||||||
@echo "Removing $(TARGET).bin ..."
|
@echo "Removing $(TARGET).elf ..."
|
||||||
@rm -f $(TARGET).bin
|
@rm -f $(TARGET).elf
|
||||||
|
@@ -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.
|
|
@@ -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.
|
|
Reference in New Issue
Block a user