Skip to content

Commit ff664cc

Browse files
committed
fixes for espruino#2609 - tidy up for testing
1 parent 6bf44af commit ff664cc

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

boards/ESP32C3_IDF4.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@
4545
# available memory. Using too small a JsVar format will under utilise
4646
# available memory.
4747

48+
# MakeFile identifier ESP_FORCE_NO_USB_SERIAL_JTAG
49+
# --------------------------------------------------------------
50+
# The 'makefile' list in the 'info' dictionary below can define ESP_FORCE_NO_USB_SERIAL_JTAG using 'DEFINES+=-ESP_FORCE_NO_USB_SERIAL_JTAG'
51+
# where necessary.
52+
# When defined ESP_FORCE_NO_USB_SERIAL_JTAG overrides the default console driver assignment in the Espruino build for the ESP32-C3.
53+
# When NOT defined, By default the Espruino console will use the USB port with usb_serial_jtag_driver.
54+
# This will support the case where the USB connector on the board is wired directly to the D+ and D- pins on the ESP32-C3.
55+
# Alternatively in the case where the USB is wired to an ESP32-C3's UART RX and TX pins (usually via a USB to UART conversion chip),
56+
# ESP_FORCE_NO_USB_SERIAL_JTAG should be defined to set the console for UART operation.
57+
# This method is introduced for fix to issue #2609 and replaces the previous method using the 'USB_CDC' identifier.
58+
59+
4860

4961
import pinutils;
5062
info = {
@@ -74,7 +86,7 @@
7486
'DEFINES+=-DESP_STACK_SIZE=25000',
7587
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
7688
'DEFINES+=-DUSE_FONT_6X8',
77-
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
89+
# 'DEFINES+=-ESP_FORCE_NO_USB_SERIAL_JTAG' # see npote above
7890
'ESP32_FLASH_MAX=1572864'
7991
]
8092
}

boards/ESP32S3_IDF4.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@
4545
# available memory. Using too small a JsVar format will under utilise
4646
# available memory.
4747

48+
# MakeFile identifier ESP_FORCE_NO_USB_SERIAL_JTAG
49+
# --------------------------------------------------------------
50+
# The 'makefile' list in the 'info' dictionary below can define ESP_FORCE_NO_USB_SERIAL_JTAG using 'DEFINES+=-ESP_FORCE_NO_USB_SERIAL_JTAG'
51+
# where necessary.
52+
# When defined ESP_FORCE_NO_USB_SERIAL_JTAG overrides the default console driver assignment in the Espruino build for the ESP32-S3.
53+
# When NOT defined, By default the Espruino console will use the USB port with usb_serial_jtag_driver.
54+
# This will support the case where the USB connector on the board is wired directly to the D+ and D- pins on the ESP32S3.
55+
# Alternatively in the case where the USB is wired to an ESP32S3's UART RX and TX pins (usually via a USB to UART conversion chip),
56+
# ESP_FORCE_NO_USB_SERIAL_JTAG should be defined to set the console for UART operation.
57+
# This method is introduced for fix to issue #2609 and replaces the previous method using the 'USB_CDC' identifier.
58+
59+
4860

4961
import pinutils;
5062
info = {
@@ -74,7 +86,7 @@
7486
'DEFINES+=-DESP_STACK_SIZE=25000',
7587
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
7688
'DEFINES+=-DUSE_FONT_6X8',
77-
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
89+
# 'DEFINES+=-ESP_FORCE_NO_USB_SERIAL_JTAG' # See note above
7890
'ESP32_FLASH_MAX=1572864'
7991
]
8092
}

targets/esp32/jshardware.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ void jshUSARTKick(IOEventFlags device) {
592592
#endif
593593
case EV_SERIAL1:
594594
uart_tx_one_char((uint8_t)c);
595-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
595+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
596596
// The USB CDC UART on the C3 only writes the data to USB after a newline. Ensure uartTask in main.c knows to flush the UART next time
597597
extern void esp32USBUARTWasUsed();
598598
esp32USBUARTWasUsed();

targets/esp32/jshardwareUart.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <jsdevices.h>
2424
#include "jsinteractive.h" // jsDebug() ??
2525

26-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
26+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
2727
#include "driver/usb_serial_jtag.h"
2828
#endif
2929

@@ -87,7 +87,7 @@ void initSerial(IOEventFlags device,JshUSARTInfo *inf){
8787
}
8888

8989
void initConsole(){
90-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
90+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
9191
/* Configure USB-CDC */
9292
usb_serial_jtag_driver_config_t usb_serial_config = {.tx_buffer_size = 128,
9393
.rx_buffer_size = 128};
@@ -118,7 +118,7 @@ void consoleToEspruino(){
118118
#else
119119
TickType_t ticksToWait = 100;
120120
#endif
121-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
121+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
122122
int len = usb_serial_jtag_read_bytes(rxbuf, sizeof(rxbuf), ticksToWait);
123123
#else
124124
int len = uart_read_bytes(uart_console, rxbuf, sizeof(rxbuf), ticksToWait); // Read data from UART

targets/esp32/main.c

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

4040
#include "jsvar.h"
4141

42-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
42+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
4343
#pragma message ("USB Serial JTAG console is enabled")
4444
#else
4545
#pragma message ("Using UART console")
4646
#endif
4747

4848
extern void *espruino_stackHighPtr; //Name spaced because this has to be a global variable.
4949
//Used in jsuGetFreeStack().
50-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
50+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
5151
#include "hal/usb_serial_jtag_ll.h"
5252
volatile bool usbUARTIsNotFlushed;
5353
#endif
5454

5555
void esp32USBUARTWasUsed() {
56-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
56+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
5757
usbUARTIsNotFlushed = true;
5858
#endif
5959
}
@@ -65,7 +65,7 @@ static void uartTask(void *data) {
6565
while(1) {
6666
consoleToEspruino();
6767
serialToEspruino();
68-
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL)
68+
#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && !defined(ESP_FORCE_NO_USB_SERIAL_JTAG)
6969
/* The USB CDC UART on the C3 only writes the data to USB after a newline.
7070
We don't want that, so we call flush in this uart task if any data has been sent. */
7171
if (usbUARTIsNotFlushed) {

0 commit comments

Comments
 (0)