This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This applies to nimble, btstack, axtls, mbedtls, lwip.
Rather than having the ports individually manage GIT_SUBMODULES for these
components, make extmod.mk append them when the relevant feature is
enabled.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This conflicts with the triple-usage of these variables for user-C-modules
and extmod source.
For CFLAGS_MOD, just use CFLAGS directly. For SRC, use SRC_C directly as
the relevant files are all guarded by the preprocessor anyway.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Removes the need for the port to add anything to OBJS or SRC_QSTR.
Also makes it possible for user-C-modules to differentiate between code
that should be processed for QSTR vs other files (e.g. helpers and
libraries).
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Gives the absolute path to the unix micropython binary.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
It now prints lines like:
Pin("D9", mode=IN, pull=PULL_UP, GPIO=PA07)
or
LED("LED")
showing for consistency the names as given in pins.csv. For pins, the GPIO
numer is printed as well for a reference.
Porting PR #8040 by @hoihu to SAMD, following the commit
5873390226.
One small addition: before executing keyboard interrupt, the input buffer
is cleared.
Changes are:
- The pin-af-table-SAMDxx.csv file are moved to the mcu directories with
the name as pin-af-table.csv.
- The handling in Makefile and pin_af.c is simplified.
Two new compile flags are:
MICROPY_HW_DFLL_USB_SYNC: Effective only if DFLL48 does not run from the
crystal. It will synchronize the DFLL48M clock with the USB's SOF pulse.
If no USB is connected, it will fall back to open loop mode. The DFLL48M
clock is then pretty precise, but with a higher clock jitter at SAMD51
devices.
MICROPY_HW_MCU_OSC32KULP: Effective only if the devics uses a crystal as
clock source. Run the MCU clock from the ULP 32kHz oszillator instead of
the crystal. This flag was added to cater for a interference problem of
the crystal and Neopixel/Debug pins at Adafruit FEATHER Mx boards, which
causes the board to crash. Drawback: ticks_ms() and time.time() vs. than
ticks_us() and the peripherals like PWM run at not synchronous clocks.
Changes are:
- Set the feature level for each MCU: CORE features for SAMD21, and EXTRA
features for SAMD51.
- Remove all definitions that are included in the core feature level.
- Keep the default settings for feature level and float, to make the choice
obvious.
The SAMD21 implementation is an adaption of @jimmo's code for STM32Lxx.
The only changes are the addresses and names of the port registers and the
timing parameters.
SAMD21: The precision is about +/-25ns at 48MHz clock frequency. The first
two cycles are about 40-60 ns longer than set. But still good enough to
drive a neopixel device.
SAMD51: The precision is about +/-30ns at 120MHz clock frequency. Good
enough to drive a neopixel device.
And use mp_hal_ticks_us() for SAM21's mp_hal_ticks_cpu(). The SAMD21 has
no CYCCNT register, and the SysTick register has only a 1 ms span (== 48000
count range).
Fixes are:
- Pin definitions for ADAFRUIT_FEATHER_Mx_EXPRESS and
ADAFRUIT_ITSYBITSY_M4_EXPRESS.
- For ADAFRUIT_ITSYBITSY_M0_EXPRESS, change the MISO/MOSI name.
- For MINISAM_M4, add the default SPI pins.
- For boards with 32k crystal, add the XOSC32K setting.
It can be enabled/disabled by a configuration switch. The code size
increase is 308 bytes, but it requires RAM space for buffers, the larger
UART object and root pointers.
Allowing to set a time and retrieve the time. It is based on systick_ms()
with the precision of the MCU clock. Unless that is based on a crystal,
the error seen was about 0.5% at room temperature.
It suuports 1 channel @ 10 bit for SAMD21, 2 channels @ 12 bit for SAMD51.
Instantiation by:
dac = machine.DAC(ch) # 0 or 1
Method write:
dac.write(value)
The output voltage range is 0..Vdd.
By reducing the methods to on(), off(), toggle() and call, and using the
method implementation of the machine.Pin class.
The code size reduction is 756 byte.
All board pins that have UART's assigned can be used. Baud rate range is
75 Baud to ~2 MBaud.
No flow control yet, and only RX is buffered. TX buffer and flow control
may be added later for SAMD51 with its larger RAM and Flash.
Its API conforms to the docs. There are 16 IRQ channels available, which
will be used as assignable to the GPIO numbers. In most cases, the irq
channel is GPIO_no % 16.
Changes are:
- Have two separate tables for SAM21 and SAMD51.
- Use a short table for SAMD21.
- Add a comment to each line telling what it's for, making further use
easier.
- Add preliminary handlers/entries for PendSV, EIC and Sercom. These will
be replaced later when the respecitve modules are added.
Features are:
- 3 to 5 different frequency groups.
- Freq range of 1Hz - 24 MHz.
- Duty rate stays stable on freq change.
Keyword options to the PWM constructor:
- device=n Select a specific PWM device. If no device is specified, a free
device is chosen, if available at that pin.
- freq=nnnn
- duty_u16=nnnn
- duty_ns=nnnn
- invert=True/False Allowing two outputs on the same device/channel to have
complementary signals.
If both freq and duty are provided, PWM output will start immediately.
Pins at the same device have the same frequency. If the PWM output number
exceeds the number of channels at the PWM device, the effctive channel_no
is output_no % channel_count. So with a channel count of 4, output 7 is
assigned to channel 3. Pins at a certain channel have the same frequency
and duty rate, but may be seperately inverted.
With the method read_u16(). Keyword arguments of the constructor are:
- bits=n The resolution; default is 12.
- average=n The average of samples, which are taken and cumulated. The
default value is 16. Averaging by hw is faster than averaging
in code.
The ADC runs at a clock freq 1.5 MHz. A single 12 bit conversion takes
8 microseconds.
The pin af table is a representation of the MUX table from the data sheet.
It provides information for each pin about the supported device functions.
That information is needed by pin.irq, machine.ADC, machine.PWM,
machine.UART, machine.SPI and machine.I2C. For each of these, the table
tells for each pin, which device number, af number and pad number is
assigned. Using the table gives a straight, uniform access to the
information, where the benefit outweights the size of the table, which is
not that large.
The tables are MCU-specific. It is not required to tell for each board,
which and where each of the above devices is available. That makes addding
boards easy.
Note: The information for DAC and I2S was not included, since it affects
only a few pins.
Changes in this commit are:
- Use mphal_xx functions whenever possible.
- Remove obsolete includes.
- Clean up traces of a non-functional pin.irq() from earlier builds.
Pin.irq() will be added in further commits in a working manner.
The changes in this commit are:
- Add an interface for pin open-drain mode.
- Improve ticks_us() by using the us-counter.
- Improve ticks_cpu() by using the CPU's SysTick.
Clock settings:
- GCLK0: 48 MHz (SAMD21) or 120 MHz(SAMD51).
- GCLK1: 32768 Hz for driving the PLL.
- GCLK2: 48 MHz for tzhe peripheral clock.
- GCLK3: 1 MHz (SAMD21) or 8 MHz (SAMD51) for the µs ticks timer.
- GCLK8: 1 kHz for WDT (SAMD21 only).
If a 32 kHz crystal is present, it will be used as clock source. Otherwise
the DFLL48M in open-loop mode is used.
GCLK0 for SAM51 can be changed between 48 MHz and 200 MHz. The specified
range is 96 MHz - 120 MHz.
These two boards are used for testing, so it is favorable to have them
added early.
The full test set is:
- ADAFRUIT_FEATHER_M4_EXPRESS: SAMD51 with 32kHz crystal.
- ADAFRUIT_ITSYBITSY_M0_EXPRESS: SAMD21 without crystal.
- ADAFRUIT_ITSYBITSY_M4_EXPRESS: SAMD51 without crystal.
- SEEED_XIAO: SAM21 with 32kHz crystal.
Auto DMA channel is supported in IDF v4.4, and is required to be used on S3
chips, so use this simpler configuration option where possible.
Fixes issue #8634.
Signed-off-by: Damien George <damien@micropython.org>
Updates all README.md and docs, and manifests to `require("mip")`.
Also extend and improve the documentation on freezing and packaging.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This uses the frozentest.mpy that is also used by ports/minimal.
Also fixes two bugs that these new tests picked up:
- File extension matching in manifestfile.py.
- Handling of freeze_mpy results in makemanifest.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
frozentest.mpy was previously duplicated in ports/minimal and
ports/powerpc.
This needs to be re-generated on every .mpy version increase, so might as
well just have a single copy of it.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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>
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>
This will always have the maximum/minimum size of a mp_obj_type_t
representation and can be used as a member in other structs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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>
In that case, no Pin will be configured for the CS signal, even if it is
internally still generated. That setting allows to use any pin for CS,
which then must be controlled by the Python script.
Also make the default cs=-1 to match other ports (software CS).
The new teensy loader keeps the file system under certain conditions:
- The file size is properly set in the file header.
- The header version is 4.3
These changes are implemented here, requiring a backport of
fsl_flexspi_nor_boot.c. There is still a problem with the command line
version of the teensy loader, which fails on the first attempt. At the
second attempt it works. The GUI version of the teensy loader is fine.
All variants (except minimal) enable text compression and fat/lfs, so move
them to the common mpconfigport.mk.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This is a no-op for coverage and minimal.
The standard and dev variants have been merged and enable the same feature
set as a typical bare-metal board. And remove the CI for the dev build.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The freedos variant is untested by CI and is difficult to maintain. The
fast variant is not a good name for what it does.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
I.e. for whichever SPI/I2C instance is PICO_DEFAULT_I2C, there's no need to
set MICROPY_HW_SPIn_SCK.
The only ones remaining are for the non-default instance.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
In most cases, it's calculated automatically from the board name, and so
doesn't need to be set at all.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Since L4 HAL version 1.17.0, HAL_TIM_IC_Start_IT() checks whether specified
channel of timer is busy or not, which is the case if this function is
called more than once without first calling HAL_TIM_IC_Stop_IT(). The fix
in this commit is to call the stop function before calling start. The PWM
and OC modes have the same issue with the same fix.
Fixes issue #8732.
Prior to this commit, excuting this code:
i2c = I2C(1, I2C.CONTROLLER, dma=True)
i2c.send(data, addr=i2c_addr)
the call to i2c.send() does not return and the board needs a reset. This
code works when dma=False.
According to the specification, I2Cx_EV_IRQHandler should:
- Write DR to address when Start condition generated.
- Clear ADDR by reading SR2 after reading SR2 when address sent.
These processes are included in HAL_I2C_EV_IRQHandler(), however the
firmware size increses about 2KB if HAL_I2C_EV_IRQHandler is called. This
commit adds above processes to i2c_ev_irq_handler, and increases firmware
by less than 100 bytes.
Fixes issue #2643.
pyb.ADC(channel) checks whether specified channel is valid or have ADC
capability but pyb.ADCAll().read_channel() does not.
This change adds checking whether specified channel is valid and throw
ValueError if channel is invalid. This is same as pyb.ADC().
Although this driver and associated hardware can be used on any board, it
makes to only freeze it for PYB and PYBD boards. It can be easily copied
to any board if needed.
Fixes issue #8056.
Signed-off-by: Damien George <damien@micropython.org>
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>
micropython-lib is now a submodule, and the manifest compilation process
will ensure it is available, so manifests no longer need to check that it
is available.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
uart.flush()
flush() will wait until all characters have been sent.
To avoid a permanent lock, a timeout applies depending on the
size of FIFO and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress.
ret is False otherwise.
Since uart.write() of the nrf port waits until all bytes but the last
one have been sent, uart.flush() and uart.txdone() are implemented
as empty functions to provide API consistency.
uart.flush()
flush() will always return immediately, even if the last byte
may still be sent.
ret = uart.txdone()
uart.txdone() will always return True, even if the last byte
may still be sent.
Since uart.write() of the STM32 port waits until all bytes have
been sent, uart.flush() and uart.txdone() are implemented as empty
functions to provide API consistency.
uart.flush()
flush() will always return immediately.
ret = uart.txdone()
uart.txdone() will always return True.
uart.flush()
flush() will wait until all characters but the last one have been sent.
It returns while the last character is sent. If needed, the calling
code has to add one character wait time. To avoid a permanent lock,
a timeout applies depending on the size of the FIFO and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress. It returns already True when
the last byte of a transfer is sent.
ret is False otherwise.
uart.flush()
flush() will wait until all characters have been sent.To avoid a
permanent lock, a timeout applies depending on the size of txbuf
and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress.
ret is False otherwise.
uart.flush()
flush() will wait until all characters have been sent.To
avoid a permanent lock, a timeout applies depending on the
size of txbuf and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress.
ret is False otherwise.
uart.flush()
flush() will wait until all characters have been sent. It may return
while the last character is sent. if needed, the calling code has to
add one character wait time. To avoid a permanent lock, a timeout
applies depending on the size of txbuf and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress. It may return True if the
last byte of a transfer is sent.
ret is False otherwise.
Changes are:
- Remove unix- and stm32-specific sections (move unix to its own
README.md), stm32 was duplicated.
- Add links to GitHub Discussions and Discord.
- Update information about the project.
- Add a getting started section.
- Explain `make submodules`.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
So that everything is reset and the SD card can be created again after
calling SDCard.deinit() (and after a soft reset).
Fixes issue #8949.
Signed-off-by: Damien George <damien@micropython.org>
Having two separate manifests is confusing. It's simpler to have the daily
builds use the same configuration as the stable, release builds.
Signed-off-by: Damien George <damien@micropython.org>
The new `mp_obj_new_str_from_utf8_vstr` can be used when you know you
already have a unicode-safe string.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Previously the desired output type was specified. Now make the type part
of the function name. Because this function is used in a few places this
saves code size due to smaller call-site.
This makes `mp_obj_new_str_type_from_vstr` a private function of objstr.c
(which is almost the only place where the output type isn't a compile-time
constant).
This saves ~140 bytes on PYBV11.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The existing non-Docker instructions are basically impossible to follow
because the esp-open-sdk does not compile. Update these instructions to
use the exact toolchain that our CI uses.
Also split the Docker from non-Docker instructions, to avoid confusion
about which commands need to be prefixed.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
It has been about 8 years since support for this chip was added. Reasons
to remove it are:
- It is no longer easy to obtain this part.
- There are now many other options for WiFi.
- It's not a good use of developer time to maintain it.
Signed-off-by: Damien George <damien@micropython.org>
Not safe to use mp_hal_delay_ms before boot if threading is enabled,
because threading will not have been initialised, and
MICROPY_EVENT_POLL_HOOK assumes threading is initialised.
HAL_Delay doesn't call MICROPY_EVENT_POLL_HOOK, but is still
power-efficient like mp_hal_delay_ms (unlike mp_hal_delay_us).
Fixes#7816.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Rather than having the autobuild know about the particular variants, have
the mpconfigboard.mk describe them and make autobuild discover them
automatically.
Adds a "query-variants" target to stm32/Makefile to allow the set of
possible variants to be queried.
Removes pybv3 from the autobuild as this isn't use by the downloads page.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
If mboot is built with support for packing (signing/encryption) it needs up
to 32KiB. So for simplicity increase the mboot region to 32KiB
unconditionally for WB55 boards (custom WB55 board configurations can still
provide their own linker scripts to override this).
It used to be 10 bit times, which is too short. The break state must be
longer than a regular character time, at least 13 bit times. This is now
implemented by reducing the baudrate while sending the "0". The break time
will now vary with data length and parity setting, but will at least be 15
bit times.
Tested with a GENERIC_SPIRAM, GENERIC_C3 and UM_TINYS2 board.
Set the channel with esp_wifi_set_channel(), which adds support for setting
the channel of the STA interface
Get the channel with esp_wifi_get_channel() which returns the actual wifi
channel of the radio, rather than the configured channel.
Since commit e65d1e69e8 there is no longer an
io.FileIO class, so this option is no longer needed.
This option also controlled whether or not files supported being opened in
binary mode (eg 'rb'), and could, if disabled, lead to confusion as to why
opening a file in binary mode silently did the wrong thing (it would just
open in text mode if MICROPY_PY_IO_FILEIO was disabled).
The various VFS implementations (POSIX, FAT, LFS) were the only places
where enabling this option made a difference, and in almost all cases where
one of these filesystems were enabled, MICROPY_PY_IO_FILEIO was also
enabled. So it makes sense to just unconditionally enable this feature
(ability to open a file in binary mode) in all cases, and so just remove
this config option altogether. That makes configuration simpler and means
binary file support always exists (and opening a file in binary mode is
arguably more fundamental than opening in text mode, so if anything should
be configurable then it should be the ability to open in text mode).
Signed-off-by: Damien George <damien@micropython.org>
It seems sometimes gcc with LTO will generate otherwise valid assembly
listings that cause 'as' to error out when generating DWARF debug info; see
https://sourceware.org/bugzilla/show_bug.cgi?id=29494
Therefore, don't enable -g by default if LTO is on.
Enabling LTO=1 DEBUG=1 is still possible but may result in random errors
at link time due to 'as' (the error in this case is "Error: unaligned
opcodes detected in executable segment", and the only other easy workaround
is CFLAGS+=-fno-jump-tables which may increase code size significantly).
Follows on from fdfe4eca74
These were added in Python 3.5.
Enabled via MICROPY_PY_BUILTINS_BYTES_HEX, and enabled by default for all
ports that currently have ubinascii.
Rework ubinascii to use the implementation of these methods.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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.
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.
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 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>
For bare metal ARM & xtensa targets, passing -g will make the ELF file
larger but doesn't change the binary size. However, this means tools like
gdb, addr2line, etc can extract source-level information from the ELF.
Also standardise -ggdb to -g, these produce the exact same ELF file on
arm-none-eabi-gcc and will use DWARF format for all these ports.
This adds #ifdefs around each of the mp_hal_* time functions for the unix
port. This allows variants to override individual functions as needed.
Signed-off-by: David Lechner <david@pybricks.com>
Still see some USB issues apparently caused by delays loading wifi
firmware. cyw43_delay_ms is used to wait in the driver, so we should call
the event hook in there.
Fixes#8963.
The state machines were not properly restarted in the case that the same
PIO program was shared among multiple StateMachine instances. This is
because only the first StateMachine to use the program would set the
rp2_state_machine_initial_pc variable.
See https://forum.micropython.org/viewtopic.php?f=21&t=12776&p=69464#p69464
Fixes:
- Should read `definitions` rather than `defintions`.
- Should read `resolution` rather than `resoultion`.
- Should read `inefficient` rather than `inefficent`.
- Should read `closed` rather than `closded`.
Signed-off-by: Tim Gates <tim.gates@iress.com>
With a new option to evenly split the GC heap over multiple areas. This
adds code coverage for gc_add() and code associated with
MICROPY_GC_SPLIT_HEAP.
1. Add -Wno-array-bounds to avoid false positive on gcc 12.1; see related
issue #8685.
2. Remove always-true not-NULL-check (Msg.Rsp.Args.Common.Bssid is an array
not a pointer).
3. Fix pointer-to-freed-stack in wlan_set_security.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Originally in drivers/ninaw10/nina_wifi_bsp.c but that isn't a QSTR source.
Also remove outdated commment about root pointers in mpconfigport.h.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This is a statically-allocated UART (see machine_uart.c), and doesn't
contain any heap pointers other than the ringbufs (which are already root
pointers), so no need to track it additionally.
Saves needing to add mpbthciport.c to the QSTR sources.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
rp2: change tud_task() to tud_task_ext().
mimxrt: use lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c instead of
lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c.
nrf: add a definition for the changed tud_task(). tud_task() is changed
to tud_task_ext(), and the #define for backward compatibility is in
src/device/usbd.h.
The items I know which are fixed with this version:
- Fix for the SAMD USB lock-up.
- Support the MIMXRT11XX series of MCUs.
- Fix a wrong pin definition for MIMXRT1050_EVKB.
Tested with the MIMXRT boards, rp2 Pico, SAMD boards, nrf board.
This moves the libffi submodule variable modifier inside of the if
statement where it is actually used so that the submodule will only be
checked out if it is actually being used.
A new DEPLIBS variable is also introduced to prevent building the libffi
submodule when not needed.
Signed-off-by: David Lechner <david@pybricks.com>
All ports that use mbedtls use the custom error messages in
mp_mbedtls_errors.c. This commit simplifies the build so that ports don't
need to explicitly add this file, it's now used by default when mbedtls is
enabled.
Signed-off-by: Damien George <damien@micropython.org>
The reasons to make this switch are:
- The axtls library is not being maintained/updated, mbedtls is.
- So CI and tests can run against mbedtls, which is now the main TLS
library used by the ports (eg stm32, rp2, mimxrt, esp32). Only esp8266
uses axtls.
Increases unix standard build on x86-64 by about 89000 bytes.
Signed-off-by: Damien George <damien@micropython.org>
Based on existing bare-metal config from stm32. Also uses shorter error
messages from lib/mbedtls_errors.
Signed-off-by: Damien George <damien@micropython.org>
This uses MP_REGISTER_ROOT_POINTER() to register repl_line
instead of using a conditional inside of mp_state_vm_t.
Signed-off-by: David Lechner <david@pybricks.com>
All in-tree uses of MICROPY_PORT_ROOT_POINTERS have been replaced with
MP_REGISTER_ROOT_POINTER(), so now we can remove both
MICROPY_PORT_ROOT_POINTERS and MICROPY_BOARD_ROOT_POINTERS from the code
and remaining config files.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register pyb_stdio_uart and removes
the same from mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the renesas-ra port.
Signed-off-by: David Lechner <david@pybricks.com>
pyb_hid_report_desc is not used anywhere in the renesas-ra port (probably
was copied from stm32 port).
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register keyboard_interrupt_obj
and removes the same from mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the esp2866 port.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers for the cc3200 port.
Signed-off-by: David Lechner <david@pybricks.com>
mp_const_user_interrupt was listed as a root pointer but not used anywhere
in the code base, so it can be removed.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register mod_network_nic_list and
removes the same from all mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory
and bluetooth_nimble_root_pointers and removes the same from all
mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register
bluetooth_btstack_root_pointers and removes the same from all
mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register mp_wifi_spi, mp_wifi_timer
and mp_wifi_sockpoll_list and removes the same from all mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register mmap_region_head and
removes the same from mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register the readline_history root
pointer array used by shared/readline.c and removes the registration from
all mpconfigport.h files.
This also required adding a new MICROPY_READLINE_HISTORY_SIZE config option
since not all ports used the same sized array.
Signed-off-by: David Lechner <david@pybricks.com>
This adds new compile-time infrastructure to parse source code files for
`MP_REGISTER_ROOT_POINTER()` and generates a new `root_pointers.h` header
file containing the collected declarations. This works the same as the
existing `MP_REGISTER_MODULE()` feature.
Signed-off-by: David Lechner <david@pybricks.com>
Some devices, such as the LightBlue BTLE app on iOS, try to use Bluetooth 5
when connecting to a device. This means that they will send a
BLE_GAP_EVT_PHY_UPDATE_REQUEST message to shift to a new physical layer.
If this event isn't handled, LightBlue (and likely other Bluetooth 5.0
central devices) will try to connect and then fail, staying in
"Connecting..." state forever. This message should be replied to with
sd_ble_gap_phy_update, as documented in
drivers/bluetooth/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include/ble_gap.h.
This commit handles the event. LightBlue can now successfully connect to a
BTLE device on a P10059 nRF52840 dongle running MicroPython. Two other
related events have logging added in case they are needed in the future.
Commit 0e28a1f0e5 made it possible to set
-march=armv6m. It needs to be used when freezing for rp2.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Since nlr_jump_fail() exits the process, it can leave the terminal in raw
mode which means characters are not echoed. Fix this by restoring the
original terminal mode.
Signed-off-by: David Lechner <david@pybricks.com>
When a flash write/erase is in progress, we need to ensure that the
other core cannot be using XIP.
This also implements MICROPY_BEGIN_ATOMIC_SECTION as a full mutex, which
is necessary as it's used to syncronise access to things like the scheduler
queue.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The goal is to avoid a situation where core 1 is shut down while holding
the tinyusb spinlock, which could happen during soft reset if
mp_thread_deinit is called while core1 is running tud_task().
This also fixes a latent race where the two cores are competing to
decrement and compare `vm_hook_divisor` with no mem fence or atomic
protection -- only core0 will now do this.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>