Skip to content

Commit

Permalink
Merge branch 'docs/add_esp_msc_ota_doc' into 'master'
Browse files Browse the repository at this point in the history
docs: add usb msc ota docs

Closes AEG-1009

See merge request ae_group/esp-iot-solution!919
  • Loading branch information
leeebo committed Dec 19, 2023
2 parents 32c5e1f + bbb58d0 commit 803575c
Show file tree
Hide file tree
Showing 49 changed files with 246 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
- "components/sensors/sensor_hub/include/hal/light_sensor_hal.h"
- "components/sensors/sensor_hub/include/iot_sensor_hub.h"
- "components/sensors/sensor_hub/include/sensor_type.h"
- "components/usb/esp_msc_ota/include/esp_msc_ota.h"
- "components/usb/iot_usbh_cdc/include/iot_usbh_cdc.h"
- "components/usb/usb_device_uvc/include/usb_device_uvc.h"
- "components/usb/usb_stream/include/usb_stream.h"
Expand Down
4 changes: 4 additions & 0 deletions components/usb/esp_msc_ota/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Supports hot-plugging of USB disk.
* Supports USB disk OTA functionality.

### User Guide

Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/esp_msc_ota.html

### Adding the Component to the Project

Please use the component manager command `add-dependency` to add `esp_msc_ota` as a dependency to your project. During the `CMake` execution, this component will be automatically downloaded to the project directory.
Expand Down
4 changes: 4 additions & 0 deletions components/usb/esp_msc_ota/README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* 支持 U 盘热插拔
* 支持 U 盘 OTA 功能。

### 用户指南

请查看: https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_host/esp_msc_ota.html

### 添加组件到工程

