Commit Graph

1121 Commits

Author SHA1 Message Date
Damien George
ff0306dfa5 stm32/usb: Remove mp_hal_set_interrupt_char now that it's reset at boot. 2019-05-01 13:08:05 +10:00
Krono
fbd4e61e57 esp32/machine_wdt: Add timeout arg to select interval, make WDT panic.
The machine.WDT() now accepts the "timeout" keyword argument to select the
WDT interval.  And the WDT is changed to panic mode which means it will
reset the device if the interval expires (instead of just printing an error
message).
2019-04-30 16:53:05 +10:00
Damien George
8031b7a25c stm32/powerctrl: Deselect PLLSAI as 48MHz src before turning off PLLSAI.
On the STM32F722 (at least, but STM32F767 is not affected) the CK48MSEL bit
must be deselected before PLLSAION is turned off, or else the 48MHz
peripherals (RNG, SDMMC, USB) may get stuck without a clock source.

In such "lock up" cases it seems that these peripherals are still being
clocked from the PLLSAI even though the CK48MSEL bit is turned off.  A hard
reset does not get them out of this stuck state.  Enabling the PLLSAI and
then disabling it does get them out.  A test case to see this is:

    import machine, pyb
    for i in range(100):
        machine.freq(122_000000)
        machine.freq(120_000000)
        print(i, [pyb.rng() for _ in range(4)])

On occasion the RNG will just return 0's, but will get fixed again on the
next loop (when PLLSAI is enabled by the change to a SYSCLK of 122MHz).

Fixes issue #4696.
2019-04-29 16:31:32 +10:00
Damien George
d1dea4f577 javascript/library: Print data as raw bytes to stdout so unicode works. 2019-04-28 22:39:41 +10:00
Damien George
bd6fed8201 javascript/Makefile: Fix unrepresentable float error by using clamp.
Otherwise converting large floats to ints will fail (as seen by the
builtin_float_hash.py test).
2019-04-28 22:17:42 +10:00
Damien George
93f5f80216 javascript: Pass (error) exit value out from script to process caller. 2019-04-28 22:16:27 +10:00
Damien George
bd0bacb637 javascript/library: Use Buffer.alloc() since new Buffer() is deprecated. 2019-04-28 22:14:28 +10:00
Andrew Leech
70a28e3ad9 stm32/usb: Add USB device mode for VCP+VCP without MSC.
Selectable via pyb.usb_mode('VCP+VCP').
2019-04-28 21:31:47 +10:00
Damien George
0646e607b5 ports: Convert to use pyexec_file_if_exists() to execute boot/main.py.
The stm32 and nrf ports already had the behaviour that they would first
check if the script exists before executing it, and this patch makes all
other ports work the same way.  This helps when developing apps because
it's hard to tell (when unconditionally trying to execute the scripts) if
the resulting OSError at boot up comes from missing boot.py or main.py, or
from some other error.  And it's not really an error if these scripts don't
exist.
2019-04-26 15:22:14 +10:00
Damien George
f66c4cbfa6 stm32/usbdev: Make USB device descriptors at runtime rather than static. 2019-04-26 10:07:49 +10:00
Damien George
aa7b32c811 stm32/dac: Rework DAC driver to use direct register access.
This patch makes the DAC driver simpler and removes the need for the ST
HAL.  As part of it, new helper functions are added to the DMA driver,
which also use direct register access instead of the ST HAL.

Main changes to the DAC interface are:

- The DAC uPy object is no longer allocated dynamically on the heap,
  rather it's statically allocated and the same object is retrieved for
  subsequent uses of pyb.DAC(<id>).  This allows to access the DAC objects
  without resetting the DAC peripheral.  It also means that the DAC is only
  reset if explicitly passed initialisation parameters, like "bits" or
  "buffering".

- The DAC.noise() and DAC.triangle() methods now output a signal which is
  full scale (previously it was a fraction of the full output voltage).

- The DAC.write_timed() method is fixed so that it continues in the
  background when another peripheral (eg SPI) uses the DMA (previously the
  DAC would stop if another peripheral finished with the DMA and shut the
  DMA peripheral off completely).

Based on the above, the following backwards incompatibilities are
introduced:

- pyb.DAC(id) will now only reset the DAC the first time it is called,
  whereas previously each call to create a DAC object would reset the DAC.
  To get the old behaviour pass the bits parameter like: pyb.DAC(id, bits).

- DAC.noise() and DAC.triangle() are now full scale.  To get previous
  behaviour (to change the amplitude and offset) write to the DAC_CR (MAMP
  bits) and DAC_DHR12Rx registers manually.
2019-04-24 15:51:19 +10:00
Damien George
8402c26cfa stm32/powerctrl: Enable EIWUP to ensure RTC wakes device from standby. 2019-04-18 17:15:11 +10:00
Damien George
11657f2f20 stm32/system_stm32f0: Add support for using HSE and PLL as SYSCLK.
To configure the SYSCLK on an F0 enable one of:

    MICROPY_HW_CLK_USE_HSI48
    MICROPY_HW_CLK_USE_HSE
    MICROPY_HW_CLK_USE_BYPASS
2019-04-18 16:00:45 +10:00
Damien George
f1774fa049 stm32/system_stm32f0: Enable PWR clock on startup.
To be consistent with how F4/F7/H7/L4 works in system_stm32.c.  The power
control peripheral is needed at least for the RTC.
2019-04-18 15:36:59 +10:00
Damien George
4ce0091449 esp32/README: Add info about pyparsing and the correct Python version.
See issue #4655.
2019-04-18 14:17:01 +10:00
Damien George
194d6b6788 stm32/timer: Correctly initialise extended break settings on F7/H7/L4.
Fixes issue #4693.
2019-04-15 11:41:03 +10:00
Damien George
fd112239d6 stm32/rtc: Remove non-ASCII mu-character from source code comment.
And fix a typo in the comment on this line.
2019-04-12 11:32:24 +10:00
Damiano Mazzella
3c9f78b048 zephyr/CMakeLists.txt: Set AR to point to the Zephyr toolchain exe. 2019-04-11 12:24:05 +10:00
Damien George
fc9f2ff0cd stm32/rtc: Remove unused LSE detection code. 2019-04-11 12:14:21 +10:00
Damien George
46e5d6b889 stm32/rtc: Add auto-LSE-bypass detection with fallback to LSE then LSI.
If MICROPY_HW_RTC_USE_BYPASS is enabled the RTC startup goes as follows:
- RTC is started with LSE in bypass mode to begin with
- if that fails to start (after a given timeout) then LSE is reconfigured
  in non-bypass
