Commit Graph

459 Commits

Author SHA1 Message Date
Damien George 87f068d7d9 cc3200: Update to use size_t for tuple/list accessors. 2017-03-29 12:56:17 +11:00
Krzysztof Blazewicz 75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Damien George 1110c8873c cc3200/mods/modutime: Use generic sleep_ms and sleep_us implementations. 2017-03-22 12:57:51 +11:00
Damien George 12d0731b91 extmod/vfs_fat: Remove obsolete and unused str/len members. 2017-03-10 19:09:42 +11:00
Damien George 70201f4038 cc3200/mptask: Allocate flash VFS struct on the heap to trace root ptrs. 2017-03-10 19:09:19 +11:00
Paul Sokolovsky f5ee4d95a9 cc3200/moduos: Remove uos.sep, as it's strictly optional.
In MicroPython, the path separator is guaranteed to be "/", extra unneeded
things take precious code space (in the port which doesn't have basic things
like floating-port support).
2017-02-23 22:10:58 -08:00
Damien George 047af9b10b cc3200: Remove socket.timeout class, use OSError(ETIMEDOUT) instead.
socket.timeout is a subclass of OSError, and using the latter is more
efficient than having a dedicated class.  The argument of OSError is
ETIMEDOUT so the error can be distinguished from other kinds of
OSErrors.  This follows how the esp8266 port does it.
2017-02-22 15:08:32 +11:00
Damien George d03f089baa cc3200/mods/modusocket: Init vars to 0 to silence compiler warnings.
Some compilers can't analyse the code to determine that these variables
are always set before being used.
2017-02-22 14:58:37 +11:00
Damien George e859ddf3e1 cc3200: Enable uerrno module with short, custom list of error codes.
Since we recently replaced the OSError string messages with simple error
codes, having the uerrno module gets back some user friendly error
messages.  The total code size (after removing strings, replacing with
uerrno module) is decreased.
2017-02-22 12:58:11 +11:00
Damien George 22a6344ebe cc3200: When raising OSError's use MP_Exxx as arg instead of a string. 2017-02-22 12:58:11 +11:00
Damien George 8bb8e97dfe cc3200: Convert to using uPy internal errno numbers. 2017-02-22 12:58:11 +11:00
Damien George 85ab469c64 cc3200: Move wlan socket glue functions from modwlan to modusocket.
It saves about 400 bytes of code space because the functions can now be
inlined.
2017-02-22 11:29:19 +11:00
Damien George 71ae3f389d cc3200: Remove remaining references to std.h. 2017-02-21 18:01:43 +11:00
Damien George 8c5988bf61 cc3200/mods/modwlan: Add int casts to silence compiler warnings. 2017-02-21 17:29:40 +11:00
Damien George 0258f819bd cc3200/mods/modwlan: Allow antenna diversity to be fully compiled out. 2017-02-21 17:29:02 +11:00
Damien George a162832b1a cc3200/mods/modwlan: Make multi-threaded a proper compile-time option. 2017-02-21 17:28:14 +11:00
Damien George 26ddd4b621 cc3200/mods/modwlan: Remove unused header includes; simplify others. 2017-02-21 17:27:17 +11:00
Damien George 1c35270667 cc3200: Remove util/std.h, can just use stdio.h instead. 2017-02-21 17:26:21 +11:00
Damien George d9f7120af1 cc3200: Use simplelink API instead of emulated BSD API.
Most of cc3200 uses explicit simplelink calls anyway, and this means there
are no longer any clashes with macros from the C stdlib.
2017-02-21 17:24:12 +11:00
Damien George 29551ba566 cc3200: Move stoupper to ftp.c and define in terms of unichar_toupper.
ftp.c is the only user of this function so making it static in that file
allows it to be inlined.  Also, reusing unichar_toupper means we no longer
depend on the C stdlib for toupper, saving about 300 bytes of code space.
2017-02-21 17:20:58 +11:00
Damien George ae8d867586 py: Add iter_buf to getiter type method.
Allows to iterate over the following without allocating on the heap:
- tuple
- list
- string, bytes
- bytearray, array
- dict (not dict.keys, dict.values, dict.items)
- set, frozenset

