diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld index 85bf3a7715..ca7ddf111a 100644 --- a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld @@ -792,7 +792,7 @@ usb_dfu_force_detach = 0x40002a54; usb_dev_deinit = 0x40002a60; usb_dw_ctrl_deinit = 0x40002a6c; /* Data (.data, .bss, .rodata) */ -s_usb_osglue = 0x3fceffac; +rom_usb_osglue = 0x3fceffac; /*************************************** diff --git a/components/esp_rom/include/esp32s2/rom/usb/usb_dc.h b/components/esp_rom/include/esp32s2/rom/usb/usb_dc.h index f20e897c71..acfbf34952 100644 --- a/components/esp_rom/include/esp32s2/rom/usb/usb_dc.h +++ b/components/esp_rom/include/esp32s2/rom/usb/usb_dc.h @@ -372,19 +372,43 @@ int usb_dc_ep_read_continue(uint8_t ep); int usb_dc_ep_mps(uint8_t ep); - -//Hack - fake interrupts by pollinfg +/** + * @brief Poll for interrupts that need to be handled + * + * When the USB interrupt is not hooked up to an actual CPU interrupt, you + * can call this periodically to handle the USB events that need handling. + */ void usb_dc_check_poll_for_interrupts(void); -//Prepare for USB persist. You should reboot after this. +/* + * @brief Prepare for USB persist + * + * This takes the USB peripheral offline in such a way that it seems 'just busy' to the + * host. This way, the chip can reboot (e.g. into bootloader mode) and pick up the USB + * configuration again, without the conenction to the host being interrupted. + * + * @note Actual persistence is depending on USBDC_PERSIST_ENA being set in flags, as this + * is also used to e.g. reboot into DFU mode. + * + * @note Please reboot soon after calling this. + */ int usb_dc_prepare_persist(void); - +/* + * @brief USB interrupt handler + * + * This can be hooked up by the OS to the USB peripheral interrupt. + */ void usb_dw_isr_handler(void); +/** + * @brief Provide IDF with an interface to clear the static variable usb_dw_ctrl + * + * + */ +void usb_dw_ctrl_deinit(void); -int usb_dc_ep_write_would_block(const uint8_t ep); #ifdef __cplusplus diff --git a/components/esp_rom/include/esp32s2/rom/usb/usb_device.h b/components/esp_rom/include/esp32s2/rom/usb/usb_device.h index a63288c71b..e5103c143a 100644 --- a/components/esp_rom/include/esp32s2/rom/usb/usb_device.h +++ b/components/esp_rom/include/esp32s2/rom/usb/usb_device.h @@ -392,6 +392,12 @@ int usb_transfer_sync(uint8_t ep, uint8_t *data, size_t dlen, unsigned int flags */ void usb_cancel_transfer(uint8_t ep); +/** + * @brief Provide IDF with an interface to clear the static variable usb_dev + * + * + */ +void usb_dev_deinit(void); void usb_dev_resume(int configuration); int usb_dev_get_configuration(void); diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_common.h b/components/esp_rom/include/esp32s3/rom/usb/usb_common.h index c3bd52cfb9..06ae01a93c 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_common.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_common.h @@ -217,26 +217,6 @@ struct string_descriptor { uint16_t bString[]; } __packed; -#define ROM_MAX_CFG_DESC_CNT 1 - -struct rom_usb_descriptors { - const struct usb_device_descriptor *device_descr; - const void *config_descr[ROM_MAX_CFG_DESC_CNT]; - int string_count; // including string_descriptor_zero - const struct string_descriptor_zero *string0_descr; - const struct string_descriptor *string_descrs[]; -}; - -/* Descriptors defined in the ROM */ -extern struct usb_device_descriptor general_device_descr; -extern const void* acm_config_descr; -extern const void* dfu_config_descr; -extern const struct string_descriptor str_manu_descr; -extern const struct string_descriptor str_prod_descr; -extern const struct string_descriptor_zero string0_descr; -extern const struct rom_usb_descriptors acm_usb_descriptors; -extern const struct rom_usb_descriptors dfu_usb_descriptors; -extern const struct rom_usb_descriptors *rom_usb_curr_desc; #ifdef __cplusplus } diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_dc.h b/components/esp_rom/include/esp32s3/rom/usb/usb_dc.h index f20e897c71..2e74044057 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_dc.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_dc.h @@ -372,19 +372,42 @@ int usb_dc_ep_read_continue(uint8_t ep); int usb_dc_ep_mps(uint8_t ep); - -//Hack - fake interrupts by pollinfg +/** + * @brief Poll for interrupts that need to be handled + * + * When the USB interrupt is not hooked up to an actual CPU interrupt, you + * can call this periodically to handle the USB events that need handling. + */ void usb_dc_check_poll_for_interrupts(void); -//Prepare for USB persist. You should reboot after this. +/* + * @brief Prepare for USB persist + * + * This takes the USB peripheral offline in such a way that it seems 'just busy' to the + * host. This way, the chip can reboot (e.g. into bootloader mode) and pick up the USB + * configuration again, without the conenction to the host being interrupted. + * + * @note Actual persistence is depending on USBDC_PERSIST_ENA being set in flags, as this + * is also used to e.g. reboot into DFU mode. + * + * @note Please reboot soon after calling this. + */ int usb_dc_prepare_persist(void); - +/* + * @brief USB interrupt handler + * + * This can be hooked up by the OS to the USB peripheral interrupt. + */ void usb_dw_isr_handler(void); - -int usb_dc_ep_write_would_block(const uint8_t ep); +/** + * @brief Provide IDF with an interface to clear the static variable usb_dw_ctrl + * + * + */ +void usb_dw_ctrl_deinit(void); #ifdef __cplusplus diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_device.h b/components/esp_rom/include/esp32s3/rom/usb/usb_device.h index a63288c71b..e5103c143a 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_device.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_device.h @@ -392,6 +392,12 @@ int usb_transfer_sync(uint8_t ep, uint8_t *data, size_t dlen, unsigned int flags */ void usb_cancel_transfer(uint8_t ep); +/** + * @brief Provide IDF with an interface to clear the static variable usb_dev + * + * + */ +void usb_dev_deinit(void); void usb_dev_resume(int configuration); int usb_dev_get_configuration(void); diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_dfu.h b/components/esp_rom/include/esp32s3/rom/usb/usb_dfu.h index dec7ea93a3..1cfa80d8c5 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_dfu.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_dfu.h @@ -140,6 +140,7 @@ int dfu_custom_handle_req(struct usb_setup_packet *pSetup, typedef void(*usb_dfu_detach_routine_t)(int delay); void usb_dfu_set_detach_cb(usb_dfu_detach_routine_t cb); +void usb_dfu_force_detach(void); #ifdef __cplusplus diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_os_glue.h b/components/esp_rom/include/esp32s3/rom/usb/usb_os_glue.h index 9abad6d0b9..4989b00ec5 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_os_glue.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_os_glue.h @@ -1,16 +1,8 @@ -// Copyright 2019-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -33,7 +25,7 @@ typedef struct { usb_osglue_wait_routine_t wait_proc; } usb_osglue_data_t; -extern usb_osglue_data_t s_usb_osglue; +extern usb_osglue_data_t rom_usb_osglue; #ifdef __cplusplus } diff --git a/components/esp_rom/include/esp32s3/rom/usb/usb_persist.h b/components/esp_rom/include/esp32s3/rom/usb/usb_persist.h index bcf11b7c48..90dfe98e4a 100644 --- a/components/esp_rom/include/esp32s3/rom/usb/usb_persist.h +++ b/components/esp_rom/include/esp32s3/rom/usb/usb_persist.h @@ -1,16 +1,8 @@ -// Copyright 2019-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -34,7 +26,7 @@ extern "C" { //This being non-0 indicates a memory location where a 'testament' is stored, aka a piece of text that should be output //after a reboot. Can contain core dump info or something. -#define USBDC_TESTAMENT_LOC_MASK 0x7FFFF //bits 19-0; this is added to a base address of 0x3FF80000. +#define USBDC_TESTAMENT_LOC_MASK 0x7FFFF //bits 19-0; this is added to a base address of SOC_MEM_INTERNAL_LOW. (0x3FF9E000) //The testament is a FIFO. The ROM will output all data between textstart and textend; if textend is lower than textstart it will //output everything from textstart to memend, then memstart to textend. diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 15a10cc57e..fcf6ae5a27 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -524,8 +524,6 @@ components/esp_rom/include/esp32s3/rom/usb/usb_dc.h components/esp_rom/include/esp32s3/rom/usb/usb_descriptor.h components/esp_rom/include/esp32s3/rom/usb/usb_device.h components/esp_rom/include/esp32s3/rom/usb/usb_dfu.h -components/esp_rom/include/esp32s3/rom/usb/usb_os_glue.h -components/esp_rom/include/esp32s3/rom/usb/usb_persist.h components/esp_rom/include/esp_rom_crc.h components/esp_rom/include/esp_rom_gpio.h components/esp_rom/include/linux/soc/reset_reasons.h