- if that fails to start then RTC is switched to LSI
2019-04-11 12:09:21 +10:00
Damien George
358364b45e stm32/boards/NUCLEO_L432KC: Disable complex nos and default frozen mods.
To save space, since this board only hase 256k of flash.
2019-04-09 11:23:08 +10:00
Damien George
4831e38c7e stm32/boards/NUCLEO_H743ZI: Add config options to support mboot. 2019-04-08 14:34:37 +10:00
Damien George
fd13ce5e60 stm32/mboot: Add support for H7 MCUs, with H743 flash layout. 2019-04-08 14:33:57 +10:00
Damien George
ae1e18a346 stm32/usbd_conf: Add support for USB HS peripheral on H7 MCUs. 2019-04-08 14:30:16 +10:00
Damien George
2c3fa4ad82 stm32/i2cslave: Add support for H7 MCUs. 2019-04-08 14:28:45 +10:00
Damien George
fd523c53c3 stm32/network_wiznet5k: Automatically set MAC if device doesn't have one 2019-04-05 22:37:06 +11:00
Damien George
4f936afc44 stm32/network_wiznet5k: Add ability to set the MAC address. 2019-04-05 22:35:04 +11:00
Damien George
4410efc1e3 stm32/network_wiznet5k: Add ability to trace Ethernet TX and RX frames.
Via: nic.config(trace=2|4)
2019-04-05 22:33:49 +11:00
Damien George
69cb24a21d esp32/boards/sdkconfig: Disable WDT check of idle task on CPU1.
With dual-core enabled it's possible that the uPy task has full utilisation
of CPU1.  Fixes issue #4673.
2019-04-05 12:25:21 +11:00
Glenn Ruben Bakke
1f5d945afa nrf/Makefile: Update to match latest oofatfs version.
See corresponding commit b5f33ac2cb
2019-04-01 19:22:25 +02:00
Damien George
83f3c29d36 stm32/moduos: Allow to compile again without USB enabled. 2019-04-01 17:11:39 +11:00
Damien George
7ce2a08231 stm32: Add support for MMC driver, exposed via pyb.MMCard class.
Enable it via MICROPY_HW_ENABLE_MMCARD.
2019-04-01 17:04:43 +11:00
Damien George
9670b26526 stm32: Rename MICROPY_HW_HAS_SDCARD to MICROPY_HW_ENABLE_SDCARD.
For consistency with the majority of other MICROPY_HW_ENABLE_xxx macros.
2019-04-01 15:21:26 +11:00
Damien George
7b5bf5f6fd stm32/uart: Handle correctly the char overrun case of RXNE=0 and ORE=1.
Fixes issue #3375.
2019-04-01 13:40:35 +11:00
roland van straten
edd0e0f93d stm32/timer: Expose the PWM BRK capability of Timer 1 and 8.
The break mode is configurable via the 'brk' keyword to the Timer
constructor and init method.  It's disabled by default.
2019-04-01 13:30:37 +11:00
Andrew Leech
9d6f70f715 stm32: Make default USB_VCP stream go through uos.dupterm for main REPL.
Use uos.dupterm for REPL configuration of the main USB_VCP(0) stream on
dupterm slot 1, if USB is enabled.  This means dupterm can also be used to
disable the boot REPL port if desired, via uos.dupterm(None, 1).

For efficiency this adds a simple hook to the global uos.dupterm code to
work with streams that are known to be native streams.
2019-04-01 13:04:05 +11:00
Boris Vinogradov
6947dff7da stm32/Makefile: Allow to override CROSS_COMPILE with included Makefile. 2019-03-29 11:34:05 +11:00
Boris Vinogradov
1a608ce1e8 stm32/boards/STM32L476DISC: Enable servo support on STM32L476DISC board. 2019-03-28 15:35:58 +11:00
Damien George
92149c8a79 esp32/boards: Enable dual core support by default.
Single core is still supported, just by adding CONFIG_FREERTOS_UNICORE=y to
a custom sdkconfig file.
2019-03-27 11:20:21 +11:00
Damien George
815b79a8d0 esp32/mpthreadport: Exit vPortCleanUpTCB early if threading not init'd. 2019-03-27 11:11:06 +11:00
Damiano Mazzella
0b86ba565c unix/mpthreadport: Use named semaphores on Mac OS X.
Unnamed semaphores (via sem_init) are not supported on this OS.  See #4465.
2019-03-27 10:50:01 +11:00
Damien George
781947afdc stm32/mpconfigport.h: Remove malloc/free/realloc helper macros.
These macros are unused, and they can conflict with other entities by the
same name.  If needed they can be provided as static inline functions, or
just functions.

Fixes issue #4559.
2019-03-26 18:42:19 +11:00
roland van straten
d396a7e10d stm32/system_stm32: Provide default value for HSI calibration.
If HSI is used the calibration value must be valid.  Fixes #4596.
2019-03-26 17:10:21 +11:00
Maureen Helm
2befcb8a9d zephyr/i2c: Add support for hardware i2c.
Adds support for hardware i2c to the zephyr port. Similar to other ports
such as stm32 and nrf, we only implement the i2c protocol functions
(readfrom and writeto) and defer memory operations (readfrom_mem,
readfrom_mem_into, and writeto_mem) to the software i2c implementation.
This may need to change in the future because zephyr is considering
deprecating its i2c_transfer function in favor of i2c_write_read; in this
case we would probably want to implement the memory operations directly
using i2c_write_read.

