Wykres commitów

120 Commity (master)

Autor SHA1 Wiadomość Data
Damien George fb3820e3d6 nrf/boards: Enable MICROPY_HW_ENABLE_USBDEV on boards with USB CDC.
These boards were broken by 9d0d262be0.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-16 00:40:39 +11:00
Sebastian Romero 5c5fe87821 nrf/boards: Add named pins for Arduino Nano 33 BLE.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:10:43 +11:00
Phil Howard dda9b9c6da all: Prune trailing whitespace.
Prune trailing whitespace across the whole project (almost), done
automatically with:

    grep -IUrl --color "[[:blank:]]$" --exclude-dir=.git --exclude=*.exp |\
        xargs sed -i 's/[[:space:]]*$//'

Exceptions:
- Skip third-party code in lib/ and drivers/cc3100/
- Skip generated code in bluetooth_init_cc2564C_1.5.c
- Preserve command output whitespace in docs, eg:
  docs/esp8266/tutorial/repl.rst

Signed-off-by: Phil Howard <phil@gadgetoid.com>
2024-03-07 16:25:17 +11:00
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
Damien George 2423493774 py/obj: Change sizeof to offsetof in mp_obj_malloc_var macro.
Following b6a9778484, to properly calculate
the size of the variable-length allocation.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-19 23:40:54 +11:00
Damien George 20af857f52 nrf/boards/ARDUINO_NANO_33_BLE_SENSE: Don't enable MICROPY_MBFS.
This board has MICROPY_VFS enabled, which should take precedence over
MICROPY_MBFS (and did prior to 22d9116c8c).

Signed-off-by: Damien George <damien@micropython.org>
2023-12-04 22:18:14 +11:00
Damien George b4d288ae44 nrf: Use MICROPY_PY_MACHINE_SPI instead of MICROPY_PY_MACHINE_HW_SPI.
MICROPY_PY_MACHINE_SPI is defined in mpconfigport.h to be equal to
MICROPY_PY_MACHINE_HW_SPI, so they are equivalent options.  The former one
is preferred because it's used by all other ports.

The default in mpconfigport.h is to enable this option, and all boards that
enable SPI have this removed from their mpconfigboard.h file so they pick
up the default.

Signed-off-by: Damien George <damien@micropython.org>
2023-11-30 16:10:10 +11:00
Jim Mussared 6ef9b29f88 {cc3200,nrf}/boards/make-pins.py: Add a note about tools/boardgen.py.
It's not worth the effort to update these ports to use boardgen.py, but
put a note just in case anyone uses this as a reference for a new port.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 14:18:54 +11:00
Jim Mussared 9cabee8252 ports: Standardise arguments and output for make-pins.py script.
All ports now use `--board-csv`, `--prefix`, `--output-souce`,
`--output-header` and no longer write to stdout.  This matches the esp32
implementation.

Ports that have an AF input use `--af-csv` (to match `--board-csv`).

Any additional output files are now prefixed with `output-` (e.g.
`--output-af-const`).

Default arguments are removed (all makefiles should always specify all
arguments, using default values is likely an error).

Replaced the `af-defs-cmp-strings` and `hdr-obj-decls` args for stm32 with
just `mboot-mode`.  Previously they were set on the regular build, now the
logic is reversed so mboot sets it.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 14:04:35 +11:00
Jim Mussared 59f3c7facb examples/pins.py: Remove this pins printing example.
It's not supported on all ports, adds complexity to the build to generate
pins_af.py, and can mostly be replicated just by printing the pin objects.

Remove support for generating pins_af.py from all ports (nrf, stm32,
renesas-ra, mimxrt, rp2).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 14:03:28 +11:00
Jim Mussared 3f99dbd634 nrf/boards/make-pins.py: Don't generate qstrs.
The output pins.c can be processed for qstrs like any other C file.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 14:01:04 +11:00
Damien George 48e0986666 nrf/boards: Automatically configure MICROPY_PY_MACHINE_PWM.
This commit makes it so that MICROPY_PY_MACHINE_PWM is enabled if at least
one of MICROPY_PY_MACHINE_HW_PWM and/or MICROPY_PY_MACHINE_SOFT_PWM are
enabled.  This simplifies the configuration for boards, and fixes DVK_BL652
which enabled PWM without selecting software or hardware implementations.

With this change, DVK_BL652 and EVK_NINA_B1 now enable (hardware) PWM.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-23 11:20:49 +11:00
Jim Mussared f007d0aa3d nrf/boards: Rename all nRF boards to use uppercase.
This is to match all the other ports.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-23 13:54:37 +10:00
Jim Mussared 24a6e951ec ports: Simplify board feature tags in board.json.
This commit:
- Finds a common set of board feature tags and maps existing features to
  that reduced set.
