From d9ce695943bddf15a483a76915eff278d221d191 Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Mon, 18 Jul 2016 10:28:02 +0800 Subject: [PATCH 1/5] Mark out VID/PID/PSTRING. Makefile would supply them using env-vars. --- avr/bootloaders/HoodLoader2/Board/Board.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avr/bootloaders/HoodLoader2/Board/Board.h b/avr/bootloaders/HoodLoader2/Board/Board.h index 8c4a8c5..fe23a66 100644 --- a/avr/bootloaders/HoodLoader2/Board/Board.h +++ b/avr/bootloaders/HoodLoader2/Board/Board.h @@ -57,6 +57,7 @@ extern "C" { #define ARDUINO_MICRO_PID 0x0037 // Bootloader, not program! #define ARDUINO_DUE_PID 0x003D + #ifndef USB_DESCRIPTOR_STRING // If the Makefile did not supply a product string... // USB product string settings #if (PRODUCTID == ARDUINO_UNO_PID) #define USB_DESCRIPTOR_STRING L"HoodLoader2 Uno" @@ -73,6 +74,7 @@ extern "C" { #else #define USB_DESCRIPTOR_STRING L"HoodLoader2 Lufa" #endif + #endif // Arduino Due 16u2 #if (PRODUCTID == ARDUINO_DUE_PID) From f552c3c37982a8e2b5e4c5285780688f929902ca Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Mon, 18 Jul 2016 10:34:17 +0800 Subject: [PATCH 2/5] Cursory modifications to a customizable Makefile. --- avr/bootloaders/HoodLoader2/makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/avr/bootloaders/HoodLoader2/makefile b/avr/bootloaders/HoodLoader2/makefile index 4529dfb..13da598 100644 --- a/avr/bootloaders/HoodLoader2/makefile +++ b/avr/bootloaders/HoodLoader2/makefile @@ -11,7 +11,9 @@ # Run "make help" for target help. +ifeq ($(MCU),) MCU = atmega16u2 +endif ARCH = AVR8 BOARD = USER F_CPU = 16000000 @@ -23,6 +25,15 @@ LUFA_PATH = ../lufa-LUFA-140928/LUFA CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ $(HOODLOADER2_OPTS) -DBOOT_START_ADDR=$(BOOT_START_OFFSET) $(REGS) -flto -fuse-linker-plugin LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS),--section-start=.data=$(RAM_OFFSET) $(REGS) -flto -fuse-linker-plugin +ifneq ($(MCU),atmega8u2) +ifneq ($(MCU),atmega16u2) +ifneq ($(MCU),atmega16u4) +ifneq ($(MCU),atmega32u4) +$(error MCU must be one of atmega8u2, atmega16u2, atmega16u4 or atmega32u4) +endif +endif +endif +endif # Flash size and bootloader section sizes of the target, in KB. These must # match the target's total FLASH size and the bootloader size set in the @@ -41,8 +52,16 @@ BOOT_SECTION_SIZE_KB = 4 #define ARDUINO_MICRO_PID 0x0037 // Bootloader, not program! #define ARDUINO_DUE_PID 0x003D -HOODLOADER2_OPTS = -DVENDORID=ARDUINO_VID -HOODLOADER2_OPTS += -DPRODUCTID=ARDUINO_UNO_PID +ifeq ($(VID),) +VID := ARDUINO_VID +endif + +ifeq ($(PID),) +PID := ARDUINO_UNO_PID +endif + +HOODLOADER2_OPTS = -DVENDORID=$(VID) +HOODLOADER2_OPTS += -DPRODUCTID=$(PID) # 1200 is the baud to load the Bootloader from an Arduino sketch, # 57600 turns out to be the actual baud rate for uploading for default arduino bootloaders (and arduino nano by default!) From 6d38fe8bcdff6597516d5fe187cf5d13edf4aef0 Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Mon, 18 Jul 2016 10:40:34 +0800 Subject: [PATCH 3/5] Introducing vidpid.txt --- avr/bootloaders/HoodLoader2/vidpid.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 avr/bootloaders/HoodLoader2/vidpid.txt diff --git a/avr/bootloaders/HoodLoader2/vidpid.txt b/avr/bootloaders/HoodLoader2/vidpid.txt new file mode 100644 index 0000000..5de3a1c --- /dev/null +++ b/avr/bootloaders/HoodLoader2/vidpid.txt @@ -0,0 +1,6 @@ +atmega16u2 0x2341 0x0043 HoodLoader2 Uno +atmega16u2 0x2341 0x0042 HoodLoader2 Mega +atmega16u2 0x2341 0x0044 HoodLoader2 ADK +atmega32u4 0x2341 0x0036 HoodLoader2 Leo +atmeag32u4 0x2341 0x0037 HoodLoader2 Micro +atmega32u4 0x2341 0x003c HoodLoader2 Esplora From 2c00c6f35a3c29d20b9957deb54dba93bc7d0dee Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Mon, 18 Jul 2016 10:48:09 +0800 Subject: [PATCH 4/5] The almighty build script "$@" = I can pass in flags like `-j32` to make compiling faster, utilizing all 32 logical cores on my workstation. --- avr/bootloaders/HoodLoader2/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 avr/bootloaders/HoodLoader2/build.sh diff --git a/avr/bootloaders/HoodLoader2/build.sh b/avr/bootloaders/HoodLoader2/build.sh new file mode 100644 index 0000000..ff67a5f --- /dev/null +++ b/avr/bootloaders/HoodLoader2/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +cat vidpid.txt | while read mcu vid pid name; do + make clean + make VID=$vid PID=$pid MCU=$mcu NAME="$name" "$@" all + # Please tell me where to find thebuild products... + #mv build-product.ihex hoodloader_$mcu_$vid_$pid.ihex +done From e601440ebd9953edd9dd5502bcf673fa8db68e46 Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Mon, 18 Jul 2016 10:54:00 +0800 Subject: [PATCH 5/5] Configurable names. IDK if this will work. Really. --- avr/bootloaders/HoodLoader2/makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/avr/bootloaders/HoodLoader2/makefile b/avr/bootloaders/HoodLoader2/makefile index 13da598..904db64 100644 --- a/avr/bootloaders/HoodLoader2/makefile +++ b/avr/bootloaders/HoodLoader2/makefile @@ -63,6 +63,10 @@ endif HOODLOADER2_OPTS = -DVENDORID=$(VID) HOODLOADER2_OPTS += -DPRODUCTID=$(PID) +ifneq ($(NAME),) +HOODLOADER2_OPTS += "-DUSB_DESCRIPTOR_STRING=\"$(NAME)\"" +endif + # 1200 is the baud to load the Bootloader from an Arduino sketch, # 57600 turns out to be the actual baud rate for uploading for default arduino bootloaders (and arduino nano by default!) # make also sure to change your boards.txt uploading speed!