Tested with the accelerometer on frdm_k64f and bbc_microbit boards.
2019-03-26 16:16:26 +11:00
Damien George
673db939b5 esp32/machine_pin: Rework pull mode config to fix GPIO hold feature.
For gpio_hold_en() to work properly (not draw additional current) pull
up/down must be disabled when hold is enabled.  This patch makes sure this
is the case by reworking the pull constants to be a bit mask.
2019-03-26 15:21:23 +11:00
Glenn Ruben Bakke
e0c6dfe90a nrf/readme: Add section about LTO.
Adding section about on how to disable use of the linker flag
-flto, by setting the LTO=0 argument to Make. Also, added a
note on recommended toolchains to use that works well with
LTO enabled.
2019-03-19 16:59:18 +01:00
Dave Hylands
ec6e62efc2 stm32/mboot: Set USE_MBOOT=1 by default in the Makefile.
This allows boards that need USE_MBOOT to be built properly whether or not
USE_MBOOT=1 is specified when building mboot.
2019-03-18 14:01:43 +11:00
Glenn Ruben Bakke
696549d2e5 nrf/bluetooth: Deprecate use of SoftDevice s140 v6.0.0.
Removing linker script for nrf52840 s140 v6.0.0 as pca10056
target board now points to the new v6.1.1. Also, removing the
entry from the download_ble_stack.sh script.
2019-03-15 20:50:15 +01:00
Glenn Ruben Bakke
a3a266a9c3 nrf/board: Migrate nrf52840 target to new BLE stack.
This patch moves pca10056/nrf52840 target board to use
the new SoftDevice s140 v6.1.1 instead of the legacy v6.0.0.
2019-03-15 20:50:15 +01:00
Glenn Ruben Bakke
d3c1436e75 nrf/bluetooth: Add support for SoftDevice s140 version 6.1.1.
Updating download script to fetch the new SoftDevice, and
adding corresponding linker script for the BLE stack.
2019-03-15 20:50:15 +01:00
Glenn Ruben Bakke
1e5e3e3d48 nrf/bluetooth: Deprecate use of SoftDevice s132 v6.0.0.
Removing linker script for nrf52832 s132 v6.0.0 as all target
boards now points to the new v6.1.1. Also, removing the entry
from the download_ble_stack.sh script.
2019-03-15 20:50:15 +01:00
Glenn Ruben Bakke
5f26ef1112 nrf/board: Migrate all nrf52832 targets to new BLE stack.
This patch moves all the nrf52832 target boards to use the
new SoftDevice s132 v6.1.1 instead of the legacy v6.0.0.
2019-03-15 20:50:15 +01:00
Nguyen Hoan Hoang
e8ed2dea71 nrf/bluetooth: Add support for SoftDevice s132 version 6.1.1.
Updating download script to fetch the new SoftDevice, and
adding corresponding linker script for the BLE stack.
2019-03-15 20:50:15 +01:00
roland van straten
c9eb7eb449 stm32/stm32_it: Guard UART7_IRQHandler with check for UART7 define.
All STM32 with a UART7 also have a UART8 and vice versa, but this change
improves readability and allows for them to be independent in the future.
2019-03-14 14:02:21 +11:00
Damien George
c7d19dc0ad ports/{stm32,esp8266}: Set mpy-cross native arch for frozen native code. 2019-03-14 12:22:49 +11:00
Damien George
ddc934631c esp32/machine_pin: Add new PULL_HOLD pin pull mode. 2019-03-14 07:28:57 +11:00
Damien George
349b54525e esp32/machine_pin: Make it so None as pull value disables pull up/down.
Previously specifying None as the pull value would leave the pull up/down
state unchanged.  This change makes it so -1 leaves the state unchanged and
None makes the pin float, as per the docs.
2019-03-14 07:26:59 +11:00
Wolf Vollprecht
ea2fcdd338 javascript: Fix Emscripten async load, and to compile with modern clang. 2019-03-13 23:52:15 +11:00
Rami Ali
7d675f3a17 javascript: Add new port targeting JavaScript via Emscripten.
In this port JavaScript is the underlying "machine" and MicroPython is
transmuted into JavaScript by Emscripten.  MicroPython can then run under
Node.js or in the browser.
2019-03-13 23:47:32 +11:00
Maureen Helm
493ee7df18 zephyr/prj_frdm_kw41z.conf: Add new board configuration.
Adds a new board configuration for the frdm_kw41z board, including support
for the fxos8700 accelerometer/magnetometer/die temperature sensor.
2019-03-12 17:12:13 +11:00
Maureen Helm
7748375b6e zephyr/prj_frdm_k64f.conf: Add fxos8700 sensor.
Adds the fxos8700 accelerometer/magnetometer/die temperature sensor to the
frdm_k64f board configuration.
2019-03-12 17:12:00 +11:00
Paul Sokolovsky
6d82499a48 zephyr/Makefile: Proxy ram_report, rom_report targets from Zephyr. 2019-03-12 17:11:52 +11:00
Paul Sokolovsky
755b0b807b zephyr/prj_minimal.conf: Switch to CONFIG_STDOUT_CONSOLE.
Prompted by code size analysis, after arduino_101 build overflowing ROM.
2019-03-12 17:11:46 +11:00
Paul Sokolovsky
21fc0c448e zephyr/modzsensor: Rename "TEMP" sensor channel to "DIE_TEMP".
I.e. on-die temperature sensor.  Upstream made more fine-grained channels
for different kinds of temperature.
2019-03-12 17:11:30 +11:00
Paul Sokolovsky
a42c1d9fd5 zephyr/modzephyr: Revamp stacks_analyze() call.
Underlying k_call_stacks_analyze() was gone in Zephyr, reimplement using
k_thread_foreach().
2019-03-12 17:11:09 +11:00
Damien George
297092a76a esp32/mphalport: Use ets_delay_us for mp_hal_delay_us_fast.
The system provided one is in ROM and is more accurate.
2019-03-12 15:46:44 +11:00
Damien George
fcace26d87 esp32/Makefile: Add some missing IDF source files to bootloader and app.
Functions in these files may be needed when certain features are enabled
(eg dual core mode), even if the linker does not give a warning or error
about unresolved symbols.
2019-03-11 23:17:09 +11:00
Petr Kracík
41e7ad647e esp32/modnetwork: Remove redundant esp_log include. 2019-03-08 23:36:07 +11:00
Petr Kracík
73c48b1b45 esp32/modnetwork: Implement RSSI for WiFi STA via WLAN.status('rssi'). 2019-03-08 23:35:28 +11:00
Andrew Leech
5688c9ba09 stm32/usb: Allow to override USB strings & VID/PID in app and mboot.
The override #define's should go in the board's mpconfigboard.h file.
2019-03-08 23:29:15 +11:00
Andrew Leech
0c60cb1fc4 stm32/qspi: Set pin speed to very-high and allow to config some options.
The default speed of the QSPI interface is 72Mhz whereas the standard AF
pin speed (high) is only rated to 50Mhz, so increase speed to very-high.
2019-03-08 23:17:50 +11:00
Andrew Leech
89ff506513 py: Update and rework build system for including external C modules.
How to use this feature is documented in docs/develop/cmodules.rst.
2019-03-08 22:58:42 +11:00
Andrew Leech
cf22f4793c py: Allow registration of modules at their definition.
During make, makemoduledefs.py parses the current builds c files for
MP_REGISTER_MODULE(module_name, obj_module, enabled_define)

