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

Bootloader v6.0 #548

Merged
merged 15 commits into from
Dec 22, 2023
Merged
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## Unreleased

### Features

* bootloader: added `System::BootloaderMode::DAISY`, `System::BootloaderMode::DAISY_SKIP_TIMEOUT`, and `System::BootloaderMode::DAISY_INFINITE_TIMEOUT` options to `System::ResetToBootloader` method for better firmware updating flexibility.

### Bug fixes

* bootloader: pins `D0`, `D29` and `D30` are no longer stuck when using the Daisy bootloader

### Migrating

#### Bootloader

* This version of libDaisy and greater will be compatible with any version of the Daisy bootloader, meaning you won't have to update the bootloader on your product if you want the latest changes to libDaisy.
* However, for newer versions of the bootloader, you must use a compatible version of libDaisy.
* Daisy bootloader v6.0 and up will only be compatible with libDaisy v5.3 and up.

## v5.4.0

### Features
Expand Down
10 changes: 5 additions & 5 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SYSTEM_FILES_DIR ?= \
# source
######################################

CPP_SOURCES ?=
CPP_SOURCES ?=

C_SOURCES += \
$(SYSTEM_FILES_DIR)/startup_stm32h750xx.c
Expand All @@ -68,13 +68,13 @@ PREFIX = arm-none-eabi-
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CXX = $(GCC_PATH)/$(PREFIX)g++
CXX = $(GCC_PATH)/$(PREFIX)g++
GDB = $(GCC_PATH)/$(PREFIX)gdb
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
CXX = $(PREFIX)g++
GDB = $(PREFIX)gdb
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
Expand Down Expand Up @@ -124,7 +124,7 @@ endif
# AS includes
AS_INCLUDES =

C_INCLUDES ?=
C_INCLUDES ?=

C_INCLUDES += \
-I$(LIBDAISY_DIR) \
Expand Down Expand Up @@ -204,7 +204,7 @@ QSPI_ADDRESS ?= 0x90040000
DAISY_PID = df11
STM_PID = df11

BOOT_BIN ?= $(wildcard $(SYSTEM_FILES_DIR)/dsy_bootloader*)
BOOT_BIN ?= $(SYSTEM_FILES_DIR)/dsy_bootloader_v6_2-intdfu-2000ms.bin
APP_TYPE ?= BOOT_NONE

ifeq ($(APP_TYPE), BOOT_NONE)
Expand Down
34 changes: 24 additions & 10 deletions core/STM32H750IB_flash.lds
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ ENTRY(Reset_Handler)

MEMORY
{
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (RWX) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX) : ORIGIN = 0x90000000, LENGTH = 8M
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (RWX) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
BACKUP_SRAM (RWX) : ORIGIN = 0x38800000, LENGTH = 4K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX) : ORIGIN = 0x90000000, LENGTH = 8M
}

_estack = 0x20020000;
Expand Down Expand Up @@ -122,7 +123,7 @@ SECTIONS
PROVIDE(__bss_end__ = _ebss);
} > SRAM

PROVIDE(end = .);
PROVIDE(end = .);

.dtcmram_bss (NOLOAD) :
{
Expand Down Expand Up @@ -183,8 +184,21 @@ SECTIONS
PROVIDE(__sdram_bss_end = _esdram_bss);
} > SDRAM

.backup_sram (NOLOAD) :
{
. = ALIGN(4);
_sbackup_sram = .;

PROVIDE(__backup_sram_start = _sbackup_sram);
*(.backup_sram)
*(.backup_sram*)
. = ALIGN(4);
_ebackup_sram = .;

PROVIDE(__backup_sram_end = _ebackup_sram);
} > BACKUP_SRAM

.qspiflash_text :
.qspiflash_text :
{
. = ALIGN(4);
_sqspiflash_text = .;
Expand Down
35 changes: 25 additions & 10 deletions core/STM32H750IB_qspi.lds
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ ENTRY(Reset_Handler)

MEMORY
{
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2_DMA (RWX) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D2 (RWX) : ORIGIN = 0x30008000, LENGTH = 256K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX): ORIGIN = 0x90040000, LENGTH = 7936K
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2_DMA (RWX) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D2 (RWX) : ORIGIN = 0x30008000, LENGTH = 256K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
BACKUP_SRAM (RWX) : ORIGIN = 0x38800000, LENGTH = 4K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX) : ORIGIN = 0x90040000, LENGTH = 7936K
}

