8000 Merge tag 'v1.9.1' · pcurry/circuitpython@30ee701 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30ee701

Browse files
committed
Merge tag 'v1.9.1'
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions This release provides an important fix for the USB mass storage device in the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which is now require by some Operating Systems. There are also fixes for the lwIP bindings to improve non-blocking sockets and error codes. The VFS has some regressions fixed including the ability to statvfs the root. All changes are listed below. py core: - modbuiltins: add core-provided version of input() function - objstr: catch case of negative "maxsplit" arg to str.rsplit() - persistentcode: allow to compile with complex numbers disabled - objstr: allow to compile with obj-repr D, and unicode disabled - modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled - provide mp_decode_uint_skip() to help reduce stack usage - makeqstrdefs.py: make script run correctly with Python 2.6 - objstringio: if created from immutable object, follow copy on write policy extmod: - modlwip: connect: for non-blocking mode, return EINPROGRESS - modlwip: fix error codes for duplicate calls to connect() - modlwip: accept: fix error code for non-blocking mode - vfs: allow to statvfs the root directory - vfs: allow "buffering" and "encoding" args to VFS's open() - modframebuf: fix signed/unsigned comparison pendantic warning lib: - libm: use isfinite instead of finitef, for C99 compatibility - utils/interrupt_char: remove support for KBD_EXCEPTION disabled tests: - basics/string_rsplit: add tests for negative "maxsplit" argument - float: convert "sys.exit()" to "raise SystemExit" - float/builtin_float_minmax: PEP8 fixes - basics: convert "sys.exit()" to "raise SystemExit" - convert remaining "sys.exit()" to "raise SystemExit" unix port: - convert to use core-provided version of built-in import() - Makefile: replace references to make with $(MAKE) windows port: - convert to use core-provided version of built-in import() qemu-arm port: - Makefile: adjust object-file lists to get correct dependencies - enable micropython.mem_*() functions to allow more tests stmhal port: - boards: enable DAC for NUCLEO_F767ZI board - add support for NUCLEO_F446RE board - pass USB handler as parameter to allow more than one USB handler - usb: use local USB handler variable in Start-of-Frame handler - usb: make state for USB device private to top-level USB driver - usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command - convert from using stmhal's input() to core provided version cc3200 port: - convert from using stmhal's input() to core provided version teensy port: - convert from using stmhal's input() to core provided version esp8266 port: - Makefile: replace references to make with $(MAKE) - Makefile: add clean-modules target - convert from using stmhal's input() to core provided version zephyr port: - modusocket: getaddrinfo: Fix mp_obj_len() usage - define MICROPY_PY_SYS_PLATFORM (to "zephyr") - machine_pin: use native Zephyr types for Zephyr API calls docs: - machine.Pin: remove out_value() method - machine.Pin: add on() and off() methods - esp8266: consistently replace Pin.high/low methods with .on/off - esp8266/quickref: polish Pin.on()/off() examples - network: move confusingly-named cc3200 Server class to its reference - uos: deconditionalize, remove minor port-specific details - uos: move cc3200 port legacy VFS mounting functions to its ref doc - machine: sort machine classes in logical order, not alphabetically - network: first step to describe standard network class interface examples: - embedding: use core-provided KeyboardInterrupt object
2 parents 97fcdfb + 869cdcf commit 30ee701

File tree

917 files changed

+25159
-47824
lines changed

Some content is hidden

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

917 files changed

+25159
-47824
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
*.png binary
1111
*.jpg binary
1212
*.dxf binary
13+
*.mpy binary
1314