Allows to call the following without heap memory:
- all, any, min, max, sum

TODO: still need to allocate stack memory in bytecode for iter_buf.
2017-02-16 18:38:06 +11:00
Damien George b7d27e31e8 cc3200: Refactor "ticks" functions to use common extmod implementation.
The port now uses the common mp_utime_ticks_{ms,us,cpu,add,diff} functions
from extmod/utime_mphal.c.

The mp_utime_sleep_XXX functions are still cc3200-specific because they
handle the GIL differently to the ones in extmod.

The files misc/mpsystick.[ch] have been removed because they contain 2
unused functions, and the other remaining function is renamed to
mp_hal_ticks_us and moved to hal/cc3200_hal.c.
2017-02-06 11:14:16 +11:00
Damien George b697c89009 extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat
specific things.
2017-01-30 12:26:08 +11:00
Damien George 0bd61d23b9 extmod/vfs_fat: Remove MICROPY_FATFS_OO config option.
Everyone should now be using the new ooFatFs library.  The old one is no
longer supported and will be removed.
2017-01-30 12:26:07 +11:00
Damien George 56506fd64a cc3200: Convert to use new VFS sub-system and new ooFatFs library. 2017-01-30 12:26:07 +11:00
Paul Sokolovsky 3a3543251f cc3200/modusocket: Remove deprecated socket.error.
socket.error is deprecated even in upstream:
https://docs.python.org/3/library/socket.html#socket.error,
and never was a part of MicroPython socket API.
2017-01-29 02:47:26 +03:00
Damien George bfa948c0a5 cc3200: Add implementations of mp_import_stat and builtin_open.
They disappeared when stmhal changed to use new MICROPY_VFS code.
2017-01-27 23:22:15 +11:00
Damien George 32a1138b9f extmod: Rename vfs_fat_file.h to vfs_fat.h.
And move declaration of mp_fat_vfs_type to this file.
2017-01-27 15:04:17 +11:00
Damien George 4d7fba83a6 cc3200: Convert to use builtin help function. 2017-01-22 11:56:16 +11:00
Paul Sokolovsky 044f96c330 cc3200/modwlan: Add network.WLAN.print_ver() diagnostic function.
Prints NWP/MAC/PHY version, as affected by servicepack installed.
2017-01-07 19:48:12 +03:00
Paul Sokolovsky eac22e29a5 all: Consistently update signatures of .make_new and .call methods.
Otherwise, they serve reoccurring source of copy-paste mistakes and
breaking nanbox build.
2017-01-04 16:10:42 +03:00
Paul Sokolovsky b315d76b6b cc3200/README: Reorganize and update to the current state of affairs.
Try to put sections in more logical order, and information about cc3200tool
to be the default flashing method.
2016-12-29 19:46:25 +03:00
Paul Sokolovsky 0748143a4c cc3200: Add targets to erase flash, deploy firmware using cc3200tool.
cc3200tool, https://github.com/ALLTERCO/cc3200tool is a (mostly, some
binary blobs present) open-source, Linux-friendly tool to flash a cc3200
devices. It's an alternative to fully proprietary, Windows-only Uniflash
from TI.