_estack = 0x20020000;
Expand Down Expand Up @@ -136,7 +137,7 @@ SECTIONS
_ebss = .;

PROVIDE(__bss_end__ = _ebss);
} > SRAM
} > SRAM

.dtcmram_bss (NOLOAD) :
{
Expand Down Expand Up @@ -183,6 +184,20 @@ SECTIONS
PROVIDE(__sdram_bss_end = _esdram_bss);
} > SDRAM

.backup_sram (NOLOAD) :
{
. = ALIGN(4);
_sbackup_sram = .;

PROVIDE(__backup_sram_start = _sbackup_sram);
*(.backup_sram)
*(.backup_sram*)
. = ALIGN(4);
_ebackup_sram = .;

PROVIDE(__backup_sram_end = _ebackup_sram);
} > BACKUP_SRAM


/* .qspiflash_text :
{
Expand Down
36 changes: 25 additions & 11 deletions core/STM32H750IB_sram.lds
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ ENTRY(Reset_Handler)

MEMORY
{
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K - 32K
RAM_D2_DMA (RWX) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D2 (RWX) : ORIGIN = 0x30008000, LENGTH = 256K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX): ORIGIN = 0x90040000, LENGTH = 7936K
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
SRAM (RWX) : ORIGIN = 0x24000000, LENGTH = 512K - 32K
RAM_D2_DMA (RWX) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D2 (RWX) : ORIGIN = 0x30008000, LENGTH = 256K
RAM_D3 (RWX) : ORIGIN = 0x38000000, LENGTH = 64K
BACKUP_SRAM (RWX) : ORIGIN = 0x38800000, LENGTH = 4K
ITCMRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (RWX) : ORIGIN = 0xc0000000, LENGTH = 64M
QSPIFLASH (RX) : ORIGIN = 0x90040000, LENGTH = 7936K
}

_estack = 0x20020000;
Expand Down Expand Up @@ -135,7 +136,7 @@ SECTIONS
_ebss = .;

PROVIDE(__bss_end__ = _ebss);
} > DTCMRAM
} > DTCMRAM

.dtcmram_bss (NOLOAD) :
{
Expand Down Expand Up @@ -182,8 +183,21 @@ SECTIONS
PROVIDE(__sdram_bss_end = _esdram_bss);
} > SDRAM

.backup_sram (NOLOAD) :
{
. = ALIGN(4);
_sbackup_sram = .;

PROVIDE(__backup_sram_start = _sbackup_sram);
*(.backup_sram)
*(.backup_sram*)
. = ALIGN(4);
_ebackup_sram = .;

PROVIDE(__backup_sram_end = _ebackup_sram);
} > BACKUP_SRAM

.qspiflash_text :
.qspiflash_text :
{
. = ALIGN(4);
_sqspiflash_text = .;
Expand Down
Binary file removed core/dsy_bootloader_v5_4.bin
Binary file not shown.
Binary file added core/dsy_bootloader_v6_2-extdfu-10ms.bin
Binary file not shown.
Binary file added core/dsy_bootloader_v6_2-extdfu-2000ms.bin
Binary file not shown.
Binary file added core/dsy_bootloader_v6_2-intdfu-10ms.bin
Binary file not shown.
Binary file added core/dsy_bootloader_v6_2-intdfu-2000ms.bin
Binary file not shown.
35 changes: 35 additions & 0 deletions examples/BootloaderBlink/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Project Name
TARGET = BootloaderBlink.bin

# Configure for debugging
# common configurations:
# use DEBUG = 1 and OPT = -Og for debugging
# or DEBUG = 0 and OPT = -O3 for performance
DEBUG = 1
OPT = -O0
APP_TYPE=BOOT_SRAM

# Sources
CPP_SOURCES = main.cpp

# Libraries
LIBDAISY_DIR = ../../
#DAISYSP_DIR = # specify path to external DaisySP

# (optional) Includes FatFS source files within project.
#USE_FATFS = 1

# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core

# Specify alternate bootloader configuration
# This only changes the configuration programmed
# via the "make program-boot" command.
# All configurations are located in libDaisy/core/

#BOOT_BIN=$(SYSTEM_FILES_DIR)/dsy_bootloader_v6_2-intdfu-2000ms.bin # default
#BOOT_BIN=$(SYSTEM_FILES_DIR)/dsy_bootloader_v6_2-intdfu-10ms.bin
#BOOT_BIN=$(SYSTEM_FILES_DIR)/dsy_bootloader_v6_2-extdfu-2000ms.bin
#BOOT_BIN=$(SYSTEM_FILES_DIR)/dsy_bootloader_v6_2-extdfu-10ms.bin

include $(SYSTEM_FILES_DIR)/Makefile
61 changes: 61 additions & 0 deletions examples/BootloaderBlink/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/** Daisy Blink Example for external DFU bootloader
*
* This example blinks the Daisy Seed's LED
*
* This project is made to demonstrate testing DAisy's v6 bootloader
* with external USB DFU configuration.
*
* The application can use any method it wants to jump to the bootloader.
* With the infinite timeout below, the unit will stay in the bootloader
* indefinitely, or until power cycled.
*
* As a test, you can recompile this project with different blink delays
*
* To enter the bootloader connect D27 to GND, and then release.
* This is SW 1 on the Daisy Pod, but can be replaced with any method of your preference.
*
*/
#include "daisy_seed.h"

