diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index b0de38d0a..09230f439 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -121,6 +121,7 @@ SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_hmc5843.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/pios_iap.c +SRC += $(PIOSCOMMON)/pios_bl_helper.c ## CMSIS for STM32 SRC += $(CMSISDIR)/core_cm3.c @@ -304,39 +305,16 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.ahrs.osx.cfg -f ../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.ahrs.cfg -f ../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" -# terminate OOCD after programming +# # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- + # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/AHRS/ahrs.c b/flight/AHRS/ahrs.c index 1c15d5c69..57f9e11e2 100644 --- a/flight/AHRS/ahrs.c +++ b/flight/AHRS/ahrs.c @@ -99,8 +99,6 @@ void affine_rotate(float scale[3][4], float rotation[3]); void calibration(float result[3], float scale[3][4], float arg[3]); /* Bootloader related functions and var*/ -static uint32_t iap_calc_crc(void); -static void read_description(uint8_t *); void firmwareiapobj_callback(AhrsObjHandle obj); volatile uint8_t reset_count=0; @@ -1249,36 +1247,15 @@ void firmwareiapobj_callback(AhrsObjHandle obj) } } } - else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=iap_calc_crc()) + else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc()) { - read_description(firmwareIAPObj.Description); - firmwareIAPObj.crc=iap_calc_crc(); + PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION); + firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc(); firmwareIAPObj.BoardRevision=BOARD_REVISION; FirmwareIAPObjSet(&firmwareIAPObj); } } -static uint32_t iap_calc_crc(void) -{ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); - CRC_ResetDR(); - CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2); - return CRC_GetCRC(); -} -static uint8_t *FLASH_If_Read(uint32_t SectorAddress) -{ - return (uint8_t *) (SectorAddress); -} -static void read_description(uint8_t * array) -{ - uint8_t x = 0; - for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) { - array[x] = *FLASH_If_Read(i); - ++x; - } -} - - /** * @} */ diff --git a/flight/AHRS/inc/pios_config.h b/flight/AHRS/inc/pios_config.h index e60544d60..64f3559a0 100644 --- a/flight/AHRS/inc/pios_config.h +++ b/flight/AHRS/inc/pios_config.h @@ -40,5 +40,6 @@ #define PIOS_INCLUDE_HMC5843 #define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_BL_HELPER #endif /* PIOS_CONFIG_H */ diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 60bbc4755..f7d101443 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -291,31 +291,8 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_stm32f10x_$(MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.ahrs.osx.cfg -f ../../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.ahrs.cfg -f ../../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" @@ -323,8 +300,6 @@ OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Bootloaders/AHRS/inc/pios_config.h b/flight/Bootloaders/AHRS/inc/pios_config.h index 601701c1e..488d99b83 100644 --- a/flight/Bootloaders/AHRS/inc/pios_config.h +++ b/flight/Bootloaders/AHRS/inc/pios_config.h @@ -35,6 +35,7 @@ #define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SYS #define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #define PIOS_INCLUDE_GPIO #endif /* PIOS_CONFIG_H */ diff --git a/flight/Bootloaders/AHRS/main.c b/flight/Bootloaders/AHRS/main.c index 41d04175a..1a8798702 100644 --- a/flight/Bootloaders/AHRS/main.c +++ b/flight/Bootloaders/AHRS/main.c @@ -96,7 +96,7 @@ int main() { } PIOS_Board_Init(); boot_status = idle; - Fw_crc = crc_memory_calc(); + Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc(); PIOS_LED_On(LED1); while (1) { process_spi_request(); @@ -146,7 +146,7 @@ void process_spi_request(void) { case OPAHRS_MSG_V0_REQ_FWUP_VERIFY: opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS); - Fw_crc = crc_memory_calc(); + Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc(); lfsm_user_set_tx_v0(&user_tx_v0); boot_status = idle; PIOS_LED_Off(LED1); @@ -216,7 +216,7 @@ void process_spi_request(void) { uint32_t adr=user_rx_v0.payload.user.v.req.fwdn_data.adress; for(uint8_t x=0;x<4;++x) { - user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*FLASH_If_Read(adr+x); + user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*PIOS_BL_HELPER_FLASH_If_Read(adr+x); } lfsm_user_set_tx_v0(&user_tx_v0); break; @@ -226,7 +226,7 @@ void process_spi_request(void) { user_tx_v0.payload.user.v.rsp.fwup_status.status = boot_status; lfsm_user_set_tx_v0(&user_tx_v0); PIOS_LED_On(LED1); - if (FLASH_Start() == TRUE) { + if (PIOS_BL_HELPER_FLASH_Start() == TRUE) { boot_status = started; PIOS_LED_Off(LED1); } else { diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index 264e94547..425513e64 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -64,8 +64,8 @@ USE_THUMB_MODE = YES # - MODEL used for linker-script name (-T) and passed as define # - BOARD just passed as define (optional) MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD ?= NULL +CHIP = STM32F103CBT +BOARD ?= NULL MODEL ?= NULL ifeq ($(USE_BOOTLOADER), YES) @@ -330,41 +330,15 @@ else quote = endif -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) - -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program +OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. CC = $(TCHAIN_PREFIX)gcc diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index ce0f9020b..89ed0d53d 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -370,40 +370,15 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_stm32f10x_$(MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program +OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Bootloaders/CopterControl/inc/pios_config.h b/flight/Bootloaders/CopterControl/inc/pios_config.h index bfdea4f1a..594029bba 100644 --- a/flight/Bootloaders/CopterControl/inc/pios_config.h +++ b/flight/Bootloaders/CopterControl/inc/pios_config.h @@ -31,6 +31,7 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H #define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #define USB_HID /* Enable/Disable PiOS Modules */ #define PIOS_INCLUDE_DELAY @@ -61,4 +62,4 @@ /** * @} * @} - */ + */ diff --git a/flight/Bootloaders/CopterControl/op_dfu.c b/flight/Bootloaders/CopterControl/op_dfu.c index 3a84d4d16..9da07835b 100644 --- a/flight/Bootloaders/CopterControl/op_dfu.c +++ b/flight/Bootloaders/CopterControl/op_dfu.c @@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) { } break; case Self_flash: - SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset); - SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1); - SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2); - SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3); + SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset); + SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1); + SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2); + SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3); break; } */ @@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) { uint8_t result = 0; switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Ini(); + result = PIOS_BL_HELPER_FLASH_Ini(); break; case Remote_flash_via_spi: result = TRUE; @@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) { if (TransferType == FW) { switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Start(); + result = PIOS_BL_HELPER_FLASH_Start(); break; case Remote_flash_via_spi: result = FALSE; @@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) { uint32_t CalcFirmCRC() { switch (currentProgrammingDestination) { case Self_flash: - return crc_memory_calc(); + return PIOS_BL_HELPER_CRC_Memory_Calc(); break; case Remote_flash_via_spi: return 0; @@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) { break; case Self_flash: for (uint8_t x = 0; x < 4; ++x) { - buffer[x] = *FLASH_If_Read(adr + x); + buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x); } return TRUE; break; diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index 41d527d0d..81cce20e3 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -371,40 +371,15 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_stm32f10x_$(MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program +OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Bootloaders/OpenPilot/inc/pios_config.h b/flight/Bootloaders/OpenPilot/inc/pios_config.h index f0c46c8ed..4f881c26f 100644 --- a/flight/Bootloaders/OpenPilot/inc/pios_config.h +++ b/flight/Bootloaders/OpenPilot/inc/pios_config.h @@ -31,6 +31,7 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H #define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #define USB_HID /* Enable/Disable PiOS Modules */ #define PIOS_INCLUDE_DELAY @@ -64,4 +65,4 @@ /** * @} * @} - */ + */ diff --git a/flight/Bootloaders/OpenPilot/op_dfu.c b/flight/Bootloaders/OpenPilot/op_dfu.c index 3b3fa159e..92b3c7d7b 100644 --- a/flight/Bootloaders/OpenPilot/op_dfu.c +++ b/flight/Bootloaders/OpenPilot/op_dfu.c @@ -158,7 +158,7 @@ void processComand(uint8_t *xReceive_Buffer) { uint8_t result = 0; switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Ini(); + result = PIOS_BL_HELPER_FLASH_Ini(); break; case Remote_flash_via_spi: result = TRUE; @@ -195,7 +195,7 @@ void processComand(uint8_t *xReceive_Buffer) { if (TransferType == FW) { switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Start(); + result = PIOS_BL_HELPER_FLASH_Start(); break; case Remote_flash_via_spi: PIOS_OPAHRS_bl_FwupStart(&rsp); @@ -525,7 +525,7 @@ uint32_t CalcFirmCRC() { struct opahrs_msg_v0 rsp; switch (currentProgrammingDestination) { case Self_flash: - return crc_memory_calc(); + return PIOS_BL_HELPER_CRC_Memory_Calc(); break; case Remote_flash_via_spi: PIOS_OPAHRS_bl_FwupVerify(&rsp); @@ -574,7 +574,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) { break; case Self_flash: for (uint8_t x = 0; x < 4; ++x) { - buffer[x] = *FLASH_If_Read(adr + x); + buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x); } return TRUE; break; diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index fe8a29636..7ec9e819d 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -370,40 +370,15 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_stm32f10x_$(MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program +OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Bootloaders/PipXtreme/inc/pios_config.h b/flight/Bootloaders/PipXtreme/inc/pios_config.h index bfdea4f1a..594029bba 100644 --- a/flight/Bootloaders/PipXtreme/inc/pios_config.h +++ b/flight/Bootloaders/PipXtreme/inc/pios_config.h @@ -31,6 +31,7 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H #define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #define USB_HID /* Enable/Disable PiOS Modules */ #define PIOS_INCLUDE_DELAY @@ -61,4 +62,4 @@ /** * @} * @} - */ + */ diff --git a/flight/Bootloaders/PipXtreme/op_dfu.c b/flight/Bootloaders/PipXtreme/op_dfu.c index 3a84d4d16..9da07835b 100644 --- a/flight/Bootloaders/PipXtreme/op_dfu.c +++ b/flight/Bootloaders/PipXtreme/op_dfu.c @@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) { } break; case Self_flash: - SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset); - SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1); - SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2); - SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3); + SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset); + SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1); + SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2); + SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3); break; } */ @@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) { uint8_t result = 0; switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Ini(); + result = PIOS_BL_HELPER_FLASH_Ini(); break; case Remote_flash_via_spi: result = TRUE; @@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) { if (TransferType == FW) { switch (currentProgrammingDestination) { case Self_flash: - result = FLASH_Start(); + result = PIOS_BL_HELPER_FLASH_Start(); break; case Remote_flash_via_spi: result = FALSE; @@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) { uint32_t CalcFirmCRC() { switch (currentProgrammingDestination) { case Self_flash: - return crc_memory_calc(); + return PIOS_BL_HELPER_CRC_Memory_Calc(); break; case Remote_flash_via_spi: return 0; @@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) { break; case Self_flash: for (uint8_t x = 0; x < 4; ++x) { - buffer[x] = *FLASH_If_Read(adr + x); + buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x); } return TRUE; break; diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index fd846b208..a6ff62c70 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -216,6 +216,7 @@ SRC += $(PIOSCOMMON)/pios_adxl345.c SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_i2c_esc.c SRC += $(PIOSCOMMON)/pios_iap.c +SRC += $(PIOSCOMMON)/pios_bl_helper.c SRC += $(PIOSCOMMON)/printf-stdarg.c ## Libraries for flight calculations SRC += $(FLIGHTLIB)/fifo_buffer.c @@ -477,31 +478,8 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" @@ -509,7 +487,6 @@ OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/CopterControl/System/alarms.c b/flight/CopterControl/System/alarms.c index 2ebc6385f..e899be779 100644 --- a/flight/CopterControl/System/alarms.c +++ b/flight/CopterControl/System/alarms.c @@ -77,7 +77,6 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity { alarms.Alarm[alarm] = severity; SystemAlarmsSet(&alarms); - SystemAlarmsUpdated(); // force telemetry update since the alarm was changed } // Release lock diff --git a/flight/CopterControl/System/inc/pios_config.h b/flight/CopterControl/System/inc/pios_config.h index ed4e83aab..67328c0f8 100644 --- a/flight/CopterControl/System/inc/pios_config.h +++ b/flight/CopterControl/System/inc/pios_config.h @@ -65,6 +65,7 @@ #define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_WDG +#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_ADXL345 #define PIOS_INCLUDE_FLASH diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 28ec16803..8e0423a45 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -313,39 +313,15 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" -# terminate OOCD after programming +# # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Modules/FirmwareIAP/firmwareiap.c b/flight/Modules/FirmwareIAP/firmwareiap.c index 2301363ba..71de8c390 100644 --- a/flight/Modules/FirmwareIAP/firmwareiap.c +++ b/flight/Modules/FirmwareIAP/firmwareiap.c @@ -47,7 +47,6 @@ #define RESET_DELAY 500 /* delay between sending reset ot INS */ - #define TICKS2MS(t) ((t)/portTICK_RATE_MS) #define MS2TICKS(m) ((m)*portTICK_RATE_MS) @@ -59,18 +58,12 @@ const uint32_t iap_time_3_high_end = 5000; // Private types // Private variables -const static uint8_t version[] = { 0, 0, 1 }; -const static uint16_t SVN = 12345; static uint8_t reset_count = 0; static portTickType lastResetSysTime; // Private functions static void FirmwareIAPCallback(UAVObjEvent* ev); -static uint32_t iap_calc_crc(void); - -static void read_description(uint8_t *); - FirmwareIAPObjData data; static uint32_t get_time(void); @@ -97,7 +90,8 @@ static void resetTask(UAVObjEvent *); int32_t FirmwareIAPInitialize() { data.BoardType= BOARD_TYPE; - read_description(data.Description); + PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM); + PIOS_SYS_SerialNumberGetBinary(data.CPUSerial); data.BoardRevision= BOARD_REVISION; data.ArmReset=0; data.crc = 0; @@ -130,11 +124,12 @@ static void FirmwareIAPCallback(UAVObjEvent* ev) this_time = get_time(); delta = this_time - last_time; last_time = this_time; - if((data.BoardType==BOARD_TYPE)&&(data.crc != iap_calc_crc())) + if((data.BoardType==BOARD_TYPE)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc())) { - read_description(data.Description); + PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM); + PIOS_SYS_SerialNumberGetBinary(data.CPUSerial); data.BoardRevision=BOARD_REVISION; - data.crc = iap_calc_crc(); + data.crc = PIOS_BL_HELPER_CRC_Memory_Calc(); FirmwareIAPObjSet( &data ); } if((data.ArmReset==1)&&(iap_state!=IAP_STATE_RESETTING)) @@ -213,41 +208,6 @@ static uint32_t get_time(void) return TICKS2MS(ticks); } - - -/*! - * \brief Calculate the CRC value of the code in flash. - * \param None - * \return calculated CRC value using STM32's builtin CRC hardware - * - * \note - * I copied this function as the function crc calc function in pios_bl_helper.c - * is only included when the PIOS_BL_HELPER is defined, but this also includes - * the flash unlock and erase functions. It is safer to only have the flash - * functions in the bootloader. - * - */ - -static uint32_t iap_calc_crc(void) -{ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); - CRC_ResetDR(); - CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2); - return CRC_GetCRC(); -} -static uint8_t *FLASH_If_Read(uint32_t SectorAddress) -{ - return (uint8_t *) (SectorAddress); -} -static void read_description(uint8_t * array) -{ - uint8_t x = 0; - for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) { - array[x] = *FLASH_If_Read(i); - ++x; - } -} - /** * Executed by event dispatcher callback to reset INS before resetting OP */ diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index d649de994..80fb044d9 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -322,11 +322,12 @@ static void gpsTask(void *parameters) else { // we appear to be receiving GPS sentences OK, we've had an update + GPSPositionGet(&GpsData); + #ifdef PIOS_GPS_SETS_HOMELOCATION HomeLocationData home; HomeLocationGet(&home); - GPSPositionGet(&GpsData); if ((GpsData.Status == GPSPOSITION_STATUS_FIX3D) && (home.Set == HOMELOCATION_SET_FALSE)) setHomeLocation(&GpsData); #endif diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index da1a2e157..e281af9bd 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -208,6 +208,7 @@ SRC += $(PIOSCOMMON)/pios_bmp085.c SRC += $(PIOSCOMMON)/pios_hcsr04.c SRC += $(PIOSCOMMON)/pios_i2c_esc.c SRC += $(PIOSCOMMON)/pios_iap.c +SRC += $(PIOSCOMMON)/pios_bl_helper.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(FLIGHTLIB)/ahrs_spi_comm.c SRC += $(FLIGHTLIB)/ahrs_comm_objects.c @@ -459,31 +460,8 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OOCD_EXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.osx.cfg -f ../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.openpilot.cfg -f ../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" @@ -491,7 +469,7 @@ OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- + # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/OpenPilot/System/alarms.c b/flight/OpenPilot/System/alarms.c index 2ebc6385f..e899be779 100644 --- a/flight/OpenPilot/System/alarms.c +++ b/flight/OpenPilot/System/alarms.c @@ -77,7 +77,6 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity { alarms.Alarm[alarm] = severity; SystemAlarmsSet(&alarms); - SystemAlarmsUpdated(); // force telemetry update since the alarm was changed } // Release lock diff --git a/flight/OpenPilot/System/inc/pios_config.h b/flight/OpenPilot/System/inc/pios_config.h index 454da36d7..f3fe8671b 100644 --- a/flight/OpenPilot/System/inc/pios_config.h +++ b/flight/OpenPilot/System/inc/pios_config.h @@ -66,6 +66,7 @@ #define PIOS_INCLUDE_RTC #define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_I2C_ESC +#define PIOS_INCLUDE_BL_HELPER /* Defaults for Logging */ #define LOG_FILENAME "PIOS.LOG" diff --git a/flight/PiOS/Common/pios_bl_helper.c b/flight/PiOS/Common/pios_bl_helper.c index 99058b2cb..545a008c6 100644 --- a/flight/PiOS/Common/pios_bl_helper.c +++ b/flight/PiOS/Common/pios_bl_helper.c @@ -33,18 +33,19 @@ #if defined(PIOS_INCLUDE_BL_HELPER) #include "stm32f10x_flash.h" -uint8_t *FLASH_If_Read(uint32_t SectorAddress) +uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress) { return (uint8_t *) (SectorAddress); } -uint8_t FLASH_Ini() +#if defined(PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT) +uint8_t PIOS_BL_HELPER_FLASH_Ini() { FLASH_Unlock(); return 1; } -uint8_t FLASH_Start() +uint8_t PIOS_BL_HELPER_FLASH_Start() { uint32_t pageAdress; pageAdress = START_OF_USER_CODE; @@ -70,24 +71,27 @@ uint8_t FLASH_Start() return (fail == TRUE) ? 0 : 1; } +#endif -uint32_t crc_memory_calc() +uint32_t PIOS_BL_HELPER_CRC_Memory_Calc() { + PIOS_BL_HELPER_CRC_Ini(); CRC_ResetDR(); CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2); return CRC_GetCRC(); } -void read_description(uint8_t * array) +void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size) { uint8_t x = 0; - for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) { - array[x] = *FLASH_If_Read(i); + if (size>SIZE_OF_DESCRIPTION) size = SIZE_OF_DESCRIPTION; + for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + size; ++i) { + array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i); ++x; } } -void CRC_Ini() +void PIOS_BL_HELPER_CRC_Ini() { RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); } diff --git a/flight/PiOS/STM32F10x/pios_sys.c b/flight/PiOS/STM32F10x/pios_sys.c index a6d67e701..2170c7811 100644 --- a/flight/PiOS/STM32F10x/pios_sys.c +++ b/flight/PiOS/STM32F10x/pios_sys.c @@ -134,6 +134,27 @@ uint32_t PIOS_SYS_getCPUFlashSize(void) return ((uint32_t) MEM16(0x1FFFF7E0) * 1000); } +/** +* Returns the serial number as a string +* param[out] str pointer to a string which can store at least 32 digits + zero terminator! +* (24 digits returned for STM32) +* return < 0 if feature not supported +*/ +int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array) +{ + int i; + + /* Stored in the so called "electronic signature" */ + for (i = 0; i < 12; ++i) { + uint8_t b = MEM8(0x1ffff7e8 + i); + + array[i] = b; + } + + /* No error */ + return 0; +} + /** * Returns the serial number as a string * param[out] str pointer to a string which can store at least 32 digits + zero terminator! diff --git a/flight/PiOS/inc/pios_bl_helper.h b/flight/PiOS/inc/pios_bl_helper.h index ca241c922..e2e9e694e 100644 --- a/flight/PiOS/inc/pios_bl_helper.h +++ b/flight/PiOS/inc/pios_bl_helper.h @@ -31,16 +31,16 @@ #ifndef PIOS_BL_HELPER_H_ #define PIOS_BL_HELPER_H_ -extern uint8_t *FLASH_If_Read(uint32_t SectorAddress); +extern uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress); -extern uint8_t FLASH_Ini(); +extern uint8_t PIOS_BL_HELPER_FLASH_Ini(); -extern uint32_t crc_memory_calc(); +extern uint32_t PIOS_BL_HELPER_CRC_Memory_Calc(); -extern void read_description(uint8_t * array); +extern void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size); -extern uint8_t FLASH_Start(); +extern uint8_t PIOS_BL_HELPER_FLASH_Start(); -extern void CRC_Ini(); +extern void PIOS_BL_HELPER_CRC_Ini(); #endif /* PIOS_BL_HELPER_H_ */ diff --git a/flight/PiOS/inc/pios_sys.h b/flight/PiOS/inc/pios_sys.h index d1f53f26b..9407fa720 100644 --- a/flight/PiOS/inc/pios_sys.h +++ b/flight/PiOS/inc/pios_sys.h @@ -36,6 +36,7 @@ extern void PIOS_SYS_Init(void); extern int32_t PIOS_SYS_Reset(void); extern uint32_t PIOS_SYS_getCPUFlashSize(void); +extern int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array); extern int32_t PIOS_SYS_SerialNumberGet(char *str); #endif /* PIOS_SYS_H */ diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index b05faff07..0a78e561b 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -349,40 +349,15 @@ LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld -# --------------------------------------------------------------------------- -# Options for OpenOCD flash-programming -# see openocd.pdf/openocd.texi for further information -# -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd -OOCD_EXE=openocd -# debug level -OOCD_CL=-d0 -# interface and board/target settings (using the OOCD target-library here) -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.pipxtreme.osx.cfg -f ../Project/OpenOCD/stm32.cfg -else - OOCD_CL+=-f ../Project/OpenOCD/floss-jtag.pipxtreme.cfg -f ../Project/OpenOCD/stm32.cfg -endif -# initialize -OOCD_CL+=-c init -# show the targets -OOCD_CL+=-c targets -# commands to prepare flash-write -OOCD_CL+= -c "reset halt" -# flash erase -OOCD_CL+=-c "stm32x mass_erase 0" -# flash-write -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# Program +OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" # Verify OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f diff --git a/flight/Project/OpenOCD/floss-jtag.ahrs.cfg b/flight/Project/OpenOCD/floss-jtag.ahrs.cfg deleted file mode 100644 index f2555e55a..000000000 --- a/flight/Project/OpenOCD/floss-jtag.ahrs.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG for AHRS -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:103" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3334 -tcl_port 6667 -telnet_port 4445 diff --git a/flight/Project/OpenOCD/floss-jtag.openpilot.cfg b/flight/Project/OpenOCD/floss-jtag.openpilot.cfg deleted file mode 100644 index d61d776b0..000000000 --- a/flight/Project/OpenOCD/floss-jtag.openpilot.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG OpenPilot -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:088" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3333 -tcl_port 6666 -telnet_port 4444 diff --git a/flight/Project/OpenOCD/floss-jtag.openpilot.osx.cfg b/flight/Project/OpenOCD/floss-jtag.openpilot.osx.cfg deleted file mode 100644 index cd5f8a28e..000000000 --- a/flight/Project/OpenOCD/floss-jtag.openpilot.osx.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG OpenPilot -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -#ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:088" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3333 -tcl_port 6666 -telnet_port 4444 diff --git a/flight/Project/OpenOCD/floss-jtag.pipxtreme.cfg b/flight/Project/OpenOCD/floss-jtag.pipxtreme.cfg deleted file mode 100644 index f2555e55a..000000000 --- a/flight/Project/OpenOCD/floss-jtag.pipxtreme.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG for AHRS -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:103" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3334 -tcl_port 6667 -telnet_port 4445 diff --git a/flight/Project/OpenOCD/floss-jtag.pipxtreme.osx.cfg b/flight/Project/OpenOCD/floss-jtag.pipxtreme.osx.cfg deleted file mode 100644 index a2214c6f4..000000000 --- a/flight/Project/OpenOCD/floss-jtag.pipxtreme.osx.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG OpenPilot -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -#ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:088" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3334 -tcl_port 6666 -telnet_port 4444 diff --git a/flight/Project/OpenOCD/floss-jtag.cfg b/flight/Project/OpenOCD/floss-jtag.reva.cfg similarity index 100% rename from flight/Project/OpenOCD/floss-jtag.cfg rename to flight/Project/OpenOCD/floss-jtag.reva.cfg diff --git a/flight/Project/OpenOCD/floss-jtag.ahrs.osx.cfg b/flight/Project/OpenOCD/foss-jtag.revb.ahrs.cfg similarity index 100% rename from flight/Project/OpenOCD/floss-jtag.ahrs.osx.cfg rename to flight/Project/OpenOCD/foss-jtag.revb.ahrs.cfg diff --git a/flight/Project/OpenOCD/floss-jtag-revb.cfg b/flight/Project/OpenOCD/foss-jtag.revb.cfg similarity index 100% rename from flight/Project/OpenOCD/floss-jtag-revb.cfg rename to flight/Project/OpenOCD/foss-jtag.revb.cfg diff --git a/flight/Project/gdb/pipx b/flight/Project/gdb/pipx index 4645698f4..d2b25a138 100644 --- a/flight/Project/gdb/pipx +++ b/flight/Project/gdb/pipx @@ -1,5 +1,5 @@ define connect - target remote localhost:3334 + target remote localhost:3333 monitor cortex_m3 vector_catch all file ./Build/PipXtreme.elf end diff --git a/flight/UAVObjects/inc/uavobjectmanager.h b/flight/UAVObjects/inc/uavobjectmanager.h index dba819c7c..e7bb8b9c7 100644 --- a/flight/UAVObjects/inc/uavobjectmanager.h +++ b/flight/UAVObjects/inc/uavobjectmanager.h @@ -63,10 +63,10 @@ typedef struct { uint8_t gcsAccess; /** Defines the access level for the local GCS transactions (readonly and readwrite), not used in the flight s/w */ uint8_t telemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */ uint8_t telemetryUpdateMode; /** Update mode used by the telemetry module (UAVObjUpdateMode) */ - int32_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */ + uint32_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */ uint8_t gcsTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */ uint8_t gcsTelemetryUpdateMode; /** Update mode used by the GCS (UAVObjUpdateMode) */ - int32_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */ + uint32_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */ uint8_t loggingUpdateMode; /** Update mode used by the logging module (UAVObjUpdateMode) */ uint32_t loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */ } __attribute__((packed)) UAVObjMetadata; diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp index ff8784746..784048b92 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp @@ -408,7 +408,7 @@ bool UAVTalk::receiveObject(quint8 type, quint32 objId, quint16 instId, quint8* UAVObject* obj = NULL; bool error = false; - bool allInstances = (instId == ALL_INSTANCES? true : false); + bool allInstances = (instId == ALL_INSTANCES); // Process message type switch (type) { diff --git a/hardware/Production/FOSS JTAG/BOM/FOSS JTAG BOM.xls b/hardware/Production/FOSS JTAG/BOM/FOSS JTAG BOM.xls index ea7a0ed66..059d89d42 100644 Binary files a/hardware/Production/FOSS JTAG/BOM/FOSS JTAG BOM.xls and b/hardware/Production/FOSS JTAG/BOM/FOSS JTAG BOM.xls differ diff --git a/hardware/Production/FOSS JTAG/FOSS JTAG Schematic.pdf b/hardware/Production/FOSS JTAG/FOSS JTAG Schematic.pdf index 1af4acad3..34ef09845 100644 Binary files a/hardware/Production/FOSS JTAG/FOSS JTAG Schematic.pdf and b/hardware/Production/FOSS JTAG/FOSS JTAG Schematic.pdf differ diff --git a/hardware/Production/FOSS JTAG/FOSS JTAG.SchDoc b/hardware/Production/FOSS JTAG/FOSS JTAG.SchDoc index 442023ba6..10851e5e7 100644 Binary files a/hardware/Production/FOSS JTAG/FOSS JTAG.SchDoc and b/hardware/Production/FOSS JTAG/FOSS JTAG.SchDoc differ diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index aff57a816..91f03f2a4 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -143,3 +143,25 @@ $($(1):.c=.s) : %.s : %.c $(V1) $(CC) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef +# --------------------------------------------------------------------------- +# # Options for OpenOCD flash-programming +# see openocd.pdf/openocd.texi for further information +# # +# OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd +OOCD_EXE=openocd +# debug level +OOCD_CL=-d0 +# interface and board/target settings (using the OOCD target-library here) +OOCD_CL+=-s $(TOP)/flight/Project/OpenOCD +OOCD_CL+=-f foss-jtag.revb.cfg -f stm32.cfg + +# initialize +OOCD_CL+=-c init +# show the targets +OOCD_CL+=-c targets +# commands to prepare flash-write +OOCD_CL+= -c "reset halt" +# flash erase +OOCD_CL+=-c "stm32x mass_erase 0" +# flash-write diff --git a/shared/uavobjectdefinition/firmwareiapobj.xml b/shared/uavobjectdefinition/firmwareiapobj.xml index 1b167cc3d..51438395e 100644 --- a/shared/uavobjectdefinition/firmwareiapobj.xml +++ b/shared/uavobjectdefinition/firmwareiapobj.xml @@ -1,8 +1,9 @@ - Firmware IAP + Queries board for SN, model, revision, and sends reset command - + + diff --git a/shared/uavobjectdefinition/systemalarms.xml b/shared/uavobjectdefinition/systemalarms.xml index 622afc173..54eedc8cd 100644 --- a/shared/uavobjectdefinition/systemalarms.xml +++ b/shared/uavobjectdefinition/systemalarms.xml @@ -5,7 +5,7 @@ elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,SDCard,Telemetry,ManualControl,Actuator,Attitude,Stabilization,Guidance,AHRSComms,Battery,FlightTime,I2C,GPS" defaultvalue="Uninitialised"/> - +