请使用组件管理器指令 `add-dependency``esp_msc_ota` 添加到项目的依赖项, 在 `CMake` 执行期间该组件将被自动下载到工程目录。
Expand Down
4 changes: 4 additions & 0 deletions components/usb/esp_msc_ota/include/esp_msc_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ extern "C" {
#include "msc_host.h"
#include "usb/usb_host.h"

/**
* @brief Declare Event Base for ESP MSC HOST
*
*/
ESP_EVENT_DECLARE_BASE(ESP_MSC_HOST_EVENT);

typedef enum {
Expand Down
12 changes: 11 additions & 1 deletion components/usb/esp_msc_ota/include/esp_msc_ota.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -18,7 +18,13 @@ extern "C"
#include "esp_app_format.h"
#include "esp_ota_ops.h"

/**
* @brief Declare Event Base for ESP MSC OTA
*
*/
/** @cond **/
ESP_EVENT_DECLARE_BASE(ESP_MSC_OTA_EVENT);
/** @endcond **/

typedef enum {
ESP_MSC_OTA_START, /*!< Start update */
Expand All @@ -39,6 +45,10 @@ typedef enum {
ESP_MSC_OTA_SUCCESS,
} esp_msc_ota_status_t;

/**
* @brief esp msc ota config
*
*/
typedef struct {
const char *ota_bin_path; /*!< OTA binary name, must be an exact match. Note: By default file names cannot exceed 11 bytes e.g. "/usb/ota.bin" */
bool bulk_flash_erase; /*!< Erase entire flash partition during initialization. By default flash partition is erased during write operation and in chunk of 4K sector size */
Expand Down
2 changes: 1 addition & 1 deletion components/usb/iot_usbh_cdc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This component implements a simple version of the USB host CDC driver. The API i

### User Guide

Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host_iot_usbh_cdc.html
Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_host_iot_usbh_cdc.html

### Add component to your project

Expand Down
2 changes: 1 addition & 1 deletion components/usb/iot_usbh_cdc/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targets:
description: Simple USB Host CDC driver maintained in esp-iot-solution
url: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh_cdc
repository: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh_cdc
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host_iot_usbh_cdc.html
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_host_iot_usbh_cdc.html
issues: https://github.com/espressif/esp-iot-solution/issues
dependencies:
idf: ">=4.4.1"
Expand Down
2 changes: 1 addition & 1 deletion components/usb/usb_device_uvc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v0.0.2 2023-12-06

* Add documentation documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_device_uvc.html
* Add documentation : https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_device/usb_device_uvc.html

## v0.0.1 Init version

Expand Down
2 changes: 1 addition & 1 deletion components/usb/usb_device_uvc/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targets:

description: USB Device UVC, Streaming Video to Host
url: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/usb_device_uvc
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_device_uvc.html
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_device/usb_device_uvc.html
repository: https://github.com/espressif/esp-iot-solution.git
issues: https://github.com/espressif/esp-iot-solution/issues

Expand Down
4 changes: 2 additions & 2 deletions components/usb/usb_stream/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Add additional delay to avoid malloc error if continuous suspend and resume

### Bug Fixes:

* Speaker:
* Speaker:
* fix some speaker resume control not work (should set freq after resume)

## v0.4.2 - 2023-01-30
Expand Down Expand Up @@ -301,7 +301,7 @@ Add additional delay to avoid malloc error if continuous suspend and resume

### Enhancements:

* add development documentation https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_stream.html
* add development documentation https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_host/usb_stream.html

## v0.3.0 - 2022-12-05

Expand Down
2 changes: 1 addition & 1 deletion components/usb/usb_stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Features:

### USB Stream User Guide

Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_stream.html
Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html

### Add component to your project

Expand Down
2 changes: 1 addition & 1 deletion components/usb/usb_stream/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

### USB Stream 用户指南

请参考:https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_stream.html
请参考:https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_host/usb_stream.html

### 添加组件到工程

Expand Down
2 changes: 1 addition & 1 deletion components/usb/usb_stream/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targets:
description: USB Host streaming driver, support UVC(video) + UAC(audio)
url: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/usb_stream
repository: https://github.com/espressif/esp-iot-solution.git
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_stream.html
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html
issues: https://github.com/espressif/esp-iot-solution/issues
dependencies:
idf: ">=4.4.1"
Expand Down
1 change: 1 addition & 0 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ INPUT = \
$(PROJECT_PATH)/components/sensors/sensor_hub/include/hal/light_sensor_hal.h \
$(PROJECT_PATH)/components/sensors/sensor_hub/include/iot_sensor_hub.h \
$(PROJECT_PATH)/components/sensors/sensor_hub/include/sensor_type.h \
$(PROJECT_PATH)/components/usb/esp_msc_ota/include/esp_msc_ota.h \
$(PROJECT_PATH)/components/usb/iot_usbh_cdc/include/iot_usbh_cdc.h \
$(PROJECT_PATH)/components/usb/usb_device_uvc/include/usb_device_uvc.h \
$(PROJECT_PATH)/components/usb/usb_stream/include/usb_stream.h \
Expand Down
14 changes: 3 additions & 11 deletions docs/en/usb/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ USB Host & Device
.. toctree::
:maxdepth: 2

USB Overview <usb_overview>
USB OTG <usb_otg>
USB Serial JTAG <usb_serial_jtag>
USB PHY <usb_phy>
USB VID PID <usb_vid_pid>
USB Host Solution <usb_host_solutions>
USB Device Solution <usb_device_solutions>
USB Self Power Device <usb_device_self_power>
USB Device Set Const COM <usb_device_const_COM>
usb_host_index
usb_driver_index
USB Overview <usb_overview/index>
USB HOST Driver <usb_host/usb_host_index>
USB Device Driver <usb_device/usb_driver_index>
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions docs/en/usb/usb_host/esp_msc_ota.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
ESP MSC OTA
==============

:link_to_translation:`zh_CN:[中文]`

`esp_msc_ota`` is an OTA (Over-The-Air) driver based on USB MSC (USB Mass Storage Class). It supports reading programs from a USB flash drive and burning them into a designated OTA partition, thereby enabling OTA upgrades via USB.

Features:

1. Supports OTA updates by retrieving programs from a USB flash drive via USB interface.
2. Supports hot-plugging of the USB flash drive.

User Guide
------------

Hardware requirements:

- Any ESP32-S2/ESP32-S3 development board with a USB interface capable of providing external power.
- A USB flash drive using the BOT (Bulk-Only Transport) protocol and Transparent SCSI command set.

Partition Table:

- Includes an OTA partition.

Code examples
---------------

1. Call `esp_msc_host_install` to initialize the MSC host driver.

.. code:: c
esp_msc_host_config_t msc_host_config = {
.base_path = "/usb",
.host_driver_config = DEFAULT_MSC_HOST_DRIVER_CONFIG(),
.vfs_fat_mount_config = DEFAULT_ESP_VFS_FAT_MOUNT_CONFIG(),
.host_config = DEFAULT_USB_HOST_CONFIG()
};
esp_msc_host_handle_t host_handle = NULL;
esp_msc_host_install(&msc_host_config, &host_handle);
2. Call `esp_msc_ota` to complete OTA updates. Use :cpp:type:`ota_bin_path` to specify the OTA file path and :cpp:type:`wait_msc_connect` to specify the waiting time for USB drive insertion in FreeRTOS ticks.

.. code:: c
esp_msc_ota_config_t config = {
.ota_bin_path = "/usb/ota_test.bin",
.wait_msc_connect = pdMS_TO_TICKS(5000),
};
esp_msc_ota(&config);
3. Call `esp_event_handler_register` to register the event handler for obtaining OTA process details.

.. code:: c
esp_event_loop_create_default();
esp_event_handler_register(ESP_MSC_OTA_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL);
API Reference
----------------

.. include-build-file:: inc/esp_msc_ota.inc
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
USB Host Drivers
*********************
======================

:link_to_translation:`zh_CN:[中文]`

.. toctree::
:maxdepth: 1

USB UVC/UAC Host <usb_stream>
USB MSC OTA <esp_msc_ota>
USB CDC Host <usb_host_iot_usbh_cdc>
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions docs/en/usb/usb_overview/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

USB Host & Device
===================

:link_to_translation:`zh_CN:[中文]`

.. toctree::
:maxdepth: 2

USB Overview <usb_overview>
USB OTG <usb_otg>
USB Serial JTAG <usb_serial_jtag>
USB PHY <usb_phy>
USB VID PID <usb_vid_pid>
USB Host Solution <usb_host_solutions>
USB Device Solution <usb_device_solutions>
USB Self Power Device <usb_device_self_power>
USB Device Set Const COM <usb_device_const_COM>
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Solution
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\303A10010101 /V IgnoreHWSerNum /t REG_BINARY /d 01
Users have the option to download the script :download:`ignore_hwserial_esp32s3c3.bat <../../_static/ignore_hwserial_esp32s3c3.bat>` , then run it with administrative privileges by right-clicking and selecting **Run as Administrator**.
Users have the option to download the script :download:`ignore_hwserial_esp32s3c3.bat <../../../_static/ignore_hwserial_esp32s3c3.bat>` , then run it with administrative privileges by right-clicking and selecting **Run as Administrator**.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Hardware:

* Chips: ESP32-S2, ESP32-S3
* Peripherals: USB-OTG
* USB Camera: Supports MJPEG format, with a bulk transfer mode of 800*480@15fps, or an isochronous transfer mode of 480*320@15fps. For camera limitations, refer to the `usb_stream API documentation <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_stream.html>`_.
* USB Camera: Supports MJPEG format, with a bulk transfer mode of 800*480@15fps, or an isochronous transfer mode of 480*320@15fps. For camera limitations, refer to the `usb_stream API documentation <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html>`_.

links:
~~~~~~~

* `usb_stream component <https://components.espressif.com/components/espressif/usb_stream>`_
* `usb_stream API reference <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_stream.html>`_
* `usb_stream API reference <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html>`_
* `USB Camera Demo video <https://www.bilibili.com/video/BV18841137qT>`_
* Example Code: USB Camera + WiFi Image Transmission: :example:`usb/host/usb_camera_mic_spk`
* Example Code: USB Camera + Local Screen Display with LCD: :example:`usb/host/usb_camera_lcd_display`
Expand Down Expand Up @@ -71,7 +71,7 @@ Links:
~~~~~~~~

* `usb_stream components <https://components.espressif.com/components/espressif/usb_stream>`_
* `usb_stream API reference <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_stream.html>`_
* `usb_stream API reference <https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html>`_
* `USB Audio Demo video <https://www.bilibili.com/video/BV1LP411975W>`_
* Example Code: MP3 Music Player + USB Headphones: :example:`usb/host/usb_audio_player`

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ USB-IF (USB Implementers Forum) is the organization responsible for establishing
Espressif's ESP32-S2/S3/C3 chips come with built-in USB-OTG or USB-Serial-JTAG peripherals, supporting a variety of USB applications. These include USB multimedia applications, USB communication applications, USB storage applications, USB human interface applications, and more.


.. image:: ../../_static/usb_solutions.png
:target: ../../_static/usb_solutions.png
.. image:: ../../../_static/usb_solutions.png
:target: ../../../_static/usb_solutions.png
:alt: USB Solution

USB Electrical Properties
Expand Down Expand Up @@ -146,8 +146,8 @@ ESP32-S2 USB Function Overview
The ESP32-S2 features an integrated **USB OTG Full-Speed Controller** and **USB Full-Speed PHY**\ . The internal architecture is as follows:


.. image:: ../../_static/usb/esp32s2_usb.png
:target: ../../_static/usb/esp32s2_usb.png
.. image:: ../../../_static/usb/esp32s2_usb.png
:target: ../../../_static/usb/esp32s2_usb.png
:alt: esp32s2_usb


Expand All @@ -157,8 +157,8 @@ ESP32-C3 USB Function Overview
The ESP32-C3 comes equipped with a built-in **USB-Serial-JTAG Controller** and **USB Full-Speed PHY**\ . The internal architecture is outlined below:


.. image:: ../../_static/usb/esp32c3_usb.png
:target: ../../_static/usb/esp32c3_usb.png
.. image:: ../../../_static/usb/esp32c3_usb.png
:target: ../../../_static/usb/esp32c3_usb.png
:alt: esp32c3_usb


Expand All @@ -168,7 +168,7 @@ ESP32-S3 USB Function Overview
The ESP32-S3 is equipped with two built-in USB controllers. **USB OTG Full-Speed Controller** and **USB-Serial-JTAG Controller**\ , Additionally, there is an integrated USB Full-speed PHY. The internal USB PHY is initially connected to the **USB-Serial-JTAG** controller by default. It can be modified through eFuse burning to change the default configuration or dynamically switched through register configuration. It is also possible to enable both controllers simultaneously by adding an external PHY. For detailed information on switching the internal USB PHY, refer to :doc:`USB PHY Switching <./usb_phy>`.


.. image:: ../../_static/usb/esp32s3_usb.png
:target: ../../_static/usb/esp32s3_usb.png
.. image:: ../../../_static/usb/esp32s3_usb.png
:target: ../../../_static/usb/esp32s3_usb.png
:alt: esp32s3_usb

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Use the internal PHY
The ESP32-S2/S3/C3 internally integrates a USB PHY, eliminating the need for an external PHY chip. It can directly connect to external USB hosts or devices through the USB D+/D- pins. However, for chips with two integrated USB controllers, such as the ESP32-S3 with built-in USB-OTG and USB-Serial-JTAG, both controllers share a single internal PHY, allowing only one to operate at a time.


.. image:: ../../_static/usb/esp32s3_usb.png
:target: ../../_static/usb/esp32s3_usb.png
.. image:: ../../../_static/usb/esp32s3_usb.png
:target: ../../../_static/usb/esp32s3_usb.png
:alt: esp32s3_usb


Expand Down Expand Up @@ -47,8 +47,8 @@ By adding an external PHY, it is possible to enable the simultaneous operation o
ESP32S2/S3 supports SP5301 or equivalent USB PHY. A typical circuit diagram for an external PHY is as follows:


.. image:: ../../_static/usb/usb_fs_phy_sp5301.png
:target: ../../_static/usb/usb_fs_phy_sp5301.png
.. image:: ../../../_static/usb/usb_fs_phy_sp5301.png
:target: ../../../_static/usb/usb_fs_phy_sp5301.png
:alt: usb_fs_phy_sp5301


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Upon connecting the USB-Serial-JTAG peripheral to a PC, the Device Manager will
For Windows as shown in the following figure:


.. image:: ../../_static/usb/device_manager_usb_serial_jtag_cn.png
:target: ../../_static/usb/device_manager_usb_serial_jtag_cn.png
.. image:: ../../../_static/usb/device_manager_usb_serial_jtag_cn.png
:target: ../../../_static/usb/device_manager_usb_serial_jtag_cn.png
:alt: device_manager_usb_serial_jtag_cn


For Linux as shown in the following figure:


.. image:: ../../_static/usb/usb_serial_jtag_linux.png
:target: ../../_static/usb/usb_serial_jtag_linux.png
.. image:: ../../../_static/usb/usb_serial_jtag_linux.png
:target: ../../../_static/usb/usb_serial_jtag_linux.png
:alt: device_manager_usb_serial_jtag_cn


Expand Down
File renamed without changes.
Loading

0 comments on commit 803575c

Please sign in to comment.