-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also include the codgen-units=1 workaround for a rustc segfault when building this crate in release mode. Some details here: rust-lang/rust#62896
- Loading branch information
1 parent
ed154b8
commit de39296
Showing
4 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.PHONY: upload | ||
|
||
BIN=rust-test | ||
DEVICE=/dev/ttyUSB0 | ||
RELEASE_DIR=target/avr-unknown-gnu-atmega2560/release | ||
ELF=$(RELEASE_DIR)/$(BIN).elf | ||
HEX=$(RELEASE_DIR)/$(BIN).hex | ||
EEP=$(RELEASE_DIR)/$(BIN).eep | ||
SRC=$(wildcard **/*.rs) | ||
|
||
build: $(HEX) | ||
|
||
upload: $(HEX) | ||
avrdude -patmega2560 -cwiring -P$(DEVICE) -b115200 -D -Uflash:w:$(HEX):i | ||
|
||
# rust builds a .elf file | ||
$(ELF): $(SRC) | ||
cargo build --release | ||
|
||
# convert elf to hex for the programmer, pull .eeprom out because that is | ||
# programmed separately | ||
# ihex is short for "intel hex", which is recognized by avrdude | ||
$(HEX): $(ELF) | ||
avr-objcopy -O ihex -R .eeprom $(ELF) $(HEX) | ||
|
||
# pull .eeprom from the elf and create a separate file representing what should | ||
# be written to the eeprom (this file is currently unused in the build process) | ||
# eeprom can also be programmed by avrdude's -U | ||
$(EEP): $(ELF) | ||
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(ELF) $(EEP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters