Skip to content

Commit 34129dc

Browse files
committed
chore: Update to use espp IDF components from component registry, also update some deps
1 parent 86cf4ca commit 34129dc

File tree

11 files changed

+84
-30
lines changed

11 files changed

+84
-30
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "components/espp"]
2-
path = components/espp
3-
url = [email protected]:esp-cpp/espp
41
[submodule "components/jpegdec"]
52
path = components/jpegdec
63
url = https://github.com/esp-cpp/jpegdec

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
66

77
# add the component directories that we want to use
88
set(EXTRA_COMPONENT_DIRS
9-
"components/espp/components"
9+
# "components/espp/components"
1010
)
1111

1212
# add compile definition ARDUINO_ARCH_ESP32, enabling jpegdec simd support

components/box-emu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ idf_component_register(
1010
"hal"
1111
"usb"
1212
"esp_tinyusb"
13+
"lvgl"
1314
"codec"
1415
"adc"
1516
"aw9523"
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/esp_tinyusb: "^1.4.2"
4-
idf: "^5.1"
3+
idf: ">=5.5"
4+
espressif/esp_tinyusb: ">=2.0"
5+
lvgl/lvgl: '>=9.2.2'
6+
espp/adc: ">=1.0"
7+
espp/aw9523: ">=1.0"
8+
espp/button: ">=1.0"
9+
espp/drv2605: ">=1.0"
10+
espp/esp-box: ">=1.0"
11+
espp/event_manager: ">=1.0"
12+
espp/max1704x: ">=1.0"
13+
espp/mcp23x17: ">=1.0"
14+
espp/task: ">=1.0"
15+
espp/timer: ">=1.0"
16+
espp/serialization: ">=1.0"

components/box-emu/include/box-emu.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
#include <tinyusb.h>
1414
#include <class/msc/msc.h>
15-
#include <tusb_msc_storage.h>
15+
#include <tinyusb_msc.h>
16+
17+
#include <tinyusb_default_config.h>
1618

1719
#include "esp-box.hpp"
1820
#include "event_manager.hpp"
@@ -367,6 +369,7 @@ class BoxEmu : public espp::BaseComponent {
367369
// usb
368370
std::atomic<bool> usb_enabled_{false};
369371
usb_phy_handle_t jtag_phy_;
372+
tinyusb_msc_storage_handle_t msc_storage_handle_{nullptr};
370373
};
371374

372375
// for libfmt printing of the BoxEmu::Version enum

components/box-emu/src/box-emu.cpp

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -650,30 +650,47 @@ bool BoxEmu::initialize_usb() {
650650
usb_del_phy(jtag_phy_);
651651

652652
fmt::print("USB MSC initialization\n");
653-
// register the callback for the storage mount changed event.
654-
tinyusb_msc_sdmmc_config_t config_sdmmc = {
655-
.card = card,
656-
.callback_mount_changed = nullptr,
657-
.callback_premount_changed = nullptr,
658-
.mount_config = {
659-
.format_if_mount_failed = false,
660-
.max_files = 5,
661-
.allocation_unit_size = 2 * 1024, // sector size is 512 bytes, this should be between sector size and (128 * sector size). Larger means higher read/write performance and higher overhead for small files.
662-
.disk_status_check_enable = false, // true if you see issues or are unmounted properly; slows down I/O
653+
esp_vfs_fat_mount_config_t fat_mount_config = {
654+
.format_if_mount_failed = false,
655+
.max_files = 5,
656+
.allocation_unit_size = 2 * 1024, // sector size is 512 bytes, this should be between sector size and (128 * sector size). Larger means higher read/write performance and higher overhead for small files.
657+
.disk_status_check_enable = false, // true if you see issues or are unmounted properly; slows down I/O
658+
};
659+
660+
tinyusb_msc_fatfs_config_t config_msc = {
661+
.base_path = (char*)mount_point,
662+
.config = fat_mount_config,
663+
.do_not_format = true,
664+
.format_flags = 0,
665+
};
666+
667+
tinyusb_msc_storage_config_t msc_storage_config = {
668+
.medium = {
669+
.card = card,
663670
},
671+
.fat_fs = config_msc,
672+
.mount_point = TINYUSB_MSC_STORAGE_MOUNT_USB,
664673
};
665-
ESP_ERROR_CHECK(tinyusb_msc_storage_init_sdmmc(&config_sdmmc));
674+
675+
ESP_ERROR_CHECK(tinyusb_msc_new_storage_sdmmc(&msc_storage_config, &msc_storage_handle_));
676+
// register the callback for the storage mount changed event.
666677
// ESP_ERROR_CHECK(tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED, storage_mount_changed_cb));
667678

668679
// initialize the tinyusb stack
669680
fmt::print("USB MSC initialization\n");
670-
tinyusb_config_t tusb_cfg;
671-
memset(&tusb_cfg, 0, sizeof(tusb_cfg));
672-
tusb_cfg.device_descriptor = &descriptor_config;
673-
tusb_cfg.string_descriptor = string_desc_arr;
674-
tusb_cfg.string_descriptor_count = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]);
675-
tusb_cfg.external_phy = false;
676-
tusb_cfg.configuration_descriptor = desc_configuration;
681+
// no device_event_handler for tud_mount and tud_unmount callbacks
682+
tinyusb_config_t tusb_cfg = TINYUSB_DEFAULT_CONFIG();
683+
tusb_cfg.task = TINYUSB_TASK_CUSTOM(4096 /*size */, 4 /* priority */,
684+
0 /* affinity: 0 - CPU0, 1 - CPU1 ... */);
685+
tusb_cfg.descriptor.device = &descriptor_config;
686+
tusb_cfg.descriptor.string = string_desc_arr;
687+
tusb_cfg.descriptor.string_count =
688+
sizeof(string_desc_arr) / sizeof(string_desc_arr[0]);
689+
tusb_cfg.descriptor.full_speed_config = desc_configuration;
690+
tusb_cfg.phy.skip_setup = false; // was external-phy = false
691+
tusb_cfg.phy.self_powered = false;
692+
tusb_cfg.phy.vbus_monitor_io = -1;
693+
677694
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
678695
fmt::print("USB MSC initialization DONE\n");
679696
usb_enabled_ = true;
@@ -686,8 +703,16 @@ bool BoxEmu::deinitialize_usb() {
686703
logger_.warn("USB MSC not initialized");
687704
return false;
688705
}
706+
esp_err_t err;
689707
logger_.info("USB MSC deinitialization");
690-
auto err = tinyusb_driver_uninstall();
708+
// deinit + delete the msc storage handle
709+
err = tinyusb_msc_delete_storage(msc_storage_handle_);
710+
if (err != ESP_OK) {
711+
logger_.error("tinyusb_msc_delete_storage failed: {}", esp_err_to_name(err));
712+
return false;
713+
}
714+
logger_.info("USB deinitialization");
715+
err = tinyusb_driver_uninstall();
691716
if (err != ESP_OK) {
692717
logger_.error("tinyusb_driver_uninstall failed: {}", esp_err_to_name(err));
693718
return false;

components/box-emu/src/make_color.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "make_color.h"
22

3-
#include <lvgl/lvgl.h>
3+
#include <lvgl.h>
44

55
extern "C" uint16_t make_color(uint8_t r, uint8_t g, uint8_t b) {
66
return lv_color_to_u16(lv_color_make(r, g, b));

components/espp

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/gui/generated/ui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
extern "C" {
1111
#endif
1212

13-
#include "lvgl/lvgl.h"
13+
#include "lvgl.h"
1414

1515
#include "ui_helpers.h"
1616
#include "ui_events.h"

components/jpegdec

Submodule jpegdec updated 39 files

0 commit comments

Comments
 (0)