summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-10-31tools/mpremote: Make RemoteFile objects iterable.Damien George
So that filesystems mounted with "mpremote mount" can have their files iterated over, making them consistent with other files. Signed-off-by: Damien George <damien@micropython.org>
2022-10-31tools/mpremote: Handle FileNotFound exceptions in listdir.Jim Mussared
The except handler for OSError didn't include the line that actually calls os.listdir, so an invalid path wasn't handled correctly. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-31esp32/machine_pwm: Verify PWM is active when config methods are called.robert-hh
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.
2022-10-31esp32/machine_pin: Fix size of machine_pin_irq_handler array.Ihor Nehrutsa
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.
2022-10-28esp32/machine_i2c: Fix clocks and timeouts for ESP32-C3, ESP32-S3.Mark Grosen
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.)
2022-10-27samd/machine_timer: Use extmod version of machine.Timer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-10-27renesas-ra/machine_timer: Use extmod version of machine.Timer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-10-27mimxrt/machine_timer: Use extmod version of machine.Timer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-10-27extmod/machine_timer: Move stm32's implementation of machine.Timer here.Damien George
So it can be reused by other ports. Signed-off-by: Damien George <damien@micropython.org>
2022-10-27nrf: Rename MICROPY_PY_MACHINE_TIMER to MICROPY_PY_MACHINE_TIMER_NRF.Damien George
So that it doesn't clash with the extmod version. Also make the default for this enabled, so that most boards do not need to configure it. Signed-off-by: Damien George <damien@micropython.org>
2022-10-27mimxrt/machine_timer: Use soft-timer implementation for machine.Timer.robert-hh
This releases the hardware timers for other tasks, which need a higher resolution and faster response. And it is less port-specific code.
2022-10-27mimxrt: Fix CPU freeze when calling __WFE() in MICROPY_EVENT_POLL_HOOK.robert-hh
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.
2022-10-27mimxrt/machine_pin: Add the Pin.toggle() method.robert-hh
For consistency with other ports, even if this method is undocumented at the moment.
2022-10-27py/makeversionhdr: Fall back to py/mpconfig.h instead of docs/conf.py.Damien George
Commit 64af916c111b61bce82c00f356a6b1cb81946d87 removed the version string from docs/conf.py. py/mpconfig.h is a better place to get the version from, so use that (when there is no git repository). Signed-off-by: Damien George <damien@micropython.org>
2022-10-26docs/samd: Add documentation for the samd port.robert-hh
Includes a general overview, a quickref, pinout tables, and the beginnings of a tutorial.
2022-10-26docs/templates/layout.html: Indicate latest vs release docs.Jim Mussared
When looking at latest (the default for docs.micropython.org), make it clear that this isn't the release version. - Changes the version in the top-left to "latest". - Adds a message to the top of each page to explain. For future release versions, add a short message to link to the latest version. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-26py/obj: Add comments explaining the slot index scheme.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-25samd/modmachine: Add machine.softreset().robert-hh
For consistency with other ports.
2022-10-25samd/machine_spi: Register SerCom objects as root pointers.robert-hh
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.
2022-10-25samd/machine_spi: Implement spi.deinit() and simplify sercom_deinit_all.robert-hh
The sercom_deinit_all() function does not need the object pointers.
2022-10-25samd/machine_uart: Use a finaliser to tidy up UART on soft reset.robert-hh
And use the common sercom_table, saving a few bytes of RAM.
2022-10-25samd/machine_pwm: Serialize fast update of PWM settings.robert-hh
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.
2022-10-25samd/boards: Rework the pins.csv files.robert-hh
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.
2022-10-25samd/modmachine: Replace the LED class by the Signal class.robert-hh
It simplifies and improves the code. The LED_Pxxx lines of the board.csv lines can still be used, but will be taken as Pin definitions.
2022-10-25samd: Make ADC, DAC, PWM, SPI objects consistent in how they print out.robert-hh
All of ADC, DAC, Pin, PWM and SPI looked different before this change.
2022-10-25samd/machine_pin: Change the pin handling and naming/numbering.robert-hh
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.
2022-10-25samd/boards/SEEED_WIO_TERMINAL: Declare more pins for SEEED WIO board.robert-hh
Defining all pins from the external 40 Pin connector, and some internal pins like the one for SD and LCD.
2022-10-25samd/clock_config: Extend the SAMD51 us-counter to 60 bit.robert-hh
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).
2022-10-25samd/machine_rtc: Add the machine.RTC class.robert-hh
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.
2022-10-25samd/mcu: Make some settings in mpconfigmcu.h conditional.robert-hh
And set the default for MICROPY_PY_MATH as 1 for both MCU types.
2022-10-25samd/machine_uart: Implement uart.txdone() and uart.flush().robert-hh
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.
2022-10-25samd/clock_config: Document the #defines use in init_clocks().robert-hh
Which may be set in the respective mpconfigboard.h files.
2022-10-25samd/modmachine: Get the bootloader magic address from the lib.robert-hh
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.
2022-10-25samd/modmachine: Implement machine.lightsleep().robert-hh
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.
2022-10-25samd/mcu/samd51: Enable FAT support for SAMD51.robert-hh
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.
2022-10-25samd/mcu/samd51: Enable onewire support for SAMD51.robert-hh
2022-10-25samd/modmachine: Add machine.dht_readinto and enable on SAMD51.robert-hh
2022-10-25samd/boards/SPARKFUN_SAMD51_THING_PLUS: Add board files for Thing Plus.robert-hh
That device uses an SAMD51J20 MCU with 256k RAM and 1024k flash.
2022-10-25samd/modmachine: Add machine.reset_cause().robert-hh
2022-10-25samd/clock_config: Support changing machine.freq() for SAMD21.robert-hh
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).
2022-10-25samd/clock_config: Extend the range of machine.freq().robert-hh
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.
2022-10-25py/persistentcode: Only emit sub-version if generated code has native.Jim Mussared
In order for v1.19.1 to load a .mpy, the formerly-feature-flags which are now used for the sub-version must be zero. The sub-version is only used to indicate a native version change, so it should be zero when emitting bytecode-only .mpy files. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-25stm32/boards/ARDUINO_PORTENTA_H7: Revert to single-precision float.Jim Mussared
Using repr C is incompatible with double-precision floats on 32-bit arch. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-25py/obj: Verify floating point type is correct for repr C.Jim Mussared
Prevents double-precision floats being enabled on 32-bit architectures where they will not fit into the mp_obj_t encoding. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-22extmod/mbedtls: Remove brainpool curves from config.Damien George
They are much slower than NIST (SECP) curves and shouldn't be needed. Reduces rp2 PICO_W firmware by 1328 bytes. Thanks to @Carglglz for the information. Signed-off-by: Damien George <damien@micropython.org>
2022-10-22extmod/mbedtls: Remove MBEDTLS_ECP_DP_CURVE25519_ENABLED config.Damien George
Curve25519 arithmetic is supported in mbedtls, but it's not used for TLS. So there's no need to have this option enabled. Reduces rp2 PICO_W firmware by 2440 bytes. Thanks to @Carglglz for the information. Signed-off-by: Damien George <damien@micropython.org>
2022-10-22extmod/mbedtls: Enable elliptic curve DH and DSA cryptography.Damien George
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>
2022-10-22extmod/mbedtls: Enable MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE.Damien George
This was already enabled on all ports except mimxrt. Now it's enabled on all of them. Signed-off-by: Damien George <damien@micropython.org>
2022-10-22extmod/mbedtls: Add common configuration file, and use it in all ports.Damien George
This is a no-op change. Signed-off-by: Damien George <damien@micropython.org>
2022-10-22extmod/btstack: Update BTstack bindings to work with latest BTstack.Damien George
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>