Skip to content

Commit

Permalink
Improve Makefile.usbmcus default parameter assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Virtual-Java committed Oct 3, 2021
1 parent b82e1f3 commit 89ea5b2
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 63 deletions.
5 changes: 4 additions & 1 deletion optiboot/bootloaders/optiboot/Makefile.isp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ ifdef EFUSE
EFUSE_CMD= -U efuse:w:0x$(EFUSE):m
endif

# Default lock fuse configuration (NO lock)
LOCKFUSE ?=3f# = APP protect mode 1, BL protect mode 1

#
# avrdude commands to erase chip, unlock memory, and program fuses.
#
ISPFUSES = -e -u -U lock:w:0x3f:m $(EFUSE_CMD) \
ISPFUSES = -e -u -U lock:w:0x$(LOCKFUSE):m $(EFUSE_CMD) \
-U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m


Expand Down
78 changes: 57 additions & 21 deletions optiboot/bootloaders/optiboot/Makefile.usbmcus
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ ifndef PRODUCTION
atmega8u2atUART: $(PROGRAM)_atmega8u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega8u2:
"$(MAKE)" atmega8u2atUART UART=1
"$(MAKE)" atmega8u2atUART UART?=1

atmega8u2_isp: atmega8u2
atmega8u2_isp: TARGET = atmega8u2
atmega8u2_isp: MCU_TARGET = atmega8u2
atmega8u2_isp: HFUSE ?= DE # 512 byte boot, JTAG disabled
atmega8u2_isp: LFUSE ?= FF # Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega8u2_isp: EFUSE ?= FE # 2.7V brownout
atmega8u2_isp: LOCK ?= 2F # APP protect mode 1, BL protect mode 2
atmega8u2_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega8u2_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega8u2_isp: EFUSE ?= FE# = 2.7V brownout
atmega8u2_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega8u2_isp: isp


Expand All @@ -55,15 +55,15 @@ ifndef PRODUCTION
atmega16u2atUART: $(PROGRAM)_atmega16u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega16u2:
"$(MAKE)" atmega16u2atUART UART=1
"$(MAKE)" atmega16u2atUART UART?=1

atmega16u2_isp: atmega16u2
atmega16u2_isp: TARGET = atmega16u2
atmega16u2_isp: MCU_TARGET = atmega16u2
atmega16u2_isp: HFUSE ?= DE # 512 byte boot, JTAG disabled
atmega16u2_isp: LFUSE ?= FF # Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega16u2_isp: EFUSE ?= FE # 2.7V brownout
atmega16u2_isp: LOCK ?= 2F # APP protect mode 1, BL protect mode 2
atmega16u2_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega16u2_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega16u2_isp: EFUSE ?= FE# = 2.7V brownout
atmega16u2_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega16u2_isp: isp


Expand All @@ -81,15 +81,15 @@ ifndef PRODUCTION
atmega32u2atUART: $(PROGRAM)_atmega32u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega32u2:
"$(MAKE)" atmega32u2atUART UART=1
"$(MAKE)" atmega32u2atUART UART?=1

atmega32u2_isp: atmega32u2
atmega32u2_isp: TARGET = atmega32u2
atmega32u2_isp: MCU_TARGET = atmega32u2
atmega32u2_isp: HFUSE ?= DE # 512 byte boot, JTAG disabled
atmega32u2_isp: LFUSE ?= FF # Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega32u2_isp: EFUSE ?= FE # 2.7V brownout
atmega32u2_isp: LOCK ?= 2F # APP protect mode 1, BL protect mode 2
atmega32u2_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega32u2_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega32u2_isp: EFUSE ?= FE# = 2.7V brownout
atmega32u2_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega32u2_isp: isp


Expand All @@ -108,15 +108,15 @@ atmega16u4atUART: $(PROGRAM)_atmega16u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega16u4:
# disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection
"$(MAKE)" atmega16u4atUART UART=1
"$(MAKE)" atmega16u4atUART UART?=1 LED_START_FLASHES?=0

atmega16u4_isp: atmega16u4
atmega16u4_isp: TARGET = atmega16u4
atmega16u4_isp: MCU_TARGET = atmega16u4
atmega16u4_isp: HFUSE ?= DE # 512 byte boot, JTAG disabled
atmega16u4_isp: LFUSE ?= FF # Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega16u4_isp: EFUSE ?= FB # 2.6V brownout
atmega16u4_isp: LOCK ?= 2F # APP protect mode 1, BL protect mode 2
atmega16u4_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega16u4_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega16u4_isp: EFUSE ?= FB# = 2.6V brownout
atmega16u4_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega16u4_isp: isp