1415
# These should also not be modified by git.
1516
tests/basics/string_cr_conversion.py -text
1617
tests/basics/string_crlf_conversion.py -text
17-
stmhal/startup_stm32f40xx.s -text
1818
stmhal/pybcdc.inf_template -text
1919
stmhal/usbd_* -text
2020
stmhal/boards/*/stm32f4xx_hal_conf.h -text
@@ -28,4 +28,3 @@ cc3200/hal/des.c -text
2828
cc3200/hal/i2s.c -text
2929
cc3200/hal/i2s.h -text
3030
cc3200/version.h -text
31-
lib/fatfs/** -text

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*.dis
1111
*.exe
1212

13-
# Packages
13+
# Packages
1414
############
1515

1616
# Logs and Databases
@@ -44,3 +44,7 @@ user.props
4444
# Sphinx output
4545
###############
4646
_build
47+
48+
# Generated rst files
49+
######################
50+
genrst/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ script:
6060
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
6161
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --via-mpy -d basics float)
6262

63-
after_success:
63+
# run coveralls coverage analysis (try to, even if some builds/tests failed)
6464
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)
6565

6666
after_failure:

atmel-samd/Makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ CFLAGS_CORTEX_M0 = \
125125
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
126126
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
127127
--param max-inline-insns-single=500
128-
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
128+
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(CFLAGS_MOD) $(COPT)
129129

130130
#Debugging/Optimization
131131
# TODO(tannewt): Figure out what NDEBUG does. Adding it to the debug build
@@ -184,7 +184,6 @@ SRC_C = \
184184
access_vfs.c \
185185
autoreload.c \
186186
background.c \
187-
builtin_open.c \
188187
fatfs_port.c \
189188
flash_api.c \
190189
main.c \
@@ -213,17 +212,15 @@ SRC_C = \
213212
boards/$(BOARD)/board.c \
214213
boards/$(BOARD)/pins.c \
215214
freetouch/adafruit_ptc.c \
216-
lib/fatfs/ff.c \
217-
lib/fatfs/option/ccsbcs.c \
215+
lib/oofatfs/ff.c \
216+
lib/oofatfs/option/ccsbcs.c \
218217
lib/timeutils/timeutils.c \
219218
lib/utils/buffer_helper.c \
220219
lib/utils/context_manager_helpers.c \
221220
lib/utils/interrupt_char.c \
222221
lib/utils/pyexec.c \
223-
lib/utils/pyhelp.c \
224222
lib/utils/stdout_helpers.c \
225223
lib/libc/string0.c \
226-
lib/mp-readline/builtin_input.c \
227224
lib/mp-readline/readline.c
228225

229226
STM_SRC_C = $(addprefix stmhal/,\
@@ -261,14 +258,14 @@ SRC_COMMON_HAL = \
261258
SRC_BINDINGS_ENUMS = \
262259
digitalio/Direction.c \
263260
digitalio/DriveMode.c \
264-
digitalio/Pull.c
261+
digitalio/Pull.c \
262+
help.c
265263

266264
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
267265
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
268266
$(addprefix common-hal/, $(SRC_COMMON_HAL))
269267

270268
SRC_SHARED_MODULE = \
271-
help.c \
272269
bitbangio/__init__.c \
273270
bitbangio/I2C.c \
274271
bitbangio/OneWire.c \

atmel-samd/access_vfs.c

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
#include "autoreload.h"
3131

3232
#include "asf/common/services/usb/class/msc/device/udi_msc.h"
33-
#include "extmod/fsusermount.h"
34-
#include "lib/fatfs/diskio.h"
33+
#include "extmod/vfs.h"
34+
#include "extmod/vfs_fat.h"
35+
#include "lib/oofatfs/ff.h"
36+
#include "lib/oofatfs/diskio.h"
37+
#include "lib/oofatfs/ffconf.h"
3538
#include "py/mpconfig.h"
3639
#include "py/mphal.h"
3740
#include "py/mpstate.h"
@@ -47,15 +50,14 @@
4750
//! An error occurred -> CTRL_FAIL
4851
Ctrl_status vfs_test_unit_ready(void)
4952
{
50-
if (VFS_INDEX >= MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
51-
return CTRL_FAIL;
52-
}
53-
DSTATUS status = disk_status(VFS_INDEX);
54-
if (status == STA_NOINIT) {
55-
return CTRL_NO_PRESENT;
53+
mp_vfs_mount_t* current_mount = MP_STATE_VM(vfs_mount_table);
54+
for (uint8_t i = 0; current_mount != NULL; i++) {
55+
if (i == VFS_INDEX) {
56+
return CTRL_GOOD;
57+
}
58+
current_mount = current_mount->next;
5659
}
57-
58-
return CTRL_GOOD;
60+
return CTRL_NO_PRESENT;
5961
}
6062

6163
//! This function returns the address of the last valid sector
@@ -81,13 +83,17 @@ Ctrl_status vfs_read_capacity(uint32_t *last_valid_sector)
8183
//!
8284
bool vfs_wr_protect(void)
8385
{
84-
if (VFS_INDEX >= MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
85-
return true;
86+
mp_vfs_mount_t* current_mount = MP_STATE_VM(vfs_mount_table);
87+
for (uint8_t i = 0; current_mount != NULL; i++) {
88+
if (i == VFS_INDEX) {
89+
break;
90+
}
91+
current_mount = current_mount->next;
8692
}
87-
fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[VFS_INDEX];
88-
if (vfs == NULL) {
93+
if (current_mount == NULL) {
8994
return true;
9095
}
96+
fs_user_mount_t *vfs = (fs_user_mount_t *) current_mount->obj;
9197

9298
// This is used to determine the writeability of the disk from USB.
9399
if (vfs->writeblocks[0] == MP_OBJ_NULL ||
@@ -170,9 +176,18 @@ Ctrl_status vfs_usb_write_10(uint32_t addr, volatile uint16_t nb_sector)
170176
}
171177
// Since by getting here we assume the mount is read-only to MicroPython
172178
// lets update the cached FatFs sector if its the one we just wrote.
173-
fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[VFS_INDEX];
174-
volatile uint16_t x = addr;
175-
(void) x;
179+
mp_vfs_mount_t* current_mount = MP_STATE_VM(vfs_mount_table);
180+
for (uint8_t i = 0; current_mount != NULL; i++) {
181+
if (i == VFS_INDEX) {
182+
break;
183+
}
184+
current_mount = current_mount->next;
185+
}
186+
if (current_mount == NULL) {
187+
return CTRL_NO_PRESENT;
188+
}
189+
fs_user_mount_t *vfs = (fs_user_mount_t *) current_mount->obj;
190+
176191
#if _MAX_SS != _MIN_SS
177192
if (vfs->ssize == FILESYSTEM_BLOCK_SIZE) {
178193
#else

atmel-samd/common-hal/audioio/AudioOut.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <stdint.h>
2828
#include <string.h>
2929

30+
#include "extmod/vfs_fat_file.h"
3031
#include "py/gc.h"
3132
#include "py/mperrno.h"
3233
#include "py/runtime.h"

atmel-samd/fatfs_port.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,8 @@
2626

2727
#include "py/mphal.h"
2828
#include "py/runtime.h"
29-
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
30-
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
31-
32-
const PARTITION VolToPart[MICROPY_FATFS_VOLUMES] = {
33-
{0, 1}, // Logical drive 0 ==> Physical drive 0, 1st partition
34-
{1, 0}, // Logical drive 1 ==> Physical drive 1 (auto detection)
35-
{2, 0}, // Logical drive 2 ==> Physical drive 2 (auto detection)
36-
{3, 0}, // Logical drive 3 ==> Physical drive 3 (auto detection)
37-
/*
38-
{0, 2}, // Logical drive 2 ==> Physical drive 0, 2nd partition
39-
{0, 3}, // Logical drive 3 ==> Physical drive 0, 3rd partition
40-
*/
41-
};
29+
#include "lib/oofatfs/ff.h" /* FatFs lower layer API */
30+
#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */
4231

