Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
24e176d
Save 4 bytes by simplifying wait_finish_transfer
sigprof Aug 20, 2021
6416c0d
Save 4 bytes by refactoring UEINTX handling subroutines
sigprof Aug 20, 2021
29403b8
Save 2 bytes by refactoring the GET_DESCRIPTOR code
sigprof Aug 24, 2021
c1e6e68
Update bootloader size info.
osamuaoki Feb 5, 2022
c636884
Save 4 bytes in the USB detach code
sigprof Sep 4, 2021
224d46c
Save 2 bytes in the USBCON init code
sigprof Sep 4, 2021
a29cb77
Save 2 bytes in the HOST_TO_DEVICE parsing code
sigprof Sep 4, 2021
3aa9547
Save 2 bytes in the DEVICE_TO_HOST parsing code
sigprof Sep 4, 2021
61a60ed
Update binary size
osamuaoki Feb 5, 2022
f242a41
Save 6 bytes by using Y+ for extended IO
osamuaoki Apr 22, 2020
1576141
Update binary size
osamuaoki Feb 5, 2022
37ff063
Move SET_HID_REPORT in preparation for fallthrough
sigprof Aug 24, 2021
ec40403
Save 2 bytes by using fallthrough for SET_HID_REPORT
osamuaoki Feb 5, 2022
3315be5
Drop UNHANDLED_DEVICE_TO_HOST thunk entry
osamuaoki Feb 5, 2022
f8e9b41
Update binary size
osamuaoki Feb 5, 2022
9c2d620
Save 2 bytes with using clear_UEINTX_bit_and_reti
osamuaoki Feb 5, 2022
55026aa
Move up UNHANDLED_SETUP_REQUEST to the center
osamuaoki Feb 6, 2022
1ccfbdc
UNHANDLED_SETUP_REQUEST is accessible
osamuaoki Feb 6, 2022
78bbe02
Save 2 bytes by using R29=YH as rZERO
osamuaoki Feb 5, 2022
b767f7a
Save 2 bytes with no LED turn-off
osamuaoki Feb 6, 2022
4b4def3
String descriptor implementation
sigprof Sep 4, 2021
a5906c7
Use 2 bytes to re-activate cli
osamuaoki Feb 6, 2022
bc7e388
Save 4 bytes with shorter product name
osamuaoki Feb 6, 2022
43e09c7
Enable to select opt-in LED features from Makefile
osamuaoki Feb 6, 2022
d143417
Drop Windows-only cosmetic and annoying code
osamuaoki Feb 6, 2022
5860383
Helper scripts for build
osamuaoki Feb 6, 2022
a75c9e3
Update binary size and mention helper scripts
osamuaoki Feb 6, 2022
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
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
#CPPFLAGS += $(CSTANDARD)


LEDDEFS =

#---------------- Assembler Options ----------------
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns: create listing
Expand All @@ -206,8 +208,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
# files -- see avr-libc docs [FIXME: not yet described there]
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
# dump that will be displayed for a given single line of source input.
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100

ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 $(LEDDEFS)

#---------------- Library Options ----------------
# Minimalistic printf version
Expand Down Expand Up @@ -636,11 +637,11 @@ clean_list :


# Create object files directory
$(shell mkdir $(OBJDIR) 2>/NUL)
$(shell mkdir -p $(OBJDIR))


