Commit Graph

509 Commits

Author SHA1 Message Date
stijn d6243568a0 all: Remove commented-out include statements. 2020-04-23 11:24:15 +10:00
stijn 70affd9ba2 all: Fix implicit floating point to integer conversions.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
stijn bcf01d1686 all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
Scott Shawcroft 7e3d4c61b5
Update TinyUSB and add interrupt hooks. 2020-04-17 14:16:49 -07:00
Jeff Epler 1d8a073c05 nrf: protomatter port 2020-04-14 18:24:58 -05:00
Jeff Epler 09dc46a984 Add Protomatter and FramebufferDisplay 2020-04-14 18:24:54 -05:00
Damien George 7a07e71915 lib/littlefs: Update littlefs2 to v2.2.0.
At commit a049f1318eecbe502549f9d74a41951985fb956f
2020-04-09 15:59:28 +10:00
Damien George fa285be9d7 lib/btstack: Update to latest master btstack commit. 2020-04-07 13:46:56 +10:00
Jim Mussared def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Jim Mussared f46782dde9 mimxrt: Add new, minimal port to NXP i.MX RT series CPUs.
This is an extremely minimal port to the NXP i.MX RT, in the style of the
SAMD port  It's largely based on the TinyUSB mimxrt implementation, using
the NXP SDK.  It currently supports the Teensy 4.0 board with a REPL over
the USB-VCP interface.

This commit also adds the NXP SDK submodule (also from TinyUSB) to
lib/nxp_driver.

Note: if you already have the tinyusb submodule initialized recursively you
will need to run the following as the tinyusb sub-submodules have been
rearranged (upstream):

    git submodule deinit lib/tinyusb
    rm -rf .git/modules/lib/tinyusb
    git submodule update --init lib/tinyusb
2020-03-11 15:34:13 +11:00
Jim Mussared 6cea369b89 lib/tinyusb: Update to a6b916ba for i.MX support. 2020-03-11 15:32:55 +11:00
Damien George d35fefe30a lib: Add BlueKitchen BTstack submodule. 2020-03-10 01:53:42 +11:00
Jeff Epler da31acfcc4 Merge remote-tracking branch 'origin/master' into ulab 2020-03-03 20:13:53 -06:00
Jeff Epler eef742bf45 oofatfs: Remove _FS_DISK_READ_ALIGNED
This workaround is no longer needed, so it can be removed.

Closes: #2332
2020-02-28 10:04:28 -06:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Jeff Epler 50438b51aa libm: Provide log2f 2020-02-27 08:30:12 -06:00
Jeff Epler 41e71485af libm: Disable float-equal diagnostics
I choose to believe these authors knew what they were doing.
2020-02-27 08:30:12 -06:00
DavePutz aca53aa1a2
Update readline.c for REPL Unicode issue 1905 2020-02-18 10:38:50 -06:00
Damien George abe2caf6df py/scheduler: Move clearing of kbd traceback to mp_keyboard_interrupt.
This is a more logical place to clear the KeyboardInterrupt traceback,
right before it is set as a pending exception.  The clearing is also
optimised from a function call to a simple store of NULL.
2020-02-07 16:08:31 +11:00
Damien George 9efb36bfa6 py/scheduler: Move mp_keyboard_interrupt from lib/utils to py core.
This function is tightly coupled to the state and behaviour of the
scheduler, and is a core part of the runtime: to schedule a pending
exception.  So move it there.
2020-02-07 16:08:26 +11:00
Damien George 5a91cd9ff3 lib/utils/pyexec: Handle pending exceptions after disabling kbd intrs.
Pending exceptions would otherwise be handled later on where there may not
be an NLR handler in place.

A similar fix is also made to the unix port's REPL handler.

Fixes issues #4921 and #5488.
2020-02-07 16:08:26 +11:00
odewdney b51a2c266a lib/utils: Change default value of pyexec_mode_kind to 0 to put in bss.
By simply reordering the enums for pyexec_mode_kind_t it eliminates a data
variable which costs ROM to initialise it.  And the minimal build now has
nothing in the data section.

It seems the compiler is smart enough so that the generated code for
if-logic which tests these enum values is unchanged.
2020-02-04 18:10:26 +11:00
Scott Shawcroft 7d8dac9211
Refine iMX RT memory layout and add three boards
Introduces a way to place CircuitPython code and data into
tightly coupled memory (TCM) which is accessible by the CPU in a
single cycle. It also frees up room in the corresponding cache for
intermittent data. Loading from external flash is slow!

The data cache is also now enabled.

Adds support for the iMX RT 1021 chip. Adds three new boards:
* iMX RT 1020 EVK
* iMX RT 1060 EVK
* Teensy 4.0

Related to #2492, #2472 and #2477. Fixes #2475.
2020-01-17 17:36:08 -08:00
Yonatan Goldschmidt 853aaa06f2 lib/mp-readline: Add word-based move/delete EMACS key sequences.
This commit adds backward-word, backward-kill-word, forward-word,
forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B,
Alt+D and Alt+Backspace respectively.  It is disabled by default and can be
enabled via MICROPY_REPL_EMACS_WORDS_MOVE.

Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings
for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W.

The features are enabled on unix micropython-coverage and micropython-dev.
2020-01-12 13:09:27 +11:00
Yonatan Goldschmidt dce590c29d lib/mp-readline: Add an assert() to catch buffer overflows.
During readline development, this function may receive bad `pos` values.
It's easier to understand the assert() failing error than to have a "stack
smashing detected" message.
2020-01-12 13:09:23 +11:00
Yonatan Goldschmidt 61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
Damien George 09376f0e47 py: Introduce MP_ROM_NONE macro for ROM to refer to None object.
This helps to prevent mistakes, and allows easily changing the ROM value of
None if needed.
2019-12-27 22:51:17 +11:00
hathach adff14c5bc
more tinyusb update 2019-12-27 09:55:16 +07:00
hathach 62c4028cde
sync with https://github.com/hathach/tinyusb/pull/246
should fix slow enumeration
2019-12-26 23:04:16 +07:00
hathach 3492ba33d5
improve usb dcd samd51
fix race condition with setup packet + scsi status response
2019-12-26 00:18:04 +07:00
Jeff Epler 5c42ae1e13 mp3: update to upstream release 1.1.1 2019-12-19 08:13:00 -06:00
David Lechner 1605c7e584 Revert "lib/tinytest: Clean up test reporting in the presence of std..."
This reverts commit f4ed2dfa94.

This lets tinytest work as it was originally designed.  An alternate
solution for the reverted commit will be implemented in a future commit.
2019-12-19 17:53:46 +11:00
hathach 554373fdd9 bump tinyusb lib submodule 2019-12-17 22:26:08 +07:00
Jeff Epler a08d9e6d8e audiocore: Add MP3File using Adafruit_MP3 library 2019-12-10 14:03:06 -06:00
Jeff Epler a484a93b29 nRF: disk_read must be 4-byte aligned
.. a requirement that oofatfs needs to be taught to respect.

This problem can be demonstrated with the following snippet, except
that the related file ("test.bin") must also be contiguous on the
filesystem.  You can ensure this by reformatting your device's filesystem
before testing, then copying any single file bigger than 4kB to test.bin.

    f = open("test.bin", "rb")
    f.seek(2048)
    b = bytearray(2048)
    v = memoryview(b)
    f.readinto(v[909:])