These are used to generate a header with the required entries for
"mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c
2019-03-08 22:46:43 +11:00
Damien George
e4ac104b7f stm32: Allow to build with threading with the GIL disabled. 2019-03-08 22:29:54 +11:00
Damien George
c6a9bb23cd unix/Makefile: Update coverage tests to match those in Travis. 2019-03-08 16:51:09 +11:00
Damien George
7852b287df minimal/frozentest: Recompile now that mpy format and version changed. 2019-03-08 15:53:05 +11:00
Jim Mussared
f2ebee9cf1 stm32/mboot: Update to match latest oofatfs version.
See corresponding commit b5f33ac2cb
2019-03-07 15:22:16 +11:00
Damien George
62483bb957 minimal/frozentest: Recompile now that mpy format changed. 2019-03-05 16:32:05 +11:00
Damien George
b5f33ac2cb ports: Update to work with new oofatfs version. 2019-03-05 15:56:39 +11:00
Francisco J. Manno
f938e70c69 stm32: Add compile-time option to use HSI as clock source.
To use HSI instead of HSE define MICROPY_HW_CLK_USE_HSI as 1 in the board
configuration file.  The default is to use HSE.

HSI has been made the default for the NUCLEO_F401RE board to serve as an
example, and because early revisions of this board need a hardware
modification to get HSE working.
2019-03-05 15:49:08 +11:00
Damien George
e61862d063 stm32/boards: Update to use new build config for lwip component. 2019-03-04 23:34:03 +11:00
Damien George
78fe979d7d stm32: Use global lwip build config and support building without lwip. 2019-03-04 23:33:02 +11:00
Damien George
84479569de stm32/boards/STM32F769DISC: Use external QSPI flash to store some code.
This demonstrates how to use external QSPI flash in XIP (execute in place)
mode.  The default configuration has all extmod/ code placed into external
QSPI flash, but other code can easily be put there by modifying the custom
f769_qspi.ld script.
2019-03-04 22:40:15 +11:00
Damien George
c8bbf2c170 stm32/Makefile: Allow a board to specify its linker sections for FW.
A board can now use the make variables TEXT0_SECTIONS and TEXT1_SECTIONS to
specify the linker sections that should go in its firmware.  Defaults are
provided which give the existing behaviour.
2019-03-04 22:26:55 +11:00
Damien George
f8f2724297 stm32/qspi: Enable sample shift and disable timeout counter.
This makes the QSPI more robust, in particular the timeout counter should
not be used with memory mapped mode (see F7 errata).
2019-03-01 16:15:14 +11:00
Damien George
47e551ba59 cc3200/mpconfigport.h: Disable compiler optimisation of OrderedDict.
This port would rather keep the code size as RAM.
2019-03-01 15:24:29 +11:00
Damien George
8ce22662fe esp8266/modmachine: Call ets_event_poll after waiti in machine.idle.
Because "waiti 0" may have waited for a while (eg 500ms) and the internal
WDT may need to be fed immediately.

