mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #18964 from gschorcht/bootloaders/riotboot_dfu_fixes
bootloaders/riotboot_dfu: fixes including sys/usb/usbus/dfu
This commit is contained in:
commit
945af26648
@ -461,6 +461,11 @@ else
|
||||
include $(RIOTMAKE)/dependency_resolution.inc.mk
|
||||
endif
|
||||
|
||||
# Include dfu-util configuration when using riotboot_dfu bootloader before
|
||||
# including the board's Makefile.include which could define dfu-util
|
||||
# configuration for other DFU bootloaders in use.
|
||||
include $(RIOTMAKE)/boot/riotboot_dfu-util.mk
|
||||
|
||||
# Include Board and CPU configuration
|
||||
INCLUDES += $(addprefix -I,$(wildcard $(BOARDDIR)/include))
|
||||
include $(BOARDDIR)/Makefile.include
|
||||
|
@ -18,6 +18,7 @@ config BOARD_COMMON_BLXXXPILL
|
||||
select HAS_PERIPH_UART
|
||||
select HAS_PERIPH_QDEC
|
||||
select HAS_PERIPH_USBDEV
|
||||
select HAS_RIOTBOOT
|
||||
|
||||
# Clock configuration
|
||||
select BOARD_HAS_HSE
|
||||
|
@ -12,3 +12,6 @@ FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
FEATURES_PROVIDED += periph_qdec
|
||||
FEATURES_PROVIDED += periph_usbdev
|
||||
|
||||
# Put other features for this board (in alphabetical order)
|
||||
FEATURES_PROVIDED += riotboot
|
||||
|
@ -5,7 +5,8 @@ INCLUDES += -I$(RIOTBOARD)/common/blxxxpill/include
|
||||
# For older versions of the DFU bootloader, set DFU_USB_ID to 1d50:6017
|
||||
DFU_USB_ID ?= 1eaf:0003
|
||||
DFU_ALT ?= 2
|
||||
DFU_USE_DFUSE = 1
|
||||
DFU_USE_DFUSE ?= 1
|
||||
|
||||
# If using STM32duino bootloader, this change is necessary.
|
||||
# Bootloader available at
|
||||
# github.com/rogerclarkmelbourne/STM32duino-bootloader/tree/master/binaries
|
||||
|
@ -4,7 +4,7 @@ INCLUDES += -I$(RIOTBOARD)/common/weact-f4x1cx/include
|
||||
# default to flashing over USB
|
||||
PROGRAMMER ?= dfu-util
|
||||
DFU_USB_ID ?= 0483:df11
|
||||
DFU_USE_DFUSE = 1
|
||||
DFU_USE_DFUSE ?= 1
|
||||
ROM_OFFSET ?= 0x0
|
||||
|
||||
# CDC ACM is available faster on STM32
|
||||
|
@ -7,8 +7,8 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
|
||||
# this board is flashed using DFU
|
||||
PROGRAMMER ?= dfu-util
|
||||
DFU_USB_ID = 0483:df11
|
||||
DFU_USE_DFUSE = 1
|
||||
DFU_USB_ID ?= 0483:df11
|
||||
DFU_USE_DFUSE ?= 1
|
||||
|
||||
# dfu-util programmer is supported
|
||||
PROGRAMMERS_SUPPORTED += dfu-util
|
||||
|
@ -8,5 +8,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
# this board is flashed using DFU
|
||||
PROGRAMMER ?= dfu-util
|
||||
PROGRAMMERS_SUPPORTED += dfu-util
|
||||
DFU_USB_ID = 1d50:607f
|
||||
DFU_USE_DFUSE = 1
|
||||
DFU_USB_ID ?= 1d50:607f
|
||||
DFU_USE_DFUSE ?= 1
|
||||
|
@ -10,7 +10,7 @@ ROM_OFFSET ?= 0x5000
|
||||
|
||||
# this board is flashed using DFU
|
||||
PROGRAMMER ?= dfu-util
|
||||
DFU_USB_ID = 1d50:607f
|
||||
DFU_USE_DFUSE = 1
|
||||
DFU_USB_ID ?= 1d50:607f
|
||||
DFU_USE_DFUSE ?= 1
|
||||
|
||||
PROGRAMMERS_SUPPORTED += dfu-util
|
||||
|
@ -51,12 +51,24 @@ When the device is attached and in DFU mode (or the current firmware uses the `u
|
||||
new firmware can be flashed to slot 0 using:
|
||||
|
||||
```
|
||||
$ FEATURES_REQUIRED+=riotboot USEMODULE+=usbus_dfu make -C examples/saul BOARD=particle-xenon PROGRAMMER=dfu-util all riotboot/flash-slot0
|
||||
$ FEATURES_REQUIRED+=riotboot USEMODULE+=usbus_dfu make -C examples/saul BOARD=particle-xenon \
|
||||
PROGRAMMER=dfu-util all riotboot/flash-slot0
|
||||
```
|
||||
|
||||
By default, the VID/PID pair 1209:7d02 is used for the device to be flashed
|
||||
in riotboot DFU mode. If necessary, this VID/PID pair can be overwritten with
|
||||
the variable `DFU_USB_ID`, e.g. if the RIOT DFU bootloader was compiled for
|
||||
a different VID/PID pair.
|
||||
|
||||
```
|
||||
$ FEATURES_REQUIRED+=riotboot USEMODULE+=usbus_dfu make -C examples/saul BOARD=particle-xenon \
|
||||
PROGRAMMER=dfu-util DFU_USB_ID=1209:7d02 all riotboot/flash-slot0
|
||||
```
|
||||
|
||||
Note that when building and flashing a different slot (eg. `flash-slot1`),
|
||||
not only is the image built for that slot, but also dfu-util gets passed
|
||||
`--alt 1` (via the `DFU_ALT` build variable) to store it in the right place.
|
||||
|
||||
# Entering DFU mode
|
||||
|
||||
When RIOT applications are built with `USEMODULE+=usbus_dfu`,
|
||||
|
@ -5,6 +5,10 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
b-l072z-lrwan1 \
|
||||
bluepill \
|
||||
bluepill-128kib \
|
||||
blackpill \
|
||||
blackpill-128kib \
|
||||
e104-bt5010a-tb \
|
||||
e104-bt5011a-tb \
|
||||
lsn50 \
|
||||
|
10
makefiles/boot/riotboot_dfu-util.mk
Normal file
10
makefiles/boot/riotboot_dfu-util.mk
Normal file
@ -0,0 +1,10 @@
|
||||
ifneq (,$(filter usbus_dfu,$(USEMODULE)))
|
||||
ifeq (,$(filter riotboot_usb_dfu,$(USEMODULE)))
|
||||
# If module usbus_dfu is used but not module riotboot_usb_dfu, the
|
||||
# application uses DFU Runtime and dfu-util as programmer to flash the
|
||||
# application with the bootloader riotboot_dfu which uses the VID/PID pair
|
||||
# allocated for the RIOT bootloader https://pid.codes/1209/7D02/
|
||||
DFU_USB_ID ?= 1209:7d02
|
||||
DFU_USE_DFUSE ?= 0
|
||||
endif
|
||||
endif
|
@ -61,12 +61,17 @@ extern "C" {
|
||||
* Set to true for active-low buttons (go to DFU if the pin is low), otherwise
|
||||
* to false (go to DFU if the pin is high).
|
||||
*
|
||||
* The default value for all boards is inverted (active-low).
|
||||
*
|
||||
* */
|
||||
* The default value for all boards is inverted (active-low), except if
|
||||
* BTN0_MODE is defined as GPIO_IN_PD. In this case the value is not
|
||||
* inverted (high-active).
|
||||
*/
|
||||
#ifndef BTN_BOOTLOADER_INVERTED
|
||||
#if (BTN0_MODE == GPIO_IN_PD)
|
||||
#define BTN_BOOTLOADER_INVERTED false
|
||||
#else
|
||||
#define BTN_BOOTLOADER_INVERTED true
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** @brief LED pin for bootloader indication
|
||||
*
|
||||
|
@ -101,7 +101,17 @@ void usbus_dfu_init(usbus_t *usbus, usbus_dfu_device_t *handler, unsigned mode)
|
||||
DEBUG("DFU: initialization\n");
|
||||
assert(usbus);
|
||||
assert(handler);
|
||||
assert((SLOT0_OFFSET % FLASHPAGE_SIZE) == 0);
|
||||
#if defined(FLASHPAGE_SIZE)
|
||||
static_assert((SLOT0_OFFSET % FLASHPAGE_SIZE) == 0,
|
||||
"SLOT0_OFFSET has to be a multiple of FLASHPAGE_SIZE");
|
||||
#elif defined(FLASHPAGE_MIN_SECTOR_SIZE)
|
||||
/* STM32F2/4/7 MCUs use sectors instead of pages, where the minimum sector
|
||||
* size is defined by FLASHPAGE_MIN_SECTOR_SIZE, which is 16KB or 32KB
|
||||
* (the first sector) depending on the CPU_MODEL. In this case SLOT0_OFFSET
|
||||
* must be a multiple of the minimum sector size to cover a whole sector. */
|
||||
static_assert((SLOT0_OFFSET % FLASHPAGE_MIN_SECTOR_SIZE) == 0,
|
||||
"SLOT0_OFFSET has to be a multiple of FLASHPAGE_MIN_SECTOR_SIZE");
|
||||
#endif
|
||||
memset(handler, 0, sizeof(usbus_dfu_device_t));
|
||||
handler->usbus = usbus;
|
||||
handler->handler_ctrl.driver = &dfu_driver;
|
||||
|
@ -5,6 +5,10 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
bluepill \
|
||||
bluepill-128kib \
|
||||
blackpill \
|
||||
blackpill-128kib \
|
||||
i-nucleo-lrwan1 \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
|
Loading…
Reference in New Issue
Block a user