- Removes some less-useful board feature tags.
- Ensures all MCUs are specified correctly.
- Ensures all boards have a vendor (and fixes some vendor names).

This is to make the downloads page show a less intimidating set of filters.

Work done in conjunction with Matt Trentini <matt.trentini@gmail.com>.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-10 14:54:03 +10:00
Jim Mussared f5f9edf645 all: Rename UMODULE to MODULE in preprocessor/Makefile vars.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:11 +10:00
Damien George b1229efbd1 all: Fix spelling mistakes based on codespell check.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:03:06 +10:00
iabdalkader a197823eb7 ports: Fix MCU tags in Arduino board.json files. 2023-03-20 15:22:24 +11:00
Damien George f450e94ba0 ports: Rename remaining "Micro Python" to "MicroPython".
Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 10:54:00 +11:00
robert-hh e3b877826c nrf/modules/machine/soft_pwm: Add PWM for nrf51x boards using soft PWM.
Using extmod/machine_pwm.c for the Python bindings and the existing
softpwm.c driver, by just adding the interface.

Properties:
- Frequency range 1-3906 Hz.
- All PWM outputs run at the same frequency but can have different duty
  cycles.
- Limited to the P0.x pins.

Since it uses the existing softpwm.c mechanism, it will be affected by
playing music with the music class.
2023-03-10 10:44:02 +11:00
robert-hh a1f838cdf1 nrf/modules/machine/pwm: Use extmod/machine_pwm.c for PWM module.
This is a breaking change, making the hardware PWM on the nrf port
compatible with the other ports providing machine.PWM.

Frequency range 4Hz - ~5.4 MHz.  The base clock range is 125kHz to 16 MHz,
and the divider range is 3 - 32767.

The hardware supports up to four outputs per PWM device with different duty
cycles, but only one output is (and was) supported.
2023-03-10 10:43:55 +11:00
iabdalkader cc645b65a9 nrf/boards/arduino_nano_33_ble_sense: Add support for REV-2 chipset.
These changes allow the firmware to support both the REV-1 and REV-2
versions of the board:
- Freeze the new device drivers used in REV-2.
- Add a board-level module that abstracts the IMU chipset.
2023-03-08 00:53:25 +11:00
robert-hh 564945a2a0 nrf/boards/seeed_xiao_nrf52: Add defn for Seeed XIAO NRF52840 Sense.
It keeps compatibility with the XIAO bootloader by:
- using Soft Device 7.3.0
- reserving 48k memory for the bootloader.

So on double reset a drive pops for uploading an uf2 image or a nrfutil zip
pkg file.  Instructions to create it from a hex file are included.  The
bootloader can as well be activated with the touch 1200 option of nrfutil.

The script download_ble_stack.sh has been adapted to get the version 7.3.0
soft device files.  It may have to be executed once before building.

The file system is set to 256k and the pin definitions are adapted.
Besides that, it has the common functionality and omissions.  The on-board
sensors and additional flash can be supported by Python scripts.
2022-12-15 14:27:08 +11:00
Damien George e8f5cfe0e1 nrf: Rename MICROPY_PY_MACHINE_TIMER to MICROPY_PY_MACHINE_TIMER_NRF.
So that it doesn't clash with the extmod version.

Also make the default for this enabled, so that most boards do not need to
configure it.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-27 14:30:58 +11:00
Jim Mussared 94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared 6da41b5900 py/obj: Merge getiter and iternext mp_obj_type_t slots.
The goal here is to remove a slot (making way to turn make_new into a slot)
as well as reduce code size by the ~40 references to mp_identity_getiter
and mp_stream_unbuffered_iter.

This introduces two new type flags:
- MP_TYPE_FLAG_ITER_IS_ITERNEXT: This means that the "iter" slot in the
  type is "iternext", and should use the identity getiter.
- MP_TYPE_FLAG_ITER_IS_CUSTOM: This means that the "iter" slot is a pointer
  to a mp_getiter_iternext_custom_t instance, which then defines both
  getiter and iternext.

And a third flag that is the OR of both, MP_TYPE_FLAG_ITER_IS_STREAM: This
means that the type should use the identity getiter, and
mp_stream_unbuffered_iter as iternext.

Finally, MP_TYPE_FLAG_ITER_IS_GETITER is defined as a no-op flag to give
the default case where "iter" is "getiter".

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:13 +10:00
Jim Mussared 9dce82776d all: Remove unnecessary locals_dict cast.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 42587c7870 all: Standardise mp_obj_type_t initialisation.
Remove setting unused slots.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 18:41:29 +10:00
Jim Mussared fb2a57800a all: Simplify buffer protocol to just a "get buffer" callback.
The buffer protocol type only has a single member, and this existing layout
creates problems for the upcoming split/slot-index mp_obj_type_t layout
optimisations.

