Editorial changes
parent
ed4508b07a
commit
12bb0422eb
|
|
@ -58,10 +58,9 @@ Since there is no ICSP header on the board, you have to program the ATtiny eithe
|
|||
### If using the makefile (Linux/Mac)
|
||||
- Make sure you have installed [avr-gcc toolchain and avrdude](http://maxembedded.com/2015/06/setting-up-avr-gcc-toolchain-on-linux-and-mac-os-x/).
|
||||
- Connect your programmer to your PC and to the ATtiny.
|
||||
- Open the makefile and change the chip if you are not using ATtiny85 and the programmer if you are not using usbasp.
|
||||
- Open a terminal.
|
||||
- Navigate to the folder with the makefile and the Arduino sketch.
|
||||
- Run "make install" to compile, burn the fuses and upload the firmware.
|
||||
- Run `DEVICE=attiny85 PROGRMR=usbasp make install` to compile, burn the fuses and upload the firmware (change DEVICE and PROGRMR accordingly).
|
||||
|
||||
# Operating Instructions
|
||||
1. Connect the device between a power supply and a consumer.
|
||||
|
|
|
|||
|
|
@ -1,31 +1,41 @@
|
|||
# ===================================================================================
|
||||
# Project: USB-Tester
|
||||
# Author: Stefan Wagner
|
||||
# Year: 2020
|
||||
# URL: https://github.com/wagiminator
|
||||
#
|
||||
# ===================================================================================
|
||||
# Type "make help" in the command line.
|
||||
# ===================================================================================
|
||||
|
||||
# Input and Output File Names
|
||||
SKETCH = USB_Tester.ino
|
||||
TARGET = usb_tester
|
||||
|
||||
# Microcontroller Options
|
||||
DEVICE = attiny85
|
||||
# Microcontroller Settings
|
||||
DEVICE ?= attiny85
|
||||
CLOCK = 1000000
|
||||
PROGRMR = usbasp
|
||||
LFUSE = 0x62
|
||||
HFUSE = 0xD5
|
||||
EFUSE = 0xFF
|
||||
|
||||
# Commands
|
||||
# Programmer Settings
|
||||
PROGRMR ?= usbasp
|
||||
|
||||
# Toolchain
|
||||
CC = avr-gcc
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
AVRSIZE = avr-size
|
||||
AVRDUDE = avrdude -c $(PROGRMR) -p $(DEVICE)
|
||||
COMPILE = avr-gcc -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++ $(SKETCH)
|
||||
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s
|
||||
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d
|
||||
|
||||
# Compiler Flags
|
||||
CFLAGS = -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++
|
||||
|
||||
# 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)"
|
||||
|
|
@ -34,18 +44,22 @@ 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
|
||||
|
||||
asm: buildelf buildasm removetemp size removeelf
|
||||
|
||||
flash: upload fuses
|
||||
|
||||
install: upload fuses
|
||||
|
||||
upload: hex
|
||||
@echo "Uploading to $(DEVICE) ..."
|
||||
@echo "Uploading $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
|
||||
@$(AVRDUDE) -U flash:w:$(TARGET).hex:i
|
||||
|
||||
fuses:
|
||||
|
|
@ -55,28 +69,34 @@ fuses:
|
|||
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 ..."
|
||||
@avr-objcopy -j .text -j .data -O ihex $(TARGET).bin $(TARGET).hex
|
||||
@$(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
|
||||
|
||||
buildasm:
|
||||
@echo "Disassembling to $(TARGET).asm ..."
|
||||
@avr-objdump -d $(TARGET).bin > $(TARGET).asm
|
||||
@$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm
|
||||
|
||||
size:
|
||||
@echo "FLASH: $(shell avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$1 + $$2}') bytes"
|
||||
@echo "SRAM: $(shell 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue