Skip to content

Commit 40a5369

Browse files
committed
Merge remote-tracking branch 'upstream/main' into esp32-pin-reset
2 parents 1c9f33a + a7ec4a0 commit 40a5369

File tree

198 files changed

+7504
-1461
lines changed

Some content is hidden

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

198 files changed

+7504
-1461
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ jobs:
199199
- "clue_nrf52840_express"
200200
- "cp32-m4"
201201
- "cp_sapling_m0"
202+
- "cp_sapling_m0_spiflash"
202203
- "datalore_ip_m4"
203204
- "datum_distance"
204205
- "datum_imu"
@@ -318,7 +319,8 @@ jobs:
318319
- "teensy40"
319320
- "teensy41"
320321
- "teknikio_bluebird"
321-
- "thunderpack"
322+
- "thunderpack_v11"
323+
- "thunderpack_v12"
322324
- "tinkeringtech_scoutmakes_azul"
323325
- "trellis_m4_express"
324326
- "trinket_m0"

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,6 @@
153153
[submodule "ports/esp32s2/esp-idf"]
154154
path = ports/esp32s2/esp-idf
155155
url = https://github.com/jepler/esp-idf.git
156+
[submodule "ports/esp32s2/certificates/nina-fw"]
157+
path = ports/esp32s2/certificates/nina-fw
158+
url = https://github.com/adafruit/nina-fw.git

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ Behavior
114114
finishes or is interrupted. After it is done running, the vm and
115115
hardware is reinitialized. **This means you cannot read state from**
116116
``code.py`` **in the REPL anymore.** CircuitPython's goal for this
117-
change includes reduce confusion about pins and memory being used.
117+
change includes reducing confusion about pins and memory being used.
118118
- After ``code.py`` the REPL can be entered by pressing any key. It no
119119
longer shares state with ``code.py`` so it is a fresh vm.
120120
- Autoreload state will be maintained across reload.
121121
- Adds a safe mode that does not run user code after a hard crash or
122122
brown out. The hope is that this will make it easier to fix code that
123123
causes nasty crashes by making it available through mass storage
124-
after the crash. A reset (the button) is needed after its fixed to
124+
after the crash. A reset (the button) is needed after it's fixed to
125125
get back into normal mode.
126126
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
127127
- Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"ports/atmel-samd/tools",
173173
"ports/cxd56/mkspk",
174174
"ports/cxd56/spresense-exported-sdk",
175+
"ports/esp32s2/certificates",
175176
"ports/esp32s2/esp-idf",
176177
"ports/esp32s2/peripherals",
177178
"ports/litex/hw",

extmod/modujson.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ typedef struct _ujson_stream_t {
5757
int errcode;
5858
mp_obj_t python_readinto[2 + 1];
5959
mp_obj_array_t bytearray_obj;
60+
size_t start;
61+
size_t end;
6062
byte cur;
6163
} ujson_stream_t;
6264

@@ -77,28 +79,44 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
7779
return s->cur;
7880
}
7981

82+
// We read from an object's `readinto` method in chunks larger than the json
83+
// parser needs to reduce the number of function calls done.
84+
85+
#define CIRCUITPY_JSON_READ_CHUNK_SIZE 64
86+
8087
STATIC mp_uint_t ujson_python_readinto(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
88+
(void) size; // Ignore size because we know it's always 1.
8189
ujson_stream_t* s = obj;
82-
s->bytearray_obj.items = buf;
83-
s->bytearray_obj.len = size;
84-
*errcode = 0;
85-
mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto);
86-
if (ret == mp_const_none) {
87-
*errcode = MP_EAGAIN;
88-
return MP_STREAM_ERROR;
90+
91+
if (s->start == s->end) {
92+
*errcode = 0;
93+
mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto);
94+
if (ret == mp_const_none) {
95+
*errcode = MP_EAGAIN;
96+
return MP_STREAM_ERROR;
97+
}
98+
s->start = 0;
99+
s->end = mp_obj_get_int(ret);
89100
}
90-
return mp_obj_get_int(ret);
101+
102+
*((uint8_t *)buf) = ((uint8_t*) s->bytearray_obj.items)[s->start];
103+
s->start++;
104+
return 1;
91105
}
92106

93107
STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
94108
const mp_stream_p_t *stream_p = mp_proto_get(MP_QSTR_protocol_stream, stream_obj);
95109
ujson_stream_t s;
110+
uint8_t character_buffer[CIRCUITPY_JSON_READ_CHUNK_SIZE];
96111
if (stream_p == NULL) {
112+
s.start = 0;
113+
s.end = 0;
97114
mp_load_method(stream_obj, MP_QSTR_readinto, s.python_readinto);
98115
s.bytearray_obj.base.type = &mp_type_bytearray;
99116
s.bytearray_obj.typecode = BYTEARRAY_TYPECODE;
117+
s.bytearray_obj.len = CIRCUITPY_JSON_READ_CHUNK_SIZE;
100118
s.bytearray_obj.free = 0;
101-
// len and items are set at read time
119+
s.bytearray_obj.items = character_buffer;
102120
s.python_readinto[2] = MP_OBJ_FROM_PTR(&s.bytearray_obj);
103121
s.stream_obj = &s;
104122
s.read = ujson_python_readinto;

lib/tinyusb

Submodule tinyusb updated 226 files

lib/utils/pyexec.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
101101
#endif
102102
}
103103

104-
// If the code was loaded from a file its likely to be running for a while so we'll long
104+
// If the code was loaded from a file it's likely to be running for a while so we'll long
105105
// live it and collect any garbage before running.
106106
if (input_kind == MP_PARSE_FILE_INPUT) {
107107
module_fun = make_obj_long_lived(module_fun, 6);
@@ -132,6 +132,10 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
132132
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
133133
// at the moment, the value of SystemExit is unused
134134
ret = pyexec_system_exit;
135+
#if CIRCUITPY_ALARM
136+
} else if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_DeepSleepRequest)) {
137+
ret = PYEXEC_DEEP_SLEEP;
138+
#endif
135139
} else {
136140
if ((mp_obj_t) nlr.ret_val != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
137141
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);

lib/utils/pyexec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern int pyexec_system_exit;
4949
#define PYEXEC_FORCED_EXIT (0x100)
5050
#define PYEXEC_SWITCH_MODE (0x200)
5151
#define PYEXEC_EXCEPTION (0x400)
52+
#define PYEXEC_DEEP_SLEEP (0x800)
5253

5354
int pyexec_raw_repl(void);
5455
int pyexec_friendly_repl(void);

0 commit comments

Comments
 (0)