Commit Graph

420 Commits

Author SHA1 Message Date
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
Damien George
50ddaafa6a cc3200: Use mp_raise_XXX helper functions to reduce code size.
Reduces code size by 632 bytes.
2016-10-18 09:53:43 +11:00
daniel
a0d97fe408 cc3200: Add ssl_version argument to ssl.wrap_socket().
This resolves issue #2343.
2016-10-01 21:35:09 +02:00
Damien George
93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Damien George
f3b5480be7 stmhal,cc3200,esp8266: Consistently use PWRON_RESET constant.
machine.POWER_ON is renamed to machine.PWRON_RESET to match other
reset-cause constants that all end in _RESET.  The cc3200 port keeps a
legacy definition of POWER_ON for backwards compatibility.
2016-09-08 12:50:38 +10:00
Delio Brignoli
e2ac8bb3f1 py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.
This new config option allows to control whether MicroPython uses its own
internal printf or not (if not, an external one should be linked in).
Accompanying this new option is the inclusion of lib/utils/printf.c in the
core list of source files, so that ports no longer need to include it
themselves.
2016-09-05 12:18:53 +10:00
Damien George
675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
Damien George
8766bc02dc cc3200, teensy: Remove broken malloc/free/realloc macro helpers.
These macros are broken and are anyway unused on these two ports.  If they
are ever needed in the future then their implementation can be taken from
either stmhal (working macros in mpconfigport.h) or esp8266 (functions).
2016-08-02 01:12:45 +10:00
Damien George
d862a7b811 cc3200: Remove obsolete singleton heart-beat object. 2016-06-28 11:28:53 +01:00
Damien George
842c2c74c0 cc3200: Allow to compile bootloader with threading enabled.
Threading is not used in the bootloader but the config optios are still
enabled so we must exclude including FreeRTOS.h.
2016-06-28 11:28:53 +01:00
Damien George
469c623bb8 cc3200: Shrink the FreeRTOS heap and place TCB+stack in freed location.
The 16k FreeRTOS heap originally had all TCBs and stacks dynamically
allocated within it (plus semaphores and some other things).  Now that
xTaskCreateStatic is used instead of xTaskCreate, the TCBs and stacks
are allocated statically and no longer use any of the FreeRTOS heap.
Therefore, the FreeRTOS stack can be shrunk by the amount that has been
made static.  Furthermore, the TCBs and stack that are now static should
be placed in the .rtos_heaps section of RAM because this RAM is treated
specially by the bootloader (the bootloader executes from the first 16k
of RAM and loads the firmware into the section starting after the 16k).

After this patch the FreeRTOS heap (ucHeap) is 7200 bytes.  The memory
available for the MicroPython heap is 54936 bytes (including GC overhead).
2016-06-28 11:28:53 +01:00
Damien George
e098eac195 cc3200: Start the simplelink spawn task using the static task creator.
In VStartSimpleLinkSpawnTask we change xTaskCreate to xTaskCreateStatic
so that the task is created using statically allocated memory for the TCB
and stack.

This means that xTaskCreate function is no longer needed (the static
version is now used exclusively).
2016-06-28 11:28:53 +01:00
Damien George
5b8e884573 cc3200: Remove .boot section attribute from osi_TaskCreate function.
This function is no longer used.  Having the .boot section attribute
meant that it was included in the firmware regargless of use.  Without
this attribute the linker can remove the function.
2016-06-28 11:28:53 +01:00
Damien George
1d5aa9d245 cc3200: In FreeRTOSConfig.h, comment on configSUPPORT_STATIC_ALLOCATION.
This config variable is now needed regardless of whether threading is
enabled or not.
2016-06-28 11:28:53 +01:00
Damien George
53562213c8 cc3200: Enable the GIL. 2016-06-28 11:28:52 +01:00
Damien George
fa2ac93c3a cc3200/mpthreadport: Move mem alloc outside the thread_mutex lock.
Otherwise there could be a deadlock, with the GC's mutex and
thread_mutex.
2016-06-28 11:28:52 +01:00
Damien George
757146efe3 cc3200/mpthreadport: Scan more root pointers from thread data. 2016-06-28 11:28:52 +01:00
Damien George
17886828c8 cc3200/gccollect: Use MP_STATE_THREAD(stack_top) to get top of stack. 2016-06-28 11:28:52 +01:00
Damien George
3b0fbfe4e5 cc3200/mpthreadport: Properly initialise the main thread's data. 2016-06-28 11:28:52 +01:00
Damien George
27241293c4 cc3200/mpthreadport: Make mutex statically allocated.
Reduced the need for the FreeRTOS heap to allocate the mutex.
2016-06-28 11:28:52 +01:00
Damien George
0455755296 cc3200: Use xTaskCreateStatic instead of osi_TaskCreate.
This allows to statically allocate the TCB (thread control block) and
thread stack in the BSS segment, reducing the need for dynamic memory
allocation.
2016-06-28 11:28:52 +01:00
Damien George
c9520c591b cc3200: Fix call to new exception to be _msg instead of _arg1. 2016-06-28 11:28:51 +01:00
Damien George
df95f52583 py/modthread: Allow to properly set the stack limit of a thread.
We rely on the port setting and adjusting the stack size so there is
enough room to recover from hitting the stack limit.
2016-06-28 11:28:51 +01:00
Damien George
eef4f13a33 cc3200: Add basic threading capabilities.
Can create a new thread and run it.  Does not use the GIL at this point.
2016-06-28 11:28:51 +01:00
Damien George
9b1c1262dc cc3200: Define our own FreeRTOS heap so it can go in a special segment. 2016-06-28 11:28:50 +01:00
Damien George
5c0fc73f33 cc3200: Update FreeRTOS to v9.0.0.
This is a pristine copy (actually a subset of files) of upstream FreeRTOS
v9.0.0.