using namespace daisy;

DaisySeed hardware;
Switch bootloader_switch;

int main()
{
hardware.Init();
bool blinkState = false;

/** Initialize the boot switch */
bootloader_switch.Init(seed::D27);

uint32_t blink_rate = 50; /**< Change me to test tweaking the program! */

/** Timing variables */
uint32_t now, blink_time;
now = blink_time = System::GetNow();

while (true)
{
now = System::GetNow();

/** Blink without blocking the loop */
if (now - blink_time > blink_rate)
{
hardware.SetLed(blinkState);
blinkState = !blinkState;
blink_time = now;
}

/** debounce the button and check for release */
bootloader_switch.Debounce();
if (bootloader_switch.FallingEdge())
{
System::ResetToBootloader(System::DAISY_INFINITE_TIMEOUT);
}

/** 1ms delay for predictable debouncing time */
System::Delay(1);
}
}
15 changes: 12 additions & 3 deletions src/daisy_patch_sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,22 @@ namespace patch_sm
System::Config syscfg;
syscfg.Boost();

auto memory = System::GetProgramMemoryRegion();
if(memory != System::MemoryRegion::INTERNAL_FLASH)
auto memory = System::GetProgramMemoryRegion();
auto boot_version = System::GetBootloaderVersion();

// When using the bootloader prior to v6, clocks have been already configured
if(boot_version == System::BootInfo::Version::LT_v6_0
&& memory != System::MemoryRegion::INTERNAL_FLASH)
{
syscfg.skip_clocks = true;
}

system.Init(syscfg);
/** Memories */
if(memory == System::MemoryRegion::INTERNAL_FLASH)
// When using the bootloader priori to v6, SDRAM has been already configured
if(boot_version != System::BootInfo::Version::LT_v6_0
|| (boot_version == System::BootInfo::Version::LT_v6_0
&& memory == System::MemoryRegion::INTERNAL_FLASH))
{
/** FMC SDRAM */
sdram.Init();
Expand Down
12 changes: 9 additions & 3 deletions src/daisy_seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,23 @@ void DaisySeed::Init(bool boost)
testpoint.mode = DSY_GPIO_MODE_OUTPUT_PP;


auto memory = System::GetProgramMemoryRegion();
auto memory = System::GetProgramMemoryRegion();
auto boot_version = System::GetBootloaderVersion();

if(memory != System::MemoryRegion::INTERNAL_FLASH)
if(boot_version == System::BootInfo::Version::LT_v6_0
&& memory != System::MemoryRegion::INTERNAL_FLASH)
{
syscfg.skip_clocks = true;
}

system.Init(syscfg);

if(memory != System::MemoryRegion::QSPI)
qspi.Init(qspi_config);

if(memory == System::MemoryRegion::INTERNAL_FLASH)
if(boot_version != System::BootInfo::Version::LT_v6_0
|| (boot_version == System::BootInfo::Version::LT_v6_0
&& memory == System::MemoryRegion::INTERNAL_FLASH))
{
dsy_gpio_init(&led);
dsy_gpio_init(&testpoint);
Expand Down
Loading
Loading