Skip to content

Commit

Permalink
Add UNLOCKED_F in Makefile to restore alt methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinHub committed Aug 13, 2019
1 parent 270f843 commit 40310f0
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions Firmware/Chameleon-Mini/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# because Atmel does not ship sh.exe anymore with the toolchain.
SHELL = /bin/sh

# Switch to 'True' to tell if you work with an unlocked flashing setup (AVRISP mkII, or
# original Atmel bootloader), or 'False' else (original RevE rebooted and USB flashing).
# Original RevE rebooted needs specific scrambling to be flashed.
# If you don't know, do not touch!
UNLOCKED_F = False
# Python binary, needed to run scrambling operations to flash.
# Change it according to your system.
PYTHON_BIN = /usr/bin/env python3

#Supported configurations
SETTINGS += -DCONFIG_MF_CLASSIC_1K_SUPPORT
#SETTINGS += -DCONFIG_MF_CLASSIC_1K_7B_SUPPORT
Expand Down Expand Up @@ -102,19 +111,19 @@ OBJDIR = Bin
OBJECT_FILES =
CRYPTO_TOOL = ../../Software/Tools/crypt_operations.py


ifeq ($(UNLOCKED_F),True)
#AVRDUDE settings
#AVRDUDE_PROGRAMMER = flip2
#AVRDUDE_MCU = $(MCU)
#AVRDUDE_PORT = usb
#AVRDUDE_WRITE_APP = -U application:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_PROGRAMMER = flip2
AVRDUDE_MCU = $(MCU)
AVRDUDE_PORT = usb
AVRDUDE_WRITE_APP = -U application:w:$(TARGET).hex
AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)

#AVRDUDE settings to program the precompiled firmware
#AVRDUDE_WRITE_APP_LATEST = -U application:w:Latest/Chameleon-Mini.hex
#AVRDUDE_WRITE_EEPROM_LATEST = -U eeprom:w:Latest/Chameleon-Mini.eep

AVRDUDE_WRITE_APP_LATEST = -U application:w:Latest/Chameleon-Mini.hex
AVRDUDE_WRITE_EEPROM_LATEST = -U eeprom:w:Latest/Chameleon-Mini.eep
endif

# Default target
all:
Expand Down Expand Up @@ -144,26 +153,39 @@ spmhelper: $(TARGET).elf
@echo $(MSG_OBJCPY_CMD) Extracting SPM helper HEX file from $(TARGET).elf
$(CROSS)-objcopy -O ihex -j .spmhelper $(SPM_HELPER_OBJCOPY) $(TARGET).elf $(TARGET).hex

ifeq ($(UNLOCKED_F),True)
# Program the device using avrdude
#program: $(TARGET).hex $(TARGET).eep
# avrdude $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_APP) $(AVRDUDE_WRITE_EEPROM)
program: $(TARGET).hex $(TARGET).eep
avrdude $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_APP) $(AVRDUDE_WRITE_EEPROM)

# Program the device using avrdude with the latest official firmware
#program-latest:
# avrdude $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_APP_LATEST) $(AVRDUDE_WRITE_EEPROM_LATEST)
program-latest:
avrdude $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_APP_LATEST) $(AVRDUDE_WRITE_EEPROM_LATEST)

# Program the device using batchisp and the DFU bootloader
# Note that the device has to be in bootloader mode already
#dfu-flip: $(TARGET).hex $(TARGET).eep
# cp $(TARGET).eep EEPROM.hex
# batchisp -hardware usb -device $(MCU) -operation erase f memory FLASH loadbuffer $(TARGET).hex program verify memory EEPROM loadbuffer EEPROM.hex program verify start reset 0
# rm EEPROM.hex
dfu-flip: $(TARGET).hex $(TARGET).eep
cp $(TARGET).eep EEPROM.hex
batchisp -hardware usb -device $(MCU) -operation erase f memory FLASH loadbuffer $(TARGET).hex program verify memory EEPROM loadbuffer EEPROM.hex program verify start reset 0
rm EEPROM.hex

# Program the device using dfu-programmer
# Program the device using dfu-programmer in unlocked flashing conditions
# Note that the device has to be in bootloader mode already
# dfu-programmer >= 0.7.2 required
dfu-prog: $(TARGET).hex $(TARGET).eep
python3 $(CRYPTO_TOOL) scramblehex $(TARGET).eep $(TARGET).eep.scramble
python3 $(CRYPTO_TOOL) scramblehex $(TARGET).hex $(TARGET).hex.scramble
-dfu-programmer $(MCU) erase --force
dfu-programmer $(MCU) flash --eeprom --force --suppress-validation $(TARGET).eep
dfu-programmer $(MCU) flash --force --suppress-validation $(TARGET).hex

else
# Program the device using dfu-programmer for unlocked RevE rebooted USB DFU scenario
# Note that the device has to be in bootloader mode already
# dfu-programmer >= 0.7.2 required
dfu-prog: $(TARGET).hex $(TARGET).eep
$(PYTHON_BIN) $(CRYPTO_TOOL) scramblehex $(TARGET).eep $(TARGET).eep.scramble
$(PYTHON_BIN) $(CRYPTO_TOOL) scramblehex $(TARGET).hex $(TARGET).hex.scramble
-dfu-programmer $(MCU) erase --force
dfu-programmer $(MCU) flash --eeprom --force --suppress-validation $(TARGET).eep.scramble
dfu-programmer $(MCU) flash --force --suppress-validation $(TARGET).hex.scramble
rm $(TARGET).eep.scramble $(TARGET).hex.scramble
endif

0 comments on commit 40310f0

Please sign in to comment.