aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf
AgeCommit message (Collapse)Author
2021-02-13nrf/drivers/usb: Add USBD_IRQHandler which calls tud_int_handler.Damien George
This is needed for TinyUSB to process USB device IRQs. Related to #6325. Signed-off-by: Damien George <damien@micropython.org>
2021-02-12ports: Update to build with new tinyusb.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-02-04all: Rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD.Damien George
The "word" referred to by BYTES_PER_WORD is actually the size of mp_obj_t which is not always the same as the size of a pointer on the target architecture. So rename this config value to better reflect what it measures, and also prefix it with MP_. For uses of BYTES_PER_WORD in setting the stack limit this has been changed to sizeof(void *), because the stack usually grows with machine-word sized values (eg an nlr_buf_t has many machine words in it). Signed-off-by: Damien George <damien@micropython.org>
2021-02-04ports: Remove def of MP_PLAT_PRINT_STRN if it's the same as the default.Damien George
To simplify config, there's no need to specify MP_PLAT_PRINT_STRN if it's the same as the default definition in py/mpconfig.h. Signed-off-by: Damien George <damien@micropython.org>
2021-01-30nrf/README: Add use of "make submodules" in alternative build paragraph.Chris Hemingway
Add "make submodules" to commands when building for the first time. Otherwise, on a first time build, the submodules have not been checked out and a lot of `fatal error: nrfx.h: No such file or directory` errors are printed.
2020-12-07nrf: Change selected boards to utilize pre-flashed bootloader.Glenn Ruben Bakke
The nrf52840-mdk-usb-dongle and pca10050 comes with a pre-flashed bootloader (OpenBootloader). This commit updates the boards "mpconfigboard.mk" to use DFU as default flashing method and set the corresponding BOOTLOADER settings such that nrf52840_open_bootloader_1.2.x.ld linker script is used. The default DFU flashing method can be disabled by issuing "DFU=0" when invoking make. This will lead to "segger" being used as default flashing tool. When using "DFU=0", the linker scripts will not compensate for any MBR and Bootloader region being present, and might overwrite them if they were present. The commit also removes the custom linker script specific to nrf52840-mdk-usb-dongle as it now points to a generic. Updated nrf52840-mdk-usb-dongle's README.md to be more clear on how to deploy the built firmware. The port README.md has also been updated. In the list of target boards a new column has been added to indicate which bootloader is present on the target board. And for consistency, changed all examples in the README.md to use "deploy" instead of "flash".
2020-12-07nrf/boards: Add linker script for nrf52840 Open Bootloader 1.2.0.Glenn Ruben Bakke
2020-12-07nrf/Makefile: Add support for flashing with nrfutil.Glenn Ruben Bakke
An additional Makefile parameter NRFUTIL_PORT can be set in order to define the serial port to used for the DFU (Default: /dev/ttyACM0). The "nrfutil" that is used as flasher towards OpenBootloader is available for installation through Python "pip". In case of SD=s140, SoftDevice ID 0xB6 is passed to nrfutil's package generation which corresponds to SoftDevice s140 v6.1.1.
2020-12-07nrf/Makefile: Add bootloader specific section.Glenn Ruben Bakke
Add the option for "mpconfigboard.mk" to define whether the board hosts a bootloader or not. The BOOTLOADER make variable must be set to the name of the bootloader. When the BOOTLOADER name is set it is also required to supply the BOOTLOADER_VERSION_MAJOR and the BOOTLOADER_VERSION_MINOR from the "mpconfigboards.mk". These will be used to resolve which bootloader linker script that should be passed to the linker. The BOOTLOADER section also supplies the C-compiler with BOOTLOADER_<bootloader name>=<version major><version minor> as a compiler define. This is for future use in case a bootloader needs to do modification to the startup files or similar (like setting the VTOR specific to a version of a bootloader).
2020-12-07nrf/boards: Update memory.ld to include bootloader offsets.Glenn Ruben Bakke
Adding variables that can be set from other linker scripts: - _bootloader_head_size: Bootloader flash offset in front of the application. - _bootloader_tail_size: Bootloader offset from the tail of the flash. In case the bootloader is located at the end. - _bootloader_head_ram_size: Bootloader RAM usage in front of the application. Updated calculations of application flash and RAM.
2020-11-23extmod/machine_i2c: Add init protocol method for generic I2C bindings.Damien George
Hardware I2C implementations must provide a .init() protocol method if they want to support reconfiguration. Otherwise the default is that i2c.init() raises an OSError (currently the case for all ports). mp_machine_soft_i2c_locals_dict is renamed to mp_machine_i2c_locals_dict to match the generic SPI bindings. Fixes issue #6623 (where calling .init() on a HW I2C would crash). Signed-off-by: Damien George <damien@micropython.org>
2020-11-22nrf/README: Describe Pin numbering scheme for nRF52840.JPFrancoia
Clarify that the nRF52840's GPIO 1.00 to 1.15 maps to Pin(32-47) in MicroPython.
2020-10-17ports: Use correct in/out endpoint size in TUD_CDC_DESCRIPTOR.Damien George
The last argument of TUD_CDC_DESCRIPTOR() is the endpoint size (or wMaxPacketSize), not the CDC RX buffer size (which can be larger than the endpoint size). Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Support legacy soft I2C/SPI construction via id=-1 arg.Damien George
With a warning that this way of constructing software I2C/SPI is deprecated. The check and warning will be removed in a future release. This should help existing code to migrate to the new SoftI2C/SoftSPI types. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Add SoftI2C and SoftSPI to machine module where appropriate.Damien George
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Remove "id" arg in SoftI2C constructor.Damien George
The SoftI2C constructor is now used soley to create SoftI2C instances, it can no longer delegate to create a hardware-based I2C instance. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Rename type to SoftI2C and add custom print method.Damien George
Also rename machine_i2c_type to mp_machine_soft_i2c_type. These changes make it clear that it's a soft-I2C implementation, and match SoftSPI. Signed-off-by: Damien George <damien@micropython.org>
2020-09-09nrf: Remove unnecessary includes of mpconfigport.h and its header guard.Damien George
The mpconfigport.h file is an internal header and should only ever be included once by mpconfig.h. Signed-off-by: Damien George <damien@micropython.org>
2020-09-09nrf/main: Make mp_builtin_open signature match that in py/builtin.h.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-08-29all: Update Python code to conform to latest black formatting.Damien George
Updating to Black v20.8b1 there are two changes that affect the code in this repository: - If there is a trailing comma in a list (eg [], () or function call) then that list is now written out with one line per element. So remove such trailing commas where the list should stay on one line. - Spaces at the start of """ doc strings are removed. Signed-off-by: Damien George <damien@micropython.org>
2020-08-26nrf/Makefile: Improve user C modules support.Roberto Colistete Jr
Add CFLAGS_EXTRA to CFLAGS. Include LDFLAGS_MOD to the compilation. And, add SRC_MOD to SRC_QSTR.
2020-07-22nrf: Enable more features for all targets.Glenn Ruben Bakke
Enabling the following features for all targets, except for nrf51 targets compiled to be used with SoftDevice: - MICROPY_PY_ARRAY_SLICE_ASSIGN - MICROPY_PY_SYS_STDFILES - MICROPY_PY_UBINASCII
2020-07-22nrf: Split mpconfigport.h into multiple files.Glenn Ruben Bakke
Splitting mpconfigport.h into multiple device specific files in order to facilitate variations between devices. Due to the fact that the devices might have variations in features and also variations in flash size it makes sense that some devices offers more functionality than others without being limited by restricted devices. For example more micropython features can be activated for nrf52840 with 1MB flash, compared to nrf51 with 256KB.
2020-07-16nrf: Add board definition for nRF52840-MDK-USB-Dongle.Matt Trentini
2020-07-16nrf/boards: Enable RTCounter machine module for nrf9160 boards.Glenn Ruben Bakke
Resolves dependencies for MICROPY_PY_TIME_TICKS which requires to link against nrfx_rtc.c functions by setting MICROPY_PY_MACHINE_RTCOUNTER to 1.
2020-07-16nrf/nrfx_config: Disable RTC2 for nRF9160 targets.Glenn Ruben Bakke
nRF9160 does not have any RTC2. Disable the configuration in case of NRF9160_XXAA.
2020-07-10nrf/boards: Add initial support for Actinius Icarus.Alex Tsamakos
Example make command: make BOARD=actinius_icarus
2020-07-08nrf: Enable nrf tick support on all boards by default.Martin Fischer
Having time.ticks_ms/us/add/diff is very useful and used by many drivers, libraries and components.
2020-07-08nrf: Add support for time.ticks_xxx functions using RTC1.Martin Fischer
This commit adds time.ticks_ms/us support using RTC1 as the timebase. It also adds the time.ticks_add/diff helper functions. This feature can be enabled using MICROPY_PY_TIME_TICKS. If disabled the system uses the legacy sleep methods and does not have any ticks functions. In addition support for MICROPY_EVENT_POLL_HOOK was added to the time.sleep_ms(x) function, making this function more power efficient and allows support for select.poll/asyncio. To support this, the RTC's CCR0 was used to schedule a ~1msec event to wakeup the CPU. Some important notes about the RTC timebase: - Since the granularity of RTC1's ticks are approx 30usec, time.ticks_us is not perfect, does not have 1us resolution, but is otherwise quite usable. For tighter measurments the ticker's 1MHz counter should be used. - time.ticks_ms(x) should *not* be called in an IRQ with higher prio than the RTC overflow irq (3). If so it introduces a race condition and possibly leads to wrong tick calculations. See #6171 and #6202.
2020-07-01nrf/Makefile: Disable ROM text compression when compiling for debug.Glenn Ruben Bakke
When compiling for debug (-O0) the .text segment cannot fit the flash region when MICROPY_ROM_TEXT_COMPRESSION=1, because the compiler does not optimise away the large if-else chain used to select the correct compressed string. This commit enforces MICROPY_ROM_TEXT_COMPRESSION=0 when compiling for debug (DEBUG=1).
2020-07-01nrf/bluetooth/ble_uart: Swap end character on cooked strings.Glenn Ruben Bakke
Changing line ending character of cooked strings makes rshell/pyboard.py work correctly over Bluetooth socat/pts devices.
2020-07-01nrf/bluetooth/ble_uart: Fix random advertisement name.Glenn Ruben Bakke
The storage space of the advertisement name is not declared static, leading to a random advertisement name. This commit fixes the issue by declaring it static.
2020-07-01nrf/bluetooth/ble_uart: Add mp_hal_stdio_poll function.Glenn Ruben Bakke
This adds support for enabling MICROPY_PY_SYS_STDFILES when running UART over Bluetooth (NUS).
2020-07-01nrf/bluetooth: Handle data length update request.Glenn Ruben Bakke
The Bluetooth link gets disconnected when connecting from a PC after 30-40 seconds. This commit adds handling of the data length update request. The data length parameter pointer is set to NULL in the reply, letting the SoftDevice automatically set values and use them in the data length update procedure.
2020-07-01nrf/bluetooth/ble_uart: Fix implicit declaration of function.Glenn Ruben Bakke
mp_keyboard_interrupt() triggers a compiler error because the function is implicitly declared. This commit adds "py/runtime.h" to the includes. Fixes issue #5732.
2020-06-17nrf/bluetooth: Use MP_ERROR_TEXT for all error messages.Glenn Ruben Bakke
This follows up on commit def76fe4d9bbc2c342594dc05861b24d7165d274. Fixes issue #6152.
2020-05-15nrf: Add openocd as a supported flasher.Jim Mussared
Tested with the Particle Debugger on a Xenon.
2020-05-15nrf: Update to work with nrfx v2.0.0, to match TinyUSB.Jim Mussared
Commit 6cea369b89b2223cf07ff8768e50dc39bbb770fe updated the TinyUSB submodule to a version based on nrfx v2.0.0. This commit updates the nrf port to work with the latest TinyUSB and nrfx v2.0.0.
2020-05-15nrf/mphalport: Remove need for "syntax unified" in mp_hal_delay_us.Damien George
Because it can confuse older versions of gcc. Instead use the correct instruction for Thumb vs Thumb-2 (sub vs subs) so the assembler emits the 2-byte instruction. Related to commit 1aa9ff914194824a78a8b010572ad7083c1bb4ec.
2020-05-15nrf/Makefile: Don't use -fno-builtin for Cortex-M0 builds.Damien George
So that error string compression is optimised correctly (it needs strcmp to be optimised away by the compiler).
2020-04-23all: Format code to add space after C++-style comment start.stijn
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.
2020-04-23all: Remove commented-out include statements.stijn
2020-04-13all: Clean up error strings to use lowercase and change cannot to can't.Damien George
Now that error string compression is supported it's more important to have consistent error string formatting (eg all lowercase English words, consistent contractions). This commit cleans up some of the strings to make them more consistent.
2020-04-05ports: Enable error text compression for various ports, but not all.Jim Mussared
Enabled on: bare-arm, minimal, unix coverage/dev/minimal, stm32, esp32, esp8266, cc3200, teensy, qemu-arm, nrf. Not enabled on others to be able to test the code when the feature is disabled (the default case). Code size change for this commit: bare-arm: -600 -0.906% minimal x86: -308 -0.208% unix x64: +0 +0.000% unix nanbox: +0 +0.000% stm32: -3368 -0.869% PYBV10 cc3200: -1024 -0.558% esp8266: -2512 -0.368% GENERIC esp32: -2876 -0.205% GENERIC[incl -3168(data)] nrf: -1708 -1.173% pca10040 samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-03-25ports: Add lib/libm/roundf.c to bare-metal Makefile's.Zoltán Vörös
This function is not used by the core but having it as part of the build allows it to be used by user C modules, or board extensions. The linker won't include it in the final firmware if it remains unused.
2020-03-25all: Remove spaces between nested paren and inside function arg paren.Damien George
Using new options enabled in the uncrustify configuration.
2020-03-18all: Convert exceptions to use mp_raise_XXX helpers in remaining places.Damien George
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28all: Add *FORMAT-OFF* in various places.Damien George
This string is recognised by uncrustify, to disable formatting in the region marked by these comments. This is necessary in the qstrdef*.h files to prevent modification of the strings within the Q(...). In other places it is used to prevent excessive reformatting that would make the code less readable.