From a version numbering point of view this is a downgrade (2.17.0 ->
2.16.x). However the latest commit for version 2.17.0 is from March 2019
and no further minor release happened after 2.17.0. This version is EOL.
2.16.x though is still actively maintained as a long term release, hence
security and stability fixes are still being backported, including
compatibility with upcoming compiler releases.
The rp2040 is _very_ marginal for mp3 playback, and currently sometimes triggers a bug that gives garbled audio output. However, it does work for some limited situations.
Also found a race condition between timer_disable and redraw, which
would happen if I debugger-paused inside common_hal_rgbmatrix_timer_disable
or put a delay or print inside it. That's what pausing inside reconstruct
fixes.
So that the "right timer" can be chosen, `timer_allocate` now gets the `self`
pointer. It's guaranteed at this point that the pin information is accurate,
so you can e.g., find a PWM unit related to the pins themselves.
This required touching each port to add the parameter even though it's
unused everywhere but raspberrypi.
This was added a long time ago in 75abee206d
when USB host support was added to the stm (now stm32) port, and when this
pyexec code was actually part of the stm port. It's unlikely to work as
intended anymore. If it is needed in the future then generic hook macros
can be added in pyexec.
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.
Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
This library is a small and easy-to-use cryptographic library which is well
suited to embedded systems.
Signed-off-by: Damien George <damien@micropython.org>
uzlib isn't actually used in any firmwares, but is built into the
"unix" port used for testing.
The main benefit of the update is to fix problems encountered on
Windows, as the old ref of uzlib had filenames with embedded colons;
this has been fixed upstream.
uzlib seems to have been reabsed since the version that we took; this
doesn't really matter to us.
Background: the friendly/normal REPL is intended for human use whereas the
raw REPL is for computer use/automation. Raw REPL is used for things like
pyboard.py script_to_run.py. The normal REPL has built-in flow control
because it echos back the characters. That's not so with raw REPL and flow
control is just implemented by rate limiting the amount of data that goes
in. Currently it's fixed at 256 byte chunks every 10ms. This is sometimes
too fast for slow MCUs or systems with small stdin buffers. It's also too
slow for a lot of higher-end MCUs, ie it could be a lot faster.
This commit adds a new raw REPL mode which includes flow control: the
device will echo back a character after a certain number of bytes are sent
to the host, and the host can use this to regulate the data going out to
the device. The amount of characters is controlled by the device and sent
to the host before communication starts. This flow control allows getting
the maximum speed out of a serial link, regardless of the link or the
device at the other end.
Also, this new raw REPL mode parses and compiles the incoming data as it
comes in. It does this by creating a "stdin reader" object which is then
passed to the lexer. The lexer requests bytes from this "stdin reader"
which retrieves bytes from the host, and does flow control. What this
means is that no memory is used to store the script (in the existing raw
REPL mode the device needs a big buffer to read in the script before it can
pass it on to the lexer/parser/compiler). The only memory needed on the
device is enough to parse and compile.
Finally, it would be possible to extend this new raw REPL to allow bytecode
(.mpy files) to be sent as well as text mode scripts (but that's not done
in this commit).
Some results follow. The test was to send a large 33k script that contains
mostly comments and then prints out the heap, run via pyboard.py large.py.
On PYBD-SF6, prior to this PR:
$ ./pyboard.py large.py
stack: 524 out of 23552
GC: total: 392192, used: 34464, free: 357728
No. of 1-blocks: 12, 2-blocks: 2, max blk sz: 2075, max free sz: 22345
GC memory layout; from 2001a3f0:
00000: h=hhhh=======================================hhBShShh==h=======h
00400: =====hh=B........h==h===========================================
00800: ================================================================
00c00: ================================================================
01000: ================================================================
01400: ================================================================
01800: ================================================================
01c00: ================================================================
02000: ================================================================
02400: ================================================================
02800: ================================================================
02c00: ================================================================
03000: ================================================================
03400: ================================================================
03800: ================================================================
03c00: ================================================================
04000: ================================================================
04400: ================================================================
04800: ================================================================
04c00: ================================================================
05000: ================================================================
05400: ================================================================
05800: ================================================================
05c00: ================================================================
06000: ================================================================
06400: ================================================================
06800: ================================================================
06c00: ================================================================
07000: ================================================================
07400: ================================================================
07800: ================================================================
07c00: ================================================================
08000: ================================================================
08400: ===============================================.....h==.........
(349 lines all free)
(the big blob of used memory is the large script).
Same but with this PR:
$ ./pyboard.py large.py
stack: 524 out of 23552
GC: total: 392192, used: 1296, free: 390896
No. of 1-blocks: 12, 2-blocks: 3, max blk sz: 40, max free sz: 24420
GC memory layout; from 2001a3f0:
00000: h=hhhh=======================================hhBShShh==h=======h
00400: =====hh=h=B......h==.....h==....................................
(381 lines all free)
The only thing in RAM is the compiled script (and some other unrelated
items).
Time to download before this PR: 1438ms, data rate: 230,799 bits/sec.
Time to download with this PR: 119ms, data rate: 2,788,991 bits/sec.
So it's more than 10 times faster, and uses significantly less RAM.
Results are similar on other boards. On an stm32 board that connects via
UART only at 115200 baud, the data rate goes from 80kbit/sec to
113kbit/sec, so gets close to saturating the UART link without loss of
data.
The new raw REPL mode also supports a single ctrl-C to break out of this
flow-control mode, so that a ctrl-C can always get back to a known state.
It's also backwards compatible with the original raw REPL mode, which is
still supported with the same sequence of commands. The new raw REPL
mode is activated by ctrl-E, which gives an error on devices that do not
support the new mode.
Signed-off-by: Damien George <damien@micropython.org>
This brings in the following, and updates us to the 1.0.4 release tag:
Submodule lib/protomatter 2a1ba8fa4..5f07ec618:
> Bumping version for release
> Merge pull request #21 from makermelissa/master
> Merge pull request #20 from makermelissa/master
> Merge pull request #18 from jepler/fix-cpy-3184
> Merge pull request #14 from hierophect/cpy-timer-allocator
We previously had the _changes_ of jepler/fix-cpy-3184 and
hierophect/cpy-timer-allocator but not their merge commits.
The only other changes in protomatter were one formatting change in the
core, plus several Arduino sketches. So this should make no practical
difference for CPy.
For time-based functions that work with absolute time there is the need for
an Epoch, to set the zero-point at which the absolute time starts counting.
Such functions include time.time() and filesystem stat return values. And
different ports may use a different Epoch.
To make it clearer what functions use the Epoch (whatever it may be), and
make the ports more consistent with their use of the Epoch, this commit
renames all Epoch related functions to include the word "epoch" in their
name (and remove references to "2000").
Along with this rename, the following things have changed:
- mp_hal_time_ns() is now specified to return the number of nanoseconds
since the Epoch, rather than since 1970 (but since this is an internal
function it doesn't change anything for the user).
- littlefs timestamps on the esp8266 have been fixed (they were previously
off by 30 years in nanoseconds).
Otherwise, there is no functional change made by this commit.
Signed-off-by: Damien George <damien@micropython.org>
mp_irq_init() is useful when the IRQ object is allocated by the caller.
The mp_irq_methods_t.init method is not used anywhere so has been removed.
Signed-off-by: Damien George <damien@micropython.org>
e.g., allocating a 192x32x6bpp matrix would be enough to trigger this
reliably on a Metro M4 Express using the "memory hogging" layout.
Allocating 64x32x6bpp could trigger it, but somewhat unreliably.
There are several things going on here:
* we make the failing call with interrupts off
* we were throwing an exception with interrupts off
* protomatter failed badly in _PM_free when it was partially-initialized
Incorporate the fix from protomatter, switch to a non-throwing malloc
variant, and ensure that interrupts get turned back on.
This decreases the quality of the MemoryError (it cannot report the size
of the failed allocation) but allows CircuitPython to survive, rather
than faulting.
In relatively unusual circumstances, such as entering `l = 17 ** 17777`
at the REPL, you could hit ctrl-c, but not get KeyboardInterrupt.
This can lead to a condition where the display would stop updating (#2689).
Currently when a utf8 character that is bigger than 1 byte is typed in
the repl, it isn't handled how it should be. If you try to move the
cursor in any direction the text gets messed up. This fixes that.
This array was of 32-bit values, but the entries were only ever
in the 0-255 range. Convert to uint8_t.
Testing performed: The result of the sum-of-sin was unchanged
>>> import math; sum(math.sin(2.**i) for i in range(21))
1.42069
This function computes the remainder of a value `x` modulo pi/2, to high
precision.
It does this by dividing the flotaing point values into several ranges
by magnitude, and applies successively slower but more accurate algorithms.
The last two steps, one covering values up to around 2^7 * pi/2
(called "medium size") and a final one covering all possible float values,
require big tables.
By eliminating the "medium size" case, a table and some code are removed
from the binary. This makes some cases take longer, but saves hundreds
of bytes. It does _NOT_ affect the result, only the speed.
```
[desktop python]
>>> sum(math.sin(2.**i) for i in range(21))
1.4206898748939305
[trinket m0, before change to ef_rem_pio2.c]
>>> sum(math.sin(2.**i) for i in range(21))
1.42069
[trinket m0, after change to ef_rem_pio2.c]
>>> sum(math.sin(2.**i) for i in range(21))
1.42069
```
Fixing 98e583430f, the semantics of strncpy
require that the remainder of dst be filled with null bytes.
Signed-off-by: Damien George <damien@micropython.org>
This code is imported from musl, to match existing code in libm_dbl.
The file is also added to the build in stm32/Makefile. It's not needed by
the core code but, similar to c5cc64175b,
allows round() to be used by user C modules or board extensions.
Changes in this new library version are:
- Update H7 HAL to v1.6.0.
- Update WB HAL to v1.6.0.
- Add patches to fix F4 ll_uart clock selection for UART9/UART10.
Signed-off-by: Damien George <damien@micropython.org>
The file `mbedtls_errors/mp_mbedtls_errors.c` can be used instead of
`mbedtls/library/error.c` to give shorter error strings, reducing the build
size of the error strings from about 12-16kB down to about 2-5kB.
So it can be unconditionally included in a port's build even if certain
configurations in that port do not use its features, to simplify the
Makefile.
Signed-off-by: Damien George <damien@micropython.org>
With only `sp_func_proto_paren = remove` set there are some cases where
uncrustify misses removing a space between the function name and the
opening '('. This sets all of the related options to `force` as well.
This update gives us access to a function we can run with interrupts
disabled to determine if the queue is empty.
Signed-off-by: Sean Cross <sean@xobs.io>
No functionality change is intended with this commit, it just consolidates
the separate implementations of GC helper code to the lib/utils/ directory
as a general set of helper functions useful for any port. This reduces
duplication of code, and makes it easier for future ports or embedders to
get the GC implementation correct.
Ports should now link against gchelper_native.c and either gchelper_m0.s or
gchelper_m3.s (currently only Cortex-M is supported but other architectures
can follow), or use the fallback gchelper_generic.c which will work on
x86/x64/ARM.
The gc_helper_get_sp function from gchelper_m3.s is not really GC related
and was only used by cc3200, so it has been moved to that port and renamed
to cortex_m3_get_sp.
This change is made for two reasons:
1. A 3rd-party library (eg berkeley-db-1.xx, axtls) may use the system
provided errno for certain errors, and yet MicroPython stream objects
that it calls will be using the internal mp_stream_errno. So if the
library returns an error it is not known whether the corresponding errno
code is stored in the system errno or mp_stream_errno. Using the system
errno in all cases (eg in the mp_stream_posix_XXX wrappers) fixes this
ambiguity.
2. For systems that have threading the system-provided errno should always
be used because the errno value is thread-local.
For systems that do not have an errno, the new lib/embed/__errno.c file is
provided.
Note: the uncrustify configuration is explicitly set to 'add' instead of
'force' in order not to alter the comments which use extra spaces after //
as a means of indenting text for clarity.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
.. 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
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
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
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.
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.
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.
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.
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.
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".
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.
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.
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.
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().
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.
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)
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
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.
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.
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.