diff --git a/flight/Bootloaders/CopterControl/inc/pios_usb_board_data.h b/flight/Bootloaders/CopterControl/inc/pios_usb_board_data.h index f1accee17..addb24f19 100644 --- a/flight/Bootloaders/CopterControl/inc/pios_usb_board_data.h +++ b/flight/Bootloaders/CopterControl/inc/pios_usb_board_data.h @@ -39,6 +39,7 @@ #define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_COPTERCONTROL #define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_COPTERCONTROL, USB_OP_BOARD_MODE_BL) +#define PIOS_USB_BOARD_SN_SUFFIX "+BL" /* * The bootloader uses a simplified report structure diff --git a/flight/Bootloaders/CopterControl/pios_usb_board_data.c b/flight/Bootloaders/CopterControl/pios_usb_board_data.c index 4f02ce424..1afdf93a1 100644 --- a/flight/Bootloaders/CopterControl/pios_usb_board_data.c +++ b/flight/Bootloaders/CopterControl/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 /* strcat */ static const uint8_t usb_product_id[28] = { sizeof(usb_product_id), @@ -50,34 +51,9 @@ static const uint8_t usb_product_id[28] = { 'l', 0, }; -static uint8_t usb_serial_number[52] = { +static uint8_t usb_serial_number[2 + 25*2 + 3*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 = { @@ -107,8 +83,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[25+3]; PIOS_SYS_SerialNumberGet((char *)sn); + + /* Add the appropriate suffix ("+BL" or "+FW") depending on what we're running */ + strcat((char *)sn, PIOS_USB_BOARD_SN_SUFFIX); + + /* Map the serial number string into the unicode serial number for USB */ for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) { usb_serial_number[2 + 2 * i] = sn[i]; } diff --git a/flight/CopterControl/System/inc/pios_usb_board_data.h b/flight/CopterControl/System/inc/pios_usb_board_data.h index 9907a4934..2dcb5f845 100644 --- a/flight/CopterControl/System/inc/pios_usb_board_data.h +++ b/flight/CopterControl/System/inc/pios_usb_board_data.h @@ -41,5 +41,6 @@ #define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_COPTERCONTROL #define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_COPTERCONTROL, USB_OP_BOARD_MODE_FW) +#define PIOS_USB_BOARD_SN_SUFFIX "+FW" #endif /* PIOS_USB_BOARD_DATA_H */ diff --git a/flight/CopterControl/System/pios_usb_board_data.c b/flight/CopterControl/System/pios_usb_board_data.c index 4f02ce424..1afdf93a1 100644 --- a/flight/CopterControl/System/pios_usb_board_data.c +++ b/flight/CopterControl/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 /* strcat */ static const uint8_t usb_product_id[28] = { sizeof(usb_product_id), @@ -50,34 +51,9 @@ static const uint8_t usb_product_id[28] = { 'l', 0, }; -static uint8_t usb_serial_number[52] = { +static uint8_t usb_serial_number[2 + 25*2 + 3*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 = { @@ -107,8 +83,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[25+3]; PIOS_SYS_SerialNumberGet((char *)sn); + + /* Add the appropriate suffix ("+BL" or "+FW") depending on what we're running */ + strcat((char *)sn, PIOS_USB_BOARD_SN_SUFFIX); + + /* Map the serial number string into the unicode serial number for USB */ for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) { usb_serial_number[2 + 2 * i] = sn[i]; } diff --git a/make/boards/coptercontrol/board-info.mk b/make/boards/coptercontrol/board-info.mk index dcad2f43e..674ad4152 100644 --- a/make/boards/coptercontrol/board-info.mk +++ b/make/boards/coptercontrol/board-info.mk @@ -1,6 +1,6 @@ BOARD_TYPE := 0x04 BOARD_REVISION := 0x02 -BOOTLOADER_VERSION := 0x02 +BOOTLOADER_VERSION := 0x03 HW_TYPE := 0x01 MCU := cortex-m3 diff --git a/make/boards/pipxtreme/board-info.mk b/make/boards/pipxtreme/board-info.mk index 19d05baf9..2fd4e4ecc 100644 --- a/make/boards/pipxtreme/board-info.mk +++ b/make/boards/pipxtreme/board-info.mk @@ -1,6 +1,6 @@ BOARD_TYPE := 0x03 BOARD_REVISION := 0x01 -BOOTLOADER_VERSION := 0x01 +BOOTLOADER_VERSION := 0x02 HW_TYPE := 0x01 MCU := cortex-m3