Skip to content

Commit 2b384fe

Browse files
authored
Merge branch 'Moddable-OpenSource:public' into linemb-demo
2 parents 90e1336 + 0135c0e commit 2b384fe

1,158 files changed

Lines changed: 71040 additions & 21585 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/devices/esp32/config/idfSerialPort

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/bin/bash
22

3+
4+
if [[ "$UPLOAD_PORT" ]]; then
5+
>&2 echo "Using <env> UPLOAD_PORT $UPLOAD_PORT"
6+
if [[ -c "$UPLOAD_PORT" ]]; then
7+
echo $UPLOAD_PORT
8+
exit
9+
fi
10+
fi
11+
312
CACHED_DIR=$MODDABLE/build/tmp/esp32
413

514
if [[ -f ${CACHED_DIR}/UPLOAD_PORT ]]; then
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Copyright (c) 2016-2025 Moddable Tech, Inc.
3+
*
4+
* This file is part of the Moddable SDK Runtime.
5+
*
6+
* The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* The Moddable SDK Runtime is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
#define __XS6PLATFORMMINIMAL__
22+
23+
#include <stdio.h>
24+
#include <stdlib.h>
25+
#include <string.h>
26+
#include "freertos/FreeRTOS.h"
27+
#include "freertos/task.h"
28+
#include "sdkconfig.h"
29+
#include "esp_log.h"
30+
31+
#include "driver/usb_serial_jtag.h"
32+
33+
#include "xs.h"
34+
#include "xsHost.h"
35+
#include "xsHosts.h"
36+
37+
#include "mc.defines.h"
38+
39+
#ifndef XT_STACK_EXTRA
40+
#define XT_STACK_EXTRA 512
41+
#endif
42+
43+
//#define WEAK __attribute__((weak))
44+
#define WEAK
45+
46+
#ifdef mxDebug
47+
extern xsMachine *gThe;
48+
#endif
49+
50+
extern void fx_putc(void *refcon, char c); //@@
51+
52+
uint8_t jtagReady = 1;
53+
uint8_t jtag0_position = 0, jtag0_available = 0;
54+
uint8_t jtag1_position = 0, jtag1_available = 0;
55+
static uint8_t jtag0[128];
56+
static uint8_t jtag1[128];
57+
58+
static void debug_task(void *pvParameter)
59+
{
60+
usb_serial_jtag_driver_config_t cfg = { .rx_buffer_size = 512, .tx_buffer_size = 512 };
61+
usb_serial_jtag_driver_install(&cfg);
62+
63+
while (true) {
64+
if (0 == jtagReady) {
65+
int amt = usb_serial_jtag_read_bytes(jtag1, sizeof(jtag1), 1);
66+
if (0 == amt)
67+
continue;
68+
jtag1_position = 0;
69+
jtag1_available = (uint8_t)amt;
70+
}
71+
else {
72+
int amt = usb_serial_jtag_read_bytes(jtag0, sizeof(jtag0), 1);
73+
if (0 == amt)
74+
continue;
75+
jtag0_position = 0;
76+
jtag0_available = (uint8_t)amt;
77+
}
78+
79+
#ifdef mxDebug
80+
fxReceiveLoop();
81+
#endif
82+
}
83+
}
84+
85+
/*
86+
Required functions provided by application
87+
to enable serial port for diagnostic information and debugging
88+
*/
89+
90+
WEAK void modLog_transmit(const char *msg)
91+
{
92+
#ifdef mxDebug
93+
if (gThe) {
94+
uint8_t c;
95+
while (0 != (c = *msg++))
96+
fx_putc(gThe, c);
97+
fx_putc(gThe, 0);
98+
}
99+
else
100+
#endif
101+
{
102+
const uint8_t crlf[] = {13, 10};
103+
ESP_put((uint8_t *)msg, strlen(msg));
104+
ESP_put((uint8_t *)crlf, 2);
105+
}
106+
}
107+
108+
WEAK void ESP_put(uint8_t *c, int count) {
109+
while (count > 0) {
110+
int sent = usb_serial_jtag_write_bytes(c, count, 10);
111+
if (sent <= 0)
112+
break;
113+
c += sent;
114+
count -= sent;
115+
}
116+
}
117+
118+
WEAK void ESP_putc(int c) {
119+
char cx = c;
120+
usb_serial_jtag_write_bytes(&cx, 1, 1);
121+
}
122+
123+
WEAK int ESP_getc(void) {
124+
if (0 == jtagReady) {
125+
if (jtag0_available) {
126+
jtag0_available--;
127+
return jtag0[jtag0_position++];
128+
}
129+
else if (jtag1_available) {
130+
jtagReady = 1;
131+
jtag1_available--;
132+
return jtag1[jtag1_position++];
133+
}
134+
}
135+
else {
136+
if (jtag1_available) {
137+
jtag1_available--;
138+
return jtag1[jtag1_position++];
139+
}
140+
else if (jtag0_available) {
141+
jtagReady = 0;
142+
jtag0_available--;
143+
return jtag0[jtag0_position++];
144+
}
145+
}
146+
147+
return -1;
148+
}
149+
150+
WEAK uint8_t ESP_isReadable() {
151+
return jtag0_available || jtag1_available;
152+
}
153+
154+
WEAK uint8_t ESP_setBaud(int baud) {
155+
return 1;
156+
}
157+
158+
void setupDebugger(void) {
159+
xTaskCreate(debug_task, "debug", (768 + XT_STACK_EXTRA) / sizeof(StackType_t), 0, 8, NULL);
160+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2016-2025 Moddable Tech, Inc.
3+
*
4+
* This file is part of the Moddable SDK Runtime.
5+
*
6+
* The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* The Moddable SDK Runtime is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
#define __XS6PLATFORMMINIMAL__
22+
23+
#include "xs.h"
24+
#include "xsHost.h"
25+
#include "xsHosts.h"
26+
27+
void setupDebugger(void) { }
28+
void modLog_transmit(const char *msg) { (void)msg; }
29+
void ESP_put(uint8_t *c, int count) { (void)c, (void)count; }
30+
void ESP_putc(int c) { (void)c; }
31+
int ESP_getc(void) { return -1; }
32+
uint8_t ESP_isReadable() { return 0; }
33+
uint8_t ESP_setBaud(int baud) { return -1; }
34+

0 commit comments

Comments
 (0)