Fixes issue #4459.
2019-02-28 15:44:37 +11:00
Damien George
823b31e528 stm32/boards/NUCLEO_F429ZI: Enable lwIP and Ethernet peripheral. 2019-02-26 23:32:19 +11:00
Damien George
ed0a530614 stm32/boards/STM32F769DISC: Enable lwIP and Ethernet peripheral. 2019-02-26 23:32:19 +11:00
Damien George
b3513f54d3 stm32/boards/STM32F7DISC: Enable lwIP and Ethernet peripheral. 2019-02-26 23:32:19 +11:00
Damien George
8daec24168 stm32/boards/NUCLEO_F767ZI: Enable lwIP and Ethernet peripheral. 2019-02-26 23:32:19 +11:00
Damien George
ac3e2f380d stm32/modnetwork: Don't call NIC callback if it's NULL. 2019-02-26 23:32:19 +11:00
Damien George
08a24c5f41 stm32/mpconfigport.h: Enable lwIP concurrency protection mechanism. 2019-02-26 23:32:19 +11:00
Damien George
c55709bf29 stm32/network_lan: Add high-level network.LAN interface to ETH driver. 2019-02-26 23:32:19 +11:00
Damien George
c950a1a35d stm32/eth: Add low-level Ethernet MAC driver. 2019-02-26 23:32:19 +11:00
Damien George
cc63e19332 stm32/mphalport: Add mp_hal_get_mac() helper function. 2019-02-26 23:32:07 +11:00
Damien George
75a35448e1 stm32/boards/NUCLEO_F767ZI: Fix up comments about HCLK computation. 2019-02-26 22:44:27 +11:00
Petr Kracík
21f9329d5d esp32/modnetwork: Fix wifi.isconnected to return False after disconnect.
esp_wifi_connect will return ESP_OK for the normal path of execution which
just means the reconnect is started, not that it is actually reconnected.
In such a case wifi.isconnected() should return False until the
reconnection is complete.  After reconnect a GOT_IP event is called and it
will change wifi_sta_connected back to True.
2019-02-26 00:49:40 +11:00
Damien George
55ff562c70 unix/modffi: Eliminate unused-argument warning when debugging disabled. 2019-02-25 14:53:17 +11:00
Petr Kracík
5801a003f0 esp32/network_lan: Make power arg to constructor optional.
A value of None for this argument is already supported, so the argument can
be made optional.
2019-02-21 23:29:10 +11:00
Petr Kracík
01c1432e32 esp32/modnetwork: Catch and report Ethernet events. 2019-02-21 23:28:51 +11:00
Petr Kracík
7d8c71c222 esp32/network_lan: Add arg to constructor to set clock mode for ETH PHY.
This optional parameter for network.LAN clock_mode can be used for cases
where the clock source is different from the default GPIO0.  Fixes #4502.
2019-02-21 23:28:17 +11:00
Stig Bjørlykke
c72391c4ce nrf/pwm: Remove superfluous NULL in machine_hard_pwm_instances.
Remove unneeded NULL entry in machine_hard_pwm_instances[] when not
building for NRF52_SERIES.
2019-02-20 22:52:18 +01:00
Stig Bjørlykke
6ca03fe8bd nrf/readme: Update make flash command when defining board.
Update the "make flash" command sample to include BOARD parameter
when building for a specific target board.
2019-02-20 22:34:08 +01:00
Glenn Ruben Bakke
ca2bb66127 nrf/bluetooth: Resolve compilation warning in ble_drv.c.
This patch makes sure that the char_data.props is first
assigned a value before other flags are OR'd in.
Resolves compilation warning on possible unitialized variable.
2019-02-20 07:25:51 +01:00
Glenn Ruben Bakke
0c6f5bc529 nrf/bluetooth: Improve advertisment behavior for nrf52 targets.
This patch makes sure that advertisment data is located in
persistent static RAM memory throughout the advertisment.

Also, setting m_adv_handle to predifined
BLE_GAP_ADV_SET_HANDLE_NOT_SET value to indicate first time
usage of the handle. Upon first advertisment configuration
this will be populated with a handle value returned by the
stack (s132/s140).
2019-02-20 07:25:51 +01:00
Glenn Ruben Bakke
ee3a01f25c nrf/readme: Update link to nrfjprog download.
After new layout of nordicsemi.com the direct links to
command line tools (nrfjprog) has changed to become dynamic.
This patch removes the old direct links to each specific OS
variant and is replaced with one single link to the download
landing page instead.
2019-02-20 07:13:36 +01:00
Andrew Leech
8ed4a28dae stm32/sdram: Increase GPIO speed for SDRAM interface to "very high".
Currently all usages of mp_hal_pin_config_alt_static() set the pin speed to
"high" (50Mhz).  The SDRAM interface typically runs much faster than this
so should be set to the maximum pin speed.

This commit adds mp_hal_pin_config_alt_static_speed() which allows setting
the pin speed along with the other alternate function details.
2019-02-20 16:54:32 +11:00
Dave Hylands
a270cf280b stm32/stm32_it: Fix RTC IRQ handler to handle all EXTI IRQs on F0 MCUs. 2019-02-19 15:17:47 +11:00
Dave Hylands
67b326d97e stm32/extint: Remove unused (and incorrect) EXTI defines. 2019-02-19 15:17:32 +11:00
Dave Hylands
3d17d9b578 stm32/extint: Add non-GPIO EXTI IRQ sources for F0. 2019-02-19 15:17:28 +11:00
Dave Hylands
92fec603d0 stm32/make-stmconst.py: Improve regex to parse more constants.
A few RTC constants weren't being parsed properly due to whitespace
differences, and this patch makes certain whitespace optional.  Changes
made:

- allow for no space between /*!< and EXTI, eg for:
  __IO uint32_t IMR; /*!<EXTI Interrupt mask register, Address offset: 0x00 */

- allow for no space between semicolon and start of comment, eg for:
  __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */
