Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable build process #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions avr/bootloaders/HoodLoader2/Board/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you using this for? If no "normal" VID/PID is recognized it will use "Lufa" as string. I think there is an else path missing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows vidpid.txt to redefine the display string to whatever the user want to.

Copy link
Owner

@NicoHood NicoHood Jul 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. But I cannot see where this is done on the c code. I might be wrong and missunderstand.
edit: looks okay

// USB product string settings
#if (PRODUCTID == ARDUINO_UNO_PID)
#define USB_DESCRIPTOR_STRING L"HoodLoader2 Uno"
Expand All @@ -73,6 +74,7 @@ extern "C" {
#else
#define USB_DESCRIPTOR_STRING L"HoodLoader2 Lufa"
#endif
#endif

// Arduino Due 16u2
#if (PRODUCTID == ARDUINO_DUE_PID)
Expand Down
8 changes: 8 additions & 0 deletions avr/bootloaders/HoodLoader2/build.sh
Original file line number Diff line number Diff line change
@@ -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...
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a move you could possibly change the target in the makefile.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is much more complicated. This build script, being a Shell script, expects the Make command have a consistent output file name.

#mv build-product.ihex hoodloader_$mcu_$vid_$pid.ihex
done
27 changes: 25 additions & 2 deletions avr/bootloaders/HoodLoader2/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

# Run "make help" for target help.

ifeq ($(MCU),)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? What id you use ?=, would this work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure you can use ?=. This is just equivalent.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?= looks fancier. Please use that, its also more simple and better understandable.

MCU = atmega16u2
endif
ARCH = AVR8
BOARD = USER
F_CPU = 16000000
Expand All @@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not required as the build would just fail. Also you missed the at90usb devices.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Nuke this.

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
Expand All @@ -41,8 +52,20 @@ 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)

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!)
Expand Down
6 changes: 6 additions & 0 deletions avr/bootloaders/HoodLoader2/vidpid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
atmega16u2 0x2341 0x0043 HoodLoader2 Uno
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to also add 8u2, 32u2 and at90usb builds.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add lines following that format.

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