stlink/swlink: Remove the DFU upgrade utility.

Hopefully no old bootloaders are around. If otherwise, revert to last
commit before this and update the DFU bootloader.
This commit is contained in:
Uwe Bonnes 2020-11-17 17:51:28 +01:00 committed by UweBonnes
parent 03a7b06eb8
commit 636bcee355
12 changed files with 14 additions and 199 deletions

View File

@ -42,7 +42,7 @@ int main(void)
if(gpio_get(GPIOB, GPIO12))
dfu_jump_app_if_valid();
dfu_protect(DFU_MODE);
dfu_protect(false);
rcc_clock_setup_in_hse_8mhz_out_72mhz();
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
@ -60,7 +60,7 @@ int main(void)
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, LED_0 | LED_1 | LED_2);
dfu_init(&st_usbfs_v1_usb_driver, DFU_MODE);
dfu_init(&st_usbfs_v1_usb_driver);
/* Configure the USB pull up pin. */
gpio_set(GPIOA, GPIO8);

View File

@ -39,16 +39,12 @@ SRC += cdcacm.c \
ifeq ($(ST_BOOTLOADER), 1)
all: blackmagic.bin
else
all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex dfu_upgrade.bin dfu_upgrade.hex
all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex
endif
blackmagic_dfu.elf: usbdfu.o dfucore.o dfu_f1.o stlink_common.o
@echo " LD $@"
$(Q)$(CC) $^ -o $@ $(LDFLAGS_BOOT)
dfu_upgrade.elf: dfu_upgrade.o dfucore.o dfu_f1.o stlink_common.o
@echo " LD $@"
$(Q)$(CC) $^ -o $@ $(LDFLAGS)
host_clean:
-$(Q)$(RM) *.bin *elf *hex

View File

@ -1,85 +0,0 @@
/*
* This file is part of the Black Magic Debug project.
*
* Copyright (C) 2013 Gareth McMullin <gareth@blacksphere.co.nz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/scb.h>
#include "usbdfu.h"
#include "general.h"
#include "platform.h"
uint32_t app_address = 0x08000000;
static uint16_t led_upgrade;
static uint32_t led2_state = 0;
extern uint32_t _stack;
static uint32_t rev;
void dfu_detach(void)
{
platform_request_boot();
scb_reset_core();
}
int main(void)
{
rev = detect_rev();
rcc_clock_setup_in_hse_8mhz_out_72mhz();
if (rev == 0)
led_upgrade = GPIO8;
else
led_upgrade = GPIO9;
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
systick_set_reload(900000);
dfu_protect(UPD_MODE);
systick_interrupt_enable();
systick_counter_enable();
if (rev > 1) /* Reconnect USB */
gpio_set(GPIOA, GPIO15);
dfu_init(&st_usbfs_v1_usb_driver, UPD_MODE);
dfu_main();
}
void dfu_event(void)
{
}
void sys_tick_handler(void)
{
if (rev == 0) {
gpio_toggle(GPIOA, led_upgrade);
} else {
if (led2_state & 1) {
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, led_upgrade);
gpio_set(GPIOA, led_upgrade);
} else {
gpio_set_mode(GPIOA, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_ANALOG, led_upgrade);
}
led2_state++;
}
}

View File

@ -42,9 +42,7 @@ int usbuart_debug_write(const char *buf, size_t len);
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware " FIRMWARE_VERSION ")"
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")"
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")"
#define DFU_IDENT "Black Magic Firmware Upgrade (STLINK)"
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
/* Hardware definitions... */
#define TDI_PORT GPIOA

View File

@ -63,7 +63,7 @@ int main(void)
if(((GPIOA_CRL & 0x40) == 0x40) && stlink_test_nrst())
dfu_jump_app_if_valid();
dfu_protect(DFU_MODE);
dfu_protect(false);
rcc_clock_setup_in_hse_8mhz_out_72mhz();
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
@ -75,7 +75,7 @@ int main(void)
if (rev > 1)
gpio_set(GPIOA, GPIO15);
dfu_init(&st_usbfs_v1_usb_driver, DFU_MODE);
dfu_init(&st_usbfs_v1_usb_driver);
dfu_main();
}

View File

