From 8d47dc1fe4edb38e2745e74c19b3f3915f10948f Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:35:13 -0400 Subject: [PATCH 01/10] revo usb: apply recent hid+vcp decscriptor changes to revo --- flight/Bootloaders/Revolution/Makefile | 1 + .../Revolution/inc/pios_usb_board_data.h | 1 + .../Revolution/pios_usb_board_data.c | 40 ++++-------------- flight/Revolution/Makefile | 1 + .../System/inc/pios_usb_board_data.h | 1 + flight/Revolution/System/pios_board.c | 42 +++++++++---------- .../Revolution/System/pios_usb_board_data.c | 40 ++++-------------- 7 files changed, 41 insertions(+), 85 deletions(-) diff --git a/flight/Bootloaders/Revolution/Makefile b/flight/Bootloaders/Revolution/Makefile index 070d1dfea..d708a6c82 100644 --- a/flight/Bootloaders/Revolution/Makefile +++ b/flight/Bootloaders/Revolution/Makefile @@ -81,6 +81,7 @@ SRC += $(PIOSCOMMON)/pios_board_info.c SRC += $(PIOSCOMMON)/pios_com_msg.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c +SRC += $(PIOSCOMMON)/pios_usb_util.c # List C source files here which must be compiled in ARM-Mode (no -mthumb). # use file-extension c for "c-only"-files diff --git a/flight/Bootloaders/Revolution/inc/pios_usb_board_data.h b/flight/Bootloaders/Revolution/inc/pios_usb_board_data.h index 2c03dc2d0..ac75b8cfa 100644 --- a/flight/Bootloaders/Revolution/inc/pios_usb_board_data.h +++ b/flight/Bootloaders/Revolution/inc/pios_usb_board_data.h @@ -39,6 +39,7 @@ #define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_REVOLUTION #define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_REVOLUTION, USB_OP_BOARD_MODE_BL) +#define PIOS_USB_BOARD_SN_SUFFIX "+BL" /* * The bootloader uses a simplified report structure diff --git a/flight/Bootloaders/Revolution/pios_usb_board_data.c b/flight/Bootloaders/Revolution/pios_usb_board_data.c index 823496c29..0fb67116d 100644 --- a/flight/Bootloaders/Revolution/pios_usb_board_data.c +++ b/flight/Bootloaders/Revolution/pios_usb_board_data.c @@ -31,6 +31,7 @@ #include "pios_usb_board_data.h" /* struct usb_*, USB_* */ #include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */ #include "pios_usbhook.h" /* PIOS_USBHOOK_* */ +#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */ static const uint8_t usb_product_id[22] = { sizeof(usb_product_id), @@ -47,40 +48,15 @@ static const uint8_t usb_product_id[22] = { 'n', 0, }; -static uint8_t usb_serial_number[52] = { +static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = { sizeof(usb_serial_number), USB_DESC_TYPE_STRING, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0 }; static const struct usb_string_langid usb_lang_id = { .bLength = sizeof(usb_lang_id), .bDescriptorType = USB_DESC_TYPE_STRING, - .bLangID = htousbs(USB_LANGID_ENGLISH_UK), + .bLangID = htousbs(USB_LANGID_ENGLISH_US), }; static const uint8_t usb_vendor_id[28] = { @@ -104,11 +80,13 @@ static const uint8_t usb_vendor_id[28] = { int32_t PIOS_USB_BOARD_DATA_Init(void) { /* Load device serial number into serial number string */ - uint8_t sn[25]; + uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1]; PIOS_SYS_SerialNumberGet((char *)sn); - for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) { - usb_serial_number[2 + 2 * i] = sn[i]; - } + + /* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */ + uint8_t * utf8 = &(usb_serial_number[2]); + utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN); + utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1); PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id)); PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number)); diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index ce8a45b6d..5d92b9359 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -155,6 +155,7 @@ SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c +SRC += $(PIOSCOMMON)/pios_usb_util.c include ./UAVObjects.inc SRC += $(UAVOBJSRC) diff --git a/flight/Revolution/System/inc/pios_usb_board_data.h b/flight/Revolution/System/inc/pios_usb_board_data.h index dbd111134..0e5dd8181 100644 --- a/flight/Revolution/System/inc/pios_usb_board_data.h +++ b/flight/Revolution/System/inc/pios_usb_board_data.h @@ -41,5 +41,6 @@ #define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_REVOLUTION #define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_REVOLUTION, USB_OP_BOARD_MODE_FW) +#define PIOS_USB_BOARD_SN_SUFFIX "+FW" #endif /* PIOS_USB_BOARD_DATA_H */ diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 0d57da254..54dcc34aa 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -27,15 +27,21 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +/* Pull in the board-specific static HW definitions. + * Including .c files is a bit ugly but this allows all of + * the HW definitions to be const and static to limit their + * scope. + * + * NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE + */ +#include "board_hw_defs.c" +#include #include #include #include "hwsettings.h" #include "manualcontrolsettings.h" -#include "board_hw_defs.c" - /** * Sensor configurations */ @@ -413,28 +419,18 @@ void PIOS_Board_Init(void) { bool usb_hid_present = false; bool usb_cdc_present = false; - uint8_t hwsettings_usb_devicetype; - HwSettingsUSB_DeviceTypeGet(&hwsettings_usb_devicetype); - - switch (hwsettings_usb_devicetype) { - case HWSETTINGS_USB_DEVICETYPE_HIDONLY: - if (PIOS_USB_DESC_HID_ONLY_Init()) { - PIOS_Assert(0); - } - usb_hid_present = true; - break; - case HWSETTINGS_USB_DEVICETYPE_HIDVCP: - if (PIOS_USB_DESC_HID_CDC_Init()) { - PIOS_Assert(0); - } - usb_hid_present = true; - usb_cdc_present = true; - break; - case HWSETTINGS_USB_DEVICETYPE_VCPONLY: - break; - default: +#if defined(PIOS_INCLUDE_USB_CDC) + if (PIOS_USB_DESC_HID_CDC_Init()) { PIOS_Assert(0); } + usb_hid_present = true; + usb_cdc_present = true; +#else + if (PIOS_USB_DESC_HID_ONLY_Init()) { + PIOS_Assert(0); + } + usb_hid_present = true; +#endif uint32_t pios_usb_id; PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg); diff --git a/flight/Revolution/System/pios_usb_board_data.c b/flight/Revolution/System/pios_usb_board_data.c index 823496c29..0fb67116d 100644 --- a/flight/Revolution/System/pios_usb_board_data.c +++ b/flight/Revolution/System/pios_usb_board_data.c @@ -31,6 +31,7 @@ #include "pios_usb_board_data.h" /* struct usb_*, USB_* */ #include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */ #include "pios_usbhook.h" /* PIOS_USBHOOK_* */ +#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */ static const uint8_t usb_product_id[22] = { sizeof(usb_product_id), @@ -47,40 +48,15 @@ static const uint8_t usb_product_id[22] = { 'n', 0, }; -static uint8_t usb_serial_number[52] = { +static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = { sizeof(usb_serial_number), USB_DESC_TYPE_STRING, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0 }; static const struct usb_string_langid usb_lang_id = { .bLength = sizeof(usb_lang_id), .bDescriptorType = USB_DESC_TYPE_STRING, - .bLangID = htousbs(USB_LANGID_ENGLISH_UK), + .bLangID = htousbs(USB_LANGID_ENGLISH_US), }; static const uint8_t usb_vendor_id[28] = { @@ -104,11 +80,13 @@ static const uint8_t usb_vendor_id[28] = { int32_t PIOS_USB_BOARD_DATA_Init(void) { /* Load device serial number into serial number string */ - uint8_t sn[25]; + uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1]; PIOS_SYS_SerialNumberGet((char *)sn); - for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) { - usb_serial_number[2 + 2 * i] = sn[i]; - } + + /* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */ + uint8_t * utf8 = &(usb_serial_number[2]); + utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN); + utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1); PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id)); PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number)); From 261e65a6f2f44e678c57d6b5cf63c332ed7cedff Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:35:52 -0400 Subject: [PATCH 02/10] revo bu: apply recent LED changes to revo so BU builds again --- flight/board_hw_defs/revolution/board_hw_defs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flight/board_hw_defs/revolution/board_hw_defs.c b/flight/board_hw_defs/revolution/board_hw_defs.c index 70a9e0c45..be9e86b77 100644 --- a/flight/board_hw_defs/revolution/board_hw_defs.c +++ b/flight/board_hw_defs/revolution/board_hw_defs.c @@ -27,6 +27,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #if defined(PIOS_INCLUDE_LED) @@ -63,6 +64,11 @@ static const struct pios_led_cfg pios_led_cfg = { .num_leds = NELEMENTS(pios_leds), }; +const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision) +{ + return &pios_led_cfg; +} + #endif /* PIOS_INCLUDE_LED */ #if defined(PIOS_INCLUDE_SPI) From c719d5b6cfd18efb2e35786a336e6b705b828fcc Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:36:56 -0400 Subject: [PATCH 03/10] f4 adc: allow PIOS ADC to be properly excluded from the build This was preventing the BL image from building --- flight/PiOS/STM32F4xx/pios_adc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flight/PiOS/STM32F4xx/pios_adc.c b/flight/PiOS/STM32F4xx/pios_adc.c index 633707e04..b9a2c177e 100644 --- a/flight/PiOS/STM32F4xx/pios_adc.c +++ b/flight/PiOS/STM32F4xx/pios_adc.c @@ -45,6 +45,8 @@ #include "pios.h" #include +#if defined(PIOS_INCLUDE_ADC) + #if !defined(PIOS_ADC_MAX_SAMPLES) #define PIOS_ADC_MAX_SAMPLES 0 #endif @@ -461,6 +463,8 @@ void PIOS_ADC_DMA_Handler(void) #endif } +#endif /* PIOS_INCLUDE_ADC */ + /** * @} * @} From decd92f21d0d14c07e014985f814aa4c872b6b72 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:37:59 -0400 Subject: [PATCH 04/10] pipx bu: apply recent LED changes so BU image builds again --- flight/board_hw_defs/pipxtreme/board_hw_defs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flight/board_hw_defs/pipxtreme/board_hw_defs.c b/flight/board_hw_defs/pipxtreme/board_hw_defs.c index bf2e713f6..7df2c8132 100644 --- a/flight/board_hw_defs/pipxtreme/board_hw_defs.c +++ b/flight/board_hw_defs/pipxtreme/board_hw_defs.c @@ -1,4 +1,5 @@ #include +#include #if defined(PIOS_INCLUDE_LED) @@ -51,6 +52,11 @@ static const struct pios_led_cfg pios_led_cfg = { .num_leds = NELEMENTS(pios_leds), }; +const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision) +{ + return &pios_led_cfg; +} + #endif /* PIOS_INCLUDE_LED */ #if defined(PIOS_INCLUDE_SPI) From 5c114aedd5e48ba977687390b149a642e34c4669 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:38:33 -0400 Subject: [PATCH 05/10] pipx: apply fixes that allow pipx to build with new gcc --- .../STM32F10x/link_STM32103CB_PIPXTREME_sections.ld | 11 ++--------- flight/PipXtreme/Makefile | 2 +- flight/PipXtreme/System/pios_board.c | 4 ++++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld index 568dddffa..fbb858118 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld @@ -98,15 +98,8 @@ SECTIONS _init_stack_top = . - 4 ; } > SRAM - - _free_ram = . ; - .free_ram (NOLOAD) : - { - . = ORIGIN(SRAM) + LENGTH(SRAM) - _free_ram ; - /* This is used by the startup in order to initialize the .bss section */ - _ebss = . ; - _eram = . ; - } > SRAM + _eram = ORIGIN(SRAM) + LENGTH(SRAM) ; + _ebss = _eram; /* keep the heap section at the end of the SRAM * this will allow to claim the remaining bytes not used diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 9ef5e9842..63f2e7907 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -53,7 +53,7 @@ USE_GPS ?= NO USE_I2C ?= YES # Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= YES +CODE_SOURCERY ?= NO # Remove command is different for Code Sourcery on Windows ifeq ($(CODE_SOURCERY), YES) diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index ab53d7611..82e49f898 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -190,6 +190,10 @@ void PIOS_Board_Init(void) { #if defined(PIOS_INCLUDE_USB_HID) + if (!usb_hid_present) { + PIOS_Assert(0); + } + /* Configure the usb HID port */ #if defined(PIOS_INCLUDE_COM) { From 1e33ba62d8993566cca33ff23225184f9eb9a379 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:39:15 -0400 Subject: [PATCH 06/10] makefile: fix dependency for EF images so they work with all_* targets --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1e7df4211..ca445bf0d 100644 --- a/Makefile +++ b/Makefile @@ -600,7 +600,7 @@ define EF_TEMPLATE .PHONY: ef_$(1) ef_$(1): ef_$(1)_bin -ef_$(1)_%: bl_$(1)_bin fw_$(1)_bin +ef_$(1)_%: bl_$(1)_bin fw_$(1)_opfw $(V1) mkdir -p $(BUILD_DIR)/ef_$(1)/dep $(V1) cd $(ROOT_DIR)/flight/EntireFlash && \ $$(MAKE) -r --no-print-directory \ From 35ed945aff355b80270a7d3a081748fd08ec07fc Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:39:55 -0400 Subject: [PATCH 07/10] revo bu: BU image doesn't currentyl work on F4 so disable it for revo --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ca445bf0d..5c299e3d1 100644 --- a/Makefile +++ b/Makefile @@ -644,10 +644,9 @@ BL_BOARDS := $(ALL_BOARDS) BU_BOARDS := $(ALL_BOARDS) EF_BOARDS := $(ALL_BOARDS) -# FIXME: The INS build doesn't have a bootloader or bootloader -# updater yet so we need to filter them out to prevent errors. -BL_BOARDS := $(filter-out ins, $(BL_BOARDS)) -BU_BOARDS := $(filter-out ins, $(BU_BOARDS)) +# FIXME: The BU image doesn't work for F4 boards so we need to +# filter them out to prevent errors. +BU_BOARDS := $(filter-out revolution, $(BU_BOARDS)) # Generate the targets for whatever boards are left in each list FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) From dca2d0ee66d9054318592ce798ec44d032e944b9 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:51:29 -0400 Subject: [PATCH 08/10] makefile: filter out unbuildable targets for SimPosix --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 5c299e3d1..bf4974908 100644 --- a/Makefile +++ b/Makefile @@ -648,6 +648,12 @@ EF_BOARDS := $(ALL_BOARDS) # filter them out to prevent errors. BU_BOARDS := $(filter-out revolution, $(BU_BOARDS)) +# SimPosix doesn't have a BL, BU or EF target so we need to +# filter them out to prevent errors on the all_flight target. +BL_BOARDS := $(filter-out simposix, $(BL_BOARDS)) +BU_BOARDS := $(filter-out simposix, $(BU_BOARDS)) +EF_BOARDS := $(filter-out simposix, $(EF_BOARDS)) + # Generate the targets for whatever boards are left in each list FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) BL_TARGETS := $(addprefix bl_, $(BL_BOARDS)) From bc09c440d6e6332a35b9ac546b694b95cdacf39d Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 27 May 2012 21:51:55 -0400 Subject: [PATCH 09/10] makefile: fix broken all_ef target due to typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf4974908..2926a04ae 100644 --- a/Makefile +++ b/Makefile @@ -673,7 +673,7 @@ all_bu: $(addsuffix _opfw, $(BU_TARGETS)) all_bu_clean: $(addsuffix _clean, $(BU_TARGETS)) .PHONY: all_ef all_ef_clean -all_ef: $(EF_TARGETS)) +all_ef: $(EF_TARGETS) all_ef_clean: $(addsuffix _clean, $(EF_TARGETS)) .PHONY: all_flight all_flight_clean From 90e4047e2c5c654f9810cd48bc44e5ea8f88c9d9 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Mon, 28 May 2012 13:09:38 +0200 Subject: [PATCH 10/10] bugfix to etasv3 - made uavobject def compatible with new update modes --- shared/uavobjectdefinition/baroairspeed.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/uavobjectdefinition/baroairspeed.xml b/shared/uavobjectdefinition/baroairspeed.xml index 1566b89ce..ffe2de18e 100644 --- a/shared/uavobjectdefinition/baroairspeed.xml +++ b/shared/uavobjectdefinition/baroairspeed.xml @@ -8,6 +8,6 @@ - +