Commit Graph

1229 Commits

Author SHA1 Message Date
Damien George
060209240b esp8266: Put new profile code in iROM. 2019-08-30 16:49:02 +10:00
Milan Rossa
310b3d1b81 py: Integrate sys.settrace feature into the VM and runtime.
This commit adds support for sys.settrace, allowing to install Python
handlers to trace execution of Python code.  The interface follows CPython
as closely as possible.  The feature is disabled by default and can be
enabled via MICROPY_PY_SYS_SETTRACE.
2019-08-30 16:44:12 +10:00
Damien George
400a128e11 stm32/stm32_it: Include correct EXTI interrupt handlers for L0 MCUs. 2019-08-29 12:00:18 +10:00
Damien George
1fe1ff935b nrf: Clean up source by removing tabs, trailing spaces, non-ASCII chars. 2019-08-28 13:34:45 +10:00
Eric Poulsen
5635b96461 esp32: Add 'config' function to network.LAN, reusing network.WLAN. 2019-08-28 13:11:48 +10:00
iabdalkader
0bec07f32b stm32/extint: Fix EXTI mapping of PVD and RTC events for H7 MCUs. 2019-08-28 12:53:42 +10:00
Damien George
af20c2ead3 py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now
provided by the global default_emit_opt variable.

Now, when -X emit=native is passed as a command-line option, the emitter
will be set for all compiled modules (included imports), not just the
top-level script.

In the future there could be a way to also set this variable from a script.

Fixes issue #4267.
2019-08-28 12:47:58 +10:00
Damien George
15b36aa0af unix/main: Only accept full emit cmd-line options if native enabled. 2019-08-28 12:47:58 +10:00
Damien George
5789558d60 stm32/boards/PYBD_SF2: Exclude certain things when building mboot. 2019-08-28 12:37:13 +10:00
Damien George
68d74b0074 stm32/mboot/Makefile: Define "BUILDING_MBOOT" when building mboot.
So boards can configure their settings based on whether mboot or the main
firmware is being built.
2019-08-28 12:37:13 +10:00
Damien George
b1e04848ef stm32/mphalport: Put PYBD specific MAC code in board specific file. 2019-08-28 12:37:13 +10:00
Damien George
96ace8082e esp8266/machine_uart: Allow remapping UART TX/RX pins from 1/3 to 15/13.
Via the standard tx/rx arguments: UART(0, 115200, tx=Pin(15), rx=Pin(13)).

Resolves issue #4718.
2019-08-21 21:16:40 +10:00
roland van straten
fe3c064d42 samd: Add minimum config for Atmel SAMD21-XPLAINED-PRO board. 2019-08-20 21:30:36 +10:00
Damien George
05eb897d06 esp32: Add esp32.Partition class to expose partition and OTA funcs.
Partitions are exposed as a standard MicroPython block device.
2019-08-20 16:49:18 +10:00
Jim Mussared
0bd1eb80ff qemu-arm: Add testing of frozen native modules.
- Split 'qemu-arm' from 'unix' for generating tests.
- Add frozen module to the qemu-arm test build.
- Add test that reproduces the requirement to half-word align native
  function data.
2019-08-20 15:14:08 +10:00
Damien George
7d851a27f1 extmod/modure: Make regex dump-code debugging feature optional.
Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix
coverage build).  This is a rarely used feature that costs a lot of code
(500-800 bytes flash).  Debugging of regular expressions can be done
offline with other tools.
2019-08-19 16:43:00 +10:00
stijn
af5c998f37 py/modmath: Implement math.isclose() for non-complex numbers.
As per PEP 485, this function appeared in for Python 3.5.  Configured via
MICROPY_PY_MATH_ISCLOSE which is disabled by default, but enabled for the
ports which already have MICROPY_PY_MATH_SPECIAL_FUNCTIONS enabled.
2019-08-17 23:23:17 +10:00
Damien George
3eff81288c stm32/i2c: Fix generation of restart condition for hw I2C on F0/F7.
Before this patch I2C transactions using a hardware I2C peripheral on F0/F7
MCUs would not correctly generate the I2C restart condition, and instead
would generate a stop followed by a start.  This is because the CR2 AUTOEND
bit was being set before CR2 START when the peripheral already had the I2C
bus from a previous transaction that did not generate a stop.