Modifications to the previous version of FreeRTOS (v8.1.2) included
addition of __attribute__ ((section (".boot"))) to the following
functions:

    pxPortInitialiseStack
    prvTaskExitError
    prvPortStartFirstTask
    xPortStartScheduler
    vPortSetupTimerInterrupt
    xTaskGenericCreate
    vTaskStartScheduler
    prvInitialiseTCBVariables
    prvInitialiseTaskLists
    prvAllocateTCBAndStack

This attribute will need to be reinstated on a case-by-case basis
because some of the above functions are now removed/changed.
2016-06-28 11:28:50 +01:00
Paul Sokolovsky
07209f8592 all: Rename mp_obj_type_t::stream_p to protocol.
It's now used for more than just stream protocol (e.g. pin protocol), so
don't use false names.
2016-06-18 18:44:57 +03:00
Damien George
70ff7350e7 stmhal, cc3200: Change i2c.scan() method to scan addresses 0x08-0x77.
A standard I2C address is 7 bits but addresses 0b0000xxx and 0b1111xxx
are reserved.  The scan() method is changed to reflect this, along with
the docs.
2016-05-02 11:15:36 +01:00
Colin Hogben
104aa26271 cc3200, stmhal, teensy: Use pyhelp_print_obj function.
Update the help() implementations in the cc3200, stmhal and teensy
ports to use the pyhelp_print_obj function.
2016-04-25 18:54:59 +03:00
Jan Čapek
d76c65f599 py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file

- add special rule for generating a central header that contains all
  extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
  variable. Each platform appends a list of sources that may contain
  qstrings into a new build variable: SRC_QSTR. Any autogenerated
  prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.

- remove most qstrings from py/qstrdefs, keep only qstrings that
  contain special characters - these cannot be easily detected in the
  sources without additional annotations

- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
  stmhal, teensy, unix, windows, pic16bit:

   - remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
   - remove all port specific qstrdefs except for special strings
   - append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-04-16 13:18:09 +01:00
Paul Sokolovsky
9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Damien George
6eb17c31a9 ports: Disable async/await on bare-arm, minimal, pic16bit, cc3200.
It costs 1188 bytes of code on Thumb 2 archs.
2016-04-13 15:31:30 +01:00
Paul Sokolovsky
4e51a3038c cc3200/mods/modwlan: Include stream.h after recent refactor. 2016-04-06 01:18:39 +03:00
danicampora
8a18084571 cc3200: Update WiPy software version to 1.2.0 2016-02-27 00:19:53 +01:00
danicampora
add930c4b5 cc3200: Rename 'server' class to 'Server' for consistency. 2016-02-22 22:54:34 +01:00
danicampora
495e7cfebc cc3200: Improve robustness of WLAN during sleep modes. 2016-02-21 22:01:18 +01:00
danicampora
f5248a087a cc3200: Fix "debug" build. 2016-02-21 21:53:21 +01:00
danicampora
fe9620a2bd test/wipy: Add Timer class tests. 2016-02-21 21:53:20 +01:00
danicampora
73c9f85b4c cc3200: Simplify the Timer API and correct the documents.
Make the PWM duty cycle configurable from 0.00 to 100.00 by
accepting values from 0 to 10000.
Add automatic Pin assignment when operating in PWM mode.
2016-02-21 21:53:16 +01:00
danicampora
562bcffd3a cc3200: Improve robustness of the I2C driver.
When scanning for devices, try reading then writing. Increase the
timeout of the transactions from 10 to 20 ms.
2016-02-21 21:41:06 +01:00