Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
713 changes: 713 additions & 0 deletions .github/instructions/ato.instructions.md

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ on:
- 'partitions.csv'
- '.github/workflows/build.yml'

env:
APP_NAME: 'Esp Box Emu'
IDF_VERSION: 'v5.5.1'
IDF_COMPONENT_MANAGER: "1" # whether to enable the component manager or not
FLASH_TOTAL_OVERRIDE: '6291456' # 6MB flash app partition for main app

jobs:
build:

Expand All @@ -30,8 +36,10 @@ jobs:
matrix:
test:
- path: '.'
name: 'box-emu'
target: esp32s3
- path: 'components/box-emu/example'
name: 'box-emu/example'
target: esp32s3

steps:
Expand All @@ -43,6 +51,17 @@ jobs:
- name: Build Examples
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.4
esp_idf_version: ${{ env.IDF_VERSION }}
target: ${{matrix.test.target}}
path: ${{matrix.test.path}}

- name: Determine Size Delta
uses: esp-cpp/esp-idf-size-delta@v1
if: ${{ matrix.test.name == 'box-emu' }}
with:
app_name: ${{ env.APP_NAME }}
app_path: ${{ matrix.test.path }}
idf_target: ${{ matrix.test.target }}
idf_version: ${{ env.IDF_VERSION }}
idf_component_manager: ${{ env.IDF_COMPONENT_MANAGER }}
flash_total_override: ${{ env.FLASH_TOTAL_OVERRIDE }}
25 changes: 23 additions & 2 deletions .github/workflows/package_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
types: [published]
workflow_dispatch:

env:
APP_NAME: 'Esp Box Emu'
IDF_TARGET: 'esp32s3'
IDF_VERSION: 'v5.5.1'
IDF_COMPONENT_MANAGER: "1" # whether to enable the component manager or not
FLASH_TOTAL_OVERRIDE: '6291456' # 6MB flash app partition for main app

jobs:
build:

Expand All @@ -25,8 +32,8 @@ jobs:
- name: Build Main Code
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.4
target: esp32s3
esp_idf_version: ${{ env.IDF_VERSION }}
target: ${{ env.IDF_TARGET }}
path: '.'
command: './patches.sh && idf.py build'

Expand All @@ -53,6 +60,20 @@ jobs:
with:
files: firmware-binaries.zip


- name: Determine Size Delta
# only run this on the esp-box build and if the release is published
if: ${{ github.event.release && github.event.action == 'published' }}
uses: esp-cpp/esp-idf-size-delta@v1
with:
app_name: ${{ env.APP_NAME }}
app_path: "."
idf_target: ${{ env.IDF_TARGET }}
idf_version: ${{ env.IDF_VERSION }}
idf_component_manager: ${{ env.IDF_COMPONENT_MANAGER }}
flash_total_override: ${{ env.FLASH_TOTAL_OVERRIDE }}
post_comment: 'false'

package:
name: Package the binaries into an executables for Windows, MacOS, and Linux (Ubuntu)
needs: build
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ jobs:
# Do not build the project and do not use cmake to generate compile_commands.json
use_cmake: false

# Use the 5.4 release version since it's what we build with
esp_idf_version: release/v5.4

# (Optional) cppcheck args
cppcheck_args: -i$GITHUB_WORKSPACE/components/gbc/gnuboy -i$GITHUB_WORKSPACE/components/nes/nofrendo -i$GITHUB_WORKSPACE/components/msx/fmsx -i$GITHUB_WORKSPACE/components/doom/prboom -i$GITHUB_WORKSPACE/components/sms/smsplus -i$GITHUB_WORKSPACE/components/genesis/gwenesis -i$GITHUB_WORKSPACE/components/gui/generated -i$GITHUB_WORKSPACE/components/menu/generated -i$GITHUB_WORKSPACE/components/jpegdec --check-level=exhaustive --force --enable=all --inline-suppr --inconclusive --platform=mips32 --std=c++17 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "components/espp"]
path = components/espp
url = [email protected]:esp-cpp/espp
[submodule "components/jpegdec"]
path = components/jpegdec
url = https://github.com/esp-cpp/jpegdec
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)

# add the component directories that we want to use
set(EXTRA_COMPONENT_DIRS
"components/espp/components"
# "components/espp/components"
)

