better makefile n readme

pull/1/head
Ondřej Hruška 8 years ago
parent 8946755340
commit b26ba76d45
  1. 23
      Makefile
  2. 26
      README.md

@ -11,9 +11,13 @@ LFUSE = 0xFF
HFUSE = 0xDE
EFUSE = 0x05
# Avrdude settings
# AVRDUDE settings
PROG_BAUD = 57600
PROG_DEV = /dev/ttyUSB0
PROG_TYPE = arduino
PROG_ARGS = -b 57600 -P /dev/ttyUSB0
# Build the final AVRDUDE arguments
PROG_ARGS = -c $(PROG_TYPE) -p $(MCU) -b $(PROG_BAUD) -P $(PROG_DEV)
#############################################
@ -112,23 +116,22 @@ clean:
## === avrdude ===
flash: $(BINARY).hex
$(AVRDUDE) -c $(PROG_TYPE) -p $(MCU) $(PROG_ARGS) -U flash:w:$<
$(AVRDUDE) $(PROG_ARGS) -U flash:w:$<
flashe: $(BINARY).eeprom
$(AVRDUDE) -c $(PROG_TYPE) -p $(MCU) $(PROG_ARGS) -U eeprom:w:$<
$(AVRDUDE) $(PROG_ARGS) -U eeprom:w:$<
shell:
$(AVRDUDE) -c $(PROG_TYPE) -p $(MCU) $(PROG_ARGS) -nt
$(AVRDUDE) $(PROG_ARGS) -nt
# === fuses ===
# this may not work with the arduino programmer, I haven't tried.
FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
fuses:
$(AVRDUDE) -c $(PROG_TYPE) -p $(MCU) $(PROG_ARGS) $(FUSE_STRING)
$(AVRDUDE) $(PROG_ARGS) $(FUSE_STRING)
show_fuses:
$(AVRDUDE) -c $(PROG_TYPE) -p $(MCU) $(PROG_ARGS) -nv
set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
set_default_fuses: fuses
$(AVRDUDE) $(PROG_ARGS) -nv

@ -37,16 +37,30 @@ The provided `main.c` is a good starting point - it contains some simple demo co
You can compile it with `make` and flash with `make flash`.
### "It doesn't work"
### Before you can flash
**Before you can flash,** check that the `avrdude` options in the file are correct for your system - especially
the device (`/dev/ttyUSB0`). It can differ if you're on Mac or Windows (`/dev/cu.xxx`, resp. `COMx`).
First, check that the `avrdude` options in the file are correct for your system - especially
the device and speed.
You may also adjust the baudrate (`-b 57600`). Some boards need 115200 or a different value.
```ini
# AVRDUDE settings
PROG_BAUD = 57600
PROG_DEV = /dev/ttyUSB0
PROG_TYPE = arduino
You can look what the Arduino IDE is using - it's running avrdude too.
# Build the final AVRDUDE arguments
PROG_ARGS = -c $(PROG_TYPE) -p $(MCU) -b $(PROG_BAUD) -P $(PROG_DEV)
```
Adjust `PROG_DEV` to the device your board is connected to. On Linux it's usually `/dev/ttyUSB0`, but it can also be `/dev/ttyACM0` or something else. On Mac, it'll be `/dev/cu.xxx`, on Windows it's some `COMx`.
Linux and Mac users can just `ls /dev` to see what devices they have. Windows users can find this in their Device Manager.
You may also adjust the baudrate (`PROG_BAUD`). Some boards need `115200`.
**TIP:** You can look what the Arduino IDE is using - it's running avrdude too.
### Adding files to the Makefile
### Adding new files
- If you *add a new C file* to the project, add an entry for it's `.o` (object file,
created by the compiler before linking) to the `OBJS` list in the Makefile.

Loading…
Cancel
Save