Fix VTOR relocate, add bootloader makefile handling

This commit is contained in:
Hierophect 2020-01-14 15:50:00 -05:00
parent c0dacba80f
commit 05093f7f54
4 changed files with 39 additions and 5 deletions

View File

@ -90,6 +90,10 @@ else
### CFLAGS += -flto ### CFLAGS += -flto
endif endif
ifndef BOOTLOADER_OFFSET
BOOTLOADER_OFFSET := 0x8000000
endif
C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU) C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU)
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
@ -257,7 +261,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
$(ECHO) "Create $@" $(ECHO) "Create $@"
$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08010000 -c -o "$(BUILD)/firmware.uf2" $^ $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b $(BOOTLOADER_OFFSET) -c -o "$(BUILD)/firmware.uf2" $^
include $(TOP)/py/mkrules.mk include $(TOP)/py/mkrules.mk

View File

@ -37,6 +37,7 @@
#define BOARD_OSC_DIV 12 #define BOARD_OSC_DIV 12
#define BOARD_NO_VBUS_SENSE #define BOARD_NO_VBUS_SENSE
#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
// On-board flash // On-board flash
#define SPI_FLASH_MOSI_PIN (&pin_PB15) #define SPI_FLASH_MOSI_PIN (&pin_PB15)

View File

@ -9,6 +9,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ
LONGINT_IMPL = MPZ LONGINT_IMPL = MPZ
BOOTLOADER_OFFSET = 0x8010000
# INTERNAL_FLASH_FILESYSTEM = 1 # INTERNAL_FLASH_FILESYSTEM = 1
# LONGINT_IMPL = NONE # LONGINT_IMPL = NONE

View File

@ -1,3 +1,27 @@
/*
* Taken from ST Cube library and modified. See below for original header.
*
* Modifications copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/** /**
****************************************************************************** ******************************************************************************
* @file system_stm32f4xx.c * @file system_stm32f4xx.c
@ -63,6 +87,7 @@
#include "stm32f4xx.h" #include "stm32f4xx.h"
#include "py/mpconfig.h"
#if !defined (HSE_VALUE) #if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
@ -193,10 +218,12 @@ void SystemInit(void)
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
/* Configure the Vector Table location add offset address ------------------*/ /* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM #if !defined(BOARD_VTOR_DEFER) //only set VTOR if the bootloader hasn't already
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else #else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
#endif #endif
} }