2019-02-19 15:17:28 +11:00
Dave Hylands
9441f4b682 stm32/extint: Fix RTC Alarm/FS USB EXTI constants for L4. 2019-02-19 15:17:28 +11:00
Dave Hylands
363900be5d stm32/extint: Fix ExtInt to work with non-GPIO pins. 2019-02-19 15:17:20 +11:00
Damien George
303f27f656 esp32/modsocket: Change socket.socket to be socket type rather than fun.
To make all ports consistent.  Addresses issue #4514.
2019-02-18 23:20:13 +11:00
Damien George
c65e5c88b8 stm32/boards/stm32f429.ld: Increase uPy heap size by 64k for F429 MCU.
The F429 has 256k total RAM, with 64k already set aside for flash write
cache, so the uPy heap can be increased this much.
2019-02-18 13:18:59 +11:00
Damien George
ed09e13943 esp32/modsocket: Fix usocket.send to accept anything with buffer proto. 2019-02-18 12:38:38 +11:00
Damien George
c551169bd8 stm32/mboot: Add hook to run board-specific code early on startup. 2019-02-15 15:34:05 +11:00
Damien George
65b1fefa31 stm32/modmachine: Add ability to pass through user data to mboot. 2019-02-15 15:10:04 +11:00
Damien George
3669198403 stm32/mboot: Add support script which can program mboot and application. 2019-02-15 15:09:59 +11:00
Damien George
3d0c31e60e stm32/mboot: Move some BSS vars to new section that isn't zeroed out.
Zeroing out data on startup takes time and is not necessary for certain
variables.  So provide a declaration for such variables and use it.
2019-02-15 15:09:54 +11:00
Damien George
ff04b78ffd stm32/mboot: Add support for loading gzip'd firmware from a filesystem.
This adds support to mboot to load and program application firmware from
a .dfu.gz file on the board's filesystem.  See mboot/README.md for details.
2019-02-15 15:09:48 +11:00
Andrew Leech
4daee31706 stm32/qspi: Use static af functions for pin configuration.
This allows qspi pin configuration to work on any supported platform.
2019-02-14 13:42:08 +11:00
Damien George
be4e5b1f87 stm32/mboot/mphalport.h: Include genhdr/pins.h for access to pin names.
So that mboot configuration can use names like pyb_pin_X1.
2019-02-14 13:39:13 +11:00
Damien George
f38397ba8d stm32/mboot/Makefile: Generate all pin header files from board pins.csv. 2019-02-14 13:36:32 +11:00
Damien George
7b2dc96251 stm32/boards/make-pins.py: Add cmdline options to support use by mboot. 2019-02-14 13:35:39 +11:00
Yonatan Goldschmidt
bc4f8b438b extmod/moduwebsocket: Refactor websocket to uwebsocket.
As mentioned in #4450, `websocket` was experimental with a single intended
user, `webrepl`. Therefore, we'll make this change without a weak
link `websocket` -> `uwebsocket`.
2019-02-14 00:35:45 +11:00
Jolatomme
d1acca3c71 stm32/boards/NUCLEO_L476RG: Add support for RNG, DAC and CAN1.
PLLQ is changed to get CAN working, and I2C1 pins are changed to those
prescribed by the board.
2019-02-14 00:28:28 +11:00
Damien George
26a1ae295f stm32/mboot/Makefile: Support specifying BOARD_DIR for custom board. 2019-02-14 00:01:14 +11:00
Yonatan Goldschmidt
66f0afc91d unix/modmachine: Handle repeated /dev/mem open errors.
If opening of /dev/mem has failed an `OSError` is appropriately raised, but
the next time `mem8/16/32` is accessed the invalid file descriptor is used
and the program gets a SIGSEGV.
2019-02-12 15:29:11 +11:00
Mike Causer
812969d615 all: Change PYB message prefix to MPY.
Replaces "PYB: soft reboot" with "MPY: soft reboot", etc.

Having a consistent prefix across ports reduces the difference between
ports, which is a general goal.  And this change won't break pyboard.py
because that tool only looks for "soft reboot".
2019-02-12 15:18:33 +11:00
Damien George
d976e4f5e8 teensy/Makefile: Use common gchelper_m3.s code from lib/utils. 2019-02-12 15:12:24 +11:00
Damien George
6e30f96b0b ports: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
Damien George
019433a17e stm32/pendsv: Fix inline asm constant and prefix with # character. 2019-02-12 14:50:27 +11:00
Damien George
d53dc04903 qemu-arm: Use gchelper code to get registers for GC scanning. 2019-02-12 14:48:29 +11:00
Damien George
c9ece68d06 cc3200: Use common gchelper_m3.s code from lib/utils. 2019-02-12 14:41:48 +11:00
Damien George
3058d46892 stm32/gccollect: Use gchelper.h header instead of explicit declaration. 2019-02-12 14:38:30 +11:00
Damien George
e6d97e8a0b stm32: Move gchelper assembler code to lib/utils for use by other ports. 2019-02-12 14:11:21 +11:00
Damien George
e7332b0584 qemu-arm: Rework to run bare-metal on boards with Cortex-M CPUs.
Adds support for 3 Cortex-M boards, selectable via "BOARD" in the Makefile:
- microbit, Cortex-M0 via nRF51822
- netduino2, Cortex-M3 via STM32F205
- mps2-an385, Cortex-M3 via FPGA

netduino2 is the default board because it's supported by older qemu
versions (down to at least 2.5.0).
2019-02-12 13:50:01 +11:00
Damien George
b546e4b7e9 stm32/pendsv: Fix NULL pointer when calling pendsv dispatch function. 2019-02-08 16:38:09 +11:00
Damien George
800871c0cb stm32/modnetwork: Change lwIP polling to be based on background systick. 2019-02-08 16:38:09 +11:00
Damien George
4d214edae8 stm32/systick: Provide better compile-time configurability of slots. 2019-02-08 15:31:02 +11:00
Damien George
18cfa156d6 stm32/pendsv: Add ability to schedule callbacks at pendsv IRQ level. 2019-02-08 01:20:13 +11:00
Damien George
b178958c07 stm32/pendsv: Clean up pendsv IRQ handler and eliminate duplicate code. 2019-02-08 01:20:13 +11:00
Damien George
1bcf4afb10 stm32/systick: Make periodic systick callbacks use a cyclic func table.
Instead of checking each callback (currently storage and dma) explicitly
for each SysTick IRQ, use a simple circular function table indexed by the
lower bits of the millisecond tick counter.  This allows callbacks to be
easily enabled/disabled at runtime, and scales well to a large number of
callbacks.
2019-02-08 01:20:13 +11:00
Damien George
5fbda53d3c stm32/systick: Rename sys_tick_XXX functions to systick_XXX. 2019-02-08 01:20:09 +11:00
Damien George
c33f538066 esp32/modmachine: Add support for changing the CPU frequency. 2019-02-07 22:51:55 +11:00
Damien George
1669e049de stm32/boards/STM32F769DISC: Configure for use with mboot by default.
This is a good board to demonstrate the use of Mboot because it only has a
USB HS port exposed so the native ST DFU mode cannot be used.  With Mboot
this port can be used.
2019-02-07 16:28:01 +11:00
Damien George
be1b1835c3 stm32/boards/STM32F769DISC: Support the use of USB HS with external PHY. 2019-02-07 16:26:46 +11:00
Damien George
b26046aca2 stm32/modmachine: Make bootloader() enter custom loader if it's enabled.
If a custom bootloader is enabled (eg mboot) then machine.bootloader() will
now enter that loader.  To get the original ST DFU loader pass any argument
to the function, like machine.bootloader(1).
2019-02-07 16:13:57 +11:00
Damien George
ab423f2969 stm32/usbd_conf: Fully support USB HS with external PHY. 2019-02-07 16:09:25 +11:00
Damien George
9f9c5c19b0 stm32/usb: Use USB HS as main USB device regardless of USB_HS_IN_FS. 2019-02-07 16:09:08 +11:00
Damien George
03a8b1cc50 stm32/mboot: Allow deploying via deploy-stlink. 2019-02-07 16:06:05 +11:00
Damien George
a81cb3576b stm32/mboot: Add support for GPIO ports G, H, I and J. 2019-02-07 16:04:48 +11:00
Damien George
39eb1e9f81 stm32/mboot: Add support for STM32F769 MCUs. 2019-02-07 16:04:06 +11:00
Damien George
9570297dd1 stm32/mboot: Use USB HS as main USB device regardless of USB_HS_IN_FS. 2019-02-07 16:03:18 +11:00
Damien George
43a894fb48 stm32/adc: Add basic support for ADC on a pin on STM32H7 MCUs. 2019-02-06 13:35:28 +11:00
Damien George
b367c425e4 stm32/boards/stm32h743_af.csv: Add ADC entries to pin capability table. 2019-02-06 13:34:53 +11:00
Damien George
02682d52ce stm32/boards/make-pins.py: Add basic support for STM32H7 ADC periphs. 2019-02-06 13:34:23 +11:00
Damien George
6a95e74387 esp32: Use SPIRAM in mem-map mode so all of it can be used for uPy heap.
Also enable CONFIG_SPIRAM_IGNORE_NOTFOUND to allow boards with faulty or
missing SPIRAM to still boot.
2019-02-06 00:10:50 +11:00
Stig Bjørlykke
98f790b03a nrf/timer: Fix disabling Timer 1 when using soft PWM.
Don't exclude the Timer instance 1 entry from machine_timer_obj[] when
using soft PWM. The usage is already checked when creating the Timer,
so just create an empty entry.
2019-02-02 11:15:52 +01:00
Andrew Leech
67689bfd7e stm32/usb: Add flow control option for USB VCP data received from host.
It's off by default and can be enabled at run-time with:

    pyb.USB_VCP().init(flow=pyb.USB_VCP.RTS)
