diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-06-20 10:56:05 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-06-20 10:56:05 -0700 |
| commit | 30ee7019ca651bce1fe966c1089fe977d51dc92b (patch) | |
| tree | 0114b6f744dd175b7722dd8edcbe24f4ee84bb45 /atmel-samd/main.c | |
| parent | 97fcdfbd08c922efd7470d6482d7c7c703ffc0ae (diff) | |
| parent | 869cdcfdfc860b1177baf9b0f8818915ba54f3f5 (diff) | |
Merge tag 'v1.9.1'2.0.0-alpha.0
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
Diffstat (limited to 'atmel-samd/main.c')
| -rw-r--r-- | atmel-samd/main.c | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 563237a3c..1f3c3405c 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -9,11 +9,11 @@ #include "py/gc.h" #include "py/stackctrl.h" -#include "lib/fatfs/ff.h" -#include "lib/fatfs/diskio.h" +#include "extmod/vfs_fat.h" +#include "lib/oofatfs/ff.h" +#include "lib/oofatfs/diskio.h" #include "lib/mp-readline/readline.h" #include "lib/utils/pyexec.h" -#include "extmod/fsusermount.h" #include "asf/common/services/sleepmgr/sleepmgr.h" #include "asf/common/services/usb/udc/udc.h" @@ -48,6 +48,7 @@ #include "tick.h" fs_user_mount_t fs_user_mount_flash; +mp_vfs_mount_t mp_vfs_mount_flash; typedef enum { NO_SAFE_MODE = 0, @@ -80,39 +81,42 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) { // want it to be executed without using stack within main() function void init_flash_fs(void) { // init the vfs object - fs_user_mount_t *vfs = &fs_user_mount_flash; - vfs->str = "/flash"; - vfs->len = 6; - vfs->flags = 0; - flash_init_vfs(vfs); - - // put the flash device in slot 0 (it will be unused at this point) - MP_STATE_PORT(fs_user_mount)[0] = vfs; + fs_user_mount_t *vfs_fat = &fs_user_mount_flash; + vfs_fat->flags = 0; + flash_init_vfs(vfs_fat); // try to mount the flash - FRESULT res = f_mount(&vfs->fatfs, vfs->str, 1); + FRESULT res = f_mount(&vfs_fat->fatfs); if (res == FR_NO_FILESYSTEM) { // no filesystem so create a fresh one - res = f_mkfs("/flash", 0, 0); + uint8_t working_buf[_MAX_SS]; + res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf)); // Flush the new file system to make sure its repaired immediately. flash_flush(); if (res != FR_OK) { - MP_STATE_PORT(fs_user_mount)[0] = NULL; return; } // set label - f_setlabel("CIRCUITPY"); + f_setlabel(&vfs_fat->fatfs, "CIRCUITPY"); } else if (res != FR_OK) { - MP_STATE_PORT(fs_user_mount)[0] = NULL; return; } + mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t); + if (vfs == NULL) { + return; + } + vfs->str = "/"; + vfs->len = 1; + vfs->obj = MP_OBJ_FROM_PTR(vfs_fat); + vfs->next = NULL; + MP_STATE_VM(vfs_mount_table) = vfs; // The current directory is used as the boot up directory. // It is set to the internal flash filesystem by default. - f_chdrive("/flash"); + MP_STATE_PORT(vfs_cur) = vfs; } static char heap[16384]; @@ -124,9 +128,7 @@ void reset_mp(void) { // Sync the file systems in case any used RAM from the GC to cache. As soon // as we re-init the GC all bets are off on the cache. - disk_ioctl(0, CTRL_SYNC, NULL); - disk_ioctl(1, CTRL_SYNC, NULL); - disk_ioctl(2, CTRL_SYNC, NULL); + flash_flush(); // Clear the readline history. It references the heap we're about to destroy. readline_init0(); @@ -230,13 +232,8 @@ void reset_samd21(void) { } bool maybe_run(const char* filename, pyexec_result_t* exec_result) { - FILINFO fno; -#if _USE_LFN - fno.lfname = NULL; - fno.lfsize = 0; -#endif - FRESULT res = f_stat(filename, &fno); - if (res != FR_OK || fno.fattrib & AM_DIR) { + mp_import_stat_t stat = mp_import_stat(filename); + if (stat != MP_IMPORT_STAT_FILE) { return false; } mp_hal_stdout_tx_str(filename); @@ -607,7 +604,8 @@ int main(void) { #ifdef CIRCUITPY_BOOT_OUTPUT_FILE FIL file_pointer; boot_output_file = &file_pointer; - f_open(boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); + f_open(&((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs, + boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); #endif // TODO(tannewt): Re-add support for flashing boot error output. @@ -688,17 +686,8 @@ void gc_collect(void) { gc_collect_end(); } -mp_import_stat_t fat_vfs_import_stat(const char *path); -mp_import_stat_t mp_import_stat(const char *path) { - #if MICROPY_VFS_FAT - return fat_vfs_import_stat(path); - #else - (void)path; - return MP_IMPORT_STAT_NO_EXIST; - #endif -} - -void nlr_jump_fail(void *val) { +void NORETURN nlr_jump_fail(void *val) { + while (1); } void NORETURN __fatal_error(const char *msg) { |