As a consequence all combined transactions, eg read-then-write for an I2C
memory transfer, generated a stop condition after the first transaction and
didn't generate a stop at the very end (but still released the bus).  Some
I2C devices require a repeated start to function correctly.

This patch fixes this by making sure the CR2 AUTOEND bit is set after the
start condition and slave address have been fully transferred out.
2019-08-16 13:34:04 +10:00
Jim Mussared
eb7eed5d92 samd/boards: Add Mini SAM M4 board configuration. 2019-08-16 00:28:30 +10:00
Jim Mussared
90188cc92b samd/boards: Add Adafruit Feather M0 Express board configuration. 2019-08-16 00:28:12 +10:00
Jim Mussared
a5d85d306c samd: Make common linker scripts, rename board.mk to mpconfigboard.mk.
The rename matches other ports, e.g. stm32, and gives consistency with
mpconfigboard.h.
2019-08-16 00:26:54 +10:00
Jim Mussared
8db517f26d esp32: Add per-board configs, following other ports.
Replaces the `SDKCONFIG` makefile variable with `BOARD`.  Defaults to
BOARD=GENERIC.  spiram can be enabled with `BOARD=GENERIC_SPIRAM`

Add example definition for TINYPICO, currently identical to GENERIC_SPIRAM
but with custom board/SoC names for the uPy banner.
2019-08-16 00:22:29 +10:00
Damien George
497683b315 gitignore: Put build-*/ pattern in top-level gitignore file. 2019-08-16 00:08:08 +10:00
Damien George
baeebc557c esp32/modules: On initial setup mount internal flash at root.
Like it's done on normal boot up.  Fixes issue #5004.
2019-08-15 22:03:09 +10:00
Milan Rossa
6f0c6bd774 unix: Enable sys.atexit, triggered after the main script ends. 2019-08-15 17:31:04 +10:00
Damien George
2ccf030fd1 esp32: Add support for mDNS queries and responder.
They are both enabled by default, but can be disabled by defining
MICROPY_HW_ENABLE_MDNS_QUERIES and/or MICROPY_HW_ENABLE_MDNS_RESPONDER to
0.  The hostname for the responder is currently taken from
tcpip_adapter_get_hostname() but should eventually be configurable.
2019-08-15 16:36:47 +10:00
Damien George
25d3509986 stm32/usbd: Make USB device FIFO sizes dynamically configurable.
Allows to optimise and configure the FIFO sizes depending on the USB device
configuration selected at runtime, eg VCP+MSC vs 3xVCP+MSC.
2019-08-15 13:56:50 +10:00
Damien George
8485b72d0d stm32/boards/NUCLEO_L432KC: Add config for USB VCP support. 2019-08-15 12:46:34 +10:00
Damien George
97e8e036c5 stm32/usbd: Support USB device mode on STM32L432 MCUs. 2019-08-15 12:46:04 +10:00
Damien George
bf733c27bb stm32/usbd: Introduce MICROPY_HW_USB_IS_MULTI_OTG to simplify USB config
This is an internal config value that is enabled for MCUs that have
multiple OTG instances, to simplify #if configuration of the USB code.
2019-08-15 12:19:28 +10:00
Damien George
ba607809f2 stm32/modpyb: Support building with PY_PYB_LEGACY on and HW_USB_HID off. 2019-08-15 12:03:32 +10:00
Kenta IDA
b6906fa573 esp32/network_ppp: Add authentication support to the PPP interface.
This commit adds the connect() method to the PPP interface and requires
that connect() be called after active(1).  This is a breaking change for
the PPP API.

