mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
build: Make all flight sw use pios_board_info_blob
Now that every bootloader build has a board info blob, make all fw and bl images use it. The following MACROS are removed: BOARD_TYPE, BOARD_REVISION, BOOTLOADER_VERSION, START_OF_USER_CODE, HW_TYPE These values are now ONLY available from the bootloader flash via the pios_board_info_blob symbol. These values must not be #defined or otherwise hard-coded into the firmware in any way. The bootloader flash is the only valid source for this information. NOTE: To ensure that we have an upgrade path from an old bootloader (without board_info_blob) to a new bootloader (with board_info_blob), it is essential that the bu_* targets do not depend on (or validate) the board_info_blob being present in the bootloader flash.
This commit is contained in:
parent
2d47427b05
commit
96827eecff
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
/* OpenPilot Includes */
|
/* OpenPilot Includes */
|
||||||
#include "ahrs.h"
|
#include "ahrs.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#include "ahrs_timer.h"
|
#include "ahrs_timer.h"
|
||||||
#include "ahrs_spi_comm.h"
|
#include "ahrs_spi_comm.h"
|
||||||
@ -1228,6 +1229,8 @@ void homelocation_callback(AhrsObjHandle obj)
|
|||||||
|
|
||||||
void firmwareiapobj_callback(AhrsObjHandle obj)
|
void firmwareiapobj_callback(AhrsObjHandle obj)
|
||||||
{
|
{
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
FirmwareIAPObjData firmwareIAPObj;
|
FirmwareIAPObjData firmwareIAPObj;
|
||||||
FirmwareIAPObjGet(&firmwareIAPObj);
|
FirmwareIAPObjGet(&firmwareIAPObj);
|
||||||
if(firmwareIAPObj.ArmReset==0)
|
if(firmwareIAPObj.ArmReset==0)
|
||||||
@ -1235,7 +1238,7 @@ void firmwareiapobj_callback(AhrsObjHandle obj)
|
|||||||
if(firmwareIAPObj.ArmReset==1)
|
if(firmwareIAPObj.ArmReset==1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if((firmwareIAPObj.BoardType==BOARD_TYPE) || (firmwareIAPObj.BoardType==0xFF))
|
if((firmwareIAPObj.BoardType==bdinfo->board_type) || (firmwareIAPObj.BoardType==0xFF))
|
||||||
{
|
{
|
||||||
|
|
||||||
++reset_count;
|
++reset_count;
|
||||||
@ -1247,11 +1250,11 @@ void firmwareiapobj_callback(AhrsObjHandle obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc())
|
else if(firmwareIAPObj.BoardType==bdinfo->board_type && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc())
|
||||||
{
|
{
|
||||||
PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION);
|
PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,bdinfo->desc_size);
|
||||||
firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc();
|
firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||||
firmwareIAPObj.BoardRevision=BOARD_REVISION;
|
firmwareIAPObj.BoardRevision=bdinfo->board_rev;
|
||||||
FirmwareIAPObjSet(&firmwareIAPObj);
|
FirmwareIAPObjSet(&firmwareIAPObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,13 @@ CDEFS = -DSTM32F10X_$(MODEL)
|
|||||||
CDEFS += -DUSE_STDPERIPH_DRIVER
|
CDEFS += -DUSE_STDPERIPH_DRIVER
|
||||||
CDEFS += -DUSE_$(BOARD)
|
CDEFS += -DUSE_$(BOARD)
|
||||||
|
|
||||||
|
# Provide (only) the bootloader with board-specific defines
|
||||||
|
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
||||||
|
BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE)
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
@ -233,8 +240,9 @@ CFLAGS += -O$(OPT)
|
|||||||
ifeq ($(DEBUG),NO)
|
ifeq ($(DEBUG),NO)
|
||||||
CFLAGS += -fdata-sections -ffunction-sections
|
CFLAGS += -fdata-sections -ffunction-sections
|
||||||
endif
|
endif
|
||||||
CFLAGS += -mcpu=$(MCU) -mthumb
|
CFLAGS += -mcpu=$(MCU)
|
||||||
CFLAGS += $(CDEFS)
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(BLONLY_CDEFS)
|
||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
CFLAGS += -mapcs-frame
|
CFLAGS += -mapcs-frame
|
||||||
@ -256,7 +264,7 @@ CONLYFLAGS += $(CSTANDARD)
|
|||||||
# Assembler flags.
|
# Assembler flags.
|
||||||
# -Wa,...: tell GCC to pass this to the assembler.
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
# -ahlns: create listing
|
# -ahlns: create listing
|
||||||
ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp
|
ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp
|
||||||
ASFLAGS += $(ADEFS)
|
ASFLAGS += $(ADEFS)
|
||||||
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
/* OpenPilot Includes */
|
/* OpenPilot Includes */
|
||||||
#include "ahrs_bl.h"
|
#include "ahrs_bl.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "pios_opahrs_proto.h"
|
#include "pios_opahrs_proto.h"
|
||||||
#include "bl_fsm.h" /* lfsm_state */
|
#include "bl_fsm.h" /* lfsm_state */
|
||||||
#include "stm32f10x_flash.h"
|
#include "stm32f10x_flash.h"
|
||||||
@ -108,6 +109,7 @@ static struct opahrs_msg_v0 link_rx_v0;
|
|||||||
static struct opahrs_msg_v0 user_tx_v0;
|
static struct opahrs_msg_v0 user_tx_v0;
|
||||||
static struct opahrs_msg_v0 user_rx_v0;
|
static struct opahrs_msg_v0 user_rx_v0;
|
||||||
void process_spi_request(void) {
|
void process_spi_request(void) {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
bool msg_to_process = FALSE;
|
bool msg_to_process = FALSE;
|
||||||
|
|
||||||
PIOS_IRQ_Disable();
|
PIOS_IRQ_Disable();
|
||||||
@ -166,15 +168,15 @@ void process_spi_request(void) {
|
|||||||
break;
|
break;
|
||||||
case OPAHRS_MSG_V0_REQ_MEM_MAP:
|
case OPAHRS_MSG_V0_REQ_MEM_MAP:
|
||||||
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_MEM_MAP);
|
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_MEM_MAP);
|
||||||
user_tx_v0.payload.user.v.rsp.mem_map.density = HW_TYPE;
|
user_tx_v0.payload.user.v.rsp.mem_map.density = bdinfo->hw_type;
|
||||||
user_tx_v0.payload.user.v.rsp.mem_map.rw_flags = (BOARD_READABLE
|
user_tx_v0.payload.user.v.rsp.mem_map.rw_flags = (BOARD_READABLE
|
||||||
| (BOARD_WRITABLA << 1));
|
| (BOARD_WRITABLA << 1));
|
||||||
user_tx_v0.payload.user.v.rsp.mem_map.size_of_code_memory
|
user_tx_v0.payload.user.v.rsp.mem_map.size_of_code_memory
|
||||||
= SIZE_OF_CODE;
|
= bdinfo->fw_size;
|
||||||
user_tx_v0.payload.user.v.rsp.mem_map.size_of_description
|
user_tx_v0.payload.user.v.rsp.mem_map.size_of_description
|
||||||
= SIZE_OF_DESCRIPTION;
|
= bdinfo->desc_size;
|
||||||
user_tx_v0.payload.user.v.rsp.mem_map.start_of_user_code
|
user_tx_v0.payload.user.v.rsp.mem_map.start_of_user_code
|
||||||
= START_OF_USER_CODE;
|
= bdinfo->fw_base;
|
||||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||||
break;
|
break;
|
||||||
case OPAHRS_MSG_V0_REQ_SERIAL:
|
case OPAHRS_MSG_V0_REQ_SERIAL:
|
||||||
@ -192,7 +194,7 @@ void process_spi_request(void) {
|
|||||||
PIOS_LED_On(LED1);
|
PIOS_LED_On(LED1);
|
||||||
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS);
|
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS);
|
||||||
if (!(user_rx_v0.payload.user.v.req.fwup_data.adress
|
if (!(user_rx_v0.payload.user.v.req.fwup_data.adress
|
||||||
< START_OF_USER_CODE)) {
|
< bdinfo->fw_base)) {
|
||||||
for (uint8_t x = 0; x
|
for (uint8_t x = 0; x
|
||||||
< user_rx_v0.payload.user.v.req.fwup_data.size; ++x) {
|
< user_rx_v0.payload.user.v.req.fwup_data.size; ++x) {
|
||||||
if (FLASH_ProgramWord(
|
if (FLASH_ProgramWord(
|
||||||
@ -250,13 +252,10 @@ void process_spi_request(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void jump_to_app() {
|
void jump_to_app() {
|
||||||
//while(TRUE)
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
//{
|
|
||||||
// PIOS_LED_Toggle(LED1);
|
|
||||||
// PIOS_DELAY_WaitmS(1000);
|
|
||||||
//}
|
|
||||||
PIOS_LED_On(LED1);
|
PIOS_LED_On(LED1);
|
||||||
if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||||
FLASH_Lock();
|
FLASH_Lock();
|
||||||
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
@ -265,10 +264,10 @@ void jump_to_app() {
|
|||||||
//_SetCNTR(0); // clear interrupt mask
|
//_SetCNTR(0); // clear interrupt mask
|
||||||
//_SetISTR(0); // clear all requests
|
//_SetISTR(0); // clear all requests
|
||||||
|
|
||||||
JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4);
|
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
|
||||||
Jump_To_Application = (pFunction) JumpAddress;
|
Jump_To_Application = (pFunction) JumpAddress;
|
||||||
/* Initialize user application's Stack Pointer */
|
/* Initialize user application's Stack Pointer */
|
||||||
__set_MSP(*(__IO uint32_t*) START_OF_USER_CODE);
|
__set_MSP(*(__IO uint32_t*) bdinfo->fw_base);
|
||||||
Jump_To_Application();
|
Jump_To_Application();
|
||||||
} else {
|
} else {
|
||||||
boot_status = jump_failed;
|
boot_status = jump_failed;
|
||||||
|
@ -252,6 +252,13 @@ ifeq ($(ENABLE_AUX_UART), YES)
|
|||||||
CDEFS += -DPIOS_ENABLE_AUX_UART
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Provide (only) the bootloader with board-specific defines
|
||||||
|
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
||||||
|
BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE)
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
@ -287,8 +294,9 @@ ifeq ($(DEBUG),NO)
|
|||||||
CFLAGS += -ffunction-sections
|
CFLAGS += -ffunction-sections
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -mcpu=$(MCU) -mthumb
|
CFLAGS += -mcpu=$(MCU)
|
||||||
CFLAGS += $(CDEFS)
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(BLONLY_CDEFS)
|
||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
CFLAGS += -mapcs-frame
|
CFLAGS += -mapcs-frame
|
||||||
@ -308,7 +316,7 @@ CONLYFLAGS += $(CSTANDARD)
|
|||||||
# Assembler flags.
|
# Assembler flags.
|
||||||
# -Wa,...: tell GCC to pass this to the assembler.
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
# -ahlns: create listing
|
# -ahlns: create listing
|
||||||
ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp
|
ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp
|
||||||
ASFLAGS += $(ADEFS)
|
ASFLAGS += $(ADEFS)
|
||||||
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Bootloader Includes */
|
/* Bootloader Includes */
|
||||||
#include <pios.h>
|
#include <pios.h>
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include "usb_lib.h"
|
#include "usb_lib.h"
|
||||||
@ -163,7 +164,9 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jump_to_app() {
|
void jump_to_app() {
|
||||||
if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||||
FLASH_Lock();
|
FLASH_Lock();
|
||||||
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
@ -171,10 +174,10 @@ void jump_to_app() {
|
|||||||
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
|
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
|
||||||
_SetCNTR(0); // clear interrupt mask
|
_SetCNTR(0); // clear interrupt mask
|
||||||
_SetISTR(0); // clear all requests
|
_SetISTR(0); // clear all requests
|
||||||
JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4);
|
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
|
||||||
Jump_To_Application = (pFunction) JumpAddress;
|
Jump_To_Application = (pFunction) JumpAddress;
|
||||||
/* Initialize user application's Stack Pointer */
|
/* Initialize user application's Stack Pointer */
|
||||||
__set_MSP(*(__IO uint32_t*) START_OF_USER_CODE);
|
__set_MSP(*(__IO uint32_t*) bdinfo->fw_base);
|
||||||
Jump_To_Application();
|
Jump_To_Application();
|
||||||
} else {
|
} else {
|
||||||
DeviceState = failed_jump;
|
DeviceState = failed_jump;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include "pios_bl_helper.h"
|
#include "pios_bl_helper.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
//programmable devices
|
//programmable devices
|
||||||
Device devicesTable[10];
|
Device devicesTable[10];
|
||||||
uint8_t numberOfDevices = 0;
|
uint8_t numberOfDevices = 0;
|
||||||
@ -382,16 +383,18 @@ void processComand(uint8_t *xReceive_Buffer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void OPDfuIni(uint8_t discover) {
|
void OPDfuIni(uint8_t discover) {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
Device dev;
|
Device dev;
|
||||||
|
|
||||||
dev.programmingType = Self_flash;
|
dev.programmingType = Self_flash;
|
||||||
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
||||||
dev.startOfUserCode = START_OF_USER_CODE;
|
dev.startOfUserCode = bdinfo->fw_base;
|
||||||
dev.sizeOfCode = SIZE_OF_CODE;
|
dev.sizeOfCode = bdinfo->fw_size;
|
||||||
dev.sizeOfDescription = SIZE_OF_DESCRIPTION;
|
dev.sizeOfDescription = bdinfo->desc_size;
|
||||||
dev.BL_Version = BOOTLOADER_VERSION;
|
dev.BL_Version = bdinfo->bl_rev;
|
||||||
dev.FW_Crc = CalcFirmCRC();
|
dev.FW_Crc = CalcFirmCRC();
|
||||||
dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION;
|
dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev);
|
||||||
dev.devType = HW_TYPE;
|
dev.devType = bdinfo->hw_type;
|
||||||
numberOfDevices = 1;
|
numberOfDevices = 1;
|
||||||
devicesTable[0] = dev;
|
devicesTable[0] = dev;
|
||||||
if (discover) {
|
if (discover) {
|
||||||
|
@ -255,6 +255,13 @@ ifeq ($(ENABLE_AUX_UART), YES)
|
|||||||
CDEFS += -DPIOS_ENABLE_AUX_UART
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Provide (only) the bootloader with board-specific defines
|
||||||
|
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
||||||
|
BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE)
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
@ -292,6 +299,7 @@ endif
|
|||||||
|
|
||||||
CFLAGS += -mcpu=$(MCU)
|
CFLAGS += -mcpu=$(MCU)
|
||||||
CFLAGS += $(CDEFS)
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(BLONLY_CDEFS)
|
||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
CFLAGS += -mapcs-frame
|
CFLAGS += -mapcs-frame
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Bootloader Includes */
|
/* Bootloader Includes */
|
||||||
#include <pios.h>
|
#include <pios.h>
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "pios_opahrs.h"
|
#include "pios_opahrs.h"
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
@ -216,7 +217,9 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jump_to_app() {
|
void jump_to_app() {
|
||||||
if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||||
FLASH_Lock();
|
FLASH_Lock();
|
||||||
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
@ -225,10 +228,10 @@ void jump_to_app() {
|
|||||||
_SetCNTR(0); // clear interrupt mask
|
_SetCNTR(0); // clear interrupt mask
|
||||||
_SetISTR(0); // clear all requests
|
_SetISTR(0); // clear all requests
|
||||||
|
|
||||||
JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4);
|
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
|
||||||
Jump_To_Application = (pFunction) JumpAddress;
|
Jump_To_Application = (pFunction) JumpAddress;
|
||||||
/* Initialize user application's Stack Pointer */
|
/* Initialize user application's Stack Pointer */
|
||||||
__set_MSP(*(__IO uint32_t*) START_OF_USER_CODE);
|
__set_MSP(*(__IO uint32_t*) bdinfo->fw_base);
|
||||||
Jump_To_Application();
|
Jump_To_Application();
|
||||||
} else {
|
} else {
|
||||||
DeviceState = failed_jump;
|
DeviceState = failed_jump;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include "pios_bl_helper.h"
|
#include "pios_bl_helper.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "pios_opahrs.h"
|
#include "pios_opahrs.h"
|
||||||
#include "ssp.h"
|
#include "ssp.h"
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -447,16 +448,18 @@ void processComand(uint8_t *xReceive_Buffer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void OPDfuIni(uint8_t discover) {
|
void OPDfuIni(uint8_t discover) {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
Device dev;
|
Device dev;
|
||||||
|
|
||||||
dev.programmingType = Self_flash;
|
dev.programmingType = Self_flash;
|
||||||
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
||||||
dev.startOfUserCode = START_OF_USER_CODE;
|
dev.startOfUserCode = bdinfo->fw_base;
|
||||||
dev.sizeOfCode = SIZE_OF_CODE;
|
dev.sizeOfCode = bdinfo->fw_size;
|
||||||
dev.sizeOfDescription = SIZE_OF_DESCRIPTION;
|
dev.sizeOfDescription = bdinfo->desc_size;
|
||||||
dev.BL_Version = BOOTLOADER_VERSION;
|
dev.BL_Version = bdinfo->bl_rev;
|
||||||
dev.FW_Crc = CalcFirmCRC();
|
dev.FW_Crc = CalcFirmCRC();
|
||||||
dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION;
|
dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev);
|
||||||
dev.devType = HW_TYPE;
|
dev.devType = bdinfo->hw_type;
|
||||||
numberOfDevices = 1;
|
numberOfDevices = 1;
|
||||||
devicesTable[0] = dev;
|
devicesTable[0] = dev;
|
||||||
if (discover) {
|
if (discover) {
|
||||||
|
@ -251,6 +251,13 @@ ifeq ($(ENABLE_AUX_UART), YES)
|
|||||||
CDEFS += -DPIOS_ENABLE_AUX_UART
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Provide (only) the bootloader with board-specific defines
|
||||||
|
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)C
|
||||||
|
BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE)
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
@ -286,8 +293,9 @@ ifeq ($(DEBUG),NO)
|
|||||||
CFLAGS += -ffunction-sections
|
CFLAGS += -ffunction-sections
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -mcpu=$(MCU) -mthumb
|
CFLAGS += -mcpu=$(MCU)
|
||||||
CFLAGS += $(CDEFS)
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(BLONLY_CDEFS)
|
||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
CFLAGS += -mapcs-frame
|
CFLAGS += -mapcs-frame
|
||||||
@ -307,7 +315,7 @@ CONLYFLAGS += $(CSTANDARD)
|
|||||||
# Assembler flags.
|
# Assembler flags.
|
||||||
# -Wa,...: tell GCC to pass this to the assembler.
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
# -ahlns: create listing
|
# -ahlns: create listing
|
||||||
ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp
|
ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp
|
||||||
ASFLAGS += $(ADEFS)
|
ASFLAGS += $(ADEFS)
|
||||||
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Bootloader Includes */
|
/* Bootloader Includes */
|
||||||
#include <pios.h>
|
#include <pios.h>
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include "usb_lib.h"
|
#include "usb_lib.h"
|
||||||
@ -170,7 +171,9 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jump_to_app() {
|
void jump_to_app() {
|
||||||
if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||||
FLASH_Lock();
|
FLASH_Lock();
|
||||||
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
@ -179,10 +182,10 @@ void jump_to_app() {
|
|||||||
_SetCNTR(0); // clear interrupt mask
|
_SetCNTR(0); // clear interrupt mask
|
||||||
_SetISTR(0); // clear all requests
|
_SetISTR(0); // clear all requests
|
||||||
|
|
||||||
JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4);
|
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
|
||||||
Jump_To_Application = (pFunction) JumpAddress;
|
Jump_To_Application = (pFunction) JumpAddress;
|
||||||
/* Initialize user application's Stack Pointer */
|
/* Initialize user application's Stack Pointer */
|
||||||
__set_MSP(*(__IO uint32_t*) START_OF_USER_CODE);
|
__set_MSP(*(__IO uint32_t*) bdinfo->fw_base);
|
||||||
Jump_To_Application();
|
Jump_To_Application();
|
||||||
} else {
|
} else {
|
||||||
DeviceState = failed_jump;
|
DeviceState = failed_jump;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include "pios_bl_helper.h"
|
#include "pios_bl_helper.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@ -414,16 +415,18 @@ void processComand(uint8_t *xReceive_Buffer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void OPDfuIni(uint8_t discover) {
|
void OPDfuIni(uint8_t discover) {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
Device dev;
|
Device dev;
|
||||||
|
|
||||||
dev.programmingType = Self_flash;
|
dev.programmingType = Self_flash;
|
||||||
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1));
|
||||||
dev.startOfUserCode = START_OF_USER_CODE;
|
dev.startOfUserCode = bdinfo->fw_base;
|
||||||
dev.sizeOfCode = SIZE_OF_CODE;
|
dev.sizeOfCode = bdinfo->fw_size;
|
||||||
dev.sizeOfDescription = SIZE_OF_DESCRIPTION;
|
dev.sizeOfDescription = bdinfo->desc_size;
|
||||||
dev.BL_Version = BOOTLOADER_VERSION;
|
dev.BL_Version = bdinfo->bl_rev;
|
||||||
dev.FW_Crc = CalcFirmCRC();
|
dev.FW_Crc = CalcFirmCRC();
|
||||||
dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION;
|
dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev);
|
||||||
dev.devType = HW_TYPE;
|
dev.devType = bdinfo->hw_type;
|
||||||
numberOfDevices = 1;
|
numberOfDevices = 1;
|
||||||
devicesTable[0] = dev;
|
devicesTable[0] = dev;
|
||||||
if (discover) {
|
if (discover) {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
#include "firmwareiap.h"
|
#include "firmwareiap.h"
|
||||||
#include "firmwareiapobj.h"
|
#include "firmwareiapobj.h"
|
||||||
@ -90,10 +91,12 @@ static void resetTask(UAVObjEvent *);
|
|||||||
|
|
||||||
int32_t FirmwareIAPInitialize()
|
int32_t FirmwareIAPInitialize()
|
||||||
{
|
{
|
||||||
data.BoardType= BOARD_TYPE;
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
data.BoardType= bdinfo->board_type;
|
||||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||||
data.BoardRevision= BOARD_REVISION;
|
data.BoardRevision= bdinfo->board_rev;
|
||||||
data.ArmReset=0;
|
data.ArmReset=0;
|
||||||
data.crc = 0;
|
data.crc = 0;
|
||||||
FirmwareIAPObjSet( &data );
|
FirmwareIAPObjSet( &data );
|
||||||
@ -112,6 +115,7 @@ int32_t FirmwareIAPInitialize()
|
|||||||
static uint8_t iap_state = IAP_STATE_READY;
|
static uint8_t iap_state = IAP_STATE_READY;
|
||||||
static void FirmwareIAPCallback(UAVObjEvent* ev)
|
static void FirmwareIAPCallback(UAVObjEvent* ev)
|
||||||
{
|
{
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
static uint32_t last_time = 0;
|
static uint32_t last_time = 0;
|
||||||
uint32_t this_time;
|
uint32_t this_time;
|
||||||
uint32_t delta;
|
uint32_t delta;
|
||||||
@ -125,11 +129,11 @@ static void FirmwareIAPCallback(UAVObjEvent* ev)
|
|||||||
this_time = get_time();
|
this_time = get_time();
|
||||||
delta = this_time - last_time;
|
delta = this_time - last_time;
|
||||||
last_time = this_time;
|
last_time = this_time;
|
||||||
if((data.BoardType==BOARD_TYPE)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc()))
|
if((data.BoardType==bdinfo->board_type)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc()))
|
||||||
{
|
{
|
||||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||||
data.BoardRevision=BOARD_REVISION;
|
data.BoardRevision=bdinfo->board_rev;
|
||||||
data.crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
data.crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||||
FirmwareIAPObjSet( &data );
|
FirmwareIAPObjSet( &data );
|
||||||
}
|
}
|
||||||
|
@ -64,23 +64,6 @@ TIM8 | | | |
|
|||||||
//------------------------
|
//------------------------
|
||||||
// BOOTLOADER_SETTINGS
|
// BOOTLOADER_SETTINGS
|
||||||
//------------------------
|
//------------------------
|
||||||
//#define FUNC_ID 2
|
|
||||||
//#define HW_VERSION 69
|
|
||||||
|
|
||||||
#define BOOTLOADER_VERSION 0
|
|
||||||
#define BOARD_TYPE 0x02
|
|
||||||
#define BOARD_REVISION 0x01
|
|
||||||
//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION
|
|
||||||
|
|
||||||
#define MEM_SIZE 0x20000 //128K
|
|
||||||
#define SIZE_OF_DESCRIPTION 100
|
|
||||||
#define START_OF_USER_CODE (uint32_t)0x08002000
|
|
||||||
#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION)
|
|
||||||
#ifdef STM32F10X_HD
|
|
||||||
#define HW_TYPE 0 //0=high_density 1=medium_density;
|
|
||||||
#elif STM32F10X_MD
|
|
||||||
#define HW_TYPE 1 //0=high_density 1=medium_density;
|
|
||||||
#endif
|
|
||||||
#define BOARD_READABLE TRUE
|
#define BOARD_READABLE TRUE
|
||||||
#define BOARD_WRITABLA TRUE
|
#define BOARD_WRITABLA TRUE
|
||||||
#define MAX_DEL_RETRYS 3
|
#define MAX_DEL_RETRYS 3
|
||||||
|
@ -60,21 +60,6 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
|
|||||||
//------------------------
|
//------------------------
|
||||||
// BOOTLOADER_SETTINGS
|
// BOOTLOADER_SETTINGS
|
||||||
//------------------------
|
//------------------------
|
||||||
//#define FUNC_ID 2
|
|
||||||
//#define HW_VERSION 69
|
|
||||||
|
|
||||||
#define BOOTLOADER_VERSION 0
|
|
||||||
#define BOARD_TYPE 0x04
|
|
||||||
#define BOARD_REVISION 0x01
|
|
||||||
#define MEM_SIZE 0x20000 //128K
|
|
||||||
#define SIZE_OF_DESCRIPTION 100
|
|
||||||
#define START_OF_USER_CODE (uint32_t)0x08003000
|
|
||||||
#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION)
|
|
||||||
#ifdef STM32F10X_HD
|
|
||||||
#define HW_TYPE 0 //0=high_density 1=medium_density;
|
|
||||||
#elif STM32F10X_MD
|
|
||||||
#define HW_TYPE 1 //0=high_density 1=medium_density;
|
|
||||||
#endif
|
|
||||||
#define BOARD_READABLE TRUE
|
#define BOARD_READABLE TRUE
|
||||||
#define BOARD_WRITABLA TRUE
|
#define BOARD_WRITABLA TRUE
|
||||||
#define MAX_DEL_RETRYS 3
|
#define MAX_DEL_RETRYS 3
|
||||||
|
@ -58,18 +58,6 @@ TIM4 | STOPWATCH |
|
|||||||
//------------------------
|
//------------------------
|
||||||
// BOOTLOADER_SETTINGS
|
// BOOTLOADER_SETTINGS
|
||||||
//------------------------
|
//------------------------
|
||||||
#define BOOTLOADER_VERSION 0
|
|
||||||
#define BOARD_TYPE 0x03
|
|
||||||
#define BOARD_REVISION 0x01
|
|
||||||
#define MEM_SIZE (0x20000 - 0x00400) // 128K - 1K (reserved for config data)
|
|
||||||
#define SIZE_OF_DESCRIPTION 100
|
|
||||||
#define START_OF_USER_CODE (uint32_t)0x08003000
|
|
||||||
#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION)
|
|
||||||
#ifdef STM32F10X_HD
|
|
||||||
#define HW_TYPE 0 //0=high_density 1=medium_density;
|
|
||||||
#elif STM32F10X_MD
|
|
||||||
#define HW_TYPE 1 //0=high_density 1=medium_density;
|
|
||||||
#endif
|
|
||||||
#define BOARD_READABLE TRUE
|
#define BOARD_READABLE TRUE
|
||||||
#define BOARD_WRITABLA TRUE
|
#define BOARD_WRITABLA TRUE
|
||||||
#define MAX_DEL_RETRYS 3
|
#define MAX_DEL_RETRYS 3
|
||||||
|
@ -69,25 +69,6 @@ TIM8 | | | |
|
|||||||
//------------------------
|
//------------------------
|
||||||
// BOOTLOADER_SETTINGS
|
// BOOTLOADER_SETTINGS
|
||||||
//------------------------
|
//------------------------
|
||||||
|
|
||||||
//#define FUNC_ID 1
|
|
||||||
//#define HW_VERSION 01
|
|
||||||
|
|
||||||
#define BOOTLOADER_VERSION 0
|
|
||||||
#define BOARD_TYPE 0x05 // INS board
|
|
||||||
#define BOARD_REVISION 0x01 // Beta version
|
|
||||||
//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION
|
|
||||||
|
|
||||||
#define MEM_SIZE 524288 //512K
|
|
||||||
#define SIZE_OF_DESCRIPTION (uint8_t) 100
|
|
||||||
#define START_OF_USER_CODE (uint32_t)0x08005000//REMEMBER SET ALSO IN link_stm32f10x_HD_BL.ld
|
|
||||||
#define SIZE_OF_CODE (uint32_t) (MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION)
|
|
||||||
|
|
||||||
#ifdef STM32F10X_HD
|
|
||||||
#define HW_TYPE 0 //0=high_density 1=medium_density;
|
|
||||||
#elif STM32F10X_MD
|
|
||||||
#define HW_TYPE 1 //0=high_density 1=medium_density;
|
|
||||||
#endif
|
|
||||||
#define BOARD_READABLE TRUE
|
#define BOARD_READABLE TRUE
|
||||||
#define BOARD_WRITABLA TRUE
|
#define BOARD_WRITABLA TRUE
|
||||||
#define MAX_DEL_RETRYS 3
|
#define MAX_DEL_RETRYS 3
|
||||||
|
@ -68,25 +68,6 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
|
|||||||
//------------------------
|
//------------------------
|
||||||
// BOOTLOADER_SETTINGS
|
// BOOTLOADER_SETTINGS
|
||||||
//------------------------
|
//------------------------
|
||||||
|
|
||||||
//#define FUNC_ID 1
|
|
||||||
//#define HW_VERSION 01
|
|
||||||
|
|
||||||
#define BOOTLOADER_VERSION 0
|
|
||||||
#define BOARD_TYPE 0x01 // OpenPilot board
|
|
||||||
#define BOARD_REVISION 0x01 // Beta version
|
|
||||||
//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION
|
|
||||||
|
|
||||||
#define MEM_SIZE 524288 //512K
|
|
||||||
#define SIZE_OF_DESCRIPTION (uint8_t) 100
|
|
||||||
#define START_OF_USER_CODE (uint32_t)0x08005000//REMEMBER SET ALSO IN link_stm32f10x_HD_BL.ld
|
|
||||||
#define SIZE_OF_CODE (uint32_t) (MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION)
|
|
||||||
|
|
||||||
#ifdef STM32F10X_HD
|
|
||||||
#define HW_TYPE 0 //0=high_density 1=medium_density;
|
|
||||||
#elif STM32F10X_MD
|
|
||||||
#define HW_TYPE 1 //0=high_density 1=medium_density;
|
|
||||||
#endif
|
|
||||||
#define BOARD_READABLE TRUE
|
#define BOARD_READABLE TRUE
|
||||||
#define BOARD_WRITABLA TRUE
|
#define BOARD_WRITABLA TRUE
|
||||||
#define MAX_DEL_RETRYS 3
|
#define MAX_DEL_RETRYS 3
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
/* Project Includes */
|
/* Project Includes */
|
||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#if defined(PIOS_INCLUDE_BL_HELPER)
|
#if defined(PIOS_INCLUDE_BL_HELPER)
|
||||||
|
#include <pios_board_info.h>
|
||||||
#include "stm32f10x_flash.h"
|
#include "stm32f10x_flash.h"
|
||||||
|
|
||||||
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
|
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
|
||||||
@ -47,10 +48,10 @@ uint8_t PIOS_BL_HELPER_FLASH_Ini()
|
|||||||
|
|
||||||
uint8_t PIOS_BL_HELPER_FLASH_Start()
|
uint8_t PIOS_BL_HELPER_FLASH_Start()
|
||||||
{
|
{
|
||||||
uint32_t pageAdress;
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
pageAdress = START_OF_USER_CODE;
|
uint32_t pageAdress = bdinfo->fw_base;
|
||||||
uint8_t fail = FALSE;
|
uint8_t fail = FALSE;
|
||||||
while ((pageAdress < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION)
|
while ((pageAdress < (bdinfo->fw_base + bdinfo->fw_size + bdinfo->desc_size))
|
||||||
|| (fail == TRUE)) {
|
|| (fail == TRUE)) {
|
||||||
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
|
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
|
||||||
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
|
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
|
||||||
@ -75,17 +76,20 @@ uint8_t PIOS_BL_HELPER_FLASH_Start()
|
|||||||
|
|
||||||
uint32_t PIOS_BL_HELPER_CRC_Memory_Calc()
|
uint32_t PIOS_BL_HELPER_CRC_Memory_Calc()
|
||||||
{
|
{
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
PIOS_BL_HELPER_CRC_Ini();
|
PIOS_BL_HELPER_CRC_Ini();
|
||||||
CRC_ResetDR();
|
CRC_ResetDR();
|
||||||
CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2);
|
CRC_CalcBlockCRC((uint32_t *) bdinfo->fw_base, (bdinfo->fw_size) >> 2);
|
||||||
return CRC_GetCRC();
|
return CRC_GetCRC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size)
|
void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size)
|
||||||
{
|
{
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
uint8_t x = 0;
|
uint8_t x = 0;
|
||||||
if (size>SIZE_OF_DESCRIPTION) size = SIZE_OF_DESCRIPTION;
|
if (size > bdinfo->desc_size) size = bdinfo->desc_size;
|
||||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + size; ++i) {
|
for (uint32_t i = bdinfo->fw_base + bdinfo->fw_size; i < bdinfo->fw_base + bdinfo->fw_size + size; ++i) {
|
||||||
array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i);
|
array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i);
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user