This changes the signatures of QSPI write_cmd_data, write_cmd_addr_data and
read_cmd_qaddr_qdata so they return an error code. The softqspi and stm32
hardware qspi driver are updated to follow this new signature. Also the
spiflash driver is updated to use these new return values.
Signed-off-by: Damien George <damien@micropython.org>
The assertion that is added here (to gc.c) fails when running this new test
if ALLOC_TABLE_GAP_BYTE is set to 0.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
The STM32H7xx HAL LPUART AF macros are missing the number, this HAL is the
only one that's inconsistent in the way it defines LPUART AF macros, so we
only need to define them for H7.
Prior to this commit, only sector 0 was erase/write protected, which may
not be enough to protect all of mboot (especially if mboot lives at a
higher address than the start of flash).
This commit makes sure all internal flash sectors that mboot lives in are
protected from erasing and writing. The linker script must define
_mboot_writable_flash_start for this to work.
Signed-off-by: Damien George <damien@micropython.org>
The original ESP32 only supports timer source clock APB so it doesn't need
and doesn't have a clk_src field.
The ESP32C3 supports timer source clock APB and XTAL so it does have a
clk_src field, and this needs to be configured to get the correct period.
Fixes#8084.
Follow up to 8a91c719 to no longer explicitly disable BLE in
mpconfigport.h.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
For STM32L4, hardware I2C can be implemented by using TIMINGR.
This commit enables:
- Use of hardware I2C in machine.I2C.
- Specifying a frequency greater than or equal to 400KHz with pyb.I2C.
For STM32L4 series, the internal sensors are connected to:
- ADC1_IN0: Internal voltage reference
- ADC1_IN17: Temperature sensor
- ADC1_IN18: VBAT battery voltage monitoring
but ADC_CHANNEL_VREFINT, ADC_CHANNEL_VBAT, ADC_CHANNEL_TEMPSENSOR are not
defined as 0, 17, 18.
This commit converts channel 0, 17, 18 to ADC_CHANNEL_x in
adc_get_internal_channel().
Prior to this commit, the actual I2C frequency can be faster than specified
one and it may exceed the I2C's specification for Fast Mode. The frequency
of SCL should be less than or equal to 400KHz in Fast Mode.
This commit fixes this issue for F4 MCUs by rounding up the division in the
frequency calculation.
Excuting the code:
i2c = I2C(1, I2C.CONTROLLER, dma=True)
tmp = i2c.recv(1, i2c_addr)
recv_data = bytearray(56)
i2c.recv(recv_data, i2c_addr)
The second i2c.recv() fails with OSError: [Errno 110] ETIMEDOUT. When
receiving greater than or equal to 2 bytes at first i2c.recv(), the second
i2c.recv() succeeds. This issue does not occur without DMA.
Details of change: when executing I2C with DMA:
- Bit 11 of I2Cx_CR2 (DMA Request Enable) should be 1 to indicate that DMA
transfer is enabled. This bit is set after I2C event interrupt is
enabled in HAL_I2C_Master_Transmit_DMA()/HAL_I2C_Master_Receive_DMA(), so
DMA Request Enable bit might be 0 in IRQHandler.
- In case of data receive:
- When only 1 byte receiption, clear I2Cx_CR1's bit 10 (ACK).
- When only 2 byte receiption, clear I2Cx_CR1's bit 10 (ACK) and set
bit 11 (POS).
- When greater than or equal to 2 byte receiption, bit 12 of I2Cx_CR2
(DMA Last Transfer) should set to generate NACK when DMA transfer
completed.
Otherwise, the I2C bus may be busy after received data from peripheral.
Instead of defining `MICROPY_PY_BTREE` in `mpconfigport.h` we can define
it via CMake similar to how other ports that use Makefiles define it in
`mpconfigport.mk`.
Signed-off-by: David Lechner <david@pybricks.com>
The RT1176 has two cores, but the actual firmware supports only the CM7.
There are currently no good plans on how to use the CM4.
The actual MIMXRT1170_EVK board is on par with the existing MIMXRT boards,
with the following extensions:
- Use 64 MB RAM for the heap.
- Support both LAN interfaces as LAN(0) and LAN(1), with LAN(1)
being the 1GB interface.
The dual LAN port interface can eventually be adapted as well for the
RT1062 MCU.
This work was done in collaboration with @alphaFred.
Avoids the 'warning: Wildcards in project items are not supported'
message from the C++ project system in Visual Studio, while otherwise
remaining completely functional.
A board can now name the CDC ports, eg:
#define MICROPY_HW_USB_CDC_NUM (3)
#define MICROPY_HW_USB_INTERFACE_CDC0_STRING "REPL"
#define MICROPY_HW_USB_INTERFACE_CDC1_STRING "GDB Server"
#define MICROPY_HW_USB_INTERFACE_CDC2_STRING "UART Port"
Signed-off-by: Damien George <damien@micropython.org>
The PWM module now detects if the pin is open drain and if so switches it
to hardware open drain before starting the PWM.
The code that was explicitly turning off the open drain output during PWM
is also removed.
Together these changes allow driving external transistor high-current
switches with PWM.
Signed-off-by: Trammell hudson <hudson@trmm.net>
Changes in this commit:
- Change file system size from 128KB to 64KB in ra6m1_ek.ld.
- Change EK-RA6M1's file system size in renesas-ra port document.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
Changes in this commit:
- Add FLASH_FS region to linker script.
- Add flash storage start & end symbols to linker script.
- Use flash storage start & end symbols in flashbdev.c
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
App the mp_ prefix to usbd_ symbols and files which are defined here and
not in TinyUSB.
rp2 only for now. This includes some groundwork for dynamic USB devices
(defined in Python).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Seems unused outside of spi.c, spi_obj[] array is the expected way to
iterate these.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This changes the CustomEvent for stdout to use the existing `detail`
property of CustomEvent instead of adding a `data` property.
Signed-off-by: David Lechner <david@pybricks.com>
mip-cmdline adds command-line support to mip, useful for the unix port, via
micropython -m mip ...
Signed-off-by: Damien George <damien@micropython.org>
This commit executes __WFI() on core 0 only to avoid core1 locking up since
it doesn't enable any interrupts by default (except for `SIO_IRQ_PROC1`).
This fixes a lockup when calling `cyw43_do_ioctl` from core1.
Fixes issue #9597.
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up. This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up. This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up. This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up. This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
Fixes issue #9634.
Most of the content of README.md became obsolete and was replaced by the
documentation of MicroPython. Instead, README.md now shows build
instructions like the other ports.
Including the uasyncio scripts and the drivers for DHT, DS18x20 and
onewire. The uasyncio scripts need about 8k of flash and are not included
for the SAMD21 boards by default.
Emscripten strongly advises the use of optimisation when compiling with
ASYNCIFY enabled. Testing the difference betwen O3 and Os for various
configurations gives:
flags firmware.wasm micropython.js perf
-O3 -s ASYNCIFY 1342003 212845 0 (baseline)
-O3 -s ASYNCIFY -s WASM=0 - 7064750 -30%
-O3 367131 196569 +140%
-O3 -s WASM=0 - 2818260 +30%
-Os -s ASYNCIFY 1135450 213064 +40%
-Os -s ASYNCIFY -s WASM=0 - 6239768 -30%
-Os 295028 196569 +180%
-Os -s WASM=0 - 2271358 +30%
The first row is prior to this commit. The second and third columns show
firmware size (add them to get the total size). The fourth column shows
the approximate change in performance compared to the baseline. The
performance was measured using run-perfbench.py and the error was large, up
to 20%, although general trends in the change in performance could still be
seen.
In summary, using using Os instead of O3 makes it a little bit faster in
all cases, and smaller output (wasm/js) in all cases.
Signed-off-by: Damien George <damien@micropython.org>
This simplifies the config file. This is not a no-op, it does enable a few
new features to bring the port in line with this config level.
Signed-off-by: Damien George <damien@micropython.org>
Checks are added for pwm.freq(), pwm_duty(), pwm_duty_u10() and
pwm.duty_u16(). This avoids a core dump on ESP32C3, and misleading error
messages on Xtensa ESP32 devices.
Set the size of machine_pin_irq_handler array to GPIO_NUM_MAX:
- Min GPIO_NUM_MAX is 22 for IDF_TARGET_ESP32C3.
- Max GPIO_NUM_MAX is 49 for IDF_TARGET_ESP32S3.
The MP_REGISTER_ROOT_POINTER entry must be hard-coded, because the location
that it's evaluated by the compiler does not include the relevant IDF
header to get a definition of GPIO_NUM_MAX.
Each SoC family has its own clocks and timings/timeouts. For I2C, the
default source clock is either APB (ESP32, ESP32-S2) or XTAL (ESP32-S3,
ESP32-C3) as shown in the datasheets. Since
machine_i2c.c/machine_hw_i2c_init() uses the default clk_flags (0), the
alternate low-power clock source is never selected in ESP-IDF
i2c.c/i2c_param_config(). There is not an API in i2c.c to get the source
clock frequency, so a compile-time value is used based on SoC family.
Also, the maximum timeout is different across the SoC families, so use the
I2C_LL_MAX_TIMEOUT constant to eliminate the warning from
i2c_set_timeout().
With these changes, the following results were obtained. The I2C SCL
frequencies were measured with a Saleae logic analyzer.
ESP32 (TTGO T Dislay)
I2C(0, scl=22, sda=21, freq=101781) Measured: 100KHz
I2C(0, scl=22, sda=21, freq=430107) Measured: 400KHz
I2C(0, scl=22, sda=21, freq=1212121) Measured: 941KHz
ESP32-S3 (TTGO T-QT)
I2C(0, scl=34, sda=33, freq=111111) Measured: 107KHz
I2C(0, scl=34, sda=33, freq=444444) Measured: 400KHz
I2C(0, scl=34, sda=33, freq=1111111) Measured: 842KHz
ESP32-C3 (XIAO ESP32C3)
I2C(0, scl=7, sda=6, freq=107816) Measured: 103KHz
I2C(0, scl=7, sda=6, freq=444444) Measured: 380KHz
I2C(0, scl=7, sda=6, freq=1176470) Measured: 800KHz
(ESP32-S2 board was not available for testing.)
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>
This issue affected i.MX RT 1052, 1062 and 1064. It seems to be addressed
by Errata ERR006223, which also mentions i.MX RT101x and 102x, but these
devices worked well even without the change. As a side effect, the current
consumption at an idle REPL drops significantly with this fix.
Fixes issue #7235.
Protect SerCom (UART, SPI, I2C) objects from getting freed by the GC when
they go out of scope without being deinitialized. Otherwise the ISR of a
Sercom may access an invalid data structure.
Any update of freq or duty_cycle requires the previous PWM cycle to be
finished. Otherwise the new settings are not accepted.
Other changes in this commit:
- Report the set duty cycles even when the PWM is not yet started.
- pwm.freq(0) stops the pwm device, instead of raising an expception.
- Clear the duty cycle value cache on soft reset.
Changes are:
- Remove the LED_Pxxx definitions from pins.csv, now that the LED class is
gone.
- Remove the '-' lines.
- Add default lines for USB and SWCLK, SWDIO.
Pin numbers are now the MCU port numbers in the range:
PA0..PA31: 0..31
PB0..PB31: 32..63
PC0..PC31: 64..95
PD0..PD31: 96..127
Pins can be denoted by the GPIO port number, the name as defined in
pins.csv or a string in the form Pxnn, like "PA16" or "PD03".
The pins.c and pins.h files are now obsolete. The pin objects are part of
the AF table.
As result of a simplification, the code now supports using pin names or
numbers instead of pin objects for modules like UART, SPI, PWM, I2C, ADC,
pininfo.
This removes the difference in the time.ticks_us() range between SAMD21 and
SAMD51.
The function mp_hal_ticks_us_64() is added and used for:
- SAMD51's mp_hal_ticks_us and mp_hal_delay_us().
For SAMD21, keep the previous methods, which are faster.
- mp_hal_ticks_ms() and mp_hal_tick_ms_64(), which saves some bytes
and removes a potential race condition every 50 days.
Also set the us-counter for SAMD51 to 16 MHz for a faster reading of the
microsecond value.
Note: With SAMD51, mp_hal_ticks_us_64() has a 60 bit range only, which is
still a long time (~36000 years).
Methods implemented are:
- rtc.init(date)
- rtc.datetime([new_date])
- rtc.calibration(value)
The presence of this class can be controlled by MICROPY_PY_MACHINE_RTC. If
the RTC module is used, the time module uses the RTC as well.
For boards without a 32kHz crystal, using RTC makes no sense, since it will
then use the ULP32K oscillator, which is not precise at all. Therefore, it
will by default only be enabled for boards using a crystal, but can be
enabled in the respective mpconfigboard.h.
Using the stream method for uart.flush().
uart.txdone() returns True, if the uart not busy, False otherwise.
uart.flush() waits until all bytes have been transmitted or a timeout
triggers. The timeout is determined by the buffer size and the baud rate.
Also fix two inconsistencies when not using txbuf:
- Report in ioctl as being writeable if there is room in the tx buffer,
only if it is configured.
- Print the txbuf size if configured.
Instead of being hard-coded, and then it works for all MCUs.
That fits except for a Sparkfun SAMD51 Thing Plus (known) bug, which uses
192k - 4 as magic address. Therefore, that address is set as well to avoid
a problem when this bug is fixed by Sparkfun.
Which just sets the CPU clock to 200kHz and switches the peripheral clock
off. There are two modes:
machine.lightsleep(duration_ms)
and
machine.lightsleep()
In any mode any configured pin.irq() event will terminate the sleep.
Current consumption in lightsleep for some boards:
- 1.5 - 2.5 mA when supplied trough an active USB
(Seeed XIAO w/o power LED, Adafruit ItsyBitsy)
- 0.8 - 2 mA when supplied through Gnd/+5V (Vusb)
(Seeed XIAO w/o power LED, Adafruit ItsyBitsy)
- < 1 mA for SAMD51 when supplied trough a battery connector
(Sparkfun Thing SAMD51 plus)
Related change: move the calls to SysTick_Config() into set_cpu_freq(). It
is required after each CPU freq change to have ticks_ms run at the proper
rate.
Tested with a SD card connected to a SAMD51 board. The SEEED WIO terminal
has a SD-Card reader built-in.
Also a side change to remove a few obsolete lines from Makefile.
The range is 1MHz - 48 MHz. Note that below 8 MHz there is no USB support.
The frequency will be set to an integer fraction of 48 MHz. And after
changing the frequency, the peripherals like PWM, UART, I2C, SPI have to be
reconfigured.
Current consumption e.g. of the Seeed Xiao board at 1 MHz is about 1.5 mA,
mostly caused by the on-board LED (green LED with 1k resistor at 3.3V).
The value given for machine.freq(f) is extend to the range of 1_000_000 to
200_000_000. Frequencies below 48 MHz will be forced to an integer
fraction of 48 MHz. At frequencies below 8 MHz USB is switched off. The
power consumption e.g. of ADAFRUIT_ITSYBITSY_M4_EXPRESS drops to about
1.5 mA at 1 MHz.
Since the peripheral frequency is dropped as well, timing e.g. of PWM,
UART, I2C and SPI is affected and frequency/baud rate has to set again
after a frequency change below 48 MHz.
This is necessary to access sites that only support these protocols.
The rp2 port already has ECDH enabled, so this just adds ECDSA there. The
other ports now gain both ECDH and ECDSA. The code size increase is:
- rp2 (PICO_W): +2916 bytes flash, +24 bytes BSS
- stm32 (PYBD_SF6): +20480 bytes flash, +32 bytes data, +48 bytes BSS
- mimxrt (TEENSY41): +20708 bytes flash, +32 bytes data, +48 bytes BSS
- unix (standard x86-64): +39344 executable, +1744 bytes data, +96 BSS
This is obviously a large increase in code size. But there doesn't seem to
be any other option because without elliptic curve cryptography devices are
partially cut off from the internet. For use cases that require small
firmware size, they'll need to build custom firmware with a custom mbedtls
config.
Signed-off-by: Damien George <damien@micropython.org>
The following multi-tests pass (eg with PYBD_SF6+LEGO_HUB_NO6):
ble_gap_advertise.py
ble_gap_connect.py
ble_gap_device_name.py
ble_gattc_discover_services.py
ble_gatt_data_transfer.py
perf_gatt_char_write.py
perf_gatt_notify.py
stress_log_filesystem.py
These are the same tests that passed prior to this BTstack update.
Also tested on the unix port using H4 transport.
Signed-off-by: Damien George <damien@micropython.org>
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.