Closes: #2332
2019-12-10 14:03:06 -06:00
Jeff Epler 238e121236 protocols: Allow them to be (optionally) type-safe
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    >>> import uos, ujson
    >>> u = uos.VfsPosix('/tmp')
    >>> ujson.load(u)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    >>> ujson.load(p)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: stream operation not supported
2019-12-04 09:29:57 -06:00
Melissa LeBlanc-Williams d763559120 Removing submodule that was accidentally stowed away in PR 2302 2019-11-19 16:17:30 -08:00
Melissa LeBlanc-Williams fe6ec9a7d4 Added Edgebadge alias for Pybadge 2019-11-19 14:53:58 -08:00
Scott Shawcroft 47e50e5659
Merge remote-tracking branch 'adafruit/master' into bleio_tweaks 2019-11-01 13:20:58 -07:00
Damien George 4e1b03d45c lib/libc/string0: Add simple implementations of strspn and strcspn.
They are needed for littlefs.
2019-10-30 12:14:52 +11:00
Damien George 22bfc47977 lib/littlefs: Add README describing origin and how to gen lfs1/lfs2. 2019-10-29 12:55:34 +11:00
Damien George 2e66d83ca4 lib/littlefs: Add littlefs v2.1.3 source. 2019-10-29 12:55:34 +11:00
Damien George 669d1d20ab lib/littlefs: Add littlefs v1.7.2 source. 2019-10-29 12:55:34 +11:00
Hierophect dadfa69061 remove old library 2019-10-22 13:13:22 -04:00
Scott Shawcroft ae30a1e5aa
Refine _bleio
This PR refines the _bleio API. It was originally motivated by
the addition of a new CircuitPython service that enables reading
and modifying files on the device. Moving the BLE lifecycle outside
of the VM motivated a number of changes to remove heap allocations
in some APIs.

It also motivated unifying connection initiation to the Adapter class
rather than the Central and Peripheral classes which have been removed.
Adapter now handles the GAP portion of BLE including advertising, which
has moved but is largely unchanged, and scanning, which has been enhanced
to return an iterator of filtered results.

Once a connection is created (either by us (aka Central) or a remote
device (aka Peripheral)) it is represented by a new Connection class.
This class knows the current connection state and can discover and
instantiate remote Services along with their Characteristics and
Descriptors.

Relates to #586
2019-10-21 18:57:03 -07:00
Dan Halbert a0d18ac4e6 add dummy common_hal_mcu_processor_get_voltage() for spresense 2019-10-15 09:07:12 -04:00
Jim Mussared 580a2656d1 stm32: Use hardware double sqrt on F7/H7 MCUs.
Identical to cd527bb324 but for doubles.
This gives a -2.754% improvement on bm_float.py, and -35% improvement on
calling sqrt in a loop.
2019-10-10 17:39:32 +11:00
Kamil Tomaszewski 49db102bdd Update tinyUSB 2019-10-09 08:32:58 +02:00
Dan Halbert 05038ea1e5 Update tinyusb to fix gamepad;add HID OUT interface descriptor 2019-10-01 15:57:16 -04:00
Damien George 21507a6f62 lib/mynewt-nimble: Add Apache mynewt nimble as a submodule.
Tag nimble_1_1_0_tag.
2019-10-01 09:51:02 +10:00
Hierophect 426ddb356e Add support for F412 via latest tinyusb update 2019-09-09 11:42:55 -04:00
Damien George af20c2ead3 py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now
provided by the global default_emit_opt variable.

Now, when -X emit=native is passed as a command-line option, the emitter
will be set for all compiled modules (included imports), not just the
top-level script.

In the future there could be a way to also set this variable from a script.

Fixes issue #4267.
2019-08-28 12:47:58 +10:00
Scott Shawcroft 966a48b23a
More size_t usage 2019-08-27 12:49:46 -07:00
Dan Halbert 44b28d1187 update tinyusb to 00c440cb 2019-08-19 19:42:45 -04:00
Jeff Epler 49d8ea648d update tinyusb
This fixes a problem with USB MIDI messages 0xc and 0xd and
Closes: #2057
2019-08-16 07:40:37 -05:00
hathach c921f6637f update tinyusb lib to 0.5.x 2019-07-24 16:46:31 +07:00
Damien George 1b79484ee3 lib/lwip: Update lwIP to v2.1.2, tag STABLE-2_1_2_RELEASE. 2019-07-04 10:36:23 +10:00
Damien George 9083166c4f lib/stm32lib: Update library for updated H7xx, new L0xx, new WBxx.
And this library now includes the startup_stm32*.s files for each MCU.
2019-07-03 23:36:43 +10:00
Damien George 258d10862d lib: Add tinyusb as a submodule. 2019-07-01 17:18:44 +10:00
Damien George 875af757bd lib: Add asf4 as a submodule. 2019-07-01 17:18:44 +10:00
Damien George b7da67cdaa lib/utils/sys_stdio_mphal: Add support to poll sys.stdin and sys.stdout.
A port must provide the following function for this to work:

    uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags);
2019-07-01 17:10:12 +10:00
Damien George 399417adba lib: Add new submodule for mbedtls, currently at v2.17.0.
From upstream source: https://github.com/ARMmbed/mbedtls.git
2019-06-05 15:21:40 +10:00
Damien George 1043f1a047 lib/netutils: Add DHCP server component. 2019-06-03 14:57:50 +10:00
Damien George 0a6c479187 lib/cmsis: Upgrade to CMSIS 5.5.1.
From https://github.com/ARM-software/CMSIS_5.git, tag 5.5.1
2019-06-03 14:40:57 +10:00
Glenn Ruben Bakke 85bde0889d lib/nrfx: Upgrade nrfx to master.
Updating the nrfx git submodule containing HAL drivers for nrf-port
from v1.3.1 to current master. The version pointed to is one commit
ahead of v1.7.1 release. The extra commit contains a bugfix for
nrfx_uart_tx_in_progress() making it report correctly.