@ -62,9 +62,9 @@ uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum)
return 100;
}
void dfu_protect(dfu_mode_t mode)
void dfu_protect(bool enable)
{
if (mode == DFU_MODE) {
if (enable) {
#ifdef DFU_SELF_PROTECT
if ((FLASH_WRPR & 0x03) != 0x00) {
flash_unlock();

View File

@ -132,15 +132,6 @@ static const char *usb_strings[] = {
if_string,
};
static char upd_if_string[] = UPD_IFACE_STRING;
static const char *usb_strings_upd[] = {
"Black Sphere Technologies",
BOARD_IDENT_UPD,
serial_no,
/* This string is used by ST Microelectronics' DfuSe utility */
upd_if_string,
};
static uint32_t get_le32(const void *vp)
{
const uint8_t *p = vp;
@ -293,12 +284,12 @@ static enum usbd_request_return_codes usbdfu_control_request(usbd_device *dev,
return USBD_REQ_NOTSUPP;
}
void dfu_init(const usbd_driver *driver, dfu_mode_t mode)
void dfu_init(const usbd_driver *driver)
{
get_dev_unique_id(serial_no);
usbdev = usbd_init(driver, &dev, &config,
(mode == DFU_MODE)?usb_strings:usb_strings_upd, 4,
usb_strings, 4,
usbd_control_buffer, sizeof(usbd_control_buffer));
usbd_register_control_callback(usbdev,
@ -357,12 +348,6 @@ static char *get_dev_unique_id(char *s)
fuse_flash_size = 0x80;
set_dfu_iface_string(fuse_flash_size - 8);
max_address = FLASH_BASE + (fuse_flash_size << 10);
/* If bootloader pages are write protected or device is read
* protected, deny bootloader update.
* User can still force updates, at his own risk!
*/
if (((FLASH_WRPR & 0x03) != 0x03) || (FLASH_OBR & FLASH_OBR_RDPRT_EN))
upd_if_string[30] = '0';
/* Fetch serial number from chip's unique ID */
for(i = 0; i < 8; i++) {
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';

View File

@ -27,20 +27,15 @@
#define CMD_ERASE 0x41
extern uint32_t app_address;
typedef enum {
DFU_MODE = 0,
UPD_MODE = 1
} dfu_mode_t;
/* dfucore.c - DFU core, common to libopencm3 platforms. */
void dfu_init(const usbd_driver *driver, dfu_mode_t mode);
void dfu_init(const usbd_driver *driver);
void dfu_main(void);
/* Device specific functions */
void dfu_check_and_do_sector_erase(uint32_t sector);
void dfu_flash_program_buffer(uint32_t baseaddr, void *buf, int len);
uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum);
void dfu_protect(dfu_mode_t mode);
void dfu_protect(bool enable);
void dfu_jump_app_if_valid(void);
void dfu_event(void);

View File

@ -29,16 +29,12 @@ SRC += cdcacm.c \
traceswoasync.c \
platform_common.c \
all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex dfu_upgrade.bin dfu_upgrade.hex
all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex
blackmagic_dfu.elf: usbdfu.o dfucore.o dfu_f1.o platform_common.o
@echo " LD $@"
$(Q)$(CC) $^ -o $@ $(LDFLAGS_BOOT)
dfu_upgrade.elf: dfu_upgrade.o dfucore.o dfu_f1.o platform_common.o
@echo " LD $@"
$(Q)$(CC) $^ -o $@ $(LDFLAGS)
host_clean:
-$(Q)$(RM) blackmagic.bin blackmagic_dfu blackmagic_dfu.bin blackmagic_dfu.hex

View File

@ -1,68 +0,0 @@
/*
* This file is part of the Black Magic Debug project.
*
* Copyright (C) 2018 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/scb.h>
#include "usbdfu.h"
#include "general.h"
#include "platform.h"
uint32_t app_address = 0x08000000;
extern uint32_t _stack;
static uint32_t rev;
void dfu_detach(void)
{
platform_request_boot();
scb_reset_core();
}
int main(void)
{
rev = detect_rev();
rcc_clock_setup_in_hse_8mhz_out_72mhz();
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
systick_set_reload(900000);
dfu_protect(UPD_MODE);
systick_interrupt_enable();
systick_counter_enable();
dfu_init(&st_usbfs_v1_usb_driver, UPD_MODE);
dfu_main();
}
void dfu_event(void)
{
}
void sys_tick_handler(void)
{
if (rev == 0) {
gpio_toggle(GPIOA, GPIO8);
} else {
gpio_toggle(GPIOC, GPIO13);
}
}

View File

@ -39,9 +39,7 @@ int usbuart_debug_write(const char *buf, size_t len);
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware " FIRMWARE_VERSION ")"
#define BOARD_IDENT_DFU "Black Magic (Upgrade), SWLINK, (Firmware " FIRMWARE_VERSION ")"
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), SWLINK, (Firmware " FIRMWARE_VERSION ")"
#define DFU_IDENT "Black Magic Firmware Upgrade (SWLINK)"
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
/* Hardware definitions... */
#define TMS_PORT GPIOA

View File

@ -75,7 +75,7 @@ int main(void)
if(((GPIOA_CRL & 0x40) == 0x40) && normal_boot)
dfu_jump_app_if_valid();
dfu_protect(DFU_MODE);
dfu_protect(false);
rcc_clock_setup_in_hse_8mhz_out_72mhz();
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
@ -84,7 +84,7 @@ int main(void)
systick_interrupt_enable();
systick_counter_enable();
dfu_init(&st_usbfs_v1_usb_driver, DFU_MODE);
dfu_init(&st_usbfs_v1_usb_driver);
dfu_main();
}