esp_rom: implement usb deinit functions added in S3 ROM for S2

This cleans up usb_console.c and prepares it for S3 support.
This commit is contained in:
Ivan Grokhotkov 2022-01-18 20:48:37 +01:00
parent 74fa41f434
commit 4a91ccf4ce
No known key found for this signature in database
GPG Key ID: 1E050E141B280628
3 changed files with 19 additions and 6 deletions

View File

@ -295,5 +295,5 @@ else() # Regular app build
endif()
if(target STREQUAL "esp32s2")
target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_descriptors.c")
target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_patches.c")
endif()

View File

@ -65,3 +65,19 @@ void rom_usb_cdc_set_descriptor_patch(void)
/* Override the pointer to descriptors structure */
rom_usb_curr_desc = &s_acm_usb_descriptors_override;
}
/* On ESP32-S2, ROM doesn't provide interfaces to clear usb_dev and usb_dw_ctrl structures.
* Starting from ESP32-S3, usb_dev_deinit and usb_dw_ctrl_deinit ROM functions are available.
* Here we implement the missing functionality for the ESP32-S2.
*/
void usb_dev_deinit(void)
{
extern char rom_usb_dev, rom_usb_dev_end;
memset((void *) &rom_usb_dev, 0, &rom_usb_dev_end - &rom_usb_dev);
}
void usb_dw_ctrl_deinit(void)
{
extern char rom_usb_dw_ctrl, rom_usb_dw_ctrl_end;
memset((void *) &rom_usb_dw_ctrl, 0, &rom_usb_dw_ctrl_end - &rom_usb_dw_ctrl);
}

View File

@ -232,12 +232,9 @@ void esp_usb_console_before_restart(void)
*/
static void esp_usb_console_rom_cleanup(void)
{
extern char rom_usb_dev, rom_usb_dev_end;
extern char rom_usb_dw_ctrl, rom_usb_dw_ctrl_end;
usb_dev_deinit();
usb_dw_ctrl_deinit();
uart_acm_dev = NULL;
memset((void *) &rom_usb_dev, 0, &rom_usb_dev_end - &rom_usb_dev);
memset((void *) &rom_usb_dw_ctrl, 0, &rom_usb_dw_ctrl_end - &rom_usb_dw_ctrl);
}
esp_err_t esp_usb_console_init(void)