The general upgrade of nrfx is considered to be safe, as almost all
changes in between 1.3.1 and 1.7.1 are related to peripherals and
target devices not used by the nrf-port as of today.
2019-05-21 17:45:01 +02:00
Damien George 1b3c1f9e6b lib/stm32lib: Update library to fix UART9/10 baudrate on F4 MCUs. 2019-05-20 15:16:14 +10:00
Damien George b3939e2513 lib/utils/printf: Exclude __GI_vsnprintf alias for gcc 9 and above.
See issue #4457.
2019-05-11 00:31:40 -05:00
Scott Shawcroft 6440af5c06
Hide the traceback for the ReloadException.
Many users think it's an error when it's us simply stopping the
code.
2019-05-08 14:53:20 -07:00
Damien George 2459162599 lib/utils/interrupt_char: Invalidate interrupt char at start up.
Otherwise mp_interrupt_char will have a value of zero on start up (because
it's in the BSS) and a KeyboardInterrupt may be raised during start up.
For example this can occur if there is a UART attached to the REPL which
sends spurious null bytes when the device turns on.
2019-05-01 12:41:07 +10:00
Andrew Leech 859596ce25 lib/utils: Make pyexec_file_if_exists run frozen scripts if they exist.
So that boot.py and/or main.py can be frozen (either as STR or MPY) in the
same way that other scripts are frozen.  Frozen scripts have preference to
scripts in the VFS.
2019-05-01 11:27:51 +10:00
Damien George 06a532c227 lib/utils/pyexec: Add pyexec_file_if_exists() helper function.
It will only execute the script if it can be stat'd and is a file.
2019-04-26 15:21:09 +10:00
hathach 9d43a25d6e update tinyusb to fix disconnect/suspend issue with #1681 2019-04-04 17:59:20 -04:00
Damien George ca5f8975fa lib/stm32lib: Update library to fix F7 MMC capacity calculation. 2019-04-01 17:04:43 +11:00
Scott Shawcroft ab6896206d
Remove lwip submodule because it is unused. 2019-03-29 15:03:10 -07:00
Scott Shawcroft 1b97325418
Update TinyUSB to fix CDC OUT buffering
Fixes #1630
2019-03-26 16:15:52 -07:00
Damien George 350dbb89e6 lib/oofatfs: Update oofatfs library to fix issue with logic not.
From https://github.com/micropython/oofatfs, branch work-R0.13c,
commit 3b4ee5a646af2769b3dddfe17d5d866233c1e45b.
2019-03-07 15:03:09 +11:00
Damien George 7eadcaa8c6 lib/oofatfs: Update ffconf.h config for new oofatfs version. 2019-03-05 15:56:39 +11:00
Damien George 1a24bac6cb lib/oofatfs: Update oofatfs library to R0.13c working branch.
From https://github.com/micropython/oofatfs, branch work-R0.13c,
commit cb05c9486d3b48ffd6bd7542d8dbbab4b1caf790.

Large code pages (932, 936, 949, 950) have been removed from ffunicode.c
because they were not included in previous versions here.
2019-03-05 15:56:39 +11:00
Damien George b6791ffbbe lib/netutils: Add function to print tracing info for Ethernet frames. 2019-02-26 23:32:19 +11:00
Dan Halbert d218069f03
Merge pull request #1584 from tannewt/disable_concurrent_write_protection
Add option to disable the concurrent write protection
2019-02-21 17:15:50 -05:00
Scott Shawcroft 1a0596a2fb
Add option to disable the concurrent write protection
This allows writing to the filesystem from the host computer and
CircuitPython by increasing the risk of filesystem corruption.
2019-02-21 10:45:41 -08:00
Craig Forbes 1532863d83 Set __file__ for the main source file (e.g. code.py, main.py) 2019-02-20 21:37:29 -06:00
Scott Shawcroft e6b140e7a0
Support print("", flush=True)
Fixes #1127
2019-02-15 16:53:19 -08:00
Mike Causer 812969d615 all: Change PYB message prefix to MPY.
Replaces "PYB: soft reboot" with "MPY: soft reboot", etc.

Having a consistent prefix across ports reduces the difference between
ports, which is a general goal.  And this change won't break pyboard.py
because that tool only looks for "soft reboot".
2019-02-12 15:18:33 +11:00
Damien George 8d1275ec0f lib/utils/gchelper: Add gchelper.h header file for assembler functions. 2019-02-12 14:37:41 +11:00
Damien George f608f54ab0 lib/utils/gchelper_m3: Add gc_helper_get_sp() function. 2019-02-12 14:37:01 +11:00
Damien George 90e1303b2d lib/utils/gchelper_m3: Add license header and clean up code.
This file generates the same code with the cortex-m3 and cortex-m4
assembler directive, so use cortex-m3 to support more CPUs.
2019-02-12 14:16:24 +11:00
Damien George e6d97e8a0b stm32: Move gchelper assembler code to lib/utils for use by other ports. 2019-02-12 14:11:21 +11:00
Lionel Debroux 591eb23e0f Fix a couple variable shadowing varnings.
Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
2019-02-07 20:10:43 +01:00
Damien George 7bbde67cb2 lib/utils/printf: Exclude __GI_vsnprintf alias for gcc 9 and above.
See issue #4457.
2019-02-06 01:12:51 +11:00
Scott Shawcroft a393a6e0c5
Add fast seek support to file objects 2019-02-03 13:41:20 -08:00
Damien George 8faf17b93c lib/nrfx: Upgrade to nrfx v1.3.1. 2019-01-31 17:38:13 +11:00
hathach d1fb384a4a
update tinyusb, work better with sd 2019-01-29 21:03:18 +07:00
Damien George 1fa8f977f5 lib/utils/pyexec: Implement paste mode with event driven REPL. 2019-01-28 23:00:19 +11:00
Damien George f874e8184c lib/stm32lib: Update library to get F413 BOR defs and fix gcc 8 warning. 2019-01-24 11:33:59 +11:00
Scott Shawcroft b5e40f52c2
Add USB MIDI support for SAMD and nRF.
The API should be identical to using a UART for MIDI.

Fixes #672
2019-01-09 14:02:11 -08:00
Tobias Badertscher 06236bf28e lib/utils: Add generic MicroPython IRQ helper functions.
Initial implementation of this is taken from the cc3200 port.
2018-12-29 17:08:55 +11:00
Scott Shawcroft 45b301856c
Switch TinyUSB back to hathach's version. The merge commit of the commit we were on. 2018-12-06 15:39:47 -08:00
Dan Halbert f6c73b35f9
Merge pull request #1323 from notro/os_mkdir_a_b
shared-module/os: Fix os.mkdir('a/b')
2018-11-27 17:08:51 -05:00
Scott Shawcroft 324301e3bc
Update tinyusb to include control fixes. 2018-11-23 13:28:10 -08:00
Scott Shawcroft fd3178b2fe
Update TinyUSB with SAMD fixes.
Fixes #1327
2018-11-14 14:54:00 -08:00
Scott Shawcroft 355abc835e
Fix output overflow and make help translatable 2018-11-09 16:41:08 -08:00
Scott Shawcroft 43f7ca7985
Incorporate feedback:
* Clean up board defines.
* Add flush on eject and stay ejected.
* Swith back to NONE protocol for CDC.
2018-11-09 11:33:56 -08:00
Noralf Trønnes 28383afa11 shared-module/os: Fix os.mkdir('a/b')
This fixes commit a99f9427420d("'/' and '\' are also acceptable ends of the path now") which broke mkdir.
The problem is where the directory name is a single letter like this:
>>> os.mkdir('a')
>>> os.mkdir('a/b')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 17] File exists
>>> os.mkdir('a/bb')
>>>

I wasn't smart enough to fix this in the oofatfs library, so I did it in the os shared module by
creating a path lookup function for the os methods that only deals with directories. I reverted
the library change introduced by the aforementioned commit.

This means that os.stat and os.rename can't handle trailing slashes. This is to avoid allowing
filenames with trailing slashes to pass through. In order to handle trailing slashes for these
it would be necessary to check if it really is a directory before stripping. I didn't do this
since the original issue was to make os.chdir tolerate trailing slashes.

There's an open MicroPython issue #2929 wrt. trailing slashes and mkdir.
2018-11-09 19:20:56 +01:00
Scott Shawcroft 168e23e466
Build refinement to handle warnings and quiet output 2018-11-09 00:11:43 -08:00
Scott Shawcroft 9d91111b1b
Move atmel-samd to tinyusb and support nRF flash.
This started while adding USB MIDI support (and descriptor support is
in this change.) When seeing that I'd have to implement the MIDI class
logic twice, once for atmel-samd and once for nrf, I decided to refactor
the USB stack so its shared across ports. This has led to a number of
changes that remove items from the ports folder and move them into
supervisor.

Furthermore, we had external SPI flash support for nrf pending so I
factored out the connection between the usb stack and the flash API as
well. This PR also includes the QSPI support for nRF.
2018-11-08 17:25:30 -08:00
Damien George f5d46a88aa lib/utils/pyexec: Forcefully unlock the heap if locked and REPL active.
Otherwise there is really nothing that can be done, it can't be unlocked by
the user because there is no way to allocate memory to execute the unlock.

