Skip to content

Commit ee36a85

Browse files
committed
Editorial changes
1 parent 02e1f21 commit ee36a85

3 files changed

Lines changed: 104 additions & 67 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ Any serial monitor (set BAUD rate to 1000000) can be used for control from the P
8484
### If using the makefile (Linux/Mac)
8585
- 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/).
8686
- Connect your programmer to your PC and to the ICSP header of the device.
87-
- Open the makefile and change the programmer if you are not using usbasp.
8887
- Open a terminal.
8988
- Navigate to the folder with the makefile and the Arduino sketch.
90-
- Run "make install" to compile, burn the fuses and upload the firmware.
89+
- Run `PROGRMR=usbasp make install` to compile, burn the fuses and upload the firmware (change PROGRMR accordingly).
9190

9291
## Installing Python and Drivers
9392
Python needs to be installed on your PC in order to use the software. Most Linux distributions already include this. Windows users can follow these [instructions](https://www.pythontutorial.net/getting-started/install-python/). In addition PySerial and Tkinter (8.6 or newer) must be installed. However, these are already included in most Python installations.

software/atmega328p/makefile

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1+
# ===================================================================================
12
# Project: EEPROM Programmer for ATmega328P(A)
23
# Author: Stefan Wagner
34
# Year: 2019
4-
# URL: https://easyeda.com/wagiminator
5-
# https://github.com/wagiminator
6-
#
5+
# URL: https://github.com/wagiminator
6+
# ===================================================================================
77
# Type "make help" in the command line.
8+
# ===================================================================================
89

910
# Input and Output File Names
10-
SKETCH = EEPROM_Programmer_m328p.ino
11-
TARGET = eeprom_programmer_m328p
12-
13-
# Microcontroller Options
14-
DEVICE = atmega328p
15-
CLOCK = 16000000
16-
PROGRMR = usbasp
17-
LFUSE = 0xff
18-
HFUSE = 0xd3
19-
EFUSE = 0xfc
20-
21-
# Commands
22-
AVRDUDE = avrdude -c $(PROGRMR) -p $(DEVICE)
23-
COMPILE = avr-gcc -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++ $(SKETCH)
24-
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s
11+
SKETCH = EEPROM_Programmer_m328p.ino
12+
TARGET = eeprom_programmer_m328p
13+
14+
# Microcontroller Settings
15+
DEVICE ?= atmega328p
16+
CLOCK = 16000000
17+
LFUSE = 0xff
18+
HFUSE = 0xd3
19+
EFUSE = 0xfc
20+
21+
# Programmer Settings
22+
PROGRMR ?= usbasp
23+
24+
# Toolchain
25+
CC = avr-gcc
26+
OBJCOPY = avr-objcopy
27+
OBJDUMP = avr-objdump
28+
AVRSIZE = avr-size
29+
AVRDUDE = avrdude -c $(PROGRMR) -p $(DEVICE)
30+
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d
31+
32+
# Compiler Flags
33+
CFLAGS = -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++
2534

2635
# Symbolic Targets
2736
help:
2837
@echo "Use the following commands:"
29-
@echo "make all compile and build $(TARGET).bin/.hex/.asm for $(DEVICE)"
38+
@echo "make all compile and build $(TARGET).elf/.bin/.hex/.asm for $(DEVICE)"
3039
@echo "make hex compile and build $(TARGET).hex for $(DEVICE)"
3140
@echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)"
3241
@echo "make bin compile and build $(TARGET).bin for $(DEVICE)"
@@ -35,18 +44,22 @@ help:
3544
@echo "make install compile, upload and burn fuses for $(DEVICE)"
3645
@echo "make clean remove all build files"
3746

38-
all: buildbin buildhex buildasm removetemp size
47+
all: buildelf buildbin buildhex buildasm removetemp size
3948

40-
bin: buildbin removetemp size
49+
elf: buildelf removetemp size
4150

