F4 Discovery: - Unconditionally use the System Bootloader - Use PC2/4/5/6 Pins for JTAG/SWD to avoid collision with eventual STLink Uart connection - Indicate Bootloader with blue LED
This commit is contained in:
parent
6659d87e9b
commit
ad151fdca8
|
@ -7,12 +7,11 @@ CFLAGS += -Istm32/include -mcpu=cortex-m4 -mthumb \
|
|||
-DSTM32F4 -DF4DISCOVERY -I../libopencm3/include \
|
||||
-Iplatforms/stm32
|
||||
|
||||
LDFLAGS_BOOT := $(LDFLAGS) -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20020000 \
|
||||
LDFLAGS = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20020000 \
|
||||
-Wl,-T,platforms/stm32/f4discovery.ld -nostartfiles -lc -lnosys \
|
||||
-Wl,-Map=mapfile -mthumb -mcpu=cortex-m4 -Wl,-gc-sections \
|
||||
-mfloat-abi=hard -mfpu=fpv4-sp-d16 \
|
||||
-L../libopencm3/lib
|
||||
LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8010000
|
||||
|
||||
VPATH += platforms/stm32
|
||||
|
||||
|
@ -21,19 +20,10 @@ SRC += cdcacm.c \
|
|||
traceswo.c \
|
||||
usbuart.c \
|
||||
|
||||
all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex
|
||||
all: blackmagic.bin
|
||||
|
||||
blackmagic.bin: blackmagic
|
||||
$(OBJCOPY) -O binary $^ $@
|
||||
|
||||
blackmagic_dfu: usbdfu.o dfucore.o dfu_f4.o
|
||||
$(CC) $^ -o $@ $(LDFLAGS_BOOT)
|
||||
|
||||
blackmagic_dfu.bin: blackmagic_dfu
|
||||
$(OBJCOPY) -O binary $^ $@
|
||||
|
||||
blackmagic_dfu.hex: blackmagic_dfu
|
||||
$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
host_clean:
|
||||
-rm blackmagic.bin blackmagic_dfu blackmagic_dfu.bin blackmagic_dfu.hex
|
||||
-rm blackmagic.bin
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
Application start address:
|
||||
=========================
|
||||
System vs BMP Bootloader
|
||||
========================
|
||||
For the BMP bootloader, flashing qas not reliable. So we use the system
|
||||
bootloder unconditional.
|
||||
|
||||
Use 0x8010000
|
||||
- lower 3 16 k pages may be used for parameter storage
|
||||
- Erasing a single 64 k Page is faster then erasing 2 16 k Pages
|
||||
eventual the 64 k page
|
||||
|
||||
|
||||
Internal boot loader:
|
||||
Connections:
|
||||
====================
|
||||
|
||||
When we request invokation of a bootloader from inside the application,
|
||||
we boot the device internal bootloader with the blue botton pressed.
|
||||
PA0: User button to force system bootloader entry with reset
|
||||
PA2/PA3 eventual connected to the STLINK/ STM32F103C8
|
||||
|
||||
That way, we can easy exchange the custom bootloader via the device
|
||||
internale bootloader
|
||||
PC2: TDI
|
||||
PC4: TMS/SWDIO
|
||||
PC5: TCK/SWCLK
|
||||
PC6: TDO/TRACESWO
|
||||
|
||||
PC1: TRST
|
||||
PC8: SRST
|
||||
|
||||
Blue Led: Indicator that system bootloader is entered via BMP
|
||||
|
||||
Bootstrapping the F4Discovery on-board ST-Link
|
||||
==============================================
|
||||
http://embdev.net/articles/STM_Discovery_as_Black_Magic_Probe has some hints
|
||||
how to modify the F4Discovery on-board ST-Link. If you try to do so and hit
|
||||
a problem that stands some test like that you load the right firmware to the
|
||||
right device via the right BMP probe, explain, report and ask on the
|
||||
blackmagic mailing list http://sourceforge.net/mail/?group_id=407419.
|
||||
|
|
|
@ -46,23 +46,28 @@ static void morse_update(void);
|
|||
|
||||
int platform_init(void)
|
||||
{
|
||||
/* Check the USER button*/
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
|
||||
if(gpio_get(GPIOA, GPIO0)) {
|
||||
assert_boot_pin();
|
||||
scb_reset_core();
|
||||
}
|
||||
|
||||
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
|
||||
|
||||
/* Enable peripherals */
|
||||
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_CRCEN);
|
||||
|
||||
|
||||
/* Set up USB Pins and alternate function*/
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
|
||||
GPIO9 | GPIO11 | GPIO12);
|
||||
gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
|
||||
|
||||
GPIOA_OSPEEDR &=~0xfc;
|
||||
GPIOA_OSPEEDR |= 0xa8;
|
||||
GPIOC_OSPEEDR &=~0xF30;
|
||||
GPIOC_OSPEEDR |= 0xA20;
|
||||
gpio_mode_setup(JTAG_PORT, GPIO_MODE_OUTPUT,
|
||||
GPIO_PUPD_NONE,
|
||||
TMS_PIN | TCK_PIN | TDI_PIN);
|
||||
|
@ -73,7 +78,7 @@ int platform_init(void)
|
|||
|
||||
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
|
||||
GPIO_PUPD_NONE,
|
||||
LED_UART | LED_IDLE_RUN | LED_ERROR | LED_SPARE1);
|
||||
LED_UART | LED_IDLE_RUN | LED_ERROR | LED_BOOTLOADER);
|
||||
|
||||
/* Setup heartbeat timer */
|
||||
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
|
||||
|
@ -85,8 +90,6 @@ int platform_init(void)
|
|||
|
||||
usbuart_init();
|
||||
|
||||
SCB_VTOR = 0x10000; // Relocate interrupt vector table here
|
||||
|
||||
cdcacm_init();
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
@ -194,16 +197,14 @@ const char *platform_target_voltage(void)
|
|||
|
||||
void assert_boot_pin(void)
|
||||
{
|
||||
if (gpio_get(GPIOA, GPIO0)) {
|
||||
/* Assert blue LED as indicator we are in the bootloader */
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
|
||||
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
|
||||
GPIO_PUPD_NONE, LED_BOOTLOADER);
|
||||
gpio_set(LED_PORT, LED_BOOTLOADER);
|
||||
|
||||
/* Jump to the built in bootloader by mapping System flash */
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
|
||||
SYSCFG_MEMRM &= ~3;
|
||||
SYSCFG_MEMRM |= 1;
|
||||
}
|
||||
else {
|
||||
/* Flag Bootloader Request by mimicing a pushed USER button*/
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT,
|
||||
GPIO_PUPD_NONE, GPIO0);
|
||||
gpio_set(GPIOA, GPIO0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,15 +49,16 @@ extern usbd_device *usbdev;
|
|||
* LED0 = PD12 (Green LED : Running)
|
||||
* LED1 = PD13 (Orange LED : Idle)
|
||||
* LED2 = PD12 (Red LED : Error)
|
||||
* LED3 = PD15 (Blue LED : Bootloader active)
|
||||
*
|
||||
* TPWR = XXX (input) -- analogue on mini design ADC1, ch8
|
||||
* nTRST = PD0
|
||||
* SRST_OUT = PD1
|
||||
* TDI = PA1
|
||||
* TMS = PA3 (input for SWDP)
|
||||
* TCK = PA8
|
||||
* TDO = PB4 (input)
|
||||
* nSRST = PD2 (input)
|
||||
* nTRST = PC1
|
||||
* SRST_OUT = PC8
|
||||
* TDI = PC2
|
||||
* TMS = PC4 (input for SWDP)
|
||||
* TCK = PC5/SWCLK
|
||||
* TDO = PC6 (input for TRACESWO
|
||||
* nSRST =
|
||||
*
|
||||
* USB cable pull-up: PA8
|
||||
* USB VBUS detect: PB13 -- New on mini design.
|
||||
|
@ -66,32 +67,32 @@ extern usbd_device *usbdev;
|
|||
*/
|
||||
|
||||
/* Hardware definitions... */
|
||||
#define JTAG_PORT GPIOA
|
||||
#define JTAG_PORT GPIOC
|
||||
#define TDI_PORT JTAG_PORT
|
||||
#define TMS_PORT JTAG_PORT
|
||||
#define TCK_PORT JTAG_PORT
|
||||
#define TDO_PORT GPIOB
|
||||
#define TDI_PIN GPIO1
|
||||
#define TMS_PIN GPIO3
|
||||
#define TCK_PIN GPIO2
|
||||
#define TDO_PIN GPIO4
|
||||
#define TDO_PORT GPIOC
|
||||
#define TDI_PIN GPIO2
|
||||
#define TMS_PIN GPIO4
|
||||
#define TCK_PIN GPIO5
|
||||
#define TDO_PIN GPIO6
|
||||
|
||||
#define SWDIO_PORT JTAG_PORT
|
||||
#define SWCLK_PORT JTAG_PORT
|
||||
#define SWDIO_PIN TMS_PIN
|
||||
#define SWCLK_PIN TCK_PIN
|
||||
|
||||
#define TRST_PORT GPIOD
|
||||
#define TRST_PIN GPIO0
|
||||
#define SRST_PORT GPIOD
|
||||
#define SRST_PIN GPIO1
|
||||
#define TRST_PORT GPIOC
|
||||
#define TRST_PIN GPIO1
|
||||
#define SRST_PORT GPIOC
|
||||
#define SRST_PIN GPIO8
|
||||
|
||||
#define LED_PORT GPIOD
|
||||
#define LED_PORT_UART GPIOD
|
||||
#define LED_UART GPIO12
|
||||
#define LED_IDLE_RUN GPIO13
|
||||
#define LED_ERROR GPIO14
|
||||
#define LED_SPARE1 GPIO15
|
||||
#define LED_BOOTLOADER GPIO15
|
||||
|
||||
#define TMS_SET_MODE() gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, \
|
||||
GPIO_PUPD_NONE, TMS_PIN);
|
||||
|
|
Loading…
Reference in New Issue