See issue #4205 and #4209.
2018-10-13 16:21:08 +11:00
hathach 21ddb6b9b9 fix tinyusb cdc issue 2018-10-05 21:37:16 +07:00
Damien George 8960a28238 lib/libm/math: Add implementation of __signbitf, if needed by a port. 2018-09-27 15:21:04 +10:00
Damien George 4c08932e73 lib/libm/math: Fix int type in float union, uint64_t should be uint32_t.
A float is 32-bits wide.
2018-09-27 15:19:53 +10:00
Damien George 5f92756c2c lib/stm32lib: Update library to fix issue with filling USB TX FIFO. 2018-09-26 12:00:25 +10:00
hathach d3e5ba83eb update nrfx to 1.3.0 2018-09-25 13:00:57 +07:00
Andrew Leech 57a73973ad lib/libm_dbl: Add implementation of copysign() for DEBUG builds.
This provides a double variant of the float copysignf from libm/math.c
which is required for DEBUG=1 builds when MICROPY_FLOAT_IMPL=double
2018-09-20 16:46:19 +10:00
Jeff Epler 014857b34b uzlib: Upgrade to uzlib v2.9 release
This fixes a large number of crashes on malformed inputs.
2018-09-09 20:22:25 -05:00
Damien George b9a133e5ad lib/libm/wf_tgamma: Fix tgammaf handling of -inf, should return nan. 2018-09-04 17:00:35 +10:00
Damien George afc7ddca31 lib/libm/math: Make tanhf more efficient and handle large numbers.
Prior to this patch tanhf(large number) would return nan due to inf/inf.
2018-09-04 17:00:30 +10:00
Damien George 0b239d458c lib/libm_dbl/tanh: Make tanh more efficient and handle large numbers.
Prior to this patch tanh(large number) would return nan due to inf/inf.
2018-09-04 16:57:46 +10:00
Dan Halbert 93100a7517
Merge pull request #1146 from hathach/nrf52_usb_serial_bug
update tinyusb to fix #1007 serial issue
2018-08-28 15:39:34 -04:00
hathach ba26ca9e41 update tinyusb to fix #1007 serial issue 2018-08-28 16:00:34 +07:00
Noralf Trønnes 39ee12d1ac Fix os.stat() to use 1970 epoch
Commit 95e70cd0ea 'time: Use 1970 epoch' changed epoch for the time
module, but not for other users. This patch does the same for the only
other core timeutils user: extmod/vfs_fat.c:fat_vfs_stat().
Other timeutils users: cc3200, esp8266 and stm32, are not changed.

Ports that don't use long ints, will still get wrong time values from
os.stat().
2018-08-25 20:43:02 +02:00
hathach 02b1b53153 Merge branch 'master' into nrf52_dfu_touch1200 2018-08-22 15:24:12 +07:00
hathach b7dd33b76e add touch 1200 for dfu-flash 2018-08-21 15:15:44 +07:00
Scott Shawcroft 4a4d84ba42
Merge pull request #1064 from notro/i2cslave
Add busio.I2CSlave
2018-08-17 16:51:45 -07:00
Scott Shawcroft 2cd166b573
Fix esp and samd 2018-08-16 17:41:35 -07:00
Noralf Trønnes 1ed0e45fc2 Add i2cslave.I2CSlave bindings 2018-08-16 17:11:20 +02:00
Scott Shawcroft 96ebf5bc3f
Two fixes and translate more strings.
* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
2018-08-09 13:29:30 -07:00
Damien George da2d2b6d88 py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to
MICROPY_DEBUG_PRINTER, moving its default definition from
lib/utils/printf.c to py/mpconfig.h to make it official and documented, and
makes this macro a pointer rather than the actual mp_print_t struct.  This
is done to get consistency with MICROPY_ERROR_PRINTER, and provide this
macro for use outside just lib/utils/printf.c.

Ports are updated to use the new macro name.
2018-08-02 14:04:44 +10:00
hathach 1e524f1b98 Merge branch 'master' into nrf52840_usb_hid 2018-08-01 00:58:23 +07:00
hathach 20c25f61d9 update tinyusb 2018-08-01 00:53:56 +07:00
hathach d15caf0dbd hid keyboard and mouse work well 2018-07-31 16:42:04 +07:00
hathach 221d54a595 workaround to use lib/utils/interrupt_char.c 2018-07-31 14:28:34 +07:00
hathach ae783b0b1a update tinyusb, set scsi sense key for unsupported commands 2018-07-31 13:54:58 +07:00
Scott Shawcroft a6d94b6845
Merge pull request #1068 from dhalbert/micropython-25ae98f-merge
Micropython 25ae98f merge
2018-07-30 12:33:44 -07:00
Dan Halbert 2e260a0eab Merge remote-tracking branch 'adafruit/master' into micropython-25ae98f-merge 2018-07-28 14:13:54 -04:00
Dan Halbert f48b70050e merge finished 2018-07-28 13:29:47 -04:00
Leszek Jakubowski a99f942742 '/' and '\' are also acceptable ends of the path now 2018-07-28 17:07:22 +02:00
hathach 21339c4155 house keeping 2018-07-27 17:22:21 +07:00
hathach e86f7d0b88 add usb msc callback description 2018-07-27 00:17:14 +07:00
hathach 5bdf40901f update tusb lib 2018-07-26 17:16:41 +07:00
Dan Halbert bc760dd341 WIP: complete manual inspection of all significant changes 2018-07-23 21:34:25 -04:00
Glenn Ruben Bakke ab815788da nrf: Upgrade to nrfx 1.1.0 2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke b7ce2f1460 nrf: Add support for reading output pin state
Current adoption on top of nrfx only reads the GPIO->IN register.
In order to read back an output state, nrf_gpio_pin_out_read has
to be called.

This patch concatinate the two read functions such that, if
either IN or OUT register has a value 1 it will return this,
else 0.

Updating lib/nrfx submodule to latest version of master to get
the new GPIO API to read pin direction.
(nrfx: d37b16f2b894b0928395f6f56ca741287a31a244)
2018-07-18 17:12:26 +10:00
glennrub 002f7d1ad7 nrf: Replace custom-HAL with nrfx-HAL
Summarized this squashed PR replaces the hal/ folder in the port. This has been replaced the official
HAL layer from Nordic Semiconductor; https://github.com/NordicSemiconductor/nrfx.

A Git submodule has been added under lib/nrfx, for the nrfx dependency.

The drivers / modules has been updated to use this new HAL layer; nrfx at v1.0.0.

Also, header files and system files for nrf51/nrf52x chip variants has been deleted from the device/ folder, only keeping back the startup files written in C. All other files are now fetched from nrfx.

3 new header files in the ports/nrf/ folder has been added to configure nrfx (nrfx_config.h), logging (nrfx_log.h) and glue nrfx together with the drivers and modules from micropython (nrfx_glue.h).

The PR has been a joint effort from @aykevl (Ayke van Laethem) and @glennrub.

For reference, the commit log will be kept to get an overview of the changes done:

* ports/nrf: Initial commit for moving hal to Nordic Semiconductor BSD-3 licensed nrfx-hal.

* ports/nrf: Adding nrfx, Nordic Semiconductor BSD-3 hal layer, as git submodule checked out at lib/nrfx.

* ports/nrf/modules/machine/uart: Fixing bug which set hwfc to parity excluded, always resulting in no flow control, hence corrupted output. Also adding an extra loop on uart_tx_char to prevent any tx when any ongoing tx is in progress.

