Fix VTOR relocate, add bootloader makefile handling
This commit is contained in:
parent
c0dacba80f
commit
05093f7f54
@ -90,6 +90,10 @@ else
|
||||
### CFLAGS += -flto
|
||||
endif
|
||||
|
||||
ifndef BOOTLOADER_OFFSET
|
||||
BOOTLOADER_OFFSET := 0x8000000
|
||||
endif
|
||||
|
||||
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)
|
||||
@ -257,7 +261,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf
|
||||
|
||||
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
|
||||
$(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
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#define BOARD_OSC_DIV 12
|
||||
#define BOARD_NO_VBUS_SENSE
|
||||
#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
|
||||
|
||||
// On-board flash
|
||||
#define SPI_FLASH_MOSI_PIN (&pin_PB15)
|
||||
|
@ -9,6 +9,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
|
||||
EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
BOOTLOADER_OFFSET = 0x8010000
|
||||
|
||||
# INTERNAL_FLASH_FILESYSTEM = 1
|
||||
# LONGINT_IMPL = NONE
|
||||
|
||||
|
@ -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
|
||||
@ -63,6 +87,7 @@
|
||||
|
||||
|
||||
#include "stm32f4xx.h"
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
#if !defined (HSE_VALUE)
|
||||
#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 */
|
||||
|
||||
/* 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 */
|
||||
#else
|
||||
#else
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user