42-
hex: buildbin buildhex removetemp size removebin
51+
bin: buildelf buildbin removetemp size removeelf
4352

44-
asm: buildbin buildasm removetemp size removebin
53+
hex: buildelf buildhex removetemp size removeelf
54+
55+
asm: buildelf buildasm removetemp size removeelf
56+
57+
flash: upload fuses
4558

4659
install: upload fuses
4760

4861
upload: hex
49-
@echo "Uploading to $(DEVICE) ..."
62+
@echo "Uploading $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
5063
@$(AVRDUDE) -U flash:w:$(TARGET).hex:i
5164

5265
fuses:
@@ -56,28 +69,34 @@ fuses:
5669
clean:
5770
@echo "Cleaning all up ..."
5871
@$(CLEAN)
59-
@rm -f $(TARGET).bin $(TARGET).hex $(TARGET).asm
72+
@rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(TARGET).asm
73+
74+
buildelf:
75+
@echo "Compiling $(SKETCH) for $(DEVICE) @ $(CLOCK)Hz ..."
76+
@$(CC) $(CFLAGS) $(SKETCH) -o $(TARGET).elf
6077

6178
buildbin:
62-
@echo "Building $(TARGET).bin for $(DEVICE) @ $(CLOCK)Hz ..."
63-
@$(COMPILE) -o $(TARGET).bin
79+
@echo "Building $(TARGET).bin ..."
80+
@$(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin
6481

6582
buildhex:
6683
@echo "Building $(TARGET).hex ..."
67-
@avr-objcopy -j .text -j .data -O ihex $(TARGET).bin $(TARGET).hex
84+
@$(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
6885

6986
buildasm:
7087
@echo "Disassembling to $(TARGET).asm ..."
71-
@avr-objdump -d $(TARGET).bin > $(TARGET).asm
88+
@$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm
7289

7390
size:
74-
@echo "FLASH: $(shell avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$1 + $$2}') bytes"
75-
@echo "SRAM: $(shell avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$2 + $$3}') bytes"
91+
@echo "------------------"
92+
@echo "FLASH: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$1 + $$2}') bytes"
93+
@echo "SRAM: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$2 + $$3}') bytes"
94+
@echo "------------------"
7695

7796
removetemp:
7897
@echo "Removing temporary files ..."
7998
@$(CLEAN)
8099

81-
removebin:
82-
@echo "Removing $(TARGET).bin ..."
83-
@rm -f $(TARGET).bin
100+
removeelf:
101+
@echo "Removing $(TARGET).elf ..."
102+
@rm -f $(TARGET).elf

software/atmega8/makefile

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1+
# ===================================================================================
12
# Project: EEPROM Programmer for ATmega8(A)
23
# Author: Stefan Wagner
34
# Year: 2019
4-
# URL: https://easyeda.com/wagiminator
5-
# https://github.com/wagiminator
6-
#
5+
# URL: https://github.com/wagiminator
6+
# ===================================================================================
77
# Type "make help" in the command line.
8+
# ===================================================================================
89

910
# Input and Output File Names
10-
SKETCH = EEPROM_Programmer_m8.ino
11-
TARGET = eeprom_programmer_m8
11+
SKETCH = EEPROM_Programmer_m8.ino
12+
TARGET = eeprom_programmer_m8
1213

13-
# Microcontroller Options
14-
DEVICE = atmega8
15-
CLOCK = 16000000
16-
PROGRMR = usbasp
17-
LFUSE = 0x3f
18-
HFUSE = 0xd1
14+
# Microcontroller Settings
15+
DEVICE = atmega8
16+
CLOCK = 16000000
17+
LFUSE = 0x3f
18+
HFUSE = 0xd1
1919

20-
# Commands
21-
AVRDUDE = avrdude -c $(PROGRMR) -p $(DEVICE)
22-
COMPILE = avr-gcc -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++ $(SKETCH)
23-
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s
20+
# Programmer Settings
21+
PROGRMR ?= usbasp
22+
23+
# Toolchain
24+
CC = avr-gcc
25+
OBJCOPY = avr-objcopy
26+
OBJDUMP = avr-objdump
27+
AVRSIZE = avr-size
28+
AVRDUDE = avrdude -c $(PROGRMR) -p $(DEVICE)
29+
CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d
30+
31+
# Compiler Flags
32+
CFLAGS = -Wall -Os -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++
2433

2534
# Symbolic Targets
2635
help:
2736
@echo "Use the following commands:"
28-
@echo "make all compile and build $(TARGET).bin/.hex/.asm for $(DEVICE)"
37+
@echo "make all compile and build $(TARGET).elf/.bin/.hex/.asm for $(DEVICE)"
2938
@echo "make hex compile and build $(TARGET).hex for $(DEVICE)"
3039
@echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)"
3140
@echo "make bin compile and build $(TARGET).bin for $(DEVICE)"
@@ -34,18 +43,22 @@ help:
3443
@echo "make install compile, upload and burn fuses for $(DEVICE)"
3544
@echo "make clean remove all build files"
3645

37-
all: buildbin buildhex buildasm removetemp size
46+
all: buildelf buildbin buildhex buildasm removetemp size
47+
48+
elf: buildelf removetemp size
3849

39-
bin: buildbin removetemp size
50+
bin: buildelf buildbin removetemp size removeelf
4051

41-
hex: buildbin buildhex removetemp size removebin
52+
hex: buildelf buildhex removetemp size removeelf
4253

43-
asm: buildbin buildasm removetemp size removebin
54+
asm: buildelf buildasm removetemp size removeelf
55+
56+
flash: upload fuses
4457

4558
install: upload fuses
4659

4760
upload: hex
48-
@echo "Uploading to $(DEVICE) ..."
61+
@echo "Uploading $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..."
4962
@$(AVRDUDE) -U flash:w:$(TARGET).hex:i
5063

5164
fuses:
@@ -55,28 +68,34 @@ fuses:
5568
clean:
5669
@echo "Cleaning all up ..."
5770
@$(CLEAN)
58-
@rm -f $(TARGET).bin $(TARGET).hex $(TARGET).asm
71+
@rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(TARGET).asm
72+
73+
buildelf:
74+
@echo "Compiling $(SKETCH) for $(DEVICE) @ $(CLOCK)Hz ..."
75+
@$(CC) $(CFLAGS) $(SKETCH) -o $(TARGET).elf
5976

6077
buildbin:
61-
@echo "Building $(TARGET).bin for $(DEVICE) @ $(CLOCK)Hz ..."
62-
@$(COMPILE) -o $(TARGET).bin
78+
@echo "Building $(TARGET).bin ..."
79+
@$(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin
6380

6481
buildhex:
6582
@echo "Building $(TARGET).hex ..."
66-
@avr-objcopy -j .text -j .data -O ihex $(TARGET).bin $(TARGET).hex
83+
@$(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
6784

6885
buildasm:
6986
@echo "Disassembling to $(TARGET).asm ..."
70-
@avr-objdump -d $(TARGET).bin > $(TARGET).asm
87+
@$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm
7188

7289
size:
73-
@echo "FLASH: $(shell avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$1 + $$2}') bytes"
74-
@echo "SRAM: $(shell avr-size -d $(TARGET).bin | awk '/[0-9]/ {print $$2 + $$3}') bytes"
90+
@echo "------------------"
91+
@echo "FLASH: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$1 + $$2}') bytes"
92+
@echo "SRAM: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$2 + $$3}') bytes"
93+
@echo "------------------"
7594

7695
removetemp:
7796
@echo "Removing temporary files ..."
7897
@$(CLEAN)
7998

80-
removebin:
81-
@echo "Removing $(TARGET).bin ..."
82-
@rm -f $(TARGET).bin
99+
removeelf:
100+
@echo "Removing $(TARGET).elf ..."
101+
@rm -f $(TARGET).elf

0 commit comments

Comments
 (0)