diff --git a/README.md b/README.md index c20040c..178e081 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,12 @@ If you're not running Linux or OSX natively, you can use ### Change Log +#### v1.2 + +* Added a new CLI command: `gpio`. This command allows one to control the SMD GPIO pads via USB/UART. +* [Fixed handling of zero-length USB transactions](http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429). +* Fixed naming of software version fields in the bootloader: `fw_` --> `sw_`. + #### v1.1 * CAN terminator is turned ON by default. diff --git a/bootloader/Makefile b/bootloader/Makefile index b1d287a..9adfbd8 100644 --- a/bootloader/Makefile +++ b/bootloader/Makefile @@ -21,7 +21,7 @@ PROJECT = com.zubax.babel HW_VERSION = 1 BL_VERSION_MAJOR = 1 -BL_VERSION_MINOR = 0 +BL_VERSION_MINOR = 1 APPLICATION_OFFSET = 32768 diff --git a/bootloader/src/cli.cpp b/bootloader/src/cli.cpp index fc2f9d5..f7ce71b 100644 --- a/bootloader/src/cli.cpp +++ b/bootloader/src/cli.cpp @@ -92,8 +92,8 @@ class ZubaxIDCommand : public os::shell::ICommandHandler if (appinfo.second) { const auto& inf = appinfo.first; - ios.print("fw_version : '%u.%u'\n", inf.major_version, inf.minor_version); - ios.print("fw_vcs_commit: %u\n", inf.vcs_commit); + ios.print("sw_version : '%u.%u'\n", inf.major_version, inf.minor_version); + ios.print("sw_vcs_commit: %u\n", inf.vcs_commit); } } } static cmd_zubax_id; diff --git a/bootloader/src/usb_cdc.cpp b/bootloader/src/usb_cdc.cpp index d28f15d..b09cc0d 100644 --- a/bootloader/src/usb_cdc.cpp +++ b/bootloader/src/usb_cdc.cpp @@ -242,6 +242,22 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp, uint8_t dtype, uint8 return NULL; } +/* + * USB stack crash workaround. + * See http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429 + * This bug is fixed in ChibiOS 18+, so the workaround does not have to be here after the OS is updated. + */ +static void sduDataReceivedProxy(USBDriver* const usbp, const usbep_t ep) +{ + if (auto sdup = static_cast(usbp->out_params[ep - 1U])) + { + if (usbGetReceiveTransactionSizeX(sdup->config->usbp, sdup->config->bulk_out) > 0) + { + sduDataReceived(usbp, ep); + } + } +} + /* * USB endpoints */ @@ -267,7 +283,7 @@ static const USBEndpointConfig ep2config = ///< EP1 initialization structur USB_EP_MODE_TYPE_BULK, NULL, sduDataTransmitted, - sduDataReceived, + sduDataReceivedProxy, 0x0040, 0x0040, &ep2instate, diff --git a/firmware/src/board/board.cpp b/firmware/src/board/board.cpp index 6116a96..77d5c2c 100644 --- a/firmware/src/board/board.cpp +++ b/firmware/src/board/board.cpp @@ -171,23 +171,23 @@ void restart() void setStatusLED(bool state) { - palWritePad(GPIOE, GPIOE_LED_STATUS, !state); + palWritePad(GPIOE, GPIOE_LED_STATUS, std::uint8_t(!state)); } void setTrafficLED(bool state) { - palWritePad(GPIOE, GPIOE_LED_TRAFFIC, !state); + palWritePad(GPIOE, GPIOE_LED_TRAFFIC, std::uint8_t(!state)); } void enableCANPower(bool state) { - palWritePad(GPIOA, GPIOA_CAN_POWER_DIS, !state); - palWritePad(GPIOB, GPIOB_LED_CAN_POWER_DIS, !state); + palWritePad(GPIOA, GPIOA_CAN_POWER_DIS, std::uint8_t(!state)); + palWritePad(GPIOB, GPIOB_LED_CAN_POWER_DIS, std::uint8_t(!state)); } void enableCANTerminator(bool state) { - palWritePad(GPIOB, GPIOB_CAN_TERMINATOR_EN, state); + palWritePad(GPIOB, GPIOB_CAN_TERMINATOR_EN, std::uint8_t(state)); } float getBusVoltage() diff --git a/firmware/src/usb_cdc.cpp b/firmware/src/usb_cdc.cpp index 434624d..3ec897a 100644 --- a/firmware/src/usb_cdc.cpp +++ b/firmware/src/usb_cdc.cpp @@ -240,6 +240,22 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp, uint8_t dtype, uint8 return NULL; } +/* + * USB stack crash workaround. + * See http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429 + * This bug is fixed in ChibiOS 18+, so the workaround does not have to be here after the OS is updated. + */ +static void sduDataReceivedProxy(USBDriver* const usbp, const usbep_t ep) +{ + if (auto sdup = static_cast(usbp->out_params[ep - 1U])) + { + if (usbGetReceiveTransactionSizeX(sdup->config->usbp, sdup->config->bulk_out) > 0) + { + sduDataReceived(usbp, ep); + } + } +} + /* * USB endpoints */ @@ -265,7 +281,7 @@ static const USBEndpointConfig ep2config = ///< EP1 initialization structur USB_EP_MODE_TYPE_BULK, NULL, sduDataTransmitted, - sduDataReceived, + sduDataReceivedProxy, 0x0040, 0x0040, &ep2instate, @@ -299,7 +315,7 @@ static void usb_event(USBDriver* usbp, usbevent_t event) chSysLockFromISR(); /* - * Enables the endpoints specified into the configuration. + * Enables the endpoints specified in the configuration. * Note, this callback is invoked from an ISR so I-Class functions * must be used. */