The provided make targets are for erasing flash, flashing the uPy
bootloader and firmware, and flashing vendor's WiFi firmware "servicepacks"
(the latter needs to be downloaded from vendor side, a link is present
inside Makefile).
2016-12-29 17:12:47 +03:00
Paul Sokolovsky 45a8cc8f0b cc3200: make: Rename "deploy" target to "deploy-ota".
There should be target to deploy uPy over wired (UART) connection, and
wired and OTA targets should be named differently.
2016-12-29 01:27:50 +03:00
Paul Sokolovsky 514b82900c cc3200/README: (Re)add information about accessing REPL on serial. 2016-12-28 21:44:47 +03:00
Paul Sokolovsky 076b80467b cc3200: Enable UART REPL by default.
To allow access and testing without complex access methods like WiFi.
Enabled for both WiPy and TI LaunchXL.
2016-12-28 14:57:36 +03:00
Paul Sokolovsky 25f44c19f1 cc3200: Re-add support for UART REPL (MICROPY_STDIO_UART setting).
UART REPL support was lost in os.dupterm() refactorings, etc. As
os.dupterm() is there, implement UART REPL support at the high level -
if MICROPY_STDIO_UART is set, make default boot.py contain os.dupterm()
call for a UART. This means that changing MICROPY_STDIO_UART value will
also require erasing flash on a module to force boot.py re-creation.
2016-12-27 01:05:37 +03:00
Damien George 2d329c4a56 extmod/moduselect: Use configurable EVENT_POLL_HOOK instead of WFI.
To make moduselect be usable by any port.
2016-12-02 16:40:39 +11:00
Damien George 304cfda8c4 py/stream: Move ad-hoc ioctl constants to stream.h and rename them.
The constants MP_IOCTL_POLL_xxx, which were stmhal-specific, are moved
from stmhal/pybioctl.h (now deleted) to py/stream.h.  And they are renamed
to MP_STREAM_POLL_xxx to be consistent with other such constants.

All uses of these constants have been updated.
2016-12-02 16:37:29 +11:00
Paul Sokolovsky f14e9187ac cc3200: Update for moduselect moved to extmod/. 2016-11-21 01:08:15 +03:00
Damien George e5ef15a9d7 py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
2016-11-16 18:13:51 +11:00
Damien George 6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Damien George 3f8bb80eb2 cc3200/mods/pybspi: Remove SPI.MASTER constant, it's no longer needed. 2016-11-15 16:35:54 +11:00
Paul Sokolovsky 7602dc5f32 cc3200/pybspi: Remove static mode=SPI.MASTER parameter for latest HW API.
Per the latest HW API, "SPI" class implements only master side of the
protocol, so mode=SPI.MASTER (which was static for WiPy anyway) is not
required (or allowed). This change is required to correspond to updated
documentation of machine.SPI class which no longer lists "mode".
2016-11-15 16:31:57 +11:00
Damien George aed3b5b7ba cc3200/tools/smoke.py: Change readall() to read(). 2016-11-14 23:31:08 +11:00
Paul Sokolovsky 59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
2016-11-14 00:24:22 +03:00
Damien George 4ebdb1f2b2 py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.
In order to have more fine-grained control over how builtin functions are
constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific,
with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW.  These names now
match the MP_DEFINE_CONST_FUN_OBJ macros.
2016-10-21 16:26:01 +11:00
Damien George 17ba6ef5fa cc3200: Fix thread mutex's so threading works with interrupts.
Running Python code on a hard interrupt is incompatible with having a GIL,
because most of the time the GIL will be held by the user thread when the
interrupt arrives.  Hard interrupts mean that we should process them right
away and hence can't wait until the GIL is released.

The problem with the current code is that a hard interrupt will try to
exit/enter the GIL while it is still held by the user thread, hence leading
to a deadlock.

This patch works around such a problem by just making GIL exit/enter a
no-op when in an interrupt context, or when interrupts are disabled.

See issue #2406.
2016-10-19 14:24:56 +11:00
Damien George 5c93d0b916 cc3200: Enable loading of precompiled .mpy files.
Adds 1072 bytes to the code size.
2016-10-18 10:17:54 +11:00
Damien George 628799cd36 cc3200/mods/pybspi: Allow "write" arg of read/readinto to be positional.
To conform with Hardware API.
2016-10-18 10:16:46 +11:00