Documentation about float - #1
Open
massimosala wants to merge 4300 commits into
Open
massimosala wants to merge 4300 commits into
massimosala wants to merge 4300 commits into
Conversation
This commit refactors `basics/string_fstring.py` to extract the part of the test that requires floating point support into its own file under the `float/` tests directory. The QEMU/PPC64 port currently supports F-Strings but has no floating point support enabled as well. Such a combination was not taken into account and thus the test would fail at the very end on that port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds support for the POWERNV9 QEMU board, emulating a PowerPC POWER9 system. The board can be interacted with using the same Makefile targets as the other boards, by using `POWERNV9` as the `BOARD=` argument value. Given the current toolchain state, right now floating point support is not enabled, as the toolchain expects to either use a Linux-compatible standard library running under a proper OS, or to not use any standard library at all (meaning we have to provide our own). There are plans to introduce an on-demand built version of either newlib or picolibc, but they will involve a series of commits that will be submitted later on. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds the PPC64 variant of the QEMU port to the list of targets to be tested as part of the CI process. The target is limited to regular test runs, as it has no native modules support and no native emitter. This means the example natmods cannot be tested against the built interpreter, and the full test run also includes executing the standard suite of tests after being compiled via the native emitter backend. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit removes the stand-alone PowerPC port from the MicroPython source tree. Now that QEMU gained support for PPC64 images, it makes little sense to keep the standalone PPC64 port around - especially since said port has been sort of neglected in the past years. Given that the QEMU port is routinely tested there are more chances for the PPC64 architecture to be better supported this way rather than in its previous incarnation. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
- mpconfigport.h: Configure the CAN include file. - alif-mk: Add the fdcan.c driver to the soucr list. - Makefile: Export $(BOARD) to alif.mk. Signed-off-by: robert-hh <robert@hammelrath.com>
For both the OPENMV_AE3 and ALIF_ENSEMBLE boards. - mpconfigboard.h: Specify the CAN name "CAN1" and numbers. - pins.csv: Add the CAN_RXD and CAN_TXD pin names. - ensemble_pin_alt.csv: Add the CAN pin ALT symbols - mphalport.h: Add the CAN enum symbols. The CAN interface pins: ALIF_ENSEMBLE: P12_4 for RX and P12_5 for TX. OPENMV_AE3: P0_4 for RX and P0_5 for TX. The OPENMV_AE3 board has 1.8V/3.3V level shifters at these pins. Signed-off-by: robert-hh <robert@hammelrath.com>
Just one device, no arguments. Signed-off-by: robert-hh <robert@hammelrath.com>
- multi_extmod/machine_can_04_tx_order.py: Skip for Alif, since the Alif port has an opaque send queue which provides no information of the slot number of a message in the TX queue. - multi_extmod/machine_can_05_tx_prio_cancel.py: Skip for Alif, since the Alif port has an opaque send queue which does not allow specific cancels and provides no information of the slot number of a message in the TX queue. - tests/multi_extmod/machine_can_07_error_states.py: Swap the order of resetting the baud rate and restart(). If restart() happens before resetting the baud rate, then the REC counter increases fast and the bus state switched to PASSIVE before the baud rate can be fixed. - tests/multi_extmod/machine_can_07_error_states.py: Add a delay after sending the message "PAYLOAD" avoiding a collision with the test broadcast messages. - multi_extmod/machine_can_08_init_mode.py: Cater for error frames not being reported in SILENT mode. Signed-off-by: robert-hh <robert@hammelrath.com>
Signed-off-by: robert-hh <robert@hammelrath.com>
Supporting CAN 2.0.
The send and receive FIFOs of the Alif CAN controller are opaque and
provide no information, which message slot is used for a specific
message. Therefore, specific messages cannot be removed from the FIFO.
Some of the CAN tests should therefore fail.
Observations from the implementation:
- Even if the 160M clock is used, the 38M4 clock has to be enabled.
- Bit timing is off by 1 clock cycle if set according the data sheet.
Use tseg1 - 1 for S_SEG1 instead of tseg1 - 2, which seems to be
suggested by the data sheet.
- IRQs are re-triggered as long as the respective flags is set, even if
the IRQ source is disabled. Therefore all IRQ events have to be
handled in the IRQ handler.
- Acceptance filters can only be enabled in reset state. Therefore that
filter setting are collected, and when done init() is called to
activate the filters. As a side effect, the error numbers are cleared.
- There is a problem with the TX FIFO under heavy load. In an attempt to
fill messages faster than they can be sent, The behaviour gets strange.
Instead of just rejecting messages when the FIFO is full, the following
appears:
- messages were told to be accepted for sending, but they never were
sent.
- messages were sent twice, but other messages were missing.
- the priority rule was broken by messages not being sent in proper
sequence.
It seems that the "full" state is the problem. As a fix the can.send()
now refuses messages if the FIFO is more than half full. Then the
situation seems stable.
Signed-off-by: robert-hh <robert@hammelrath.com>
The events are put in the ringbuf when a callback is scheduled.It can then be obtained using can.irq().flags() and provides the IRQ_FLAGS state at the moment when the callback was scheduled. Signed-off-by: robert-hh <robert@hammelrath.com>
- No TX queue index reported for sent messages. - Unable to cancel a specific message. - No exact numbers reported for the number of messages in the TX/RX queue Signed-off-by: robert-hh <robert@hammelrath.com>
It was 0, but that was to high affecting other operations. Now it is at 80, in the range of other medium speed I/O devices. Change suggested by Damian George. Signed-off-by: robert-hh <robert@hammelrath.com>
To calculate RTSS_Hx_CLK frequency. Signed-off-by: Damien George <damien@micropython.org>
This commit implements watchdog timer support on the alif port. On the HP core with default clock settings it supports a timeout of up to 10.7s. When the watchdog fires it triggers the NMI IRQ handler, so custom code is added to reset the SoC when that occurs. Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Waiting for the link has a 5 second timeout, and the system should sleep efficiently and poll/process other events while waiting. Fixes issue #19410. Signed-off-by: Damien George <damien@micropython.org>
Required by the include-based linker script support that follows. Signed-off-by: Phil Howard <github@gadgetoid.com>
Pico SDK 2.3.0 makes its default linker script overridable via includes, so the port no longer needs to carry a full copy. Replace the monolithic memmap_mp_rp2040.ld and memmap_mp_rp2350.ld with memmap_mp_rp2.ld, which includes the SDK default, plus small override fragments under memmap_rp2/, memmap_rp2040/ and memmap_rp2350/ that supply only the MicroPython parts: the FLASH/FLASH_FS split, moving gc/vm/parse into RAM, and the GC heap and stack layout. Memory region boundaries are unchanged. Co-authored-by: Phil Howard <github@gadgetoid.com> Signed-off-by: Phil Howard <github@gadgetoid.com>
ROMFS is carved off the top of the code space (just below the user filesystem) by rp2_flash.c, but the FLASH region only excluded the filesystem, so the application region overlapped ROMFS. A firmware that grew into ROMFS was not caught by the linker, only by a debug-only runtime assert. Add MICROPY_HW_ROMFS_BYTES as a CMake variable, feeding both a linker defsym and a compile definition from one source, and give ROMFS its own FLASH_ROMFS region so the FLASH application region excludes it. The linker now fails at build time if the firmware overlaps ROMFS. With the default of 0 bytes the layout is unchanged. Signed-off-by: Phil Howard <github@gadgetoid.com>
Bring the port's runtime_init_clocks() in line with the pico-sdk 2.3.0 version, since it was originally derived from this function. PLL_COMMON_REFDIV is deprecated in the SDK in favour of the separate PLL_SYS_REFDIV and PLL_USB_REFDIV macros; use those so a board that only sets the new per-PLL values is honoured, and so the port keeps building if the deprecated macro is eventually removed. Configure the divide-by-1 clocks (ref, sys, usb, adc, peri, hstx) with clock_configure_undivided(), and clk_rtc with clock_configure_int_divider(), as the SDK now does. Both avoid the 64-bit division that clock_configure() pulls in to compute a fractional divider. Drop the --wrap=runtime_init_clocks linker flag: the SDK declares runtime_init_clocks() as __weak, so a plain strong definition in the port overrides it, which makes the wrap redundant. Also switch the HSTX guard to HAS_HSTX and take RTC_CLOCK_FREQ_HZ from hardware/rtc.h, matching upstream. No functional change to the clock configuration on existing boards. Signed-off-by: Phil Howard <github@gadgetoid.com>
Without -fno-math-errno the compiler must keep sqrt()/sqrtf() as library calls so they can set errno on a domain error, even though the Cortex-M33 FPU has a single VSQRT.F32 instruction. MicroPython's math module detects domain errors via isnan/isinf checks on the result rather than errno, so disabling errno here is safe and lets sqrt leverage hardware. Benchmarked on a Pico 2 (RP2350, perfbench N=150 M=100, avg of 3): misc_mandel (complex abs() in its inner loop) improves by ~12%, with no measurable change to non-sqrt benchmarks and a slightly smaller binary. Signed-off-by: Phil Howard <github@gadgetoid.com>
rp2/CMakeLists.txt: Use quoted literals for the BTstack and oofatfs config files, so the escaped double quotes don't break syntax highlighting in VSCode and GitHub's web UI. Signed-off-by: Phil Howard <github@gadgetoid.com>
The bundled TinyUSB device endpoint-transfer API gained a trailing bool is_isr argument on usbd_edpt_xfer()/usbd_edpt_xfer_fifo() and on the matching dcd_edpt_xfer()/dcd_edpt_xfer_fifo() driver entry points, and the stm32_fsdev driver was split into a shared fsdev_common.c. Adapt the in-tree users so the bump builds across ports: - extmod/machine_usb_device.c: pass is_isr=false on the USBDevice.submit_xfer() path (never an ISR), guarded by TUSB_VERSION_NUMBER so ports building against an older bundled TinyUSB (e.g. esp32 via ESP-IDF) still compile. - ports/alif/tinyusb_port: the port's custom dcd driver takes the new argument on both entry points (unused by this driver). - ports/stm32: build the new lib/tinyusb fsdev_common.c, which provides the PMA/btable helpers used by dcd_stm32_fsdev.c. Signed-off-by: Andrew Leech <andrew@alelec.net>
4KB CDC buffers max out USB packet movement performance with HS USB. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Works for bytes.decode() and str constructor. Previously ascii arg was treated the same as utf8, now only 7-bit bytes are treated as valid ascii characters. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
bytes() constructor uses the same code path. Also brings over the same supported encodings check for the bytes constructor that already exists for str.encode(). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Partially this is documenting some additional limitations added recently now that the encoding argument is not totally ignored. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
The port used the smallest lwipopts_common.h memory tier: MSS=800, an 8*MSS=6400 byte window and an 8000 byte heap. On WiFi round-trip times that window caps TCP at window/RTT, and the sub-MTU MSS costs per-packet efficiency on every link. Measured on an OpenMV RT1060 (CYW4343W WiFi): TCP was limited to 6.4Mbit/s transmit / 15.9Mbit/s receive. Switch to MSS=1460 with a 7*MSS receive window, 6*MSS send buffer and a 13K heap (sized so the heap comfortably exceeds the send buffer, keeping lwIP's ERR_MEM retry path cold). With this configuration the same benchmark measures 22.2Mbit/s transmit / 24Mbit/s receive (3.5x / 1.5x), with UDP unaffected. 100M ethernet on the same silicon still runs at line rate. All values are guarded so a board can override them, and only boards with a network interface build lwIP on this port. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
The RTC prescalers were fixed at compile time via RTC_ASYNCH_PREDIV and RTC_SYNCH_PREDIV, sized for a 32768Hz LSE. When the RTC actually runs from the ~32kHz LSI -- because the LSE failed to start, or because a bootloader configured it that way before MicroPython ran -- the same divider leaves the RTC about 2.3% slow (over half an hour per day), far beyond what rtc.calibration() can correct. Select the prescalers at startup for the clock source the RTC actually uses: RTC_x_PREDIV_LSE (defaulting to the existing RTC_x_PREDIV values) when running from the LSE, and RTC_x_PREDIV_LSI (defaulting to a divide by the LSI's nominal 32000) when running from the LSI, whether found already running, chosen at fresh init, or entered via the LSE-failure fallback. The existing wrong-prescaler repair path now also targets the selected values, so moving between sources corrects the divider without losing the date and time. The subsecond/microsecond conversions previously baked RTC_SYNCH_PREDIV in at compile time; they now use the runtime prescaler (with 64-bit intermediate math, exact for any prescaler value) so subseconds stay correct for whichever source is in use. Measured on an Arduino Nicla Vision (RTC held on the LSI by its stock bootloader): the timekeeping error improves from -22300ppm to -684ppm, with the remaining part-specific LSI offset trimmable via rtc.calibration(). Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
The Arduino Giga, Nicla Vision, Opta and Portenta H7 have an accurate external 32768Hz oscillator (a SiT1532, +-20ppm) on OSC32_IN, but their stock Arduino MCUboot bootloader is built with Mbed's lse_available disabled and reinitialises the RTC onto the LSI at every hard reset when it finds any other clock source selected -- and the backup-domain reset that requires wipes the calendar. Verified on a Nicla Vision: with the RTC switched to LSE bypass (which does start and keep +-0ppm time while running), every machine.reset() and deep-sleep wake came back on the LSI with the calendar reset to the bootloader's 2021-01-01 epoch. So these boards run the RTC from the LSI, but the prescalers divided by 32768, making the RTC about 2.3% slow -- over half an hour per day, far beyond what rtc.calibration() can correct. Set the LSI prescalers to divide by the LSI's nominal 32000 instead, and drop the MICROPY_HW_RCC_RTC_CLKSOURCE override so the runtime prescaler selection sees whichever source the bootloader provides: boards updated to an LSE-enabled bootloader get the SiT1532 with 32768Hz prescalers automatically, everything else stays on the corrected LSI. Tested on an Arduino Nicla Vision (stock bootloader): -684ppm over 240s measurements against the HSE-derived SysTick (previously -22300ppm measured over two hours against NTP), time preserved through machine.deepsleep(20000) and machine.reset(), and the microsecond subsecond fields still exact (32000/64 = 500). Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
If `_thread.start_new_thread` fails to allocate stack space because of MemoryError, it leaves the environment stuck in a way that appears to have a thread running on core1. Later, when memory is available, `start_new_thread` will continue to fail because it will appear that core1 is in use. To remedy this, the `core1_entry` pointer is not setup until after the stack space is successfully allocated. Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>
This commit adds board support for the Seeed XIAO SAMD21 Plus to the samd port. It reuses the existing SEEED_XIAO_SAMD21 standard board definition, which is the same except for additional pins. Note that the pin names "A0_D0" etc has been removed and replaced with individual names "A0", "D0" etc. Signed-off-by: cumin <13809292481@163.com>
Expose zepyhr regulator api. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The machine_timer_obj_head linked list is updated from thread context when a timer is created or deinitialised, and from IRQ context when a one-shot timer expires: machine_timer_callback() runs in the k_timer expiry function and calls machine_timer_deinit() to unlink the timer. A timer expiring while the main thread is in the middle of inserting or unlinking an entry can corrupt the list, losing timers or leaving it circular so a later traversal never terminates. Guard both places that touch the list with MICROPY_BEGIN_ATOMIC_SECTION and MICROPY_END_ATOMIC_SECTION, which on this port are irq_lock() and irq_unlock() and so nest safely when machine_timer_deinit() is reached from the expiry function. Fixes issue #18728. Signed-off-by: Calin Faja <calinfaja@gmail.com>
Commit 6bde1b5 removed this configuration because TinyUSB 0.21.0 no longer uses it. But the esp32 port still uses an older TinyUSB version/fork (based on TinyUSB 0.18.0) and therefore still needs this runtime CDC configuration. Signed-off-by: Damien George <damien@micropython.org>
run-perfbench -s fails when benchmark result contains tests that are skipped with "too large". To fix this issue, skip line that contains "skipped: " and "skipped because they are too large: " using regular expression. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit tweaks `mpy-tool.py`'s printout of qstr strings when disassemblying a MPY file. Now strings will be printed with non-printable and control codes being quoted (using Python's `repr()`), and containing a special marker in case a qstr is encoded as an index in the static qstr table. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Regression since v1.23 (exact commit unknown). Adds a unit test that fails without this fix, and succeeds with it. (Test is added in extmod_hardware but currently doesn't pass on any other ports that I have access to...) This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
The ESP32-C5 bootloader lives at 0x2000, as on the other C5 boards, but this board's deploy instructions said to write the firmware at 0. Doing so leaves no valid image at the bootloader offset and the ROM loops on "invalid header". Fixes issue #19696. Signed-off-by: Tejas Nagmote <tejasnagmote520@gmail.com>
D13 and D15 were mapped to each other's GPIO. Per the Seeed Studio wiki pin map and the board schematic, D13 is wired to GPIO21 (SCL1) and D15 to GPIO19. This also makes D13 agree with the existing SCL1 entry (GPIO21) and D14 with SDA1 (GPIO20). Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: cumin <13809292481@163.com>
machine.RTC will now keep its value after machine.reset() or machine.deepsleep(). Only changes behaviour on RP2350. On RP2040 the AON timer is never running at this point, but it may be possible to keep it on by changing mp_machine_reset(). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
__StackLimit is __bss_end__ + MICROPY_C_HEAP_SIZE, so it inherits the alignment of __bss_end__. newlib's malloc grows its arena to page boundaries, and _sbrk refuses anything past __StackLimit, so growth fails with the heap partly free. Boards linking C++ user modules malloc during static init, before USB is up, where PICO_MALLOC_PANIC halts the core with no output. Whether a build fails depends on where the link put __bss_end__. Round the ceiling up to a page. MICROPY_C_HEAP_SIZE of 0 still gives a ceiling of exactly __bss_end__. Signed-off-by: Phil Howard <github@gadgetoid.com>
This commit lets `machine.lightsleep` restore the original CPU and peripherals frequencies upon wakeup if they were previously set to different values than the defaults. The original implementation of `machine.lightsleep` would restore the default speed for CPU and peripherals as part of the wakeup procedure, which would ignore previously set values. These changes force an optional frequency values set once the MCU wakes up, by simply jumping into the internal implementation for `machine.freq`. The relevant lightsleep test was also updated to verify the changes in question. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com> Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com> Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
The peripheral clock divider type (bit resolution) was selected only from the requested divider value, always choosing the minimum required resolution. That behavior caused two issues in divider allocation. First, not every peripheral exposes every divider resolution type. If a low-resolution divider was requested on hardware lacking that type, allocation failed even when a compatible higher-resolution divider was available. Second, even when all divider types existed, allocation was too strict: once all minimum-resolution dividers were used, free higher-resolution ones were ignored, even though they were valid for the same target clock destination and settings. With this change, allocation now falls back to any compatible free divider type. Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com> Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com> Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
Use the RTC irq handler to call the handler if required. Defining the proper IRQ handler for the IRQ table was missing. Signed-off-by: robert-hh <robert@hammelrath.com>
That makes it available for the code and it is used by machine.deepsleep(). Signed-off-by: robert-hh <robert@hammelrath.com>
machine.deepsleep(ms) works now as intended by powering down the board for ms/1000 seconds and then resetting it. That can be repeated several times. For MIMXRT10xx MCUs machine.deepsleep() works as intended. The WAKEUP pin pull-up was enabled and set to 100k to ensure a high/low transition. machine.deepsleep() does not work as intended for mimxrt1176. It can be called once and recover from deepsleep by pulling the WAKEUP_DIG pin low, but then attempts to call machine.deepsleep with or without a timeout fail until a power cycle is done. So waking up from deepsleep using the WAKEUP_DIG pin is not enabled. It is however possible to wakeup the device with >1 sec low pulse at the ONOFF pin. Signed-off-by: robert-hh <robert@hammelrath.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi
Please see
micropython#11735
The official page
https://docs.micropython.org/en/latest/genrst/builtin_types.html#float
should be updated about the different result of
(and eventually other inconsistencies) between Python and MicroPython.