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 /cc3200/mptask.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 'cc3200/mptask.c')
| -rw-r--r-- | cc3200/mptask.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/cc3200/mptask.c b/cc3200/mptask.c index 9c34e962c..1a74301ec 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -33,6 +33,11 @@ #include "py/runtime.h" #include "py/gc.h" #include "py/mphal.h" +#include "lib/mp-readline/readline.h" +#include "lib/oofatfs/ff.h" +#include "lib/oofatfs/diskio.h" +#include "extmod/vfs.h" +#include "extmod/vfs_fat.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" @@ -47,7 +52,6 @@ #include "lib/utils/pyexec.h" #include "gccollect.h" #include "gchelper.h" -#include "readline.h" #include "mperror.h" #include "simplelink.h" #include "modnetwork.h" @@ -56,13 +60,12 @@ #include "serverstask.h" #include "telnet.h" #include "debug.h" -#include "ff.h" -#include "diskio.h" #include "sflash_diskio.h" #include "mpexception.h" #include "random.h" #include "pybi2c.h" #include "pins.h" +#include "mods/pybflash.h" #include "pybsleep.h" #include "pybtimer.h" #include "cryptohash.h" @@ -94,7 +97,7 @@ OsiTaskHandle svTaskHandle; /****************************************************************************** DECLARE PRIVATE DATA ******************************************************************************/ -static FATFS *sflash_fatfs; +static fs_user_mount_t *sflash_vfs_fat; static const char fresh_main_py[] = "# main.py -- put your code here!\r\n"; static const char fresh_boot_py[] = "# boot.py -- run on boot-up\r\n" @@ -149,7 +152,6 @@ soft_reset: timer_init0(); readline_init0(); mod_network_init0(); - moduos_init0(); rng_init0(); pybsleep_reset_cause_t rstcause = pyb_sleep_get_reset_cause(); @@ -270,7 +272,7 @@ STATIC void mptask_pre_init (void) { ASSERT (OSI_OK == VStartSimpleLinkSpawnTask(SIMPLELINK_SPAWN_TASK_PRIORITY)); // Allocate memory for the flash file system - ASSERT ((sflash_fatfs = mem_Malloc(sizeof(FATFS))) != NULL); + ASSERT ((sflash_vfs_fat = mem_Malloc(sizeof(*sflash_vfs_fat))) != NULL); // this one allocates memory for the nvic vault pyb_sleep_pre_init(); @@ -296,17 +298,19 @@ STATIC void mptask_pre_init (void) { STATIC void mptask_init_sflash_filesystem (void) { FILINFO fno; -#if _USE_LFN - fno.lfname = NULL; - fno.lfsize = 0; -#endif // Initialise the local flash filesystem. + // init the vfs object + fs_user_mount_t *vfs_fat = sflash_vfs_fat; + vfs_fat->flags = 0; + pyb_flash_init_vfs(vfs_fat); + // Create it if needed, and mount in on /flash. - FRESULT res = f_mount(sflash_fatfs, "/flash", 1); + FRESULT res = f_mount(&vfs_fat->fatfs); if (res == FR_NO_FILESYSTEM) { // no filesystem, so create a fresh one - res = f_mkfs("/flash", 1, 0); + uint8_t working_buf[_MAX_SS]; + res = f_mkfs(&vfs_fat->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); if (res == FR_OK) { // success creating fresh LFS } else { @@ -316,33 +320,46 @@ STATIC void mptask_init_sflash_filesystem (void) { mptask_create_main_py(); } else if (res == FR_OK) { // mount sucessful - if (FR_OK != f_stat("/flash/main.py", &fno)) { + if (FR_OK != f_stat(&vfs_fat->fatfs, "/main.py", &fno)) { // create empty main.py mptask_create_main_py(); } } else { + fail: __fatal_error("failed to create /flash"); } + // mount the flash device (there should be no other devices mounted at this point) + // we allocate this structure on the heap because vfs->next is a root pointer + mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t); + if (vfs == NULL) { + goto fail; + } + vfs->str = "/flash"; + vfs->len = 6; + 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; // create /flash/sys, /flash/lib and /flash/cert if they don't exist - if (FR_OK != f_chdir ("/flash/sys")) { - f_mkdir("/flash/sys"); + if (FR_OK != f_chdir(&vfs_fat->fatfs, "/sys")) { + f_mkdir(&vfs_fat->fatfs, "/sys"); } - if (FR_OK != f_chdir ("/flash/lib")) { - f_mkdir("/flash/lib"); + if (FR_OK != f_chdir(&vfs_fat->fatfs, "/lib")) { + f_mkdir(&vfs_fat->fatfs, "/lib"); } - if (FR_OK != f_chdir ("/flash/cert")) { - f_mkdir("/flash/cert"); + if (FR_OK != f_chdir(&vfs_fat->fatfs, "/cert")) { + f_mkdir(&vfs_fat->fatfs, "/cert"); } - f_chdir ("/flash"); + f_chdir(&vfs_fat->fatfs, "/"); // make sure we have a /flash/boot.py. Create it if needed. - res = f_stat("/flash/boot.py", &fno); + res = f_stat(&vfs_fat->fatfs, "/boot.py", &fno); if (res == FR_OK) { if (fno.fattrib & AM_DIR) { // exists as a directory @@ -354,7 +371,7 @@ STATIC void mptask_init_sflash_filesystem (void) { } else { // doesn't exist, create fresh file FIL fp; - f_open(&fp, "/flash/boot.py", FA_WRITE | FA_CREATE_ALWAYS); + f_open(&vfs_fat->fatfs, &fp, "/boot.py", FA_WRITE | FA_CREATE_ALWAYS); UINT n; f_write(&fp, fresh_boot_py, sizeof(fresh_boot_py) - 1 /* don't count null terminator */, &n); // TODO check we could write n bytes @@ -374,7 +391,7 @@ STATIC void mptask_enter_ap_mode (void) { STATIC void mptask_create_main_py (void) { // create empty main.py FIL fp; - f_open(&fp, "/flash/main.py", FA_WRITE | FA_CREATE_ALWAYS); + f_open(&sflash_vfs_fat->fatfs, &fp, "/main.py", FA_WRITE | FA_CREATE_ALWAYS); UINT n; f_write(&fp, fresh_main_py, sizeof(fresh_main_py) - 1 /* don't count null terminator */, &n); f_close(&fp); |
