espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.7k stars 7.3k forks source link

esp_tinyuf2 firmware update (IDFGH-12092) #13150

Closed kaspernyhus closed 6 months ago

kaspernyhus commented 9 months ago

Answers checklist.

IDF version.

v5.1.2

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

Use esp_tinyuf2 along features from the esp_tinyusb component

What is the actual behavior?

not compiling/linking

Steps to reproduce.

add to idf-component.yml

## IDF Component Manager Manifest File
dependencies:
  espressif/esp_tinyuf2: "^0.2.0"
  espressif/esp_tinyusb: "^1.4.3"

Build or installation Logs.

No response

More Information.

I am developing an appication that will use UF2 for firmware updates and other usb features found in the esp_tinyusb component. Is is possible to have these features at the same time? Booting between modes for UF2/non-UF2 is fine, if the tinyusb stacks have to be initialized with different paramters.

tore-espressif commented 8 months ago

Hello @kaspernyhus thank you for the issue.

That is a very reasonable requirement, however, at the moment these two components do not work together. What specific feature from esp_tinyusb do you need? It should be feasible to merge features from esp_tinyusb to esp_tinyuf2 as they are both based on TinyUSB

cc @leeebo

kaspernyhus commented 8 months ago

Hi Tomas, thanks for getting back.

I need HID and USB Audio which I pulled into esp_tinyusb in a fork of idf-extra-components here

Which approach would you recommend:

  1. merge the features (hid and audio) from esp_tinyusb into esp_tinyuf2
  2. pick UF2 functionality from esp_tinyuf2 and build on top of MSC in esp_tinyusb

thanks a lot!

leeebo commented 8 months ago
Is it possible to have these features at the same time?

@kaspernyhus Yes, I recommend you pick the esp_tinyuf2 code to your tinyusb project, just like what you have done for adding UAC class to esp_tinyusb. (add uf2 related source files and modify the descriptors and so on.)

Booting between modes for UF2/non-UF2 is fine

If you have enough flash space, it's a good idea to build a separate UF2-enabled APP then flash to a separate partition, in this case you don't need to merge the code. please refer boot-from-test-firmware and the esp-box chatgpt demo

StevenMacias commented 8 months ago
Is it possible to have these features at the same time?

@kaspernyhus Yes, I recommend you pick the esp_tinyuf2 code to your tinyusb project, just like what you have done for adding UAC class to esp_tinyusb. (add uf2 related source files and modify the descriptors and so on.)

Booting between modes for UF2/non-UF2 is fine

If you have enough flash space, it's a good idea to build a separate UF2-enabled APP then flash to a separate partition, in this case you don't need to merge the code. please refer boot-from-test-firmware and the esp-box chatgpt demo

@leeebo thank you so much for your answer. I have checked the boot-from-test-firmware documentation. Is it only possible to boot from a test partition by using a GPIO pin? Is there any method that can be used to software reboot in a different partition? Thanks again!

leeebo commented 8 months ago

@StevenMacias Sure, you can use API esp_ota_set_boot_partition to choose boot partition, please refer https://github.com/espressif/esp-box/blob/master/examples/chatgpt_demo/factory_nvs/main/main.c#L41C5-L41C31

StevenMacias commented 8 months ago

@leeebo Thanks again for the fast and useful reply. Currently we are using the idf.py uf2-ota command to generate the .uf2 files. How we could include the UF2-enabled APP in the .uf2 firmware? We are interested on separating the stacks as you suggested but also on being able to update both the main application and the UF2-enabled APP.

leeebo commented 6 months ago

@StevenMacias If using UF2-enabled APP + normal uf2 app, the UF2-enabled APP works as the special featured app / "bootloader", if you want to update it, an additional partition "UF2-enabled APP2" needs to be add.

Then you have to judge by the uf2 file name, and choose corresponding partition to write during the OTA process.

kaspernyhus commented 6 months ago

Thanks for the help, we went the simple route with one uf2 partition. Will close this.