8000 Merge from MicroPython v1.20.0 by dhalbert · Pull Request #8481 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Merge from MicroPython v1.20.0 #8481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact i 10000 ts maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1,185 commits into from
Oct 16, 2023
Merged

Merge from MicroPython v1.20.0 #8481

merged 1,185 commits into from
Oct 16, 2023

Conversation

dhalbert
Copy link
Collaborator

Minor notes:

  • Removed #includes for translate.h and supervisor/linker.h many places because they're already included by runtime.h.
  • Everything converted to use MP_REGISTER_ROOT_POINTER.
  • Everything converted to use MP_DEFINE_CONST_OBJ_TYPE.

dpgeorge and others added 30 commits March 8, 2023 14:04
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Damien George <damien@micropython.org>
The device-under-test should use `multitest.expect_reboot()` to indicate
that it will reboot.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Damien George <damien@micropython.org>
And any other board that exposes this pin with a button.
This function seems to work fine in multi-core applications now.

The delay is now in units of microseconds instead of depending on the clock
speed, and is adjustable by board configuration headers.

Also added documentation.
Borrowing an idea from the mimxrt port (also stm32 port): in the loader
input file memmap_mp.ld calculate __GcHeapStart and __GcHeapEnd as the
unused RAM.  Then in main.c use these addresses as arguments to gc_init().

The benefits of this change are:

1) When libraries are added or removed in the future changing BSS usage,
   main.c's sizing of the GC heap does not need to be changed.

2) Currently these changes make the GC area about 30 KBytes larger, eg on
   PICO_W the GC heap increases from 166016 to 192448 bytes.  Without that
   change this RAM would never get used.

3) If someone wants to disable one or more SRAM blocks on the RP2040 to
   reduce power consumption it will be easy: just change the MEMORY section
   in memmap_mp.ld.  For instance to not use SRAM2 and SRAM3 change it to:

        MEMORY
        {
            FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2048k
            RAM(rwx) : ORIGIN =  0x21000000, LENGTH = 128k
            SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
            SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
        }

   Then to turn off clocks for SRAM2 and SRAM3 from MicroPython, set the
   appropriate bits in WAKE_EN0 and SLEEP_EN0.

Tested by running the firmware.uf2 file on PICO_W and displaying
micropython.mem_info().  Confirmed GC total size approximately matched the
size calculated by the loader.

Signed-off-by: cpottle9 <cpottle9@outlook.com>
When := is used in a comprehension the target variable is bound to the
parent scope, so it's either a global or a nonlocal.  Prior to this commit
that was handled by simply using the parent scope's id_info for the
target variable.  That's completely wrong because it uses the slot number
for the parent's Python stack to store the variable, rather than the slot
number for the comprehension.  This will in most cases lead to incorrect
behaviour or memory faults.

This commit fixes the scoping of the target variable by explicitly
declaring it a global or nonlocal, depending on whether the parent is the
global scope or not.  Then the id_info of the comprehension can be used to
access the target variable.  This fixes a lot of cases of using := in a
comprehension.

Code size change for this commit:

       bare-arm:    +0 +0.000%
    minimal x86:    +0 +0.000%
       unix x64:  +152 +0.019% standard
          stm32:   +96 +0.024% PYBV10
         cc3200:   +96 +0.052%
        esp8266:  +196 +0.028% GENERIC
          esp32:  +156 +0.010% GENERIC[incl +8(data)]
         mimxrt:   +96 +0.027% TEENSY40
     renesas-ra:   +88 +0.014% RA6M2_EK
            nrf:   +88 +0.048% pca10040
            rp2:  +104 +0.020% PICO
           samd:   +88 +0.033% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Fixes issue micropython#10895.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
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.
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.
These have the same frequency, but can have different duty cycle and
polarity.

pwm.deinit() stops all channels of a module, but does not release the
module.  pwm.init() without arguments restarts all outputs.
Signed-off-by: Damien George <damien@micropython.org>
So that callers can redirect the output if needed.

Signed-off-by: Damien George <damien@micropython.org>
The C-level printf is usually used for internal debugging prints, and a
port/board may want to redirect this somewhere other than stdout.

Signed-off-by: Damien George <damien@micropython.org>
Without this, building the unix port variants gives:
ports/unix/main.c:667: undefined reference to `mp_obj_is_package',
when MICROPY_ENABLE_EXTERNAL_IMPORT is 0.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
Moving forward, tags in this repository will always have three components.

Signed-off-by: Damien George <damien@micropython.org>
Update arguments to mp_raw_code_load_mem so that the embed port can build
when MICROPY_PERSISTENT_CODE_LOAD is enabled.
@tannewt tannewt self-requested a review October 16, 2023 21:04
@tannewt tannewt added this to the 9.0.0 milestone Oct 16, 2023
Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more minor things. Will test imx rt and silabs shortly.

@tannewt
Copy link
Member
tannewt commented Oct 16, 2023

Smoke tests run:

  • Fetch test on ESP32-S3 matrix portal
  • 1 + 1 REPL test on Adafruit QtPy ESP32 pico
  • 1 + 1 REPL test on Adafruit ItsyBitsy M4 Express
  • 1 + 1 REPL test on Adafruit Metro 1011 SD

1 + 1 REPL test on mgm240p (silabs) "feather" fails on S3 as well so it is unrelated to this PR.

@dhalbert
Copy link
Collaborator Author

I tested Pico W, including wifi, nRF52840 with BLE Heart Rate Monitor, Spresense blinking LEDs, STM32F405 doing I2C.

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0