* ports/nrf/i2c: Moving I2C over to nrfx driver.

* ports/nrf/modules/machine/i2c: Alignment. Renaming print function param 'o' to 'self_in'

* ports/nrf/spi: Updating SPI machine module to use nrfx drivers.

* ports/nrf: Renaming modules/machine/rtc.c/.h to rtcounter.c/.h to not confuse the peripheral with Real-Time Clock:

* ports/nrf: Updating various files after renaming machine module RTC to RTCounter.

* ports/nrf: Renaming RTC to RTCounter in modmachine globals dict table. Also updating object type name to reflect new module name.

* ports/nrf: Fixing leftovers after renaming rtc to rtcounter.

* ports/nrf: Early untested adoption of nrfx_rtc in RTCounter. Untested.

* nrf/modules/machine/i2c: Improve keyword argument handling

* ports/nrf/modules/temp: Updating Temp machine module to use nrfx defined hal nrf_temp.h. Moving logic of BLE stack awareness to machine module.

* ports/nrf/boards/pca10040: Enable machine Temp module.

* nrf/modules/machine/rtcounter: Remove magic constants.

* ports/nrf: Adding base support for nrfx module logging. Adding option to disable logging of UART as it might log its own setup over UART while the peripheral is not yet set up. Logging of UART could make sense if other transport of log is used.

* ports/nrf: updating nrfx_log.h with more correct parenthisis on macro grouping.

* ports/nrf: Updating nrfx logging with configuration to disable logging of UART module. The pattern can be used to turn off other modules as well. However, for now UART is the only module locking itself by logging before the peripheral is configured. Logging is turned off by default, can be enabled in nrfx_config.h by setting NRFX_LOG_ENABLED=1.

* ports/nrf/modules/random: Updating modrandom to use nrfx hal for rng. Not using nrfx-driver for this peripheral as its blocking mode would do the trick on RNG. Moving softdevice aware code from legacy hal to modrandom.c.

* nrf: Enable Peripheral Resource Sharing.

This enables TWI and SPI to be enabled at the same time.

* nrf/Makefile: Define MCU sub variant (e.g. NRF51822/NRF51422)

* nrf: Port TIMER peripheral to nrfx HAL.

* nrf/modules/machine/uart: Optimize UART module

For a nRF51, this results in a size reduction of:
.text: -68 bytes
.data: -56 bytes

* nrf/modules/machine/uart: Don't use magic index numbers.

* nrf/modules/machine/uart: Fix off-by-one error.

For nrf51:
.text: -40 bytes

* nrf/modules/machine/rtcounter: Update for nrfx HAL.

* nrf/modules/machine/i2c: Reduce RAM consumption.

Reductions for the nrf51:
flash: -108 bytes
RAM:   -72 bytes

* nrf/mpconfigport: Avoid unnecessary root pointers.

This saves 92 bytes of RAM.

* nrf: Support SoftDevice with nrfx HAL.

* nrf: Add NVMC peripheral (microbitfs) support.

There is no support yet for a SoftDevice.

It also fixes a potentially serious bug in start_index generation.

* nrf/modules/machine/spi: Optimize SPI peripheral.

nrf51:
text: -340 bytes
data: -72  bytes

nrf52:
text: -352 bytes
data: -108 bytes

* nrf/modules/random: Forgot to commit header file.

* nrf: Make nrfx_config.h universal for all boards.

* nrf: Use SoftDevice API for flash access when built for SD

* nrf/drivers/bluetooth: Remove legacy HAL driver includes.

These were not used anymore so can be removed.

* ports/nrf/microbit: Port microbit targets to nrfx HAL

Initial port of microbit modules to use nrfx HAL layer.
Tested display/image and modmusic on micro:bit to verify that
softpwm and ticker for nrf51 is working as expected.

Changing IRQ priority on timer to priority 2, as 1 might collide if
used side by side of SD110 BLE stack.

The patch reserves Timer1 peripheral compile time. This is not ideal
and should be resolved in seperate task.

* nrf/boards/microbit: Remove custom nrfx_config.h from microbit target, adding disablement of timer1 if softpwm is enabled.

* nrf/adc: Update ADC module to use nrfx

* nrf/modules/machine/pwm: Updating machine PWM module to use nrfx HAL driver.

examples/nrf52_pwm.py and examples/nrf52_servo.py tested on pca10040.

* nrf: Removing hal folder and boards nrf5x_hal_conf.h headers.

* nrf/nrfx_glue: Adding direct NVIC access for S110 BLE stack

If SoftDevice s110 has not yet been initialized, the IRQ will not be forwarded to
the application using the sd_nvic* function calls. Hence, direct access to cmsi
nvic functions are used instead if SoftDevice is not enabled.

* nrf/drivers/ticker: Setting IRQ priority 3 on Timer1

SoftDevice fails to initilize if Timer1 has been configured to priority
level 2 before enabling the SD. The timer is set to priority 1, higher than BLE
stack in order to provide better quality of music rendering when used with the
music module. This might be too high, time will show.

* nrf/examples: Updating ubluepy_temp after moving RTCounter to nrfx.

* nrf: delete duplicate files from device folder which can be located in nrfx/mdk.

* nrf/Makefile: Fetch system files from nrfx.

Testing on each device sub-variant to figure out which system file to
use. Reason for this is that nrf52.c is actually defining nrf52832.

Removing NRF_DEFINES parameter setting the device in use into the
same sub-variant test, as NRF52 is unique to nrf52832 when using nrfx.
Without this exclusion of -DNRF52 in compilation for nrf52840, the
device will be interpreted as a nrf52, hence nrf52832.

Also, changing name on variable SRC_NRF_HAL to SRC_NRFX_HAL to
explicitly tell the origin of the file.

* nrf: Updating device #ifdefs to be more open to non-nrf51 targets.

* nrf/modules/machine/uart: Removing second instance of UART for nrf52840 as it only has one non-DMA variant.

* nrf/device: Removing system files as these are now used from nrfx/mdk

* nrf: Moving startup files in device one level up as there is no need for deep hierarchy.

* nrf: Use NRF52_SERIES defined in nrfx/mdk/nrf.h as define value when testing for both nrf52(832) and nrf52840 variants.

* nrf/modules/machine/uart: Enable UART RX by default

Enable rx by default after intiialization of the peripheral.
Else, the nrfx driver will re-enable rx for each byte read
on uart REPL, clearing the EVENT_RXDRDY before second byte,
which again will make second byte get lost and read will get stuck.

This happens if the bytes are transmitted nrf(51) while still
processing the previous byte. Not seen on nrf52, but should
also become an issue at higher speeds.

This patch sets rx to always be enabled. Hence, not clearing the event
between read bytes, and it will be able to detect next byte recieved
upon finishing the first.

* nrf/modules/machine/timer: Fixing defines excluding Timer1 if ticker/softpwm is used.

* nrf: Switching import form mpconfigboard.h to mpconfigport.h in nrfx_config.h as mpconfigboard.h might define default values for defines not set by board specific header.

* nrf/modules/machine/i2c: nrfx integration fixes

Increasing speed to 400K.

Returning Address NACK's as MP error code; MP_ENODEV.

Returning MP_ETIMEOUT on all other error codes from TWI nrfx driver
except the ANACK.

Enabling and disabling the TWI peripheral before and after each transaction.

* nrf/examples: Updating ssd1306_mod.py to split framebuffer transfer into multiple chunks

* nrf/modules/machine/i2c: Return MP_EIO error if Data NACK occurs.

* nrf: Addressing review comments.

