Added support for bootloader 2.0 to Maple mini, and added source and binary for maple_mini_boot20.bin to the repo

This commit is contained in:
rogerclarkmelbourne 2015-04-25 19:15:48 +10:00
parent eb4edd90af
commit f92904f577
6 changed files with 64 additions and 15 deletions

View File

@ -3,6 +3,7 @@
menu.cpu=Processor
menu.cpu_upload_menu=CPU & Upload mode
menu.device_variant=Variant
menu.bootloader_version=Bootloader version
menu.upload_method=Upload method
@ -29,12 +30,18 @@ maple_mini.build.extra_flags=-DMCU_STM32F103CB -mthumb -DSERIAL_USB -march=armv
maple_mini.build.ldscript=ld/flash.ld
maple_mini.build.variant=maple_mini
maple_mini.build.variant_system_lib=libmaple.a
maple_mini.build.vect=VECT_TAB_ADDR=0x8005000
maple_mini.build.density=STM32_MEDIUM_DENSITY
maple_mini.build.error_led_port=GPIOB
maple_mini.build.error_led_pin=1
maple_mini.build.gcc_ver=gcc-arm-none-eabi-4.8.3-2014q1
maple_mini.menu.bootloader_version.original = Original
maple_mini.menu.bootloader_version.original.build.vect=VECT_TAB_ADDR=0x8005000
maple_mini.menu.bootloader_version.original.build.ldscript=ld/flash.ld
maple_mini.menu.bootloader_version.bootloader20 = Bootloader 2.0
maple_mini.menu.bootloader_version.bootloader20.build.vect=VECT_TAB_ADDR=0x8002000
maple_mini.menu.bootloader_version.bootloader20.build.ldscript=ld/bootloader_20.ld
##############################################################
maple.name=LeafLabs Maple Rev 3+ to Flash

View File

@ -0,0 +1,30 @@
/*
* libmaple linker script for "Flash" builds.
*
* A Flash build puts .text (and .rodata) in Flash, and
* .data/.bss/heap (of course) in SRAM, but offsets the sections by
* enough space to store the Maple bootloader, which lives in low
* Flash and uses low memory.
*/
/*
* This pulls in the appropriate MEMORY declaration from the right
* subdirectory of stm32/mem/ (the environment must call ld with the
* right include directory flags to make this happen). Boards can also
* use this file to use any of libmaple's memory-related hooks (like
* where the heap should live).
*/
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
rom (rx) : ORIGIN = 0x08002000, LENGTH = 120K
}
/* Provide memory region aliases for common.inc */
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
REGION_ALIAS("REGION_RODATA", rom);
/* Let common.inc handle the real work. */
INCLUDE common.inc

View File

@ -17,7 +17,7 @@ ST_LIB = stm32_lib
ST_USB = usb_lib
# Optimization level [0,1,2,3,s]
OPT ?= 0
OPT ?= s
DEBUG =
#DEBUG = dwarf-2
@ -74,7 +74,7 @@ MSG_CLEANING = Cleaning project:
# Combine all necessary flags and optional flags.
# Add target processor to flags.
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(TARGETFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# --------------------------------------------- #
@ -113,8 +113,18 @@ ELFSIZE = $(SIZE) -A $(TARGET).elf
# go!
all: begin gccversion build sizeafter finished end
maple-mini: begin gccversion build_maple-mini sizeafter finished end
maple-rev3: begin gccversion build_maple-rev3 sizeafter finished end
build: elf bin lss sym
build_maple-mini: TARGETFLAGS= -DTARGET_MAPLE_MINI
build_maple-mini: elf bin lss sym
build_maple-rev3: TARGETFLAGS= -DTARGET_MAPLE_REV3
build_maple-rev3: elf bin lss sym
bin: $(TARGET).bin
elf: $(TARGET).elf
lss: $(TARGET).lss

Binary file not shown.

View File

@ -35,7 +35,12 @@
#include "common.h"
/* Speed controls for strobing the LED pin */
#define BLINK_FAST 0x50000
#define BLINK_SLOW 0x100000
/* On the Mini, LED is PB1 */
#if defined(TARGET_MAPLE_MINI)
#define LED_BANK GPIOB
#define LED 1
#define LED_BANK_CR GPIO_CRL(LED_BANK)
@ -43,10 +48,6 @@
#define LED_CR_MODE 0x00000010
#define RCC_APB2ENR_LED 0x00000008 /* enable PB */
/* Speed controls for strobing the LED pin */
#define BLINK_FAST 0x50000
#define BLINK_SLOW 0x100000
/* On the Mini, BUT is PB8 */
#define BUTTON_BANK GPIOB
#define BUTTON 8
@ -54,13 +55,18 @@
#define BUT_CR_MASK 0xFFFFFFF0
#define BUT_CR_OUTPUT_IN 0x00000004
#define RCC_APB2ENR_BUT 0x00000008 /* enable PB */
#else
#error "No config for this target"
#endif
#define STARTUP_BLINKS 5
#define BOOTLOADER_WAIT 6
#define USER_CODE_RAM ((u32)0x20000C00)
#define RAM_END ((u32)0x20005000)
#define USER_CODE_FLASH ((u32)0x08005000)
#define USER_CODE_FLASH ((u32)0x08002000)
#define FLASH_END ((u32)0x08020000)
#define VEND_ID0 0xAF

View File

@ -45,9 +45,7 @@ int main() {
strobePin(LED_BANK, LED, STARTUP_BLINKS, BLINK_FAST);
/* wait for host to upload program or halt bootloader */
bool no_user_jump =
(!checkUserCode(USER_CODE_FLASH) && !checkUserCode(USER_CODE_RAM)) ||
readPin(BUTTON_BANK,BUTTON);
bool no_user_jump = !checkUserCode(USER_CODE_FLASH) || readPin(BUTTON_BANK,BUTTON);
int delay_count = 0;
while ((delay_count++ < BOOTLOADER_WAIT)
@ -60,14 +58,12 @@ int main() {
}
}
if (checkUserCode(USER_CODE_RAM)) {
jumpToUser(USER_CODE_RAM);
} else if (checkUserCode(USER_CODE_FLASH)) {
if (checkUserCode(USER_CODE_FLASH))
{
jumpToUser(USER_CODE_FLASH);
} else {
// some sort of fault occurred, hard reset
strobePin(LED_BANK, LED, 5, BLINK_FAST);
systemHardReset();
}
}