From 0eb655a0fb5285bf774a3acabeed3ce048b2ef0a Mon Sep 17 00:00:00 2001 From: WestfW Date: Sun, 29 Jul 2018 01:35:54 -0700 Subject: [PATCH] Reorganize Makefiles slightly; implement "make help" Make things reasonably self-documenting. Group related options together (LED, COMM, extra features.) Group similar targets together. Or less randomly, anyway. --- optiboot/bootloaders/optiboot/Makefile | 146 ++++++++++-------- optiboot/bootloaders/optiboot/Makefile.1284 | 7 + optiboot/bootloaders/optiboot/Makefile.2560 | 2 + optiboot/bootloaders/optiboot/Makefile.atmel | 3 + optiboot/bootloaders/optiboot/Makefile.custom | 1 + optiboot/bootloaders/optiboot/Makefile.extras | 11 ++ 6 files changed, 105 insertions(+), 65 deletions(-) diff --git a/optiboot/bootloaders/optiboot/Makefile b/optiboot/bootloaders/optiboot/Makefile index c756333..5b0341f 100644 --- a/optiboot/bootloaders/optiboot/Makefile +++ b/optiboot/bootloaders/optiboot/Makefile @@ -39,6 +39,7 @@ # * This software is licensed under version 2 of the Gnu Public Licence. # * See optiboot.c for details. +HELPTEXT = "" #---------------------------------------------------------------------- # # program name should not be changed... @@ -144,6 +145,7 @@ SIZE = $(GCCROOT)avr-size # appropriate parameters ("-DLED_START_FLASHES=10") to gcc # +HELPTEXT += "Option BAUD_RATE=nnnn - set the bit rate for communications\n" ifdef BAUD_RATE BAUD_RATE_CMD = -DBAUD_RATE=$(BAUD_RATE) dummy = FORCE @@ -151,6 +153,13 @@ else BAUD_RATE_CMD = -DBAUD_RATE=115200 endif +HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n" +ifdef LED +LED_CMD = -DLED=$(LED) +dummy = FORCE +endif + +HELPTEXT += "Option LED_START_FLASHES=n - set number of LED flashes when bootloader starts\n" ifdef LED_START_FLASHES LED_START_FLASHES_CMD = -DLED_START_FLASHES=$(LED_START_FLASHES) dummy = FORCE @@ -158,28 +167,7 @@ else LED_START_FLASHES_CMD = -DLED_START_FLASHES=3 endif -ifdef LED_START_ON -ifneq ($(LED_START_ON), 0) -LED_START_ON_CMD = -DLED_START_ON=1 -endif -dummy = FORCE -endif - -# BIG_BOOT: Include extra features, up to 1K. -ifdef BIGBOOT -ifneq ($(BIGBOOT), 0) -BIGBOOT_CMD = -DBIGBOOT=1 -dummy = FORCE -endif -endif - -ifdef SOFT_UART -ifneq ($(SOFT_UART), 0) -SOFT_UART_CMD = -DSOFT_UART=1 -dummy = FORCE -endif -endif - +HELPTEXT += "Option LED_DATA_FLASH=1 - flash the LED each time data is received.\n" ifdef LED_DATA_FLASH ifneq ($(LED_DATA_FLASH), 0) LED_DATA_FLASH_CMD = -DLED_DATA_FLASH=1 @@ -187,11 +175,40 @@ dummy = FORCE endif endif -ifdef LED -LED_CMD = -DLED=$(LED) +HELPTEXT += "Option LED_START_ON=1 - Turn the LED on at bootload start\n" +ifdef LED_START_ON +ifneq ($(LED_START_ON), 0) +LED_START_ON_CMD = -DLED_START_ON=1 +endif dummy = FORCE endif +HELPTEXT += "Option BIGBOOT=1 - enable extra features up to 1kbytes\n" +# BIGBOOT: Include extra features, up to 1K. +ifdef BIGBOOT +ifneq ($(BIGBOOT), 0) +BIGBOOT_CMD = -DBIGBOOT=1 +dummy = FORCE +endif +endif + +HELPTEXT += "Option SUPPORT_EEPROM=1 - Include code to read/write EEPROM\n" +ifdef SUPPORT_EEPROM +ifneq ($(SUPPORT_EEPROM), 0) +SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM +dummy = FORCE +endif +endif + + +HELPTEXT += "Option SOFT_UART=1 - use a software (bit-banged) UART\n" +ifdef SOFT_UART +ifneq ($(SOFT_UART), 0) +SOFT_UART_CMD = -DSOFT_UART=1 +dummy = FORCE +endif +endif + ifdef SINGLESPEED ifneq ($(SINGLESPEED), 0) SS_CMD = -DSINGLESPEED=1 @@ -203,16 +220,11 @@ COMMON_OPTIONS += $(SOFT_UART_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(SS_CMD) COMMON_OPTIONS += $(SUPPORT_EEPROM_CMD) $(LED_START_ON_CMD) #UART is handled separately and only passed for devices with more than one. +HELPTEXT += "Option UART=n - use UARTn for communications\n" ifdef UART UART_CMD = -DUART=$(UART) endif -ifdef SUPPORT_EEPROM -ifneq ($(SUPPORT_EEPROM), 0) -SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM -dummy = FORCE -endif -endif # Not supported yet # ifdef TIMEOUT_MS @@ -244,8 +256,11 @@ endif #--------------------------------------------------------------------------- # +HELPTEXT += "\n-------------\n\n" + # Test platforms # Virtual boot block test +HELPTEXT += "target virboot8 - ATmega8 with virtual boot partition\n" virboot8: TARGET = atmega8 virboot8: MCU_TARGET = atmega8 virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-Dsave_vect_num=EE_RDY_vect_num' @@ -256,6 +271,7 @@ virboot8: $(PROGRAM)_virboot8.hex virboot8: $(PROGRAM)_virboot8.lst +HELPTEXT += "target virboot328p - ATmega328 with virtual boot partition\n" virboot328: TARGET = atmega328 virboot328: MCU_TARGET = atmega328p virboot328: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' @@ -291,7 +307,37 @@ virboot8_isp: isp # Diecimila, Duemilanove with m168, and NG use identical bootloaders # Call it "atmega168" for generality and clarity, keep "diecimila" for # backward compatibility of makefile + +# ATmega8 # +HELPTEXT += "target atmega8 - ATmega8, ATmega8A, ATmega8L\n" +atmega8: TARGET = atmega8 +atmega8: MCU_TARGET = atmega8 +atmega8: CFLAGS += $(COMMON_OPTIONS) +atmega8: AVR_FREQ ?= 16000000L +ifndef BIGBOOT +atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version +else +atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version +endif +atmega8: $(PROGRAM)_atmega8.hex +atmega8: $(PROGRAM)_atmega8.lst + +atmega8_isp: atmega8 +atmega8_isp: TARGET = atmega8 +atmega8_isp: MCU_TARGET = atmega8 +ifndef BIGBOOT +# SPIEN, CKOPT (for full swing xtal), Bootsize=512B +atmega8_isp: HFUSE ?= CC +else +# SPIEN, CKOPT (for full swing xtal), Bootsize=1024B +atmega8_isp: HFUSE ?= CA +endif +# 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms +atmega8_isp: LFUSE ?= BF +atmega8_isp: isp + +HELPTEXT += "target atmega168 - ATmega168, ATmega168A\n" atmega168: TARGET = atmega168 atmega168: MCU_TARGET = atmega168 atmega168: CFLAGS += $(COMMON_OPTIONS) @@ -319,13 +365,7 @@ atmega168_isp: EFUSE ?= FA endif atmega168_isp: isp -atmega16: TARGET = atmega16 -atmega16: MCU_TARGET = atmega16 -atmega16: CFLAGS += $(COMMON_OPTIONS) -atmega16: AVR_FREQ ?= 16000000L -atmega16: $(PROGRAM)_atmega16.hex -atmega16: $(PROGRAM)_atmega16.lst - +HELPTEXT += "target atmega328 - ATmega328p\n" atmega328: TARGET = atmega328 atmega328: MCU_TARGET = atmega328p atmega328: CFLAGS += $(COMMON_OPTIONS) @@ -356,6 +396,7 @@ atmega328_isp: EFUSE ?= FD atmega328_isp: isp #Atmega1280 +HELPTEXT += "target atmega1280 - ATmega1280 (100pin, 128k)\n" atmega1280: MCU_TARGET = atmega1280 atmega1280: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD) atmega1280: AVR_FREQ ?= 16000000L @@ -364,34 +405,6 @@ atmega1280: $(PROGRAM)_atmega1280.hex atmega1280: $(PROGRAM)_atmega1280.lst -# ATmega8 -# -atmega8: TARGET = atmega8 -atmega8: MCU_TARGET = atmega8 -atmega8: CFLAGS += $(COMMON_OPTIONS) -atmega8: AVR_FREQ ?= 16000000L -ifndef BIGBOOT -atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -else -atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -endif -atmega8: $(PROGRAM)_atmega8.hex -atmega8: $(PROGRAM)_atmega8.lst - -atmega8_isp: atmega8 -atmega8_isp: TARGET = atmega8 -atmega8_isp: MCU_TARGET = atmega8 -ifndef BIGBOOT -# SPIEN, CKOPT (for full swing xtal), Bootsize=512B -atmega8_isp: HFUSE ?= CC -else -# SPIEN, CKOPT (for full swing xtal), Bootsize=1024B -atmega8_isp: HFUSE ?= CA -endif -# 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms -atmega8_isp: LFUSE ?= BF -atmega8_isp: isp - #--------------------------------------------------------------------------- # "Board-level Platform" targets. @@ -598,3 +611,6 @@ clean: %.bin: %.elf $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@ + +help: + @echo $(HELPTEXT) diff --git a/optiboot/bootloaders/optiboot/Makefile.1284 b/optiboot/bootloaders/optiboot/Makefile.1284 index 81b10c1..a7485ee 100644 --- a/optiboot/bootloaders/optiboot/Makefile.1284 +++ b/optiboot/bootloaders/optiboot/Makefile.1284 @@ -7,6 +7,7 @@ # Chip level targets # +HELPTEXT += "target atmega644p - ATmega644p\n" atmega644p: TARGET = atmega644p atmega644p: MCU_TARGET = atmega644p atmega644p: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT @@ -16,6 +17,7 @@ atmega644p: CFLAGS += $(UART_CMD) atmega644p: $(PROGRAM)_atmega644p.hex atmega644p: $(PROGRAM)_atmega644p.lst +HELPTEXT += "target atmega1284 - ATmega1284p (40 pin, 128k)\n" atmega1284: TARGET = atmega1284p atmega1284: MCU_TARGET = atmega1284p atmega1284: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT @@ -44,6 +46,7 @@ atmega1284_isp: isp # Sanguino has a minimum boot size of 1024 bytes, so enable extra functions # +HELPTEXT += "target sanguino - ATmega644p board\n" sanguino: TARGET = $@ sanguino: CHIP = atmega644p sanguino: @@ -62,6 +65,7 @@ sanguino_isp: LFUSE ?= F7 sanguino_isp: EFUSE ?= FD sanguino_isp: isp +HELPTEXT += "target mighty1284 - ManiacBug Mighty1284 board\n" mighty1284: TARGET = $@ mighty1284: CHIP = atmega1284p mighty1284: @@ -80,6 +84,7 @@ mighty1284_isp: LFUSE ?= F7 mighty1284_isp: EFUSE ?= FD mighty1284_isp: isp +HELPTEXT += "target bobuino - Crossroads 1284 board\n" bobuino: TARGET = $@ bobuino: CHIP = atmega1284p bobuino: @@ -102,6 +107,7 @@ bobuino_isp: isp # Wicked Devices "Wildfire" boards (1284 with wireless!) # +HELPTEXT += "target wildfirev2 - Wicked Devices board\n" wildfirev2: TARGET = $@ wildfirev2: CHIP = atmega1284p wildfirev2: @@ -120,6 +126,7 @@ wildfirev2_isp: LFUSE ?= F7 wildfirev2_isp: EFUSE ?= FD wildfirev2_isp: isp +HELPTEXT += "target wildfirev3 - Wicked Devices board\n" wildfirev3: TARGET = $@ wildfirev3: CHIP = atmega1284p wildfirev3: diff --git a/optiboot/bootloaders/optiboot/Makefile.2560 b/optiboot/bootloaders/optiboot/Makefile.2560 index c4faa03..a0df373 100644 --- a/optiboot/bootloaders/optiboot/Makefile.2560 +++ b/optiboot/bootloaders/optiboot/Makefile.2560 @@ -7,6 +7,7 @@ # Chip level targets # +HELPTEXT += "target atmega2560 - ATmega2560p (100pin, 256k)\n" atmega2560: TARGET = atmega2560 atmega2560: MCU_TARGET = atmega2560 atmega2560: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT @@ -34,6 +35,7 @@ atmega2560_isp: isp # Arduino/Geniuno MEGA 256 has a minimum boot size of 1024 bytes, so enable extra functions # +HELPTEXT += "target mega2560 - Arduino MEGA2560 board, 2560ADK\n" mega2560: TARGET = $@ mega2560: CHIP = atmega2560 mega2560: diff --git a/optiboot/bootloaders/optiboot/Makefile.atmel b/optiboot/bootloaders/optiboot/Makefile.atmel index 2b0b1af..8c45bc2 100644 --- a/optiboot/bootloaders/optiboot/Makefile.atmel +++ b/optiboot/bootloaders/optiboot/Makefile.atmel @@ -12,6 +12,7 @@ # # # +HELPTEXT += "target xplained168pb - Atmel Xplained Mini 168pb Eval board\n" xplained168pb: TARGET = $@ xplained168pb: CHIP = atmega168 xplained168pb: @@ -19,6 +20,7 @@ xplained168pb: mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst +HELPTEXT += "target xplained328pb - Atmel Xplained Mini 328pb Eval board\n" xplained328pb: TARGET = $@ xplained328pb: CHIP = atmega328 xplained328pb: @@ -26,6 +28,7 @@ xplained328pb: mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst +HELPTEXT += "target xplained328p - Atmel Xplained Mini 328p Eval board\n" xplained328p: TARGET = $@ xplained328p: CHIP = atmega328 xplained328p: diff --git a/optiboot/bootloaders/optiboot/Makefile.custom b/optiboot/bootloaders/optiboot/Makefile.custom index dee23ff..aa970ab 100644 --- a/optiboot/bootloaders/optiboot/Makefile.custom +++ b/optiboot/bootloaders/optiboot/Makefile.custom @@ -6,6 +6,7 @@ # * See optiboot.c for details. +HELPTEXT += "target wildfire - Wicked Devices Wildfire v1 board\n" wildfire: TARGET = $@ wildfire: CHIP = atmega1284p wildfire: diff --git a/optiboot/bootloaders/optiboot/Makefile.extras b/optiboot/bootloaders/optiboot/Makefile.extras index b10ddad..996a740 100644 --- a/optiboot/bootloaders/optiboot/Makefile.extras +++ b/optiboot/bootloaders/optiboot/Makefile.extras @@ -14,6 +14,7 @@ # # ATmega88 # +HELPTEXT += "target atmega88 - ATmega88 or ATmega88p (28pin, 8k)\n" atmega88: TARGET = atmega88 atmega88: MCU_TARGET = atmega88 atmega88: CFLAGS += $(COMMON_OPTIONS) @@ -47,6 +48,7 @@ atmega88p_isp: isp # # ATmega168p [QFN32] # +HELPTEXT += "target atmega168p - ATmega168p\n" atmega168p: TARGET = atmega168p atmega168p: MCU_TARGET = atmega168p atmega168p: CFLAGS += $(COMMON_OPTIONS) @@ -64,9 +66,18 @@ atmega168p_isp: LFUSE ?= FF atmega168p_isp: EFUSE ?= 04 atmega168p_isp: isp +HELPTEXT += "target atmega16 - ATmega16 (40pin, 16k)\n" +atmega16: TARGET = atmega16 +atmega16: MCU_TARGET = atmega16 +atmega16: CFLAGS += $(COMMON_OPTIONS) +atmega16: AVR_FREQ ?= 16000000L +atmega16: $(PROGRAM)_atmega16.hex +atmega16: $(PROGRAM)_atmega16.lst + # # ATmega32 # +HELPTEXT += "target atmega32 - ATmega32 (40pin, 32k)\n" atmega32: TARGET = atmega32 atmega32: MCU_TARGET = atmega32 atmega32: CFLAGS += $(COMMON_OPTIONS)