This commit adds the bytes methods to bytearray, matching CPython. The
existing implementations of these methods for str/bytes are reused for
bytearray with minor updates to match CPython return types.
For details on the CPython behaviour see
https://docs.python.org/3/library/stdtypes.html#bytes-and-bytearray-operations
The work to merge locals tables for str/bytes/bytearray/array was done by
@jimmo. Because of this merging of locals the change in code size for this
commit is mostly negative:
bare-arm: +0 +0.000%
minimal x86: +29 +0.018%
unix x64: -792 -0.128% standard[incl -448(data)]
unix nanbox: -436 -0.078% nanbox[incl -448(data)]
stm32: -40 -0.010% PYBV10
cc3200: -32 -0.017%
esp8266: -28 -0.004% GENERIC
esp32: -72 -0.005% GENERIC[incl -200(data)]
mimxrt: -40 -0.011% TEENSY40
renesas-ra: -40 -0.006% RA6M2_EK
nrf: -16 -0.009% pca10040
rp2: -64 -0.013% PICO
samd: +148 +0.105% ADAFRUIT_ITSYBITSY_M4_EXPRESS
The hash is either 8 or 16 bits (depending on MICROPY_QSTR_BYTES_IN_HASH)
so will fit in a size_t.
This saves 268 bytes on the unix nanbox build. Non-nanbox configurations
are unchanged because mp_uint_t is the same size as size_t.
Signed-off-by: Damien George <damien@micropython.org>
PR #9012 (b2e8240268) changed the output to
$(BUILD)/$(PROG) but the tests are still looking for $(PROG).
Also remove the now-unnecessary override of $(PROG) in the standard
variant.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The separate A and RM toolchains have been discontinued and replaced
by a single toolchain. This updates the links to the RM toolchain to
the new toolchain.
Signed-off-by: David Lechner <david@pybricks.com>
Figure out path to arm-none-eabi-size the same way it's done for the
other binaries, instead of assuming it to be in the user's $PATH.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Create a new linker section .unitialized_bss for bss that does not need
zero-initialising.
Move gc_heap to this section, which saves ~30ms from rising edge of RESET
to setting a pin HIGH in MicroPython.
Zero fill happens in Pico SDK crt0.S before ROSC is configured. It's very,
very slow.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
stty can provide the current terminal settings, so that they can be
stored in a shell variable and restored after running the firmware. This
avoids the complete "blanking" of the terminal, and thus also removes the
need for the sleep call.
The run target now references the firmware file using the BUILD variable
instead of using the hard coded "build/" path.
Due to inline assembly, wrong instructions were generated. Use
corresponding 32 bit instructions and fix the offsets used.
Signed-off-by: Efi Weiss <efiwiss@gmail.com>
The executable now lives in the build directory, and since the build
directory already contains the variant name there is no need to also add
it to the executable.
Signed-off-by: Damien George <damien@micropython.org>
Binaries built using the Make build system now no longer appear in the
working directory of the build, but rather in the build directory. Thus
some paths had to be adjusted.
The rules for lib (static library with name $(LIBMICROPYTHON)) and the
default rule to build a binary (name $(PROG)) produced outputs in the
current working directory. Change this to build these files in the build
directory.
Note: An empty BUILD variable can cause issues (references to the root
directory); this is not addressed by this commit due to multiple other
places having the same issue.
Instead of using the fixed machine_spi_type entity to get the SPI transfer
function, this transfer function is now extracted dynamically from the type
of the SPI object.
This allows the SPI object used to communicate with the WIZNET5K hardware
to be SoftSPI or hardware SPI, or anything that has the SPI protocol (at
the C level).
Signed-off-by: Damien George <damien@micropython.org>
Avoiding conflicts between the IRQ and an active transfers. Before this
change the device could lock up in heavy traffic situations.
Fix found and code supplied by @omogenot.
If nic.active(True) is called several times in a row, the device may lock
up. Even if that is bad coding practice, calling wiznet5k_deinit() in
wiznet5k_init() prevents the lock.
Drop an obsolete and wrong argument check, which prevented specifying a pin
for the interrupt signal. The proper checks are now done further down in
the code.
In-the-field use of these FUS/WS firmware update scripts has exposed some
weak points, causing corrupted FUS/WS firmware to be flashed to the unit.
The problems are mostly caused with the ST GUI application, but sometimes
from un-recognised failures during bin file transfer to the WB55 prior to
running the rfcore_firmware.py script. Other failures were caused by
incorrect load addresses being used, again both from user error copying the
address from the HTML release notes to the GUI tool, but also from
similarly not updating the address correctly in rfcore_firmware.py
To guard against these errors and make it easier to prepare different
versions, this commit adds a few features to the rfcore firmware update
tools:
- When creating the bin file, automatically parse the release note in the
folder to get the correct address.
- Add a footer to the bin file containing the name, version, CRC, address
etc.
- Before flashing rfcore, check if the same version is already installed.
- Verify the CRC and obfuscation key before flashing bin.
- Log the name and version of file being flashed.
The reallocation trigger for unpacking star args with unknown length
did not take into account the number of fixed args remaining. So it was
possible that the unpacked iterators could take up exactly the memory
allocated then nothing would be left for fixed args after the star args.
This causes a segfault crash.
This is fixed by taking into account the remaining number of fixed args
in the check to decide whether to realloc yet or not.
Signed-off-by: David Lechner <david@pybricks.com>
The ntptime module was previously only included in the ESP8266 port. This
commit factors that module out into the extmod directory, makes it support
different epochs, and includes it in the rp2 port.
This adds support for the LEGO Hub No. 7, aka LEGO Technic Small hub, aka
LEGO SPIKE Essential hub. This board is largely similar to Hub No. 6:
- Same MCU (STM32F413 - different packaging with fewer pins).
- Same Bluetooth chip (TI CC2564).
- Same IMU chip.
- Similar external flash chip - 4MiB instead of 32MiB.
- 2 I/O ports instead of 6.
- No display - only status and battery LEDs.
- Different LED driver chip.
- Only 1 button which is also the power button.
- No speaker.
Signed-off-by: David Lechner <david@pybricks.com>
This adds configurable macros to define the timer and channel used to
provide the Bluetooth 32768 MHz clock. This will allow code to be shared
with LEGO_HUB_NO7.
Signed-off-by: David Lechner <david@pybricks.com>
This changes spiflash.py to read the flash chip ID at runtime to select the
read/write/erase commands. This will allow the code to be shared with
LEGO_HUB_NO7 which doesn't use the 32-bit commands.
Also remove an unused constant while we are touching this.
Signed-off-by: David Lechner <david@pybricks.com>
This changes appupdate.py to get the filesystem size at runtime. This will
allow the code to be shared with LEGO_HUB_NO7 which has a similar flash
chip with a different size.
Signed-off-by: David Lechner <david@pybricks.com>
This changes all uses of pins to use the alias names of the pins. This
makes the code easier to understand and will also allow sharing more code
with LEGO_HUB_NO7.
Signed-off-by: David Lechner <david@pybricks.com>
Also use mkrules.mk's submodule target rather than duplicating the call to
`submodule sync`.
Until we can find a way to use idf.py/cmake to discover submodules we have
no way to discover optional or board-specific submodules so need to err on
the side of including everything.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Used to be special-cased for Pico, but now everything depends on
micropython-lib if it's using a frozen manifest.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Several boards now depend on libraries from micropython-lib. Rather than
expecting micropython-lib to be available as a sibling of the micropython
repo, instead make it a submodule.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>