Expand All @@ -135,5 +135,41 @@ atmega32u4atUART: $(PROGRAM)_atmega32u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega32u4:
# disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection
"$(MAKE)" atmega32u4atUART UART=1 LED_START_FLASHES=0
"$(MAKE)" atmega32u4atUART UART?=1 LED_START_FLASHES?=0

atmega32u4_isp: atmega32u4
atmega32u4_isp: TARGET = atmega32u4
atmega32u4_isp: MCU_TARGET = atmega32u4
atmega32u4_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega32u4_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega32u4_isp: EFUSE ?= FB# = 2.6V brownout
atmega32u4_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega32u4_isp: isp


#-----------------------
# ATmega 32u6
#-----------------------
#ATmega32u6
atmega32u6atUART: TARGET = atmega32u6
atmega32u6atUART: MCU_TARGET = atmega32u6
atmega32u6atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
atmega32u6atUART: AVR_FREQ ?= 16000000L
atmega32u6atUART: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega32u6atUART: $(PROGRAM)_atmega32u6_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
ifndef PRODUCTION
atmega32u6atUART: $(PROGRAM)_atmega32u6_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
endif
atmega32u6:
# disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection
"$(MAKE)" atmega32u6atUART UART?=1

atmega32u6_isp: atmega32u6
atmega32u6_isp: TARGET = atmega32u6
atmega32u6_isp: MCU_TARGET = atmega32u6
atmega32u6_isp: HFUSE ?= DE# = 512 byte boot, JTAG disabled
atmega32u6_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms
atmega32u6_isp: EFUSE ?= FB# = 2.6V brownout
atmega32u6_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2
atmega32u6_isp: isp

1 change: 1 addition & 0 deletions optiboot/bootloaders/optiboot/makeall.usbmcus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare -a mcu_and_params=(
"atmega32u2" "LED=D5 LED_START_FLASHES=2 UART=1"
"atmega16u4" "LED=C7 LED_START_FLASHES=0 UART=1" # disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection
"atmega32u4" "LED=C7 LED_START_FLASHES=0 UART=1" # disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection
"atmega32u6" "LED=C6 LED_START_FLASHES=2 UART=1" # for some reason it is not necessary to disable blinking the LED for this device
)

declare -a clock_and_baud=(
Expand Down
61 changes: 20 additions & 41 deletions optiboot/bootloaders/optiboot/pin_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,9 @@
#endif

/*------------------------------------------------------------------------ */
#if defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)
#if defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) \
|| (__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U6__)
/*------------------------------------------------------------------------ */

#if !defined(LED)
#define LED D5
#endif

/* Fix different register names */
#define MPCM0 MPCM1
#define U2X0 U2X1
Expand Down Expand Up @@ -525,53 +521,36 @@
#define UART_TX_BIT 3
#define UART_RX_BIT 2
#endif

/*------------------------------------------------------------------------ */
#if defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)
/*------------------------------------------------------------------------ */

#if !defined(LED)
#define LED D5 // because of Arduino Uno USB-MCU TXLED
#endif
#endif // AtmegaXYu2

/*------------------------------------------------------------------------ */
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
/*------------------------------------------------------------------------ */

#if !defined(LED)
#define LED C7
#define LED C7 // because of Arduino Micro LED_BUILTIN (D13)
#endif
#endif // AtmegaXYu4

/* Fix different register names */
#define MPCM0 MPCM1
#define U2X0 U2X1
#define UPE0 UPE1
#define DOR0 DOR1
#define FE0 FE1
#define UDRE0 UDRE1
#define TXC0 TXC1
#define RXC0 RXC1
/*------------------------------------------------------------------------ */
#if defined(__AVR_ATmega32U6__)
/*------------------------------------------------------------------------ */

#define TXB80 TXB81
#define RXB80 RXB81
#define UCSZ02 UCSZ12
#define TXEN0 TXEN1
#define RXEN0 RXEN1
#define UDRIE0 UDRIE1
#define TXCIE0 TXCIE1
#define RXCIE0 RXCIE1
#if !defined(LED)
#define LED C6 // because of PWM (OSC3A)
#endif
#endif // AtmegaXYu6

#define UCPOL0 UCPOL1
#define UCSZ00 UCSZ10
#define UCSZ01 UCSZ11
#define USBS0 USBS1
#define UPM00 UPM10
#define UPM01 UPM11
#define UMSEL00 UMSEL10
#define UMSEL01 UMSEL11

/* Ports for soft UART */
#if SOFT_UART
#define UART_PORT PORTD
#define UART_PIN PIND
#define UART_DDR DDRD
#define UART_TX_BIT 3
#define UART_RX_BIT 2
#endif
#endif
#endif // usbmcus

/*------------------------------------------------------------------------ */
#if defined(__AVR_ATtiny1634__)
Expand Down

0 comments on commit 89ea5b2

Please sign in to comment.