From 18ff84aa04c3dbf39166d4bad210e91a9381960f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 25 Jul 2022 13:17:23 -0400 Subject: [PATCH] usb_cdc: Rename usb_request_bootloader() to bootloader_request() Rename this board API function to a more generic name. This is in preparation for calling the function from the canbus code. Signed-off-by: Kevin O'Connor --- src/atsam/main.c | 4 ++-- src/atsamd/usbserial.c | 3 ++- src/avr/usbserial.c | 3 ++- src/generic/misc.h | 2 ++ src/generic/usb_cdc.c | 2 +- src/generic/usb_cdc.h | 1 - src/lpc176x/usbserial.c | 2 +- src/rp2040/main.c | 14 ++++++++++++++ src/rp2040/usbserial.c | 7 ------- src/stm32/stm32f0.c | 7 ++++--- src/stm32/stm32f1.c | 10 +++++----- src/stm32/stm32f4.c | 8 ++++---- src/stm32/stm32g0.c | 5 +++-- src/stm32/stm32h7.c | 9 +++++---- 14 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/atsam/main.c b/src/atsam/main.c index 5a19d529..8c2e4318 100644 --- a/src/atsam/main.c +++ b/src/atsam/main.c @@ -6,7 +6,7 @@ #include "board/armcm_boot.h" // armcm_main #include "board/irq.h" // irq_disable -#include "board/usb_cdc.h" // usb_request_bootloader +#include "board/misc.h" // bootloader_request #include "command.h" // DECL_COMMAND_FLAGS #include "internal.h" // WDT #include "sched.h" // sched_main @@ -94,7 +94,7 @@ DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset"); #endif void noinline __aligned(16) // align for predictable flash code access -usb_request_bootloader(void) +bootloader_request(void) { irq_disable(); // Request boot from ROM (instead of boot from flash) diff --git a/src/atsamd/usbserial.c b/src/atsamd/usbserial.c index e3848926..531c7dae 100644 --- a/src/atsamd/usbserial.c +++ b/src/atsamd/usbserial.c @@ -9,6 +9,7 @@ #include "board/armcm_boot.h" // armcm_enable_irq #include "board/io.h" // readl #include "board/irq.h" // irq_disable +#include "board/misc.h" // bootloader_request #include "board/usb_cdc.h" // usb_notify_ep0 #include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN #include "command.h" // DECL_CONSTANT_STR @@ -172,7 +173,7 @@ usb_set_configure(void) } void -usb_request_bootloader(void) +bootloader_request(void) { if (!CONFIG_FLASH_START) return; diff --git a/src/avr/usbserial.c b/src/avr/usbserial.c index 442ef934..ab61fde2 100644 --- a/src/avr/usbserial.c +++ b/src/avr/usbserial.c @@ -7,6 +7,7 @@ #include // USB_COM_vect #include // NULL #include "autoconf.h" // CONFIG_MACH_at90usb1286 +#include "board/misc.h" // bootloader_request #include "board/usb_cdc.h" // usb_notify_ep0 #include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN #include "pgm.h" // READP @@ -179,7 +180,7 @@ usb_set_configure(void) } void -usb_request_bootloader(void) +bootloader_request(void) { } diff --git a/src/generic/misc.h b/src/generic/misc.h index a24e8b0a..fe0804e4 100644 --- a/src/generic/misc.h +++ b/src/generic/misc.h @@ -18,4 +18,6 @@ void *dynmem_end(void); uint16_t crc16_ccitt(uint8_t *buf, uint_fast8_t len); +void bootloader_request(void); + #endif // misc.h diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c index 3a033cc9..40ff74ba 100644 --- a/src/generic/usb_cdc.c +++ b/src/generic/usb_cdc.c @@ -448,7 +448,7 @@ check_reboot(void) { if (line_coding.dwDTERate == 1200 && !(line_control_state & 0x01)) // A baud of 1200 is an Arduino style request to enter the bootloader - usb_request_bootloader(); + bootloader_request(); } static void diff --git a/src/generic/usb_cdc.h b/src/generic/usb_cdc.h index f955c840..3c92ef13 100644 --- a/src/generic/usb_cdc.h +++ b/src/generic/usb_cdc.h @@ -21,7 +21,6 @@ int_fast8_t usb_send_ep0_progmem(const void *data, uint_fast8_t len); void usb_stall_ep0(void); void usb_set_address(uint_fast8_t addr); void usb_set_configure(void); -void usb_request_bootloader(void); struct usb_string_descriptor *usbserial_get_serialid(void); // usb_cdc.c diff --git a/src/lpc176x/usbserial.c b/src/lpc176x/usbserial.c index bbb90438..af7d66b5 100644 --- a/src/lpc176x/usbserial.c +++ b/src/lpc176x/usbserial.c @@ -247,7 +247,7 @@ usb_set_configure(void) } void -usb_request_bootloader(void) +bootloader_request(void) { if (!CONFIG_SMOOTHIEWARE_BOOTLOADER) return; diff --git a/src/rp2040/main.c b/src/rp2040/main.c index fbbe3b56..462e69c6 100644 --- a/src/rp2040/main.c +++ b/src/rp2040/main.c @@ -5,11 +5,13 @@ // This file may be distributed under the terms of the GNU GPLv3 license. #include // uint32_t +#include "board/misc.h" // bootloader_request #include "hardware/structs/clocks.h" // clock_hw_t #include "hardware/structs/pll.h" // pll_hw_t #include "hardware/structs/resets.h" // sio_hw #include "hardware/structs/watchdog.h" // watchdog_hw #include "hardware/structs/xosc.h" // xosc_hw +#include "internal.h" // enable_pclock #include "sched.h" // sched_main @@ -36,6 +38,18 @@ watchdog_init(void) DECL_INIT(watchdog_init); +/**************************************************************** + * Bootloader + ****************************************************************/ + +void +bootloader_request(void) +{ + // Use the bootrom-provided code to reset into BOOTSEL mode + reset_to_usb_boot(0, 0); +} + + /**************************************************************** * Clock setup ****************************************************************/ diff --git a/src/rp2040/usbserial.c b/src/rp2040/usbserial.c index 83838d2d..aafe53ef 100644 --- a/src/rp2040/usbserial.c +++ b/src/rp2040/usbserial.c @@ -160,13 +160,6 @@ usb_set_configure(void) USB_BUF_CTRL_AVAIL | USB_BUF_CTRL_LAST | DPBUF_SIZE); } -void -usb_request_bootloader(void) -{ - // Use the bootrom-provided code to reset into BOOTSEL mode - reset_to_usb_boot(0, 0); -} - /**************************************************************** * USB Errata workaround diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index 8ea8f43c..98933b9d 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -8,6 +8,7 @@ #include "board/armcm_boot.h" // armcm_main #include "board/armcm_reset.h" // try_request_canboot #include "board/irq.h" // irq_disable +#include "board/misc.h" // bootloader_request #include "command.h" // DECL_CONSTANT_STR #include "internal.h" // enable_pclock #include "sched.h" // sched_main @@ -130,7 +131,7 @@ hsi14_setup(void) /**************************************************************** - * USB bootloader + * Bootloader ****************************************************************/ #define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 1024) @@ -160,9 +161,9 @@ check_usb_dfu_bootloader(void) : : "r"(sysbase[0]), "r"(sysbase[1])); } -// Handle USB reboot requests +// Handle reboot requests void -usb_request_bootloader(void) +bootloader_request(void) { try_request_canboot(); usb_reboot_for_dfu_bootloader(); diff --git a/src/stm32/stm32f1.c b/src/stm32/stm32f1.c index 820a5518..9d3c3b97 100644 --- a/src/stm32/stm32f1.c +++ b/src/stm32/stm32f1.c @@ -1,6 +1,6 @@ // Code to setup clocks and gpio on stm32f1 // -// Copyright (C) 2019-2021 Kevin O'Connor +// Copyright (C) 2019-2022 Kevin O'Connor // // This file may be distributed under the terms of the GNU GPLv3 license. @@ -8,7 +8,7 @@ #include "board/armcm_boot.h" // VectorTable #include "board/armcm_reset.h" // try_request_canboot #include "board/irq.h" // irq_disable -#include "board/usb_cdc.h" // usb_request_bootloader +#include "board/misc.h" // bootloader_request #include "internal.h" // enable_pclock #include "sched.h" // sched_main @@ -213,7 +213,7 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) /**************************************************************** - * USB bootloader + * Bootloader ****************************************************************/ // Reboot into USB "HID" bootloader @@ -240,9 +240,9 @@ usb_stm32duino_bootloader(void) NVIC_SystemReset(); } -// Handle USB reboot requests +// Handle reboot requests void -usb_request_bootloader(void) +bootloader_request(void) { try_request_canboot(); if (CONFIG_STM32_FLASH_START_800) diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c index 9c6880cf..0b032de7 100644 --- a/src/stm32/stm32f4.c +++ b/src/stm32/stm32f4.c @@ -8,7 +8,7 @@ #include "board/armcm_boot.h" // VectorTable #include "board/armcm_reset.h" // try_request_canboot #include "board/irq.h" // irq_disable -#include "board/usb_cdc.h" // usb_request_bootloader +#include "board/misc.h" // bootloader_request #include "command.h" // DECL_CONSTANT_STR #include "internal.h" // enable_pclock #include "sched.h" // sched_main @@ -188,7 +188,7 @@ clock_setup(void) /**************************************************************** - * USB bootloader + * Bootloader ****************************************************************/ // Reboot into USB "HID" bootloader @@ -228,9 +228,9 @@ check_usb_dfu_bootloader(void) : : "r"(sysbase[0]), "r"(sysbase[1])); } -// Handle USB reboot requests +// Handle reboot requests void -usb_request_bootloader(void) +bootloader_request(void) { try_request_canboot(); if (CONFIG_STM32_FLASH_START_4000) diff --git a/src/stm32/stm32g0.c b/src/stm32/stm32g0.c index 36520dfb..36191ebf 100644 --- a/src/stm32/stm32g0.c +++ b/src/stm32/stm32g0.c @@ -8,6 +8,7 @@ #include "board/armcm_boot.h" // armcm_main #include "board/armcm_reset.h" // try_request_canboot #include "board/irq.h" // irq_disable +#include "board/misc.h" // bootloader_request #include "command.h" // DECL_CONSTANT_STR #include "internal.h" // enable_pclock #include "sched.h" // sched_main @@ -103,7 +104,7 @@ clock_setup(void) /**************************************************************** - * USB bootloader + * Bootloader ****************************************************************/ #define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 1024) @@ -132,7 +133,7 @@ check_usb_dfu_bootloader(void) // Handle USB reboot requests void -usb_request_bootloader(void) +bootloader_request(void) { try_request_canboot(); usb_reboot_for_dfu_bootloader(); diff --git a/src/stm32/stm32h7.c b/src/stm32/stm32h7.c index bb0fe454..565353dc 100644 --- a/src/stm32/stm32h7.c +++ b/src/stm32/stm32h7.c @@ -6,8 +6,9 @@ #include "autoconf.h" // CONFIG_CLOCK_REF_FREQ #include "board/armcm_boot.h" // VectorTable -#include "board/irq.h" // irq_disable #include "board/armcm_reset.h" // try_request_canboot +#include "board/irq.h" // irq_disable +#include "board/misc.h" // bootloader_request #include "command.h" // DECL_CONSTANT_STR #include "internal.h" // get_pclock_frequency #include "sched.h" // sched_main @@ -185,7 +186,7 @@ clock_setup(void) /**************************************************************** - * USB bootloader + * Bootloader ****************************************************************/ #define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 1024) @@ -212,9 +213,9 @@ check_usb_dfu_bootloader(void) : : "r"(sysbase[0]), "r"(sysbase[1])); } -// Handle USB reboot requests +// Handle reboot requests void -usb_request_bootloader(void) +bootloader_request(void) { try_request_canboot(); usb_reboot_for_dfu_bootloader();