2019-01-31 23:31:26 +11:00
Stig Bjørlykke
63eae33b7b nrf/ticker: Remove duplicate NRFX_IRQ_PRIORITY_SET. 2019-01-31 17:50:10 +11:00
Ayke van Laethem
e8678cd1c9 nrf/pin: Print pull information in Pin.__str__. 2019-01-31 17:38:13 +11:00
Ayke van Laethem
2d293873a6 nrf/pin: Cleanup Pin.__str__ to print relevant information.
Code size change:
nrf51: -44
nrf52: -52
2019-01-31 17:31:58 +11:00
Ayke van Laethem
4e1c2fc831 nrf: Shrink "<peripheral> does not exist" error messages.
Code size reductions:
nrf51: -132
nrf52: -188
2019-01-31 17:26:26 +11:00
Ayke van Laethem
1ba962ff57 nrf/uart: Remove unused machine.UART() parameters.
If needed these parameters can be added back and made functional one at a
time.  It's better to explicitly not support them than to silently allow
but ignore them.
2019-01-31 17:18:23 +11:00
Ayke van Laethem
a293fa3d6d nrf/uart: Use formula instead of switch for baudrate calculation.
This saves a bit of code:
nrf51: -176
nrf52: -152
2019-01-31 17:06:59 +11:00
Paul Sokolovsky
2f5d113fad py/warning: Support categories for warnings.
Python defines warnings as belonging to categories, where category is a
warning type (descending from exception type). This is useful, as e.g.
allows to disable warnings selectively and provide user-defined warning
types.  So, implement this in MicroPython, except that categories are
represented just with strings.  However, enough hooks are left to implement
categories differently per-port (e.g. as types), without need to patch each
and every usage.
2019-01-31 16:48:30 +11:00
Damien George
86f06d6a87 stm32/sdcard: Don't use SD clock bypass on F7 MCUs.
With clock bypass enabled the attached SD card is clocked at the maximum
48MHz.  But some SD cards are unreliable at these rates.  Although it's
nice to have high speed transfers it's more important that the transfers
are reliable for all cards.  So disable this clock bypass option.
2019-01-31 12:49:48 +11:00
Damien George
e5509a910f stm32/mboot: Add option to autodetect the USB port that DFU uses.
Enable in mpconfigboard.h via #define MBOOT_USB_AUTODETECT_USB (1).
Requires MICROPY_HW_USB_FS and MICROPY_HW_USB_HS to be enabled as well.
2019-01-31 12:05:39 +11:00
Damien George
4bed17e786 stm32/boards/stm32f429_af.csv: Fix typos in UART defs Tx->TX and Rx->RX.
Fixes issue #4445.
2019-01-31 01:02:42 +11:00
Damien George
3ff3e96865 esp8266/modmachine: In lightsleep, only waiti if wifi is turned off.
Otherwise the STA interface can't do DTIM sleeping correctly and power
consumption goes up.
2019-01-31 00:05:00 +11:00
Damien George
d5d060ead9 nrf/modmachine: Rename machine.sleep to machine.lightsleep. 2019-01-30 14:15:38 +11:00
Damien George
0a954e0196 cc3200/modmachine: Rename machine.sleep to machine.lightsleep. 2019-01-30 14:15:08 +11:00
Damien George
808dc95ab8 esp8266/modmachine: Implement simple machine.lightsleep function.
Use of "waiti 0" reduces power consumption by about 3mA compared to a
time.sleep_ms call.
2019-01-30 14:05:53 +11:00
Damien George
2911e3554a esp8266/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 14:05:53 +11:00
Damien George
d7cc92383c esp8266/modmachine: Implement optional time_ms arg to machine.deepsleep. 2019-01-30 14:05:53 +11:00
Damien George
8de17b3d96 esp32/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 13:00:26 +11:00
Damien George
dadee5fa24 esp32/modsocket: Fix crashes when connect/bind can't resolve given addr.
Fixes issue #4441.
2019-01-30 12:40:50 +11:00
Damien George
38022ddb2c stm32/main: Make board-defined UART REPL use a static object and buffer.
This way the UART REPL does not need the MicroPython heap and exists
outside the MicroPython runtime, allowing characters to still be received
during a soft reset.
2019-01-28 22:56:55 +11:00
Damien George
f431795caf esp32/boards: Use auto xtal freq config instead of default 40MHz.
Auto-detection of the crystal frequency is convenient and allows for a
single binary for many different boards.  But it can be unreliable in
certain situations so in production, for a given board, it's recommended to
configure the correct fixed frequency.
2019-01-28 20:42:12 +11:00
Damien George
5d88272342 esp32/Makefile: Make sure that directory exists for sdkconfig.h. 2019-01-28 20:41:13 +11:00
Damien George
9ac9aa989c esp32/machine_timer: Deinit all active timers on soft reset.
Otherwise they will keep triggering the callback and access invalid data on
the heap.
2019-01-28 16:16:03 +11:00
Damien George
3d49b157b8 esp32: Update to latest ESP IDF using sdkconfig and new ldgen procedure.
Configuration for the build is now specified using sdkconfig rather than
sdkconfig.h, which allows for much easier configuration with defaults from
the ESP IDF automatically applied.  sdkconfig.h is generated using the new
ESP IDF kconfig_new tool written in Python.  Custom configuration for a
particular ESP32 board can be specified via the make variable SDKCONFIG.

