aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-08-15py/emitnative: Use small tables to simplify handling of local regs.Damien George
2018-08-14stm32/spi: Add implementation of low-level SPI protocol.Damien George
Can be used, for example, to configure external SPI flash using a hardware SPI interface (code to be put in a board's bdev.c file): STATIC const spi_proto_cfg_t hard_spi_bus = { .spi = &spi_obj[5], .baudrate = 10000000, .polarity = 0, .phase = 0, .bits = 8, .firstbit = SPI_FIRSTBIT_MSB, }; STATIC mp_spiflash_cache_t spi_bdev_cache; const mp_spiflash_config_t spiflash_config = { .bus_kind = MP_SPIFLASH_BUS_SPI, .bus.u_spi.cs = pin_A0, .bus.u_spi.data = (void*)&hard_spi_bus, .bus.u_spi.proto = &spi_proto, .cache = &spi_bdev_cache, }; spi_bdev_t spi_bdev;
2018-08-14unix/Makefile: Enable ussl module with nanbox build.Damien George
2018-08-14extmod/modussl_axtls: Use MP_ROM_PTR for objects in allowed args array.Damien George
2018-08-14extmod/modbtree: Update to work with new mp_stream_posix_XXX signatures.Damien George
2018-08-14py/stream: Adjust mp_stream_posix_XXX to take void*, not mp_obj_t.Damien George
These POSIX wrappers are assumed to be passed a concrete stream object so it is more efficient (eg on nan-boxing builds) to pass in the pointer rather than mp_obj_t, because then the users of these functions only need to store a void* (and mp_obj_t may be wider than a pointer). And things would be further improved if the stream protocol functions eventually took a pointer as their first argument (instead of an mp_obj_t). This patch is a step to getting ussl/axtls compiling on nan-boxing builds. See issue #3085.
2018-08-14mpy-cross/Makefile: Also undefine MICROPY_FORCE_32BIT and CROSS_COMPILE.Paul Sokolovsky
mpy-cross is a host, not target binary. It should not be build with the target compiler, compiler options and other settings. For example, If someone currently tries to build from pristine checkout the unix port with the following command: make CROSS_COMPILE=arm-linux-gnueabihf- then mpy-cross will be built with arm-linux-gnueabihf-gcc and of course won't run on the host, leading to overall build failure. This situation was worked around for some options in 1d8c3f4cff1, so add MICROPY_FORCE_32BIT and CROSS_COMPILE to that set too.
2018-08-14stm32/spi: Split out pyb.SPI and machine.SPI bindings to their own filesDamien George
The aim here is to have spi.c contain the low-level SPI driver which is independent (not fully but close) of MicroPython objects and methods, and the higher-level bindings are separated out to pyb_spi.c and machine_spi.c.
2018-08-14esp32: Update to latest ESP IDF.Damien George
Among other things, this requires putting bootloader object files in to their relevant .a archive, so that they can be correctly referenced by the ESP IDF's linker script.
2018-08-14py/objarray: Allow to build again when bytearray is disabled.Damien George
2018-08-14py/gc: In gc_alloc, reset n_free var right before search for free mem.Damien George
Otherwise there is the possibility that n_free starts out non-zero from the previous iteration, which may have found a few (but not enough) free blocks at the end of the heap. If this is the case, and if the very first blocks that are scanned the second time around (starting at gc_last_free_atb_index) are found to give enough memory (including the blocks at the end of the heap from the previous iteration that left n_free non-zero) then memory will be allocated starting before the location that gc_last_free_atb_index points to, most likely leading to corruption. This serious bug did not manifest itself in the past because a gc_collect always resets gc_last_free_atb_index to point to the start of the GC heap, and the first block there is almost always allocated to a long-lived object (eg entries from sys.path, or mounted filesystem objects), which means that n_free would be reset at the start of the search loop. But with threading enabled with the GIL disabled it is possible to trigger the bug via the following sequence of events: 1. Thread A runs gc_alloc, fails to find enough memory, and has a non-zero n_free at the end of the search. 2. Thread A calls gc_collect and frees a bunch of blocks on the GC heap. 3. Just after gc_collect finishes in thread A, thread B takes gc_mutex and does an allocation, moving gc_last_free_atb_index to point to the interior of the heap, to a place where there is most likely a run of available blocks. 4. Thread A regains gc_mutex and does its second search for free memory, starting with a non-zero n_free. Since it's likely that the first block it searches is available it will allocate memory which overlaps with the memory before gc_last_free_atb_index.
2018-08-14stm32/boards/STM32F7DISC: Enable onboard SDRAM.forester3
The default SYSCLK frequency is reduced to 192MHz because SDRAM requires it to be 200MHz or less.
2018-08-14stm32/boards/STM32F429DISC: Add burst len and autorefresh to SDRAM cfg.forester3
To align with recent changes to sdram.c.
2018-08-14stm32/sdram: Allow additional config by a board, and tune MPU settings.forester3
- Allow configuration by a board of autorefresh number and burst length. - Increase MPU region size to 8MiB. - Make SDRAM region cacheable and executable.
2018-08-14docs/library/machine.UART.rst: Specify optional txbuf and rxbuf args.Damien George
If a port would like to expose the configuration of transmit and/or receive buffers then it can use these arguments.
2018-08-14unix/Makefile: coverage: Explicitly build "axtls" too.Paul Sokolovsky
"coverage" build uses different BUILD directory comparing to the normal build. Previously, any build picked up libaxtls.a from normal build's directory, but that was fixed recently. So, for each build, we must build axtls explicitly. This fixes Travis build in particular.
2018-08-14py/py.mk: Don't hardcode path to libaxtls.a.Paul Sokolovsky
Use -L$(BUILD), not -Lbuild. Otherwise, builds for different archs/subarchs using different values of BUILD may fail.
2018-08-14windows/msvc: Support custom compiler for header generation.stijn
Use overrideable properties instead of hardcoding the use of the default cl executable used by msvc toolsets. This allows using arbitrary compiler commands for qstr header generation. The CLToolExe and CLToolPath properties are used because they are, even though absent from any official documentation, the de-facto standard as used by the msvc toolsets themselves.
2018-08-13py/compile: For dynamic compiler, widen literal 1 to get correct shift.Damien George
Without this patch, on 64-bit architectures the "1 << (small_int_bits - 1)" is computed using only 32-bit values (since small_int_bits is a uint8_t) and so will overflow (and give the wrong result) if small_int_bits is larger than 32.
2018-08-10stm32/spi: Round up prescaler calc to never exceed requested baudrate.Damien George
Requesting a baudrate of X should never configure the peripheral to have a baudrate greater than X because connected hardware may not be able to handle higher speeds. This patch makes sure to round the prescaler up so that the actual baudrate is rounded down.
2018-08-10run-tests: Make .exp and .out file names unique by prefixing with dir.stijn
Input files like basics/string_format.py and float/string_format.py have the same basename so using that name for writing the output (.exp and .out files) when both tests fail, results in the output of the first one being overwritten. Avoid this by using unique names for the output, replacing path characters with underscores.
2018-08-10stm32/dma: Fix spelling of "corresponding" in two locations.David Lechner
2018-08-10tools/pyboard.py: Change base class of PyboardError to Exception.Martin Dybdal
Following standard practice for defining custom exceptions.
2018-08-08drivers/cc3000: Use cc3000_time_t instead of time_t for custom typedef.roland
Otherwise it can clash with time_t from the C standard include headers.
2018-08-07py/emitnative: Allocate space for local stack info as it's needed.Damien George
2018-08-06py/emitnative: Simplify handling of exception objects from nlr_buf_t.Damien George
There is no need to have three copies of the exception object on the top of the native value stack. Instead, the values on the stack should be the first two items in an nlr_buf_t: the prev pointer and the ret_val pointer. This is all that is needed and is what the rest of the native emitter expects is on the stack. This patch is essentially an optimisation. Behaviour is unchanged, although the stack layout for native exception handling now makes more sense.
2018-08-04py/emitnative: Fix native locals stack to start at correct location.Damien George
A native function allocates space on its C stack for mp_code_state_t, followed by its Python stack, then its locals. This patch makes sure that the native function actually starts at the start of its Python stack, rather than at the start of mp_code_state_t (which didn't lead to any issues so far because the mp_code_state_t is unused after the native function sets itself up).
2018-08-04py/asmx86: Use generic emit function to simplify cmp emit function.Damien George
2018-08-04tests/run-tests: Enable bool1.py test with native emitter.Damien George
It should work reliably now.
2018-08-04tests/micropython/viper_cond: Add test for large int as bool.Damien George
2018-08-04py/emitnative: Fix x86 native zero checks by comparing full word.Damien George
On x86 archs (both 32 and 64 bit) a bool return value only sets the 8-bit al register, and the higher bits of the ax register have an undefined value. When testing the return value of such cases it is required to just test al for zero/non-zero. On the other hand, checking for truth or zero/non-zero on an integer return value requires checking all bits of the register. These two cases must be distinguished and handled correctly in generated native code. This patch makes sure of this. For other supported native archs (ARM, Thumb2, Xtensa) there is no such distinction and this patch does not change anything for them.
2018-08-04py/emitnative: Factor common code for native jump helper.Damien George
2018-08-04docs/library/machine.I2C.rst: Clarify availability of primitive I2C ops.Peter Hinch
2018-08-04tools/pyboard: Run exec: command as a string.Ayke van Laethem
The Python documentation recommends to pass the command as a string when using Popen(..., shell=True). This is because "sh -c <string>" is used to execute the command and additional arguments after the command string are passed to the shell itself (not the executing command). https://docs.python.org/3.5/library/subprocess.html#subprocess.Popen
2018-08-04tests: Make tests work on targets without float support.Ayke van Laethem
2018-08-04stm32/adc: Fix ADC reading on F0 MCUs to only sample a single channel.Damien George
And increase sampling time to get better results for internal channels.
2018-08-04stm32/adc: Disable VBAT in read channel helper function.Damien George
Prior to this patch, if VBAT was read via ADC.read() or ADCAll.read_channel(), then it would remain enabled and subsequent reads of TEMPSENSOR or VREFINT would not work. This patch makes sure that VBAT is disabled for all cases that it could be read.
2018-08-02nrf/uart: Fix UART.writechar() to write just 1 byte.Ayke van Laethem
2018-08-02nrf/uart: Remove unused UART.char_width field.Ayke van Laethem
Also, clean up some code. Code size change: nrf51: -24 nrf52: -28
2018-08-02nrf: Use separate config for each PWM instance.Stig Bjørlykke
The hard_configs table has entries for each PWM instance. Use them.
2018-08-02py: Fix compiling with debug enabled and make more use of DEBUG_printf.Damien George
DEBUG_printf and MICROPY_DEBUG_PRINTER is now used instead of normal printf, and a fault is fixed in mp_obj_class_lookup with debugging enabled; see issue #3999. Debugging can now be enabled on all ports including when nan-boxing is used.
2018-08-02py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.Damien George
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to MICROPY_DEBUG_PRINTER, moving its default definition from lib/utils/printf.c to py/mpconfig.h to make it official and documented, and makes this macro a pointer rather than the actual mp_print_t struct. This is done to get consistency with MICROPY_ERROR_PRINTER, and provide this macro for use outside just lib/utils/printf.c. Ports are updated to use the new macro name.
2018-08-01nrf: Correct index checking of ADC/PWM/RTCounter instances.Stig Bjørlykke
Avoid trying to use ADC, PWM and RTCounter instances which is one past last available, because this will give a HardFault.
2018-08-01nrf: Enable all PWM, RTC and Timer instances for nrf52840.Stig Bjørlykke
The NRF52 define only covers nrf52832, so update the define checks to use NRF52_SERIES to cover both nrf52832 and nrf52840. Fixed machine_hard_pwm_instances table in modules/machine/pwm.c This enables PWM(0) to PWM(3), RTCounter(2), Timer(3) and Timer(4), in addition to NFC reset cause, on nrf52840.
2018-08-01nrf/uos: Add mbfs __enter__ and __exit__ handlers.Stig Bjørlykke
This will make 'with open('file', 'r') as f:' work by properly close the file after the suite is finished.
2018-08-01tools/mpy-tool: Set sane initial dynamic qstr pool size with frozen modsRich Barlow
The first dynamic qstr pool is double the size of the 'alloc' field of the last const qstr pool. The built in const qstr pool (mp_qstr_const_pool) has a hardcoded alloc size of 10, meaning that the first dynamic pool is allocated space for 20 entries. The alloc size must be less than or equal to the actual number of qstrs in the pool (the 'len' field) to ensure that the first dynamically created qstr triggers the creation of a new pool. When modules are frozen a second const pool is created (generally mp_qstr_frozen_const_pool) and linked to the built in pool. However, this second const pool had its 'alloc' field set to the number of qstrs in the pool. When freezing a large quantity of modules this can result in thousands of qstrs being in the pool. This means that the first dynamically created qstr results in a massive allocation. This commit sets the alloc size of the frozen qstr pool to 10 or less (if the number of qstrs in the pool is less than 10). The result of this is that the allocation behaviour when a dynamic qstr is created is identical with an without frozen code. Note that there is the potential for a slight memory inefficiency if the frozen modules have less than 10 qstrs, as the first few dynamic allocations will have quite a large overhead, but the geometric growth soon deals with this.
2018-08-01stm32/modmachine: Get machine.sleep working on L4 MCUs.Damien George
When waking from stop mode most of the system is still in the same state as before entering stop, so only minimal configuration is needed to bring the system clock back online.
2018-08-01stm32/extint.h: Use correct EXTI lines for RTC interrupts.Damien George
2018-07-31docs: Move WiPy specific Timer class to separate doc file.Damien George
The WiPy machine.Timer class is very different to the esp8266 and esp32 implementations which are better candidates for a general Timer class. By moving the WiPy Timer docs to a completely separate file, under a new name machine.TimerWiPy, it gives a clean slate to define and write the docs for a better, general machine.Timer class. This is with the aim of eventually providing documentation that does not have conditional parts to it, conditional on the port. While the new docs are being defined it makes sense to keep the WiPy docs, since they describe its behaviour. Once the new Timer behaviour is defined the WiPy code can be changed to match it, and then the TimerWiPy docs would be removed.
2018-07-31stm32/modmachine: Get machine.sleep working on F0 MCUs.Damien George