Skip to content

Commit f92904f

Browse files
author
rogerclarkmelbourne
committed
Added support for bootloader 2.0 to Maple mini, and added source and binary for maple_mini_boot20.bin to the repo
1 parent eb4edd9 commit f92904f

6 files changed

Lines changed: 64 additions & 15 deletions

File tree

STM32F1/boards.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
menu.cpu=Processor
44
menu.cpu_upload_menu=CPU & Upload mode
55
menu.device_variant=Variant
6+
menu.bootloader_version=Bootloader version
67

78
menu.upload_method=Upload method
89

@@ -29,12 +30,18 @@ maple_mini.build.extra_flags=-DMCU_STM32F103CB -mthumb -DSERIAL_USB -march=armv
2930
maple_mini.build.ldscript=ld/flash.ld
3031
maple_mini.build.variant=maple_mini
3132
maple_mini.build.variant_system_lib=libmaple.a
32-
maple_mini.build.vect=VECT_TAB_ADDR=0x8005000
3333
maple_mini.build.density=STM32_MEDIUM_DENSITY
3434
maple_mini.build.error_led_port=GPIOB
3535
maple_mini.build.error_led_pin=1
3636
maple_mini.build.gcc_ver=gcc-arm-none-eabi-4.8.3-2014q1
3737

38+
maple_mini.menu.bootloader_version.original = Original
39+
maple_mini.menu.bootloader_version.original.build.vect=VECT_TAB_ADDR=0x8005000
40+
maple_mini.menu.bootloader_version.original.build.ldscript=ld/flash.ld
41+
42+
maple_mini.menu.bootloader_version.bootloader20 = Bootloader 2.0
43+
maple_mini.menu.bootloader_version.bootloader20.build.vect=VECT_TAB_ADDR=0x8002000
44+
maple_mini.menu.bootloader_version.bootloader20.build.ldscript=ld/bootloader_20.ld
3845

3946
##############################################################
4047
maple.name=LeafLabs Maple Rev 3+ to Flash
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* libmaple linker script for "Flash" builds.
3+
*
4+
* A Flash build puts .text (and .rodata) in Flash, and
5+
* .data/.bss/heap (of course) in SRAM, but offsets the sections by
6+
* enough space to store the Maple bootloader, which lives in low
7+
* Flash and uses low memory.
8+
*/
9+
10+
/*
11+
* This pulls in the appropriate MEMORY declaration from the right
12+
* subdirectory of stm32/mem/ (the environment must call ld with the
13+
* right include directory flags to make this happen). Boards can also
14+
* use this file to use any of libmaple's memory-related hooks (like
15+
* where the heap should live).
16+
*/
17+
MEMORY
18+
{
19+
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
20+
rom (rx) : ORIGIN = 0x08002000, LENGTH = 120K
21+
}
22+
23+
/* Provide memory region aliases for common.inc */
24+
REGION_ALIAS("REGION_TEXT", rom);
25+
REGION_ALIAS("REGION_DATA", ram);
26+
REGION_ALIAS("REGION_BSS", ram);
27+
REGION_ALIAS("REGION_RODATA", rom);
28+
29+
/* Let common.inc handle the real work. */
30+
INCLUDE common.inc

usb_bootloader/STM32F1/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ST_LIB = stm32_lib
1717
ST_USB = usb_lib
1818

1919
# Optimization level [0,1,2,3,s]
20-
OPT ?= 0
20+
OPT ?= s
2121
DEBUG =
2222
#DEBUG = dwarf-2
2323

@@ -74,7 +74,7 @@ MSG_CLEANING = Cleaning project:
7474
# Combine all necessary flags and optional flags.
7575
# Add target processor to flags.
7676
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
77-
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
77+
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(TARGETFLAGS) $(GENDEPFLAGS)
7878
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
7979

8080
# --------------------------------------------- #
@@ -113,8 +113,18 @@ ELFSIZE = $(SIZE) -A $(TARGET).elf
113113

