Skip to content

Commit 63ba966

Browse files
committed
Merge pull request #1341 from petermm/use_usb_serial-menuconfig
Add menuconfig option for USE_USB_SERIAL Improve DX a lot for enabling serial over usb for boards like the S2 Mini. <img width="572" alt="Screenshot 2024-10-15 at 11 36 22" src="https://github.com/user-attachments/assets/ea851cbd-52b8-4874-ae04-0ebf79609f3d"> Will fail in a good way if enabled without esp_tinyusb being installed: ``` /AtomVM/src/platforms/esp32/main/main.c:45:10: fatal error: tinyusb.h: No such file or directory 45 | #include "tinyusb.h" | ^~~~~~~~~~~ compilation terminated. ninja: build stopped: subcommand failed. HINT: tinyusb.h was removed. Please use esp_tinyusb component from IDF component manager instead. You can install `esp_tinyusb` using 'idf.py add-dependency espressif/esp_tinyusb' command. Refer to the migration guide for more details. ``` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 3d71182 + 568df98 commit 63ba966

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Added a limited implementation of the OTP `ets` interface
1111
- Added `code:all_loaded/0` and `code:all_available/0`
12+
- Added menuconfig option for enabling USE_USB_SERIAL, eg. serial over USB for certain ESP32-S2 boards etc.
1213

1314
## [0.6.6] - Unreleased
1415

src/platforms/esp32/main/Kconfig.projbuild

+14
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@ menu "AtomVM configuration"
2626
help
2727
Reboot the ESP32 device if the start/0 entrypoint does not return the `ok` atom.
2828

29+
config USE_USB_SERIAL
30+
bool "Enable USB CDC Serial"
31+
default n
32+
select TINYUSB_CDC_ENABLED
33+
help
34+
Enable USB CDC Serial functionality.
35+
36+
config TINYUSB_CDC_ENABLED
37+
bool "Enable TinyUSB CDC (requires 'idf.py add-dependency esp_tinyusb')"
38+
default y
39+
depends on USE_USB_SERIAL
40+
help
41+
Enable TinyUSB CDC functionality if USE_USB_SERIAL is enabled.
42+
2943
endmenu

src/platforms/esp32/main/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
// before enabling this:
4141
// idf.py add-dependency esp_tinyusb
42-
// and enable CDC in menu config
43-
#ifdef USE_USB_SERIAL
42+
// and enable USE_USB_SERIAL in menu config
43+
#ifdef CONFIG_USE_USB_SERIAL
4444
void init_usb_serial(void);
4545
#include "tinyusb.h"
4646
#include "tusb_cdc_acm.h"
@@ -70,7 +70,7 @@ void app_main()
7070
{
7171
esp32_sys_queue_init();
7272

73-
#ifdef USE_USB_SERIAL
73+
#ifdef CONFIG_USE_USB_SERIAL
7474
init_usb_serial();
7575
#endif
7676

@@ -151,7 +151,7 @@ void app_main()
151151
}
152152
}
153153

154-
#ifdef USE_USB_SERIAL
154+
#ifdef CONFIG_USE_USB_SERIAL
155155
void init_usb_serial()
156156
{
157157
/* Setting TinyUSB up */

0 commit comments

Comments
 (0)