* nrf: Updating git submodule and users to nrfx v1.0.0.

* nrf/modules/machine/adc: Update adc module to follow v1.0.0 nrfx API.

* nrf/modules/machine/spi: Implement init and deinit functions

Extending SPI objects with a config member such that
configuration can be kept between new() and init().

Moving initialization done in new() to common init
function shared between the module functions.

If SPI is already configured, the SPI peripheral will
be uninitialized before initalized again.

Adding logic to handle initialization of polarity and
phase. As well, updating default speed to 1M from 500K.

* nrf/modules/machine: Removing unused nrfx includes in machine module header files
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke 8a4a05c1ee lib/utils: Expose pyb_set_repl_info function public
The patch enables the possibility to disable or initialize the repl
info from outside of the module. Can also be used to initialize the
repl_display_debugging_info in pyexec.c if not startup file is clearing
.bss segment.
2018-07-18 17:12:25 +10:00
hathach bb28faf39c arturo182 review 2018-07-17 23:57:49 +07:00
hathach 3525d65af3 should fix #1021
- update tinyusb for wanted char
- move usb code into usb.c
2018-07-17 21:24:49 +07:00
Dan Halbert 2809b4f9dd Merge branch 'master' into micropython-25ae98f-merge 2018-07-16 19:36:40 -04:00
Dan Halbert 7c219600a2 WIP: after merge; before testing 2018-07-11 16:45:30 -04:00
hathach a53b1c7cf1 code format 2018-07-10 22:49:51 +07:00
hathach ce01496d44 try to fix travis build error 2018-07-10 12:06:54 +07:00
hathach 0e819599e7 Merge branch 'master' into nrf52840_usbboot 2018-07-10 02:02:52 +07:00
hathach c5089d7274 generate uf2 by default
update tusb
2018-07-10 01:02:33 +07:00
Damien George b2b06450e3 lib/utils: Fix to support compiling with object representation D. 2018-07-08 23:13:37 +10:00
stijn 8ad30fa433 lib/utils/printf: Make DEBUG_printf implementation more accessible.
The definition of DEBUG_printf doesn't depend on
MICROPY_USE_INTERNAL_PRINTF so move it out of that preprocessor
block and compile it conditionally just depending on the
MICROPY_DEBUG_PRINTERS macro. This allows a port to use DEBUG_printf
while providing it's own printf definition.
2018-07-05 19:44:18 +10:00
hathach 0365912e28 implement msc with internal_flash api
Note: only work with SD is disabled.
2018-07-05 16:19:04 +07:00
hathach 7fff7f5e70 add usb msc support for nrf52840 2018-07-04 16:40:53 +07:00
hathach a73effa5b6 update tusb 2018-07-04 00:28:43 +07:00
Scott Shawcroft 519287550c
Long-live code.py itself. 2018-07-03 05:45:50 -07:00
hathach 36e2f38933 update tools/uf2 to have family support 2018-07-03 17:49:59 +07:00
hathach 46c453cf0a add tinyusb as submodule 2018-07-03 17:46:08 +07:00
Damien George 191e2cf90a lib/stm32lib: Update library to include support for STM32F0 MCUs.
Now points to branch: work-F0-1.9.0+F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1
2018-05-28 21:46:20 +10:00
hathach 52ebfd07a5 update nrfutil to 0.5.2d with singlebank option 2018-05-17 15:20:07 +07:00
Damien George 7d7b9cd5df lib/lwip: Update lwIP to v2.0.3, tag STABLE-2_0_3_RELEASE. 2018-05-17 13:11:31 +10:00
Jeff Epler a6072f7ae3 uzlib: convert to submodule
Textualy, the files in lib/uzlib/src were identical to the ones committed
in extmod/uzlib so there should be no behavioral change possible as a
result of this commit.
2018-05-07 20:03:30 -05:00
Scott Shawcroft 7dd1d6afcc Prevent a heap pointer from living on the stack longer than we need. 2018-04-09 16:02:32 -07:00
Damien George 23f07b77e5 lib/stm32lib: Update library for fix to H7 SPI strict aliasing error. 2018-03-25 23:58:56 +11:00
Damien George e22ef277b8 lib/stm32lib: Update library to include support for STM32H7 MCUs.
Now points to the branch: work-F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1
2018-03-09 14:31:34 +11:00
microbuilder ea30622318 Updated nrfutil to 0.5.2b for nRF52840 erase time fix 2018-02-16 16:01:33 +01:00
Damien George d9b9fbc41a lib/utils/pyexec: Update to work with new MICROPY_HW_ENABLE_USB option. 2018-02-13 18:56:12 +11:00
Damien George 925c5b1da2 lib/utils/pyexec.h: Include py/obj.h because its decls are needed. 2018-01-31 18:21:07 +11:00
Dan Halbert 065e82015f merge from 2.2.0 + fix up board defs 2018-01-02 21:25:41 -05:00
microbuilder 60a23f0fb6 nRF52 update with internal file system support 2017-12-21 13:49:14 +01:00
Paul Sokolovsky f4ed2dfa94 lib/tinytest: Clean up test reporting in the presence of stdout output.
tinytest is written with the idea that tests won't write to stdout, so it
prints test name witjout newline, then executes test, then writes status.
But MicroPython tests write to stdout, so the test output becomes a mess.
So, instead print it like:

    # starting basics/andor.py
    ... test output ...
    basics/andor.py: OK
2017-12-15 19:41:08 +02:00
Paul Sokolovsky 140bbced6f lib/upytesthelper: MicroPython test helper layer on top of tinytest.
Tinytest is classical assert-style framework, but MicroPython tests work
in different way - they produce content, and that content should be matched
against expected one to see if test passes. upytesthelper exactly adds
helper functions to make that possible.
2017-12-13 09:07:51 +02:00
Paul Sokolovsky e9d29c9ba9 lib/tinytest: Move from tools/tinytest.
Tinytest library was misplaced under tools/. By convention, any target
libraries belong to lib/, while tools/ contains host-side tools.
2017-12-08 19:26:15 +02:00
Kevin Townsend ce75a21e50 Revert "Supervisor REPL support for ports/nrf/boards/feather52"
This reverts commit 92113dde81.
2017-11-23 13:38:38 +01:00
Kevin Townsend 92113dde81 Supervisor REPL support for ports/nrf/boards/feather52 2017-11-23 09:22:11 +01:00
Damien George 4601759bf5 py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.
This patch simplifies the str creation API to favour the common case of
creating a str object that is not forced to be interned.  To force
interning of a new str the new mp_obj_new_str_via_qstr function is added,
and should only be used if warranted.

Apart from simplifying the mp_obj_new_str function (and making it have the
same signature as mp_obj_new_bytes), this patch also reduces code size by a
bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
2017-11-16 13:17:51 +11:00
Paul Sokolovsky 99bf5448bd axtls: Update, exposes AES functions to implement ECB chiper mode. 2017-11-05 11:37:05 +02:00
Scott Shawcroft 7b393bc406 Merge tag 'v1.9.3'
Introduction of ports subdirectory where all ports are moved to

The main change in this release is the introduction of a "ports/"
subdirectory at the top-level of the repository, and all of the ports are
moved here.  In the process the "stmhal" port is renamed to "stm32" to
better reflect the MCU that it targets.  In addition, the STM32 CMSIS and
HAL sources are moved to a new submodule called "stm32lib".

The bytecode has changed in this release, compared to the previous release,
and as a consequence the .mpy version number has increased to version 3.
This means that scripts compiled with the previous mpy-cross must be
recompiled to work with this new version.

