Skip to content

Commit 07e710b

Browse files
committed
Merge remote-tracking branch 'origin/main' into floppy
2 parents 6a7742b + a39f0cf commit 07e710b

File tree

312 files changed

+7224
-1592
lines changed

Some content is hidden

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

312 files changed

+7224
-1592
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
check_suite:
1313
types: [rerequested]
1414

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
1519
jobs:
1620
test:
1721
runs-on: ubuntu-20.04

.github/workflows/ports_windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'ports/unix/**'
1313
- 'ports/windows/**'
1414

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
1519
jobs:
1620
build:
1721
runs-on: windows-2019

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
pull_request:
99
push:
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
pre-commit:
1317
runs-on: ubuntu-20.04

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
[submodule "ports/espressif/esp-idf"]
150150
path = ports/espressif/esp-idf
151151
url = https://github.com/adafruit/esp-idf.git
152-
branch = release/v4.4
152+
branch = circuitpython-v4.4
153153
[submodule "ports/espressif/certificates/nina-fw"]
154154
path = ports/espressif/certificates/nina-fw
155155
url = https://github.com/adafruit/nina-fw.git

devices/ble_hci/common-hal/_bleio/__init__.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "hci.h"
3636

3737
void bleio_hci_background(void);
38-
void bleio_reset(void);
3938

4039
typedef struct {
4140
// ble_gap_enc_key_t own_enc;

extmod/modubinascii.c

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) 2014 Paul Sokolovsky
22
// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
3+
// SPDX-FileCopyrightText: 2022 Beat Ludin for Adafruit Industries
34
//
45
// SPDX-License-Identifier: MIT
56

@@ -204,29 +205,86 @@ STATIC mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) {
204205
}
205206
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64);
206207

207-
#if MICROPY_PY_UBINASCII_CRC32
208-
#include "lib/uzlib/tinf.h"
208+
/*
209+
* CRC32 checksum
210+
*
211+
* Copyright (c) 1998-2003 by Joergen Ibsen / Jibz
212+
* All Rights Reserved
213+
*
214+
* http://www.ibsensoftware.com/
215+
*
216+
* This software is provided 'as-is', without any express
217+
* or implied warranty. In no event will the authors be
218+
* held liable for any damages arising from the use of
219+
* this software.
220+
*
221+
* Permission is granted to anyone to use this software
222+
* for any purpose, including commercial applications,
223+
* and to alter it and redistribute it freely, subject to
224+
* the following restrictions:
225+
*
226+
* 1. The origin of this software must not be
227+
* misrepresented; you must not claim that you
228+
* wrote the original software. If you use this
229+
* software in a product, an acknowledgment in
230+
* the product documentation would be appreciated
231+
* but is not required.
232+
*
233+
* 2. Altered source versions must be plainly marked
234+
* as such, and must not be misrepresented as
235+
* being the original software.
236+
*
237+
* 3. This notice may not be removed or altered from
238+
* any source distribution.
239+
*/
240+
241+
/*
242+
* CRC32 algorithm taken from the zlib source, which is
243+
* Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
244+
*/
245+
246+
247+
static const unsigned int tinf_crc32tab[16] = {
248+
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190,
249+
0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344,
250+
0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278,
251+
0xbdbdf21c
252+
};
253+
254+
/* crc is previous value for incremental computation, 0xffffffff initially */
255+
static uint32_t from_uzlib_crc32(const void *data, unsigned int length, uint32_t crc) {
256+
const unsigned char *buf = (const unsigned char *)data;
257+
unsigned int i;
258+
259+
for (i = 0; i < length; ++i)
260+
{
261+
crc ^= buf[i];
262+
crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4);
263+
crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4);
264+
}
265+
266+
// return value suitable for passing in next time, for final value invert it
267+
return crc /* ^ 0xffffffff*/;
268+
}
209269

210270
STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
211271
mp_buffer_info_t bufinfo;
212272
check_not_unicode(args[0]);
213273
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
214274
uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0;
215-
crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff);
275+
crc = from_uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff);
216276
return mp_obj_new_int_from_uint(crc ^ 0xffffffff);
217277
}
218278
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32);
219-
#endif
279+
220280

221281
STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = {
222282
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_binascii) },
223283
{ MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&mod_binascii_hexlify_obj) },
224284
{ MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) },
225285
{ MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) },
226286
{ MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) },
227-
#if MICROPY_PY_UBINASCII_CRC32
228287
{ MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) },
229-
#endif
230288
};
231289

232290
STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table);

extmod/vfs_fat_file.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,39 +139,58 @@ STATIC const mp_arg_t file_open_args[] = {
139139
STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) {
140140
int mode = 0;
141141
const char *mode_s = mp_obj_str_get_str(args[1].u_obj);
142-
// TODO make sure only one of r, w, x, a, and b, t are specified
142+
uint32_t rwxa_count = 0;
143+
uint32_t bt_count = 0;
144+
uint32_t plus_count = 0;
145+
bool bad_mode = false;
143146
while (*mode_s) {
144147
switch (*mode_s++) {
145148
case 'r':
146149
mode |= FA_READ;
150+
rwxa_count++;
147151
break;
148152
case 'w':
149153
mode |= FA_WRITE | FA_CREATE_ALWAYS;
154+
rwxa_count++;
150155
break;
151156
case 'x':
152157
mode |= FA_WRITE | FA_CREATE_NEW;
158+
rwxa_count++;
153159
break;
154160
case 'a':
155161
mode |= FA_WRITE | FA_OPEN_ALWAYS;
162+
rwxa_count++;
156163
break;
157164
case '+':
158165
mode |= FA_READ | FA_WRITE;
166+
plus_count++;
159167
break;
160168
#if MICROPY_PY_IO_FILEIO
161169
case 'b':
170+
bt_count++;
162171
type = &mp_type_vfs_fat_fileio;
163172
break;
164173
#endif
165174
case 't':
175+
bt_count++;
166176
type = &mp_type_vfs_fat_textio;
167177
break;
178+
default:
179+
bad_mode = true;
180+
break;
168181
}
169182
}
183+
184+
if (rwxa_count != 1 || plus_count > 1 || bt_count > 1 || bad_mode) {
185+
mp_raise_ValueError(translate("Invalid mode"));
186+
}
187+
170188
assert(vfs != NULL);
171189
if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) {
172190
mp_raise_OSError(MP_EROFS);
173191
}
174192

193+
175194
pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t);
176195
o->base.type = type;
177196

0 commit comments

Comments
 (0)