4332
DWORD get_fattime(void) {
4433
// TODO(tannewt): Support the RTC.

atmel-samd/flash_api.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131
#define VFS_INDEX 0
3232

3333
void flash_set_usb_writeable(bool usb_writeable) {
34-
if (VFS_INDEX >= MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
35-
return;
34+
mp_vfs_mount_t* current_mount = MP_STATE_VM(vfs_mount_table);
35+
for (uint8_t i = 0; current_mount != NULL; i++) {
36+
if (i == VFS_INDEX) {
37+
break;
38+
}
39+
current_mount = current_mount->next;
3640
}
37-
fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[VFS_INDEX];
38-
if (vfs == NULL) {
41+
if (current_mount == NULL) {
3942
return;
4043
}
44+
fs_user_mount_t *vfs = (fs_user_mount_t *) current_mount->obj;
4145

4246
if (usb_writeable) {
4347
vfs->flags |= FSUSER_USB_WRITEABLE;

atmel-samd/flash_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_FLASH_API_H__
2727
#define __MICROPY_INCLUDED_ATMEL_SAMD_FLASH_API_H__
2828

29-
#include "extmod/fsusermount.h"
29+
#include "extmod/vfs_fat.h"
3030

3131
extern void flash_init_vfs(fs_user_mount_t *vfs);
3232
extern void flash_flush(void);

atmel-samd/internal_flash.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
#include <stdint.h>
2929
#include <string.h>
3030

31+
#include "extmod/vfs.h"
32+
#include "extmod/vfs_fat.h"
3133
#include "py/mphal.h"
3234
#include "py/obj.h"
3335
#include "py/runtime.h"
34-
#include "lib/fatfs/ff.h"
35-
#include "extmod/fsusermount.h"
36+
#include "lib/oofatfs/ff.h"
3637

3738
#include "asf/sam0/drivers/nvm/nvm.h"
3839
#include "asf/sam0/drivers/port/port.h"

atmel-samd/main.c

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include "py/gc.h"
1010
#include "py/stackctrl.h"
1111

12-
#include "lib/fatfs/ff.h"
13-
#include "lib/fatfs/diskio.h"
12+
#include "extmod/vfs_fat.h"
13+
#include "lib/oofatfs/ff.h"
14+
#include "lib/oofatfs/diskio.h"
1415
#include "lib/mp-readline/readline.h"
1516
#include "lib/utils/pyexec.h"
16-
#include "extmod/fsusermount.h"
1717

1818
#include "asf/common/services/sleepmgr/sleepmgr.h"
1919
#include "asf/common/services/usb/udc/udc.h"
@@ -48,6 +48,7 @@
4848
#include "tick.h"
4949

5050
fs_user_mount_t fs_user_mount_flash;
51+
mp_vfs_mount_t mp_vfs_mount_flash;
5152

5253
typedef enum {
5354
NO_SAFE_MODE = 0,
@@ -80,39 +81,42 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
8081
// want it to be executed without using stack within main() function
8182
void init_flash_fs(void) {
8283
// init the vfs object
83-
fs_user_mount_t *vfs = &fs_user_mount_flash;
84-
vfs->str = "/flash";
85-
vfs->len = 6;
86-
vfs->flags = 0;
87-
flash_init_vfs(vfs);
88-
89-
// put the flash device in slot 0 (it will be unused at this point)
90-
MP_STATE_PORT(fs_user_mount)[0] = vfs;
84+
fs_user_mount_t *vfs_fat = &fs_user_mount_flash;
85+
vfs_fat->flags = 0;
86+
flash_init_vfs(vfs_fat);
9187

9288
// try to mount the flash
93-
FRESULT res = f_mount(&vfs->fatfs, vfs->str, 1);
89+
FRESULT res = f_mount(&vfs_fat->fatfs);
9490

9591
if (res == FR_NO_FILESYSTEM) {
9692
// no filesystem so create a fresh one
9793

98-
res = f_mkfs("/flash", 0, 0);
94+
uint8_t working_buf[_MAX_SS];
95+
res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
9996
// Flush the new file system to make sure its repaired immediately.
10097
flash_flush();
10198
if (res != FR_OK) {
102-
MP_STATE_PORT(fs_user_mount)[0] = NULL;
10399
return;
104100
}
105101

106102
// set label
107-
f_setlabel("CIRCUITPY");
103+
f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
108104
} else if (res != FR_OK) {
109-
MP_STATE_PORT(fs_user_mount)[0] = NULL;
110105
return;
111106
}
107+
mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t);
108+
if (vfs == NULL) {
109+
return;
110+
}
111+
vfs->str = "/";
112+
vfs->len = 1;
113+
vfs->obj = MP_OBJ_FROM_PTR(vfs_fat);
114+
vfs->next = NULL;
115+
MP_STATE_VM(vfs_mount_table) = vfs;
112116

113117
// The current directory is used as the boot up directory.
114118
// It is set to the internal flash filesystem by default.
115-
f_chdrive("/flash");
119+
MP_STATE_PORT(vfs_cur) = vfs;
116120
}
117121

118122
static char heap[16384];
@@ -124,9 +128,7 @@ void reset_mp(void) {
124128

125129
// Sync the file systems in case any used RAM from the GC to cache. As soon
126130
// as we re-init the GC all bets are off on the cache.
127-
disk_ioctl(0, CTRL_SYNC, NULL);
128-
disk_ioctl(1, CTRL_SYNC, NULL);
129-
disk_ioctl(2, CTRL_SYNC, NULL);
131+
flash_flush();
130132

131133
// Clear the readline history. It references the heap we're about to destroy.
132134
readline_init0();
@@ -230,13 +232,8 @@ void reset_samd21(void) {
230232
}
231233

232234
bool maybe_run(const char* filename, pyexec_result_t* exec_result) {
233-
FILINFO fno;
234-
#if _USE_LFN
235-
fno.lfname = NULL;
236-
fno.lfsize = 0;
237-
#endif
238-
FRESULT res = f_stat(filename, &fno);
239-
if (res != FR_OK || fno.fattrib & AM_DIR) {
235+
mp_import_stat_t stat = mp_import_stat(filename);
236+
if (stat != MP_IMPORT_STAT_FILE) {
240237
return false;
241238
}
242239
mp_hal_stdout_tx_str(filename);
@@ -607,7 +604,8 @@ int main(void) {
607604
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
608605
FIL file_pointer;
609606
boot_output_file = &file_pointer;
610-
f_open(boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS);
607+
f_open(&((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs,
608+
boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS);
611609
#endif
612610

613611
// TODO(tannewt): Re-add support for flashing boot error output.
@@ -688,17 +686,8 @@ void gc_collect(void) {
688686
gc_collect_end();
689687
}
690688

691-
mp_import_stat_t fat_vfs_import_stat(const char *path);
692-
mp_import_stat_t mp_import_stat(const char *path) {
693-
#if MICROPY_VFS_FAT
694-
return fat_vfs_import_stat(path);
695-
#else
696-
(void)path;
697-
return MP_IMPORT_STAT_NO_EXIST;
698-
#endif
699-
}
700-
701-
void nlr_jump_fail(void *val) {
689+
void NORETURN nlr_jump_fail(void *val) {
690+
while (1);
702691
}
703692

704693
void NORETURN __fatal_error(const char *msg) {

0 commit comments

Comments
 (0)
0