# Include the dependency files.
-include $(shell mkdir .dep 2>NUL) $(wildcard .dep/*)
-include $(shell mkdir -p .dep) $(wildcard .dep/*)


# Listing of phony targets.
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@ The name *nanoBoot* comes from the fact that the compiled source fits in the sma

It's very likely that a few sections can be rewritten to make it even smaller, and the ultimate goal is to support EEPROM programming as well, although that would require changes to the host code.

The current version (commit #[d0ea26b](https://github.com/volium/nanoBoot/commit/d0ea26bb01e764340dc8ad7b473ad98cefdb52eb)) is supported as-is in the 'hid_bootloader_loader.py' script that ships with [LUFA-151115](https://github.com/abcminiuser/lufa/releases/tag/LUFA-151115), and is exactly 506 bytes long.
The current version (2022-02-06) is supported as-is in the 'hid_bootloader_loader.py' script that ships with [LUFA-151115](https://github.com/abcminiuser/lufa/releases/tag/LUFA-151115) or even newer one.

Binary size:
* 506 bytes (nanoBoot-generic.hex: No LED support)
* 510 bytes (enable LED support with "LED_ACTIVE_LEVEL 1" (Leonardo, Nano, Teensy 2.0-type)
* 512 bytes (enable LED support with "LED_ACTIVE_LEVEL 0" (Promicro-type)

Upon connecting to the host via USB, this sends following information:
```
usb 4-2: new full-speed USB device number ** using xhci_hcd
usb 4-2: New USB device found, idVendor=03eb, idProduct=2067, bcdDevice= 0.01
usb 4-2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
usb 4-2: Product: nanoBt
hid-generic 000*:03EB:2067.0026: hiddev*,hidraw*: USB HID v1.11 Device [nanoBt] on usb-0000:0*:00.*-2/input0
```

Helper scripts to build firmware with LED supports are provided as `mk-*`.

## HW assumptions:

Expand Down
9 changes: 9 additions & 0 deletions mk-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -ex
# vim:se sw=2 ts=2 sts=2 et ai:
# Script to build nanoBoot
export PATH=${PATH}:.
mk-generic
mk-teensy
mk-leonardo
mk-promicro

12 changes: 12 additions & 0 deletions mk-generic
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -ex
# vim:se sw=2 ts=2 sts=2 et ai:
# Script to build nanoBoot

#Generic board w/o LED support
DEFS="LEDDEFS="

make clean
make "$DEFS"
mv -f nanoBoot.hex nanoBoot-generic.hex


25 changes: 25 additions & 0 deletions mk-leonardo
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh -ex
# vim:se sw=2 ts=2 sts=2 et ai:
# Script to build nanoBoot

# Leonardo/Nano compatible board
# -- LED is ON with ATmega32u4 PIN C7 HIGH
# #define LED_BIT 7
# #define LED_CONF DDRC
# #define LED_PORT PORTC
# #define LED_ACTIVE_LEVEL 1
DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=7 -DLED_CONF=DDRC -DLED_PORT=PORTC -DLED_ACTIVE_LEVEL=1"

# Pro Micro compatible board
# -- LED is ON with ATmega32u4 PIN B3 LOW
# #define LED_BIT 3
# #define LED_CONF DDRB
# #define LED_PORT PORTB
# #define LED_ACTIVE_LEVEL 0
#DEFS="LEDDEFS=\"-DLED_ENABLED -DLED_BIT=3 -DLED_CONF=DDRB -DLED_PORT=PORTB -DLED_ACTIVE_LEVEL=0\""

make clean
make "$DEFS"
mv -f nanoBoot.hex nanoBoot-leonardo.hex


24 changes: 24 additions & 0 deletions mk-promicro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -ex
# vim:se sw=2 ts=2 sts=2 et ai:
# Script to build nanoBoot

# Pro Micro compatible board
# -- LED is ON with ATmega32u4 PIN D5 LOW
# #define LED_BIT 5
# #define LED_CONF DDRD
# #define LED_PORT PORTD
# #define LED_ACTIVE_LEVEL 0
DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=5 -DLED_CONF=DDRD -DLED_PORT=PORTD -DLED_ACTIVE_LEVEL=0"

# Pro Micro compatible board
# -- LED is ON with ATmega32u4 PIN B3 LOW
# #define LED_BIT 3
# #define LED_CONF DDRB
# #define LED_PORT PORTB
# #define LED_ACTIVE_LEVEL 0
#DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=3 -DLED_CONF=DDRB -DLED_PORT=PORTB -DLED_ACTIVE_LEVEL=0"
make clean
make "$DEFS"
mv -f nanoBoot.hex nanoBoot-promicro.hex


50 changes: 50 additions & 0 deletions mk-teensy
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh -ex
# vim:se sw=2 ts=2 sts=2 et ai:
# Script to build nanoBoot

# Adafruit's Atmega32u4 Breakout Board (Product ID: 296) - Now discontinued
# https://www.adafruit.com/product/296
# -- LED is ON with ATmega32u4 PIN E6 HIGH
# #define LED_BIT 6
# #define LED_CONF DDRE
# #define LED_PORT PORTE
# #define LED_ACTIVE_LEVEL 1
#DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=6 -DLED_CONF=DDRE -DLED_PORT=PORTE -DLED_ACTIVE_LEVEL=1"

# Teensy 2.0 compatible board
# -- LED is ON with ATmega32u4 PIN D6 HIGH
#define LED_BIT 6
#define LED_CONF DDRD
#define LED_PORT PORTD
#define LED_ACTIVE_LEVEL 1
DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=6 -DLED_CONF=DDRD -DLED_PORT=PORTD -DLED_ACTIVE_LEVEL=1"

# Leonardo/Nano compatible board
# -- LED is ON with ATmega32u4 PIN C7 HIGH
# #define LED_BIT 7
# #define LED_CONF DDRC
# #define LED_PORT PORTC
# #define LED_ACTIVE_LEVEL 1
#DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=7 -DLED_CONF=DDRC -DLED_PORT=PORTC -DLED_ACTIVE_LEVEL=1"

# Pro Micro compatible board
# -- LED is ON with ATmega32u4 PIN D5 LOW
# #define LED_BIT 5
# #define LED_CONF DDRD
# #define LED_PORT PORTD
# #define LED_ACTIVE_LEVEL 0
#DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=5 -DLED_CONF=DDRD -DLED_PORT=PORTD -DLED_ACTIVE_LEVEL=0"

# Pro Micro compatible board
# -- LED is ON with ATmega32u4 PIN B3 LOW
# #define LED_BIT 3
# #define LED_CONF DDRB
# #define LED_PORT PORTB
# #define LED_ACTIVE_LEVEL 0
#DEFS="LEDDEFS=-DLED_ENABLED -DLED_BIT=3 -DLED_CONF=DDRB -DLED_PORT=PORTB -DLED_ACTIVE_LEVEL=0"

make clean
make "$DEFS"
mv -f nanoBoot.hex nanoBoot-teensy.hex


Loading