There have also been various enhancements and optimisations, such as:
check for valid UTF-8 when creating str objects, support for reverse
special binary operations like __radd__, full domain checking in the math
module, support for floor-division and modulo in the viper emitter,
and addition of stack overflow checking when executing a regex.

The stm32 port sees improved support for F7 MCUs, addition of a new board
B_L475E_IOT01A based on the STM32L475, and support for the Wiznet W5500
chipset along with improved socket behaviour.

A detailed list of changes follows.

py core:
- objstr: startswith, endswith: check arg to be a string
- nlrx86,x64: replace #define of defined() with portable macro usage
- objtype: handle NotImplemented return from binary special methods
- objtype: mp_obj_class_lookup: improve debug logging
- map: remove unused new/free functions
- make m_malloc_fail() have void return type, since it doesn't return
- modstruct: in struct.pack, stop converting if there are no args left
- modstruct: check and prevent buffer-read overflow in struct unpacking
- modstruct: check and prevent buffer-write overflow in struct packing
- nlrthumb: get working again on standard Thumb arch (ie not Thumb2)
- objfloat: fix binary ops with incompatible objects
- obj: fix comparison of float/complex NaN with itself
- objtype: implement fallback for instance inplace special methods
- objtuple: properly implement comparison with incompatible types
- objstr: add check for valid UTF-8 when making a str from bytes
- objlist: properly implement comparison with incompatible types
- runtime0.h: move relational ops to the beginning of mp_binary_op_t
- runtime0.h: move MP_BINARY_OP_DIVMOD to the end of mp_binary_op_t
- objtype: make sure mp_binary_op_method_name has full size again
- runtime0.h: put inplace arith ops in front of normal operations
- builtinhelp: simplify code slightly by extracting object type
- runtime: implement dispatch for "reverse op" special methods
- nlrx86: fix building for Android/x86
- builtinhelp: change signature of help text var from pointer to array
- runtime.h: change empty mp_warning macro so var-args are non empty
- modbuiltins: implement abs() by dispatching to MP_UNARY_OP_ABS
- {objfloat,objcomplex}: optimise MP_UNARY_OP_ABS by reusing variables
- mpconfig.h: add note that using computed gotos in VM is not C99
- objstr: strip: don't strip "\0" by default
- objexcept: prevent infinite recursion when allocating exceptions
- stream: remove unnecessary checks for NULL return from vstr_add_len
- vstr: raise a RuntimeError if fixed vstr buffer overflows
- vm: use lowercase letter at start of exception message
- persistentcode: define mp_raw_code_save_file() for any unix target
- add config option to print warnings/errors to stderr
- objfloat: support raising a negative number to a fractional power
- objset: simplify set and frozenset by separating their locals dicts
- objset: check that RHS of a binary op is a set/frozenset
- objset: include the failed key in a KeyError raised from set.remove
- objtype: change type of enum-to-qstr table to uint16_t to save space
- objstr: make empty bytes object have a null-terminating byte
- mpprint: only check for null string printing when NDEBUG not defined
- objtype: clean up unary- and binary-op enum-to-qstr mapping tables
- persistentcode: bump .mpy version number to version 3
- bc: update opcode_format_table to match the bytecode
- modmath: add full checks for math domain errors
- modmath: convert log2 macro into a function
- formatfloat: don't print the negative sign of a NaN value
- formatfloat: use standard isinf, isnan funcs instead of custom ones
- modbuiltins: use existing utf8_get_char helper in builtin ord func
- emitnative: implement floor-division and modulo for viper emitter
- objtype: use CPython compatible method name for sizeof
- objtype: fit qstrs for special methods in byte type
- objtype: define all special methods if requested
- objtype: introduce MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS

extmod:
- modubinascii: only include uzlib/tinf.h when it's really needed
- modussl_mbedtls: allow to compile with MBEDTLS_DEBUG_C disabled
- machine_pinbase: put PinBase singleton in ROM
- re1.5: upgrade to v0.8.2, adds hook for stack overflow checking
- modure: add stack overflow checking when executing a regex
- uos_dupterm: update uos.dupterm() and helper funcs to have index
- uos_dupterm: swallow any errors from dupterm closing the stream
- vfs: replace VLA in proxy func with small, static sized array
- modussl: add finaliser support for ussl objects
- modussl_mbedtls: allow to compile with unix coverage build

lib:
- add new submodule, stm32lib containing STM32 CMSIS and HAL source
- embed/abort_: use mp_raise_msg helper function
- libm: fix tanhf so that it correctly handles +/- infinity args
- libm: remove implementation of log2f, use MP_NEED_LOG2 instead
- axtls: update, support for SSL_EAGAIN return code
- berkeley-db-1.xx: update, allow to override MINCACHE, DEFPSIZE

drivers:
- memory/spiflash: change from hard-coded soft SPI to generic SPI
- display/ssd1306.py: improve performance of graphics methods
- nrf24l01: make nRF24L01 test script more portable
- display/ssd1306: implement SSD1306_I2C poweron method
- display/ssd1306: make poweron() work the same with SSD1306_SPI
- wiznet5k: improve the performance of socket ops with threading
- wiznet5k: get low-level W5500 driver working

tools:
- upip: upgrade to 1.2.2
- pyboard: use repr() when quoting data in error messages
- pyboard: update docstring for additional device support

tests:
- object_new: better messages, check user __new__() method
- class_new: add checks for __init__ being called and other improvements
- class_new: add another testcase for __new__/__init__ interaction
- class_inplace_op: test for inplace op fallback to normal one
- run-bench-tests: update locations of executables, now in ports/
- class_reverse_op: test for reverse arith ops special methods
- run-tests: skip class_inplace_op for minimal profile
- run-tests: fix copy-paste mistake in var name
- cpydiff: add cases for locals() discrepancies
- extmod: add test for ure regexes leading to infinite recursion
- extmod: add test for '-' in character class in regex
- run-tests: close device under test using "finally"
- net_inet: update tls test to work with CPython and incl new site

unix port:
- rename modsocket.c to modusocket.c
- modusocket: remove #if MICROPY_SOCKET_EXTRA code blocks
- enable MICROPY_PY_REVERSE_SPECIAL_METHODS