114114
# go!
115115
all: begin gccversion build sizeafter finished end
116+
maple-mini: begin gccversion build_maple-mini sizeafter finished end
117+
maple-rev3: begin gccversion build_maple-rev3 sizeafter finished end
118+
116119
build: elf bin lss sym
117120

121+
122+
build_maple-mini: TARGETFLAGS= -DTARGET_MAPLE_MINI
123+
build_maple-mini: elf bin lss sym
124+
125+
build_maple-rev3: TARGETFLAGS= -DTARGET_MAPLE_REV3
126+
build_maple-rev3: elf bin lss sym
127+
118128
bin: $(TARGET).bin
119129
elf: $(TARGET).elf
120130
lss: $(TARGET).lss
6.66 KB
Binary file not shown.

usb_bootloader/STM32F1/config.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,38 @@
3535

3636
#include "common.h"
3737

38+
/* Speed controls for strobing the LED pin */
39+
#define BLINK_FAST 0x50000
40+
#define BLINK_SLOW 0x100000
41+
3842
/* On the Mini, LED is PB1 */
43+
#if defined(TARGET_MAPLE_MINI)
3944
#define LED_BANK GPIOB
4045
#define LED 1
4146
#define LED_BANK_CR GPIO_CRL(LED_BANK)
4247
#define LED_CR_MASK 0xFFFFFF0F
4348
#define LED_CR_MODE 0x00000010
4449
#define RCC_APB2ENR_LED 0x00000008 /* enable PB */
4550

46-
/* Speed controls for strobing the LED pin */
47-
#define BLINK_FAST 0x50000
48-
#define BLINK_SLOW 0x100000
49-
5051
/* On the Mini, BUT is PB8 */
5152
#define BUTTON_BANK GPIOB
5253
#define BUTTON 8
5354
#define BUT_BANK_CR GPIO_CRH(BUTTON_BANK)
5455
#define BUT_CR_MASK 0xFFFFFFF0
5556
#define BUT_CR_OUTPUT_IN 0x00000004
5657
#define RCC_APB2ENR_BUT 0x00000008 /* enable PB */
58+
#else
59+
60+
#error "No config for this target"
61+
62+
#endif
5763

5864
#define STARTUP_BLINKS 5
5965
#define BOOTLOADER_WAIT 6
6066

6167
#define USER_CODE_RAM ((u32)0x20000C00)
6268
#define RAM_END ((u32)0x20005000)
63-
#define USER_CODE_FLASH ((u32)0x08005000)
69+
#define USER_CODE_FLASH ((u32)0x08002000)
6470
#define FLASH_END ((u32)0x08020000)
6571

6672
#define VEND_ID0 0xAF

usb_bootloader/STM32F1/main.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ int main() {
4545
strobePin(LED_BANK, LED, STARTUP_BLINKS, BLINK_FAST);
4646

4747
/* wait for host to upload program or halt bootloader */
48-
bool no_user_jump =
49-
(!checkUserCode(USER_CODE_FLASH) && !checkUserCode(USER_CODE_RAM)) ||
50-
readPin(BUTTON_BANK,BUTTON);
48+
bool no_user_jump = !checkUserCode(USER_CODE_FLASH) || readPin(BUTTON_BANK,BUTTON);
5149
int delay_count = 0;
5250

5351
while ((delay_count++ < BOOTLOADER_WAIT)
@@ -60,14 +58,12 @@ int main() {
6058
}
6159
}
6260

63-
if (checkUserCode(USER_CODE_RAM)) {
64-
jumpToUser(USER_CODE_RAM);
65-
} else if (checkUserCode(USER_CODE_FLASH)) {
61+
if (checkUserCode(USER_CODE_FLASH))
62+
{
6663
jumpToUser(USER_CODE_FLASH);
6764
} else {
6865
// some sort of fault occurred, hard reset
6966
strobePin(LED_BANK, LED, 5, BLINK_FAST);
7067
systemHardReset();
7168
}
72-
7369
}

0 commit comments

Comments
 (0)