From 443ced62d4e47d73da13746a836369d8421b4fe8 Mon Sep 17 00:00:00 2001 From: Brennan Ashton Date: Tue, 13 Aug 2019 23:31:07 -0700 Subject: [PATCH] Target latest libopencm3 Required fixes: * use usbd_request_return_codes -- commit 54b117c5a5767df8dc114612dfd8e8cb88b72c6b * drop deprecated timer_reset() -- commit 034dbf20ff8c54dcbee5238390b37a0d35180f44 * drop 48 & 120 MHz configs -- commit a9dde2832eb8039b9e0d21a50b9b991ddbfc4e2d * ld scripts: drop duplication of standard sections -- commit 9a05dcb6c0aef712052d337457838f6041ffd57a --- libopencm3 | 2 +- src/platforms/common/cdcacm.c | 24 ++++++++++++------------ src/platforms/f4discovery/platform.c | 2 +- src/platforms/hydrabus/platform.c | 2 +- src/platforms/launchpad-icdi/platform.h | 2 +- src/platforms/stm32/blackmagic.ld | 2 +- src/platforms/stm32/dfucore.c | 24 ++++++++++++------------ src/platforms/stm32/f4discovery.ld | 2 +- src/platforms/stm32/stlink.ld | 2 +- src/platforms/stm32/stm32_can.ld | 2 +- src/platforms/stm32/traceswo.c | 2 -- src/platforms/stm32/usbuart.c | 1 - src/platforms/tm4c/tm4c.ld | 2 +- 13 files changed, 33 insertions(+), 36 deletions(-) diff --git a/libopencm3 b/libopencm3 index db7a8d7..3eff201 160000 --- a/libopencm3 +++ b/libopencm3 @@ -1 +1 @@ -Subproject commit db7a8d71ca30dd9ce7947aa036897b910bdc4ad2 +Subproject commit 3eff201a4bb3759a9c967a6f5e3fd0aad46dc5af diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index ccf6706..8f5f779 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -419,7 +419,7 @@ static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req) scb_reset_core(); } -static int cdcacm_control_request(usbd_device *dev, +static enum usbd_request_return_codes cdcacm_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *dev, struct usb_setup_data *req)) { @@ -433,23 +433,23 @@ static int cdcacm_control_request(usbd_device *dev, cdcacm_set_modem_state(dev, req->wIndex, true, true); /* Ignore if not for GDB interface */ if(req->wIndex != 0) - return 1; + return USBD_REQ_HANDLED; cdcacm_gdb_dtr = req->wValue & 1; - return 1; + return USBD_REQ_HANDLED; case USB_CDC_REQ_SET_LINE_CODING: if(*len < sizeof(struct usb_cdc_line_coding)) - return 0; + return USBD_REQ_NOTSUPP; switch(req->wIndex) { case 2: usbuart_set_line_coding((struct usb_cdc_line_coding*)*buf); - return 1; + return USBD_REQ_HANDLED; case 0: - return 1; /* Ignore on GDB Port */ + return USBD_REQ_HANDLED; /* Ignore on GDB Port */ default: - return 0; + return USBD_REQ_NOTSUPP; } case DFU_GETSTATUS: if(req->wIndex == DFU_IF_NO) { @@ -461,17 +461,17 @@ static int cdcacm_control_request(usbd_device *dev, (*buf)[5] = 0; /* iString not used here */ *len = 6; - return 1; + return USBD_REQ_HANDLED; } - return 0; + return USBD_REQ_NOTSUPP; case DFU_DETACH: if(req->wIndex == DFU_IF_NO) { *complete = dfu_detach_complete; - return 1; + return USBD_REQ_HANDLED; } - return 0; + return USBD_REQ_NOTSUPP; } - return 0; + return USBD_REQ_NOTSUPP; } int cdcacm_get_config(void) diff --git a/src/platforms/f4discovery/platform.c b/src/platforms/f4discovery/platform.c index 89b82c1..4703317 100644 --- a/src/platforms/f4discovery/platform.c +++ b/src/platforms/f4discovery/platform.c @@ -62,7 +62,7 @@ void platform_init(void) scb_reset_core(); } - rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]); + rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* Enable peripherals */ rcc_periph_clock_enable(RCC_OTGFS); diff --git a/src/platforms/hydrabus/platform.c b/src/platforms/hydrabus/platform.c index bf3db04..e0893e8 100644 --- a/src/platforms/hydrabus/platform.c +++ b/src/platforms/hydrabus/platform.c @@ -46,7 +46,7 @@ void platform_init(void) scb_reset_core(); } - rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]); + rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* Enable peripherals */ rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN); diff --git a/src/platforms/launchpad-icdi/platform.h b/src/platforms/launchpad-icdi/platform.h index a710c52..7450aa7 100644 --- a/src/platforms/launchpad-icdi/platform.h +++ b/src/platforms/launchpad-icdi/platform.h @@ -68,7 +68,7 @@ extern uint8_t running_status; gpio_set_output_config(SWDIO_PORT, GPIO_OTYPE_PP, GPIO_DRIVE_2MA, SWDIO_PIN); \ } -extern usbd_driver lm4f_usb_driver; +extern const usbd_driver lm4f_usb_driver; #define USB_DRIVER lm4f_usb_driver #define USB_IRQ NVIC_USB0_IRQ #define USB_ISR usb0_isr diff --git a/src/platforms/stm32/blackmagic.ld b/src/platforms/stm32/blackmagic.ld index 9755309..c1d1ce7 100644 --- a/src/platforms/stm32/blackmagic.ld +++ b/src/platforms/stm32/blackmagic.ld @@ -25,5 +25,5 @@ MEMORY } /* Include the common ld script from libopenstm32. */ -INCLUDE libopencm3_stm32f1.ld +INCLUDE cortex-m-generic.ld diff --git a/src/platforms/stm32/dfucore.c b/src/platforms/stm32/dfucore.c index 61cfd04..adeff9a 100644 --- a/src/platforms/stm32/dfucore.c +++ b/src/platforms/stm32/dfucore.c @@ -198,20 +198,20 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req) } } -static int usbdfu_control_request(usbd_device *dev, +static enum usbd_request_return_codes usbdfu_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *dev, struct usb_setup_data *req)) { (void)dev; if((req->bmRequestType & 0x7F) != 0x21) - return 0; /* Only accept class request */ + return USBD_REQ_NOTSUPP; /* Only accept class request */ switch(req->bRequest) { case DFU_DNLOAD: if((len == NULL) || (*len == 0)) { usbdfu_state = STATE_DFU_MANIFEST_SYNC; - return 1; + return USBD_REQ_HANDLED; } else { /* Copy download data for use on GET_STATUS */ prog.blocknum = req->wValue; @@ -222,22 +222,22 @@ static int usbdfu_control_request(usbd_device *dev, if ((addr < app_address) || (addr >= max_address)) { current_error = DFU_STATUS_ERR_TARGET; usbdfu_state = STATE_DFU_ERROR; - return 1; + return USBD_REQ_HANDLED; } else prog.addr = addr; } usbdfu_state = STATE_DFU_DNLOAD_SYNC; - return 1; + return USBD_REQ_HANDLED; } case DFU_CLRSTATUS: /* Clear error and return to dfuIDLE */ if(usbdfu_state == STATE_DFU_ERROR) usbdfu_state = STATE_DFU_IDLE; - return 1; + return USBD_REQ_HANDLED; case DFU_ABORT: /* Abort returns to dfuIDLE state */ usbdfu_state = STATE_DFU_IDLE; - return 1; + return USBD_REQ_HANDLED; case DFU_UPLOAD: if ((usbdfu_state == STATE_DFU_IDLE) || (usbdfu_state == STATE_DFU_DNLOAD_IDLE) || @@ -250,10 +250,10 @@ static int usbdfu_control_request(usbd_device *dev, dfu_function.wTransferSize); memcpy(*buf, (void*)baseaddr, *len); } - return 1; + return USBD_REQ_HANDLED; } else { usbd_ep_stall_set(dev, 0, 1); - return 0; + return USBD_REQ_NOTSUPP; } case DFU_GETSTATUS: { uint32_t bwPollTimeout = 0; /* 24-bit integer in DFU class spec */ @@ -268,16 +268,16 @@ static int usbdfu_control_request(usbd_device *dev, *complete = usbdfu_getstatus_complete; - return 1; + return USBD_REQ_HANDLED; } case DFU_GETSTATE: /* Return state with no state transision */ *buf[0] = usbdfu_state; *len = 1; - return 1; + return USBD_REQ_HANDLED; } - return 0; + return USBD_REQ_NOTSUPP; } void dfu_init(const usbd_driver *driver, dfu_mode_t mode) diff --git a/src/platforms/stm32/f4discovery.ld b/src/platforms/stm32/f4discovery.ld index b066426..812d2eb 100644 --- a/src/platforms/stm32/f4discovery.ld +++ b/src/platforms/stm32/f4discovery.ld @@ -25,5 +25,5 @@ MEMORY } /* Include the common ld script from libopenstm32. */ -INCLUDE libopencm3_stm32f4.ld +INCLUDE cortex-m-generic.ld diff --git a/src/platforms/stm32/stlink.ld b/src/platforms/stm32/stlink.ld index 3b4af4e..64a3a84 100644 --- a/src/platforms/stm32/stlink.ld +++ b/src/platforms/stm32/stlink.ld @@ -25,4 +25,4 @@ MEMORY } /* Include the common ld script from libopenstm32. */ -INCLUDE libopencm3_stm32f1.ld +INCLUDE cortex-m-generic.ld diff --git a/src/platforms/stm32/stm32_can.ld b/src/platforms/stm32/stm32_can.ld index 86861b8..0b497fc 100644 --- a/src/platforms/stm32/stm32_can.ld +++ b/src/platforms/stm32/stm32_can.ld @@ -25,4 +25,4 @@ MEMORY } /* Include the common ld script from libopenstm32. */ -INCLUDE libopencm3_stm32f1.ld +INCLUDE cortex-m-generic.ld diff --git a/src/platforms/stm32/traceswo.c b/src/platforms/stm32/traceswo.c index 5007378..25ae60a 100644 --- a/src/platforms/stm32/traceswo.c +++ b/src/platforms/stm32/traceswo.c @@ -42,8 +42,6 @@ void traceswo_init(void) { TRACE_TIM_CLK_EN(); - timer_reset(TRACE_TIM); - /* Refer to ST doc RM0008 - STM32F10xx Reference Manual. * Section 14.3.4 - 14.3.6 (General Purpose Timer - Input Capture) * diff --git a/src/platforms/stm32/usbuart.c b/src/platforms/stm32/usbuart.c index a466ab5..ddcda80 100644 --- a/src/platforms/stm32/usbuart.c +++ b/src/platforms/stm32/usbuart.c @@ -68,7 +68,6 @@ void usbuart_init(void) /* Setup timer for running deferred FIFO processing */ USBUSART_TIM_CLK_EN(); - timer_reset(USBUSART_TIM); timer_set_mode(USBUSART_TIM, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); timer_set_prescaler(USBUSART_TIM, diff --git a/src/platforms/tm4c/tm4c.ld b/src/platforms/tm4c/tm4c.ld index 8fe93a4..c2169c7 100644 --- a/src/platforms/tm4c/tm4c.ld +++ b/src/platforms/tm4c/tm4c.ld @@ -25,5 +25,5 @@ MEMORY } /* Include the common ld script from libopenstm32. */ -INCLUDE libopencm3_lm4f.ld +INCLUDE cortex-m-generic.ld