The esp32.common.ld file is also now generated using the standard ESP IDF
ldgen.py tool.
2019-01-28 12:44:03 +11:00
Damien George
f59904f799 esp32/Makefile: Put all IDF compenents in .a libs to use IDF ld script.
When the ESP IDF builds a project it puts all separate components into
separate .a library archives.  And then the esp32.common.ld linker script
references these .a libraries by explicit name to put certain object files
in iRAM.

This patch does a similar thing for the custom build system used here,
putting all IDF .o's into their respective .a.  So a custom linker script
is no longer needed.
2019-01-28 12:41:37 +11:00
Damien George
e7ab475276 esp32: Don't put py/scheduler.o in iRAM, it's no longer needed.
ISR's no longer need to be in iRAM, and the ESP IDF provides an option to
specify that they are in iRAM if an application needs lower latency when
handling them.  But we don't use this feature for user interrupts: both
timer and gpio ISR routines are registered without the ESP_INTR_FLAG_IRAM
option, and so the scheduling code no longer needs to be in iRAM.
2019-01-27 16:15:47 +11:00
Damien George
4caf5b2358 stm32/usbdev: Add USB config option for max power drawn by the board.
The new compile-time option is MICROPY_HW_USB_MAX_POWER_MA.  Set this in
the board configuration file to the maximum current in mA that the board
will draw over USB.  The default is 500mA.
2019-01-27 14:02:10 +11:00
Damien George
7d8db42d17 stm32/usbdev: Add USB config option for board being self powered.
The new compile-time option is MICROPY_HW_USB_SELF_POWERED.  Set this
option to 1 in the board configuration file to indicate that the USB device
is self powered.  This option is disabled by default (previous behaviour).
2019-01-27 13:52:43 +11:00
Damien George
c2886868b9 stm32/rtc: Check RTCEN=1 when testing if RTC is already running on boot.
It can be that LSEON and LSERDY are set yet the RTC is not enabled (this
can happen for example when coming out of the ST DFU mode on an F405 with
the RTC not previously initialised).  In such a case the RTC is never
started because the code thinks it's already running.  This patch fixes
this case by always checking if RTCEN is set when booting up (and also
testing for a valid RTCSEL value in the case of using an LSE).
2019-01-27 13:21:31 +11:00
stijn
42863830be py: Add optional support for 2-argument version of built-in next().
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2019-01-27 13:01:28 +11:00
Reagan Sanders
51577629b2 cc3200/mods/modussl: Fix ca_certs arg validation in mod_ssl_wrap_socket.
Commit a0d97fe408 changed the argument index
of ca_certs but missed updating one of the references to the new index.
2019-01-27 12:51:34 +11:00
Mikhail Zakharov
18723e9889 unix/mpthreadport: Remove busy wait loop in thread garbage collection.
One can't use pthread calls in a signal handler because they are not
async-signal-safe (see man signal-safety).  Instead, sem_post can be used
to post from within a signal handler and this should be more efficient than
using a busy wait loop, waiting on a volatile variable.
2019-01-27 12:40:10 +11:00
Mikhail Zakharov
1e7b422226 unix/mpthreadport: Cleanup used memory on thread exit. 2019-01-27 12:39:45 +11:00
Mikhail Zakharov
f8c1be85d1 unix/mpthreadport: Add thread deinit code to stop threads on exit.
Free unused memory for threads and cancel any outstanding threads on
interpreter exit to avoid possible segmentaiton fault.
2019-01-27 12:38:23 +11:00
Damien George
285d265eee stm32: Implement machine.lightsleep(). 2019-01-27 11:13:32 +11:00
Damien George
6d480f50ac pic16bit: Update to compile with latest xc16 v1.35 compiler.
This port has been verified to work with these latest changes.
2019-01-25 16:06:13 +11:00
Damien George
da72bb6833 esp32/machine_hw_spi: Make HW SPI objects statically allocated.
This aligns more closely with the hardware, that there are two, fixed HW
SPI peripherals.  And it allows to recreate the HW SPI objects without
error, as well as create them again after a soft reset.

Fixes issue #4103.
2019-01-23 23:47:36 +11:00
Damien George
d82f344f61 esp32/machine_hw_spi: Use separate DMA channels for HSPI and VSPI.
Otherwise only one of HSPI or VSPI can be used at a time.  Fixes
issue #4068.
2019-01-23 23:40:06 +11:00
Matt Trentini
cd52d2c691 esp32/modules/neopixel.py: Change NeoPixel to different default timings.
In order to suit the more common 800KHz by default (instead of 400KHz), and
also have the same behaviour as the esp8266 port.

Resolves #4396.

Note! This is a breaking change. Anyone that has previously used the
NeoPixel class on an ESP32 board may be affected.
2019-01-23 14:22:38 +11:00