With the connect() method it's now possible to pass in authentication
information for PAP/CHAP, eg:

    ppp.active(1)
    ppp.connect(authmode=ppp.AUTH_PAP, username="user", "password="password")

If no authentication is needed simply call connect() without any
parameters.  This will get the original behaviour of calling active(1).
2019-08-14 17:20:58 +10:00
Chris Wilson
3d02ebb4e8 stm32/sdcard: Support configuring the SD/MMC bus width to 1 or 4 bits.
Some SD/MMC breakout boards don't support 4-bit bus mode.  This adds a new
macro MICROPY_HW_SDMMC_BUS_WIDTH that allows each board to define the width
of the SD/MMC bus interface used on that board, defaulting to 4 bits.
2019-08-08 12:53:05 +10:00
Damien George
2d3d4f7483 esp8266/mpconfigport.h: Enable lwIP raw sockets. 2019-08-06 15:56:05 +10:00
Damien George
102815f700 stm32/mpconfigport.h: Enable lwIP raw sockets. 2019-08-06 15:56:05 +10:00
Damien George
0e2b224b07 stm32/lwip_inc: Enable raw socket type. 2019-08-06 15:56:05 +10:00
Damien George
7c15e50eb8 esp32/Makefile: Include CFLAGS_EXTRA in CFLAGS definition.
Following other ports, so builds can be customised more easily, eg on the
command line building with a user C-module.
2019-07-30 17:31:23 +10:00
Damien George
473157eeb9 stm32/usbd_hid_interface: Include extra header to build with threading. 2019-07-26 12:44:14 +10:00
Damien George
ad0b7cb017 stm32/boards/xxx_WB55: Enable USB HID now that it works on WB MCUs. 2019-07-25 17:49:53 +10:00
Damien George
fa07deda9f stm32/usbd_hid_interface: Rewrite USB HID interface code.
The previous version did not work on MCUs that only had USB device mode
(compared to OTG) because of the handling of NAK.  And this previous
handling of NAK had a race condition where a new packet could come in
before USBD_HID_SetNAK was called (since USBD_HID_ReceivePacket clears NAK
as part of its operation).  Furthermore, the double buffering of incoming
reports was not working, only one buffer could be used at a time.

This commit rewrites the HID interface code to have a single incoming
buffer, and only calls USBD_HID_ReceivePacket after the user has read the
incoming report (similar to how the VCP does its flow control).  As such,
USBD_HID_SetNAK and USBD_HID_ClearNAK are no longer needed.

API functionality from the user's point of view should be unchanged with
this commit.
2019-07-25 17:42:17 +10:00
Damien George
b1129df478 stm32/dma: Fix re-start of DMA stream by clearing all event flags.
As per the datasheet, all event flags for a stream must be cleared before
enabling it.  Fixes issue #4944 (with DAC.write_timed).
2019-07-25 16:48:26 +10:00
badlyby
3b258ef213 stm32/boards/NUCLEO_F722ZE: Add definition files for new board. 2019-07-25 16:31:36 +10:00
badlyby
09267bb147 stm32/boards/stm32f722.ld: Provide memory regions for internal FS. 2019-07-25 16:31:36 +10:00
badlyby
0da2f6f23a stm32/flashbdev: Support internal filesystem on STM32F722/23/32/33. 2019-07-25 16:31:12 +10:00
Amir Gonnen
995f9cfdfc esp32: Pin MicroPython tasks to a specific core.
On this port the GIL is enabled and everything works under the assumption
of the GIL, ie that a given task has exclusive access to the uPy state, and
any ISRs interrupt the current task and therefore the ISR inherits
exclusive access to the uPy state for the duration of its execution.

If the MicroPython tasks are not pinned to a specific core then an ISR may
be executed on a different core to the task, making it possible for the
main task and an ISR to execute in parallel, breaking the assumption of the
GIL.

The easiest and safest fix for this is to pin all MicroPython related code
to the same CPU core, as done by this patch.  Then any ISR that accesses
MicroPython state must be registered from a MicroPython task, to ensure it
is invoked on the same core.

See issue #4895.
2019-07-25 15:33:47 +10:00
Damien George
e3e7e3a781 esp32/Makefile: Simplify include of IDF source by using wildcards. 2019-07-20 14:07:18 +10:00
Damien George
b88e51d718 esp32/Makefile: Put OBJ and LIB rule additions in gen_espidf_lib_rule. 2019-07-20 13:04:55 +10:00
Jim Mussared
331c224e07 esp32/Makefile: Fix path expansion for ESPIDF_DRIVER_O.
It was using subst to s/.c/.o/ which changed .c anywhere in the path.
2019-07-20 12:32:43 +10:00
stijn
9da46a98cb windows/mpconfigport.h: Don't define restrict/inline/alignof for C++.
The C++ standard forbids redefining keywords, like inline and alignof, so
guard these definitions to avoid that, allowing to include the MicroPython
headers by C++ code.
2019-07-19 16:58:02 +10:00
Damien George
a29334761d esp32: Add support for hardware I2C. 2019-07-19 16:31:25 +10:00
Damien George
0c12adca46 stm32/boards/USBDONGLE_WB55: Add definition files for new board. 2019-07-17 17:00:34 +10:00
Damien George
d2a8fb747f stm32/boards/NUCLEO_WB55: Add definition files for new board. 2019-07-17 17:00:34 +10:00
Damien George
9849567a06 stm32/boards: Add MCU support files for STM32WB55. 2019-07-17 16:50:42 +10:00
Damien George
59b7166d87 stm32: Add initial support for STM32WBxx MCUs.
This new series of MCUs is similar to the L4 series with an additional
Cortex-M0 coprocessor.  The firmware for the wireless stack must be managed
separately and MicroPython does not currently interface to it.  Supported
features so far include: RTC, UART, USB, internal flash filesystem.
2019-07-17 16:33:31 +10:00
Damien George
d42392b9a7 stm32/make-stmconst.py: Allow more variation in parens and int-suffix L. 2019-07-17 16:27:17 +10:00
Damien George
02b2ad4fbd stm32/boards/STM32F769DISC: Fix length of FLASH_APP section.
Fixes issue #4924.
2019-07-17 16:19:50 +10:00
Damien George
baea43bba7 stm32/boards/B_L072Z_LRWAN1: Enable USB VCP support. 2019-07-16 14:50:44 +10:00
Damien George
64aebca155 stm32/Makefile: Allow a board to disable float support.
By using "MICROPY_FLOAT_IMPL = none" in its mpconfigboard.mk file.
2019-07-16 14:47:32 +10:00
Damien George
102d9911e9 stm32/mphalport: Fix GPIO clock enable for L0 MCUs. 2019-07-16 14:47:12 +10:00
Damien George
4096fa397b stm32/powerctrlboot: Increase SYSCLK to 32MHz for L0 MCUs. 2019-07-16 14:46:31 +10:00
Damien George
4c1ad1f691 stm32: Add support for USB on L0 MCUs. 2019-07-16 14:45:53 +10:00
Damien George
788e7f50f2 stm32/usbd_cdc_interface: Make CDC TX/RX buffer sizes configurable. 2019-07-16 14:41:59 +10:00
Damien George
f302f784e9 stm32/usb: Add config options to disable USB MSC and/or HID.
The new configurations MICROPY_HW_USB_MSC and MICROPY_HW_USB_HID can be
used by a board to enabled or disable MSC and/or HID.  They are both
enabled by default.
2019-07-16 14:39:21 +10:00
Damien George
fd49fcb229 stm32/gccollect: Always use MP_STATE_THREAD(stack_top) to get stack top.
In a non-thread build, using &_ram_end as the top-of-stack is no longer
correct because the stack is not always at the very top end of RAM.  See
eg 04c7cdb668 and
3786592097.  The correct value to use is
&_estack, which is the value stored in MP_STATE_THREAD(stack_top), and
using the same code for both thread and non-thread builds makes the code
cleaner.
2019-07-11 17:32:01 +10:00
Paul m. p. P
a1c870e9f4 javascript: Enable support for frozen bytecode via FROZEN_MPY_DIR. 2019-07-09 13:17:15 +10:00
Paul m. p. P
42d30c5baf unix/unix_mphal: Include time.h for CLOCK_MONOTONIC. 2019-07-09 13:05:59 +10:00
Damien George
a17b901a9e stm32/boards/B_L072Z_LRWAN1: Add definition files for new board. 2019-07-09 12:54:09 +10:00
Damien George
278e9bffe9 stm32/mboot: Update dependencies to enable parallel build with -j. 2019-07-09 11:46:47 +10:00
Damien George
342539bdcc stm32/mboot: Use STARTUP_FILE from stm32lib. 2019-07-09 11:35:47 +10:00
Damien George
5a81d2d6b8 stm32/mboot: Remove use of BSRRL/H for H7 MCUs due to stm32lib update. 2019-07-09 11:34:54 +10:00
Damien George
c8f19f1371 stm32/mboot: Make _estack an array to avoid compiler warnings.
The compiler can warn about out-of-bounds array access if _estack is just a
single uint8_t.
2019-07-09 11:33:57 +10:00
Damien George
d43dd886a5 stm32/boards/NUCLEO_F413ZH: Remove STARTUP_FILE, it's defined globally.
The Makefile now defines this variable to the correct value (but it can
still be overridden by a board if necessary).
2019-07-09 11:32:12 +10:00
Chris Mason
c24d81119c stm32/boards/NUCLEO_L452RE: Add definition files for new board. 2019-07-08 16:50:45 +10:00
Chris Mason
64181b5f76 stm32: Add support for STM32L452 MCUs. 2019-07-08 16:50:19 +10:00
Damien George
eea61a09c4 stm32/boards/NUCLEO_F446RE: Enable DAC. 2019-07-08 16:08:40 +10:00
Damien George
5fd62c8992 stm32: Remove SystemInit funcs, use stm32lib versions instead.
stm32lib now provides system_stm32XXxx.c source files for all MCU variants,
which includes SystemInit and prescaler tables.  Since these are quite
standard and don't need to be changed, switch to use them instead of custom
variants, making the start-up code cleaner.

The SystemInit code in stm32lib was checked and is equivalent to what is
removed from the stm32 port in this commit.
2019-07-08 15:23:53 +10:00
Damien George
c15dc2c4b9 stm32/powerctrl: Move F0's SystemClock_Config to powerctrlboot.c. 2019-07-08 15:23:53 +10:00
Damien George
21ecf8be5f stm32/powerctrl: Move L0's SystemClock_Config to powerctrlboot.c file. 2019-07-08 15:23:53 +10:00
Damien George
7c2e83324b stm32/boards/NUCLEO_L073RZ: Add definition files for new board. 2019-07-05 17:28:54 +10:00
Damien George
6053e450b8 stm32/mpconfigport.h: Make "framebuf" module configurable by a board. 2019-07-05 17:26:49 +10:00
Damien George
9c096c190c stm32/boards: Add MCU support files for STM32L072. 2019-07-05 17:26:03 +10:00
Damien George
23d9c6a0fd stm32: Add initial support for STM32L0xx MCUs. 2019-07-05 17:24:59 +10:00
Eric Poulsen
fa5c0b819c esp32/network_ppp: Add ppp_set_usepeerdns(pcb, 1) when init'ing iface.
Without this you often don't get any DNS server from your network provider.
Additionally, setting your own DNS _does not work_ without this option set
(which could be a bug in the PPP stack).
2019-07-04 11:17:41 +10:00
Damien George
c1a8c7fc09 stm32/boards/PYBD_SFx: Automatically turn on EN_3V3 when powering SD/MMC 2019-07-04 11:11:11 +10:00
Damien George
7f33f158b9 stm32/sdcard: Add hook for a board to power on SD/MMC. 2019-07-04 11:10:54 +10:00
Damien George
1cd2bc066d stm32/boards/PYBD_SFx: Configure EN_3V3 pin as output on boot.
But leave it turned off, the application must turn it on if/when needed.
2019-07-04 11:03:10 +10:00
Damien George
afb2e9dd94 stm32/modmachine: Disable IRQs before entering bootloader.
To make sure that the code that enters the bootloader is not interrupted.
2019-07-04 10:49:51 +10:00
Damien George
04da8864e5 stm32/lwip_inc: Define LWIP_NO_CTYPE_H=1 to use lwIP ctype funcs. 2019-07-04 10:36:51 +10:00
Damien George
592f68449d stm32/mpu: Include MPU functions when ETH is enabled. 2019-07-03 23:50:34 +10:00
Damien George
7cf8285ac8 stm32/boards: Remove startup_stm32*.s files now they are in stm32lib. 2019-07-03 23:44:17 +10:00
Damien George
6b6403ce76 stm32/Makefile: Use startup_stm32*.s file from stm32lib.
This means that each MCU now gets a unique IRQ table, eg a specific one for
STM32F405, STM32F411, etc rather than just STM32F4xx.
2019-07-03 23:42:36 +10:00
Damien George
241e577753 stm32/Makefile: Remove Wno-attributes for ll_usb HAL file.
This HAL file is now patched so it doesn't have these warnings.
2019-07-03 23:41:33 +10:00
Damien George
73e8b7e0e4 stm32: Update components to work with new H7xx HAL. 2019-07-03 23:40:49 +10:00
Damien George
3581deec81 stm32/boards/PYBD_SF2: Put mbedtls library code in external QSPI flash.
mbedtls is large and self contained so is a good candidate to be in
external XIP flash, to keep enough spare ROM in internal flash.
2019-07-03 16:50:02 +10:00
Damien George
f88cb8a514 stm32/modmachine: Make RTC class available in machine module.
This is a start to make a more consistent machine.RTC class across ports.
The stm32 pyb.RTC class at least has the datetime() method which behaves
the same as esp8266 and esp32, and with this patch the ntptime.py script
now works with stm32.
2019-07-03 16:46:07 +10:00
Damien George
ef00048fed extmod/modwebrepl: Add config option to put filebuf[512] on stack/bss.
Since the esp8266 has a small stack this buffer is kept in the BSS.
2019-07-03 12:55:57 +10:00
Damien George
79b6688558 stm32/extint: Simplify bitband support config for different MCUs. 2019-07-03 12:02:58 +10:00
Damien George
14bec7964f stm32/spi: Factor out code to calculate SPI source frequency. 2019-07-03 12:02:46 +10:00
Damien George
f114ce0a4b stm32/usb: Add "port" keyword argument to pyb.usb_mode, to select FS/HS.
If the board supports it, the USB port can now be explicitly specified, eg:

    pyb.usb_mode('VCP', port=0).

port=0 is USB FS and port=1 is USB HS.
2019-07-03 11:58:56 +10:00
Damien George
46b3cc4572 stm32/usb: Add support to auto-detect USB interface, either FS or HS.
If both FS and HS USB peripherals are enabled for a board then the active
one used for the REPL will now be auto-detected, by checking to see if both
the DP and DM lines are actively pulled low.  By default the code falls
back to use MICROPY_HW_USB_MAIN_DEV if nothing can be detected.
2019-07-03 11:51:13 +10:00