# add compile definition ARDUINO_ARCH_ESP32, enabling jpegdec simd support
Expand Down
1 change: 1 addition & 0 deletions components/box-emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ idf_component_register(
"hal"
"usb"
"esp_tinyusb"
"lvgl"
"codec"
"adc"
"aw9523"
Expand Down
1 change: 0 additions & 1 deletion components/box-emu/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# add the component directories that we want to use
set(EXTRA_COMPONENT_DIRS
"../../../components/"
"../../../components/espp/components/"
)

set(
Expand Down
16 changes: 14 additions & 2 deletions components/box-emu/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_tinyusb: "^1.4.2"
idf: "^5.1"
idf: ">=5.5"
espressif/esp_tinyusb: ">=2.0"
lvgl/lvgl: '>=9.2.2'
espp/adc: ">=1.0"
espp/aw9523: ">=1.0"
espp/button: ">=1.0"
espp/drv2605: ">=1.0"
espp/esp-box: ">=1.0"
espp/event_manager: ">=1.0"
espp/max1704x: ">=1.0"
espp/mcp23x17: ">=1.0"
espp/task: ">=1.0"
espp/timer: ">=1.0"
espp/serialization: ">=1.0"
5 changes: 4 additions & 1 deletion components/box-emu/include/box-emu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

#include <tinyusb.h>
#include <class/msc/msc.h>
#include <tusb_msc_storage.h>
#include <tinyusb_msc.h>

#include <tinyusb_default_config.h>

#include "esp-box.hpp"
#include "event_manager.hpp"
Expand Down Expand Up @@ -367,6 +369,7 @@ class BoxEmu : public espp::BaseComponent {
// usb
std::atomic<bool> usb_enabled_{false};
usb_phy_handle_t jtag_phy_;
tinyusb_msc_storage_handle_t msc_storage_handle_{nullptr};
};

// for libfmt printing of the BoxEmu::Version enum
Expand Down
63 changes: 44 additions & 19 deletions components/box-emu/src/box-emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,30 +650,47 @@ bool BoxEmu::initialize_usb() {
usb_del_phy(jtag_phy_);

fmt::print("USB MSC initialization\n");
// register the callback for the storage mount changed event.
tinyusb_msc_sdmmc_config_t config_sdmmc = {
.card = card,
.callback_mount_changed = nullptr,
.callback_premount_changed = nullptr,
.mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.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.
.disk_status_check_enable = false, // true if you see issues or are unmounted properly; slows down I/O
esp_vfs_fat_mount_config_t fat_mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.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.
.disk_status_check_enable = false, // true if you see issues or are unmounted properly; slows down I/O
};

tinyusb_msc_fatfs_config_t config_msc = {
.base_path = (char*)mount_point,
.config = fat_mount_config,
.do_not_format = true,
.format_flags = 0,
};
Comment on lines +660 to +665
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C-style cast (char*)mount_point should be replaced with a C++ static_cast for better type safety: static_cast<char*>(mount_point).

Copilot uses AI. Check for mistakes.

tinyusb_msc_storage_config_t msc_storage_config = {
.medium = {
.card = card,
},
.fat_fs = config_msc,
.mount_point = TINYUSB_MSC_STORAGE_MOUNT_USB,
};
ESP_ERROR_CHECK(tinyusb_msc_storage_init_sdmmc(&config_sdmmc));

ESP_ERROR_CHECK(tinyusb_msc_new_storage_sdmmc(&msc_storage_config, &msc_storage_handle_));
// register the callback for the storage mount changed event.
// ESP_ERROR_CHECK(tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED, storage_mount_changed_cb));

// initialize the tinyusb stack
fmt::print("USB MSC initialization\n");
tinyusb_config_t tusb_cfg;
memset(&tusb_cfg, 0, sizeof(tusb_cfg));
tusb_cfg.device_descriptor = &descriptor_config;
tusb_cfg.string_descriptor = string_desc_arr;
tusb_cfg.string_descriptor_count = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]);
tusb_cfg.external_phy = false;
tusb_cfg.configuration_descriptor = desc_configuration;
// no device_event_handler for tud_mount and tud_unmount callbacks
tinyusb_config_t tusb_cfg = TINYUSB_DEFAULT_CONFIG();
tusb_cfg.task = TINYUSB_TASK_CUSTOM(4096 /*size */, 4 /* priority */,
0 /* affinity: 0 - CPU0, 1 - CPU1 ... */);
Comment on lines +681 to +684
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers should be defined as named constants. Consider defining constants for task size (4096), priority (4), and CPU affinity (0) to improve code maintainability.

Copilot uses AI. Check for mistakes.
tusb_cfg.descriptor.device = &descriptor_config;
tusb_cfg.descriptor.string = string_desc_arr;
tusb_cfg.descriptor.string_count =
sizeof(string_desc_arr) / sizeof(string_desc_arr[0]);
tusb_cfg.descriptor.full_speed_config = desc_configuration;
tusb_cfg.phy.skip_setup = false; // was external-phy = false
tusb_cfg.phy.self_powered = false;
tusb_cfg.phy.vbus_monitor_io = -1;

ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
fmt::print("USB MSC initialization DONE\n");
usb_enabled_ = true;
Expand All @@ -686,8 +703,16 @@ bool BoxEmu::deinitialize_usb() {
logger_.warn("USB MSC not initialized");
return false;
}
esp_err_t err;
logger_.info("USB MSC deinitialization");
auto err = tinyusb_driver_uninstall();
// deinit + delete the msc storage handle
err = tinyusb_msc_delete_storage(msc_storage_handle_);
if (err != ESP_OK) {
logger_.error("tinyusb_msc_delete_storage failed: {}", esp_err_to_name(err));
return false;
}
logger_.info("USB deinitialization");
err = tinyusb_driver_uninstall();
if (err != ESP_OK) {
logger_.error("tinyusb_driver_uninstall failed: {}", esp_err_to_name(err));
return false;
Expand Down
2 changes: 1 addition & 1 deletion components/box-emu/src/make_color.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "make_color.h"

#include <lvgl/lvgl.h>
#include <lvgl.h>

extern "C" uint16_t make_color(uint8_t r, uint8_t g, uint8_t b) {
return lv_color_to_u16(lv_color_make(r, g, b));
Expand Down
1 change: 0 additions & 1 deletion components/espp
Submodule espp deleted from 7cf2ea
2 changes: 1 addition & 1 deletion components/gui/generated/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extern "C" {
#endif

#include "lvgl/lvgl.h"
#include "lvgl.h"

#include "ui_helpers.h"
#include "ui_events.h"
Expand Down
2 changes: 1 addition & 1 deletion components/jpegdec
Submodule jpegdec updated 39 files
+284 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test.xcodeproj/project.pbxproj
+7 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+ ...EGDEC_Test.xcodeproj/project.xcworkspace/xcuserdata/laurencebank.xcuserdatad/UserInterfaceState.xcuserstate
+14 −0 .../JPEGDEC_Test/JPEGDEC_Test.xcodeproj/xcuserdata/laurencebank.xcuserdatad/xcschemes/xcschememanagement.plist
+13 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/Makefile
+3,390 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/corrupt1.h
+3,393 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/corrupt2.h
+1,842 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/corrupt3.h
+3,395 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/corrupt4.h
+3,391 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/corrupt5.h
+305 −0 MacOS/JPEGDEC_Test/JPEGDEC_Test/main.cpp
+11 −1 README.md
+9 −5 examples/ILI9431_t3_slideshow/ILI9431_t3_slideshow.ino
+117 −0 examples/crop_area/crop_area.ino
+2,335 −0 examples/crop_area/croptest.h
+118 −0 examples/dithering/dithering.ino
+15 −11 examples/esp32_jpeg/esp32_jpeg.ino
+80 −0 examples/jpegdisplay_demo/jpegdisplay_demo.ino
+245 −0 examples/jpegdisplay_demo/octocat_small.h
+96 −0 examples/lcd_dma/lcd_dma.ino
+183 −0 examples/web_image_viewer/web_image_viewer.ino
+6 −0 idf_component.yml
+2 −1 library.properties
+4 −4 linux/examples/c_cmdline/main.c
+13 −0 linux/examples/c_cmdline/makefile
+13 −0 linux/examples/showimg/makefile
+63 −0 linux/examples/showimg/showimg.cpp
+9 −7 linux/makefile
+ perf.jpg
+18 −0 src/JPEGDEC.cpp
+14 −2 src/JPEGDEC.h
+46 −0 src/JPEGDisplay.h
+277 −0 src/JPEGDisplay.inl
+133 −69 src/jpeg.inl
+3 −1 src/s3_simd_420.S
+3 −2 src/s3_simd_444.S
+1 −1 src/s3_simd_dequant.S
+115 −0 src/s3_simd_idct.S_FUTURE
+2,738 −0 test_images/zebra.h
5 changes: 5 additions & 0 deletions main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf: '>=5.4'
espp/monitor: '>=1.0'
Loading