stm32 port:
- modmachine: make machine.bootloader() work when MPU is enabled
- modmachine: improve support for sleep/deepsleep on F7 MCUs
- compute PLL freq table during build instead of at run time
- modmachine: for F7 MCU, save power by reducing internal volt reg
- boards/pllvalues.py: make script work with both Python 2 and 3
- Makefile: use lib/stm32lib instead of local cmsis and hal files
- remove cmsis and hal files, they are now a submodule
- Makefile: automatically fetch stm32lib submodule if needed
- update to new STM Cube HAL library
- fix clock initialisation of L4 MCUs
- rename stmhal port directory to stm32
- remove unused usbd_msc.c file
- boards: change remaining stm32f4xx_hal_conf.h to unix line ending
- boards: change linker scripts to use "K" instead of hex byte size
- boards: fix I2C1 pin mapping on NUCLEO_F401RE/F411RE boards
- i2c: when scanning for I2C devices only do 1 probe per address
- modnwwiznet5k: release the GIL on blocking network operations
- boards: add new board B_L475E_IOT01A based on STM32L475
- make-stmconst.py: make sure mpz const data lives in ROM
- timer: make pyb.Timer() instances persistent
- mpconfigport.h: add configuration for max periphs on L4 series
- usbdev: make the USBD callback struct const so it can go in ROM
- usbdev: change static function variable to non-static
- usbdev: put all CDC state in a struct
- usbdev: put all HID state in a struct
- usbdev: simplify CDC tx/rx buffer passing
- usbdev: simplify HID tx/rx buffer passing
- usbdev/core: add state parameter to all callback functions
- usbdev: put all state for the USB device driver in a struct
- usbdev: simplify pointers to MSC state and block dev operations
- usbdev: merge all global USB device state into a single struct
- usbdev: make device descriptor callbacks take a state pointer
- usbdev: move all the USB device descriptor state into its struct
- timer: enable ARPE so that timer freq can be changed smoothly
- modnwwiznet5k: get the IP address of an established socket
- boards: fix typos in stm32f767_af.csv table
- usbd_cdc_interface: don't reset CDC output buf on initialisation
- modnwwiznet5k: implement WIZNET5K.isconnected() method
- modusocket: make getaddrinfo() work when passed an IP address
- modusocket: return OSError(-2) if getaddrinfo fails
- mpconfigport.h: add MICROPY_THREAD_YIELD() macro
- modnwwiznet5k: add support for W5500 Ethernet chip
- modnwwiznet5k: increase SPI bus speed to 42MHz
- modnwwiznet5k: implement stream ioctl for the Wiznet driver
- mphalport: improve efficiency of mp_hal_stdout_tx_strn_cooked
- make uos.dupterm() conform to specs by using extmod version

cc3200 port:
- enable micropython.kbd_intr() method
- use standard implementation of keyboard interrupt

esp8266 port:
- rename axtls_helpers.c to posix_helpers.c
- posix_helpers: set ENOMEM on memory alloc failure
- set DEFPSIZE=1024, MINCACHE=3 for "btree" module
- esp_mphal: send data in chunks to mp_uos_dupterm_tx_strn
- modnetwork: add "bssid" keyword arg to WLAN.connect() method
- modules/webrepl_setup: add info about allowed password length

zephyr port:
- Makefile: revamp "test" target after ports were moved to ports/
- use CONFIG_NET_APP_SETTINGS to setup initial network addresses
- switch to interrupt-driven pull-style console

pic16bit port:
- add definition of SEEK_SET to unistd.h

docs:
- pyboard/tutorial: add "timeout=0" to UART in pass-through example
- more xrefs to "MicroPython port" in glossary
- library/network: fix ref to "socket" module (should be "usocket")
- machine.Signal: improve style/grammar and add usage example
- library: add description of "index" parameter to uos.dupterm()
- library/micropython: fix typo in RST formatting
- library/framebuf.rst: generalise constructor to all colour formats
- btree: describe page caching policy of the underlying implementation
- esp8266/tutorial: update neopixel with example of using 4 bbp
- library/network: clarify usage of "bssid" arg in connect() method
- pyboard/quickref: add info for Switch, RTC, CAN, Accel classes
- pyboard/tutorial: update now that yellow LED also supports PWM
- esp8266/quickref: add quickref info for RTC class
- library: add missing cross-ref links for classes in pyb module
- library/network: update docs to state that W5500 is supported
- uselect: document one-shot polling mode
- usocket: elaborate descriptions
- usocket: document inet_ntop(), inet_pton()
- library/network: add dhcp_hostname parameter
- reference/isr_rules: minor typo correction
- ussl: fix module name refs and use "MicroPython port" term
- esp8266/general: add section on TLS limitations
- usocket: document that settimeout() isn't supported by all ports
- ure: add "|" (alternative) to the list of supported operators
- reference/isr_rules.rst: add tutorial on use of micropython.schedule()

travis:
- use --upgrade when pip is installing cpp-coveralls
- update build command now that stm32 Wiznet config has changed

examples:
- hwconfig_console: add .on()/.off() methods

all:
- convert mp_uint_t to mp_unary_op_t/mp_binary_op_t where appropriate
- convert remaining "mp_uint_t n_args" to "size_t n_args"
- make new ports/ sub-directory and move all ports there
- update Makefiles and others to build with new ports/ dir layout
- remove inclusion of internal py header files
- use NULL instead of "" when calling mp_raise exception helpers

README:
- update "Dependencies" section
- add explicit section on contributing
- add gcc and arm-none-eabi-newlib to list of required components

.gitattributes:
- remove obsolete entries for stmhal/hal, stmhal/cmsis
- add entries for files that will move to ports/ dir
2017-11-02 12:41:50 -07:00
Paul Sokolovsky 8f9af63c20 lib/axtls: Update, support for SSL_EAGAIN return code.
A step towards implementing non-blocking stream support for SSL.
2017-10-29 19:53:59 +02:00
Scott Shawcroft 00766e43a0 Merge commit 'f57be61' into nrf2_merge 2017-10-24 23:26:41 -07:00
Scott Shawcroft 73c15dcf8b Merge commit 'f869d6b2e339c04469c6c9ea3fb2fabd7bbb2d8c' into nrf2_merge
This is prep for merging in the NRF5 pull request.
2017-10-24 22:31:16 -07:00
Dan Halbert 6df99b5d0e Merge 2.1.0 changes into master. 2017-10-23 15:26:36 -07:00
Damien George 81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Glenn Ruben Bakke bcab2ba0a8 ports/nrf: Upmerging port with upstream master 2017-10-04 21:45:04 +02:00
Damien George f869d6b2e3 lib/libm: Fix tanhf so that it correctly handles +/- infinity args. 2017-10-04 21:14:00 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George d36539df06 lib/embed/abort_: Use mp_raise_msg helper function. 2017-09-22 11:31:00 +10:00
Paul Sokolovsky e41bc3fcbb berkeley-db-1.xx: Update, allow to override MINCACHE, DEFPSIZE. 2017-09-10 13:51:51 +03:00
Dan Halbert acbca44512 Ctrl-C was causing a soft-reset in REPL.
Also allow an immediate ctrl-c in `input()`.
2017-09-06 14:47:23 -07:00
Damien George 8388ec4e35 stmhal: Update to new STM Cube HAL library.
This upgrades the HAL to the versions:
- F4 V1.16.0
- F7 V1.7.0
- L4 V1.8.1

The main changes were in the SD card driver.  The vendor changed the SD
read/write functions to accept block number intead of byte address, so
there is no longer any need for a custom patch for this in stm32lib.
The CardType values also changed, so pyb.SDCard().info() will return
different values for the 3rd element of the tuple, but this function was
never documented.
2017-08-29 17:03:28 +10:00
Damien George 904eb2d9f3 lib: Add new submodule, stm32lib containing STM32 CMSIS and HAL source.
Linked to https://github.com/micropython/stm32lib
2017-08-29 13:39:09 +10:00
Dan Halbert c679c80c71 Modernize module and class static dicts; update freetouch 2017-08-27 15:02:50 -04:00
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00
Javier Candeira 35a1fea90b all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError
  - OSError invocations unchanged, because the corresponding utility
    function takes ints, not strings like the long form invocation.
  - OverflowError, IndexError and RuntimeError etc. not changed for now
    until we decide whether to add new utility functions.
2017-08-13 22:52:33 +10:00
Scott Shawcroft fab634e3ee Turn on Rosie CI testing to test new builds on real hardware.
This introduces a skip_if module that can be used by tests to
determine when they should be skipped due to the environment.

Some tests have been split in order to have finer grained skip
control.
2017-08-11 17:16:13 -07:00
Daniel Tralamazza b53b691314 Merge remote-tracking branch 'upstream/master' 2017-08-08 00:45:58 +02:00
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00