If we need to make the buffer protocol more sophisticated in the future
either we can rely on the mp_obj_type_t optimisations to just add
additional slots to mp_obj_type_t or re-visit the buffer protocol then.

This change is a no-op in terms of generated code.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 18:40:39 +10:00
Jim Mussared d84c6ef0e8 ports: Use micropython-lib version of drivers in manifests. 2022-09-08 11:27:05 +10:00
Jim Mussared 203dae41fb all: Update all manifest.py files to use new features.
Changes in this commit:
- Manifest include's now use the directory path where possible (no longer
  necessary to include the manifest.py file explicitly).
- Add manifest.py for all drivers and components that are referenced by
  port/board manifests.
- Replace all uses of freeze() with package()/module(), except for port and
  board modules.
- Use opt=3 everywhere, for consistency and to reduce code size.
- Use require() instead of include() for all micropython-lib references.
- Remove support for optional board-level manifest.py in mimxrt port, to
  make it behave the same as other ports (the board must set
  FROZEN_MANIFEST to a custom manifest.py, which can optionally include the
  default, port-level manifest).
- Also reinstates modules that were accidentally removed from the esp8266
  512k build in fbe9417b90.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-09-05 18:43:18 +10:00
iabdalkader 768cbea507 nrf/boards/arduino_nano_33_ble_sense: Update deploy instructions. 2022-07-20 17:16:15 +10:00
David Lechner 8a69c54211 nrf: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers for the nrf port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
iabdalkader 5c31a6c023 nrf/boards/arduino_nano_33_ble: Add Arduino Nano 33 BLE sense board. 2022-07-07 23:58:03 +10:00
Damien George efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
It's no longer needed because this macro is now processed after
preprocessing the source code via cpp (in the qstr extraction stage), which
means unused MP_REGISTER_MODULE's are filtered out by the preprocessor.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:31:37 +10:00
Jim Mussared f67ac90fa9 nrf: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 0e7bfc88c6 all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of

    foo_t *foo = m_new_obj(foo_t);
    foo->base.type = &foo_type;

with

    foo_t *foo = mp_obj_malloc(foo_t, &foo_type);

Excludes any places where base is a sub-field or when new0/memset is used.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-03 22:28:14 +10:00
Damien George df3f59ca4b ports: Update board.json files to link to new board images.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-07 11:33:28 +11:00
Mike Causer 7f14344428 ports: Add images, features and urls to board.json. 2021-10-28 15:25:38 +11:00
Jim Mussared e359b077dd ports: Add board.json for all boards.
This will be used by https://micropython.org/download/ to generate the
full listing of boards and firmware files.

Optionally supports a board.md for additional customisation of the
download page, as well as deploy.md for flashing instructions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-27 14:04:53 +11:00
Glenn Ruben Bakke 55d4321c3e nrf/boards: Enable MICROPY_VFS_LFS2 for all target boards.
Enable LittleFS v2 for all targets, except nrf51 targets when SoftDevice is
present.
2021-08-08 23:17:55 +10:00
Glenn Ruben Bakke ffc636de2f nrf/boards: Set FROZEN_MANIFEST blank when SD present on nrf51 targets. 2021-08-08 23:17:55 +10:00
Glenn Ruben Bakke 3b594f7b27 nrf/boards/common.ld: Calculate unused flash region.
Calculate the unused flash area on the target device.  The values will be
exposed by _unused_flash_start and _unused_flash_length.  The start address
and the length are not aligned to either word or pages.
2021-08-08 23:09:26 +10:00
David Lechner ca920f7218 py/mpstate: Make exceptions thread-local.
This moves mp_pending_exception from mp_state_vm_t to mp_state_thread_t.
This allows exceptions to be scheduled on a specific thread.

Signed-off-by: David Lechner <david@pybricks.com>
2021-06-19 09:43:44 +10:00
Bruno Martins ea2d83e961 nrf/boards: Add support for evk_nina_b3 board. 2021-05-18 12:14:57 +10:00
Damien George bd54eb566f nrf/boards/microbit: Use mp_sched_exception() where appropriate.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Glenn Ruben Bakke d0b8554df4 nrf: Change selected boards to utilize pre-flashed bootloader.
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-07 20:04:50 +01:00
Glenn Ruben Bakke 7f405236a3 nrf/boards: Add linker script for nrf52840 Open Bootloader 1.2.0. 2020-12-07 20:04:50 +01:00
Glenn Ruben Bakke 2489688635 nrf/boards: Update memory.ld to include bootloader offsets.
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-12-07 20:04:50 +01:00
Damien George 06659077a8 all: Update Python code to conform to latest black formatting.
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-29 15:18:01 +10:00