Commit Graph

548 Commits

Author SHA1 Message Date
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
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
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
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
Damien George
e4ac104b7f stm32: Allow to build with threading with the GIL disabled. 2019-03-08 22:29:54 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Damien George
285d265eee stm32: Implement machine.lightsleep(). 2019-01-27 11:13:32 +11:00
Damien George
3431ea7205 stm32/main: Make thread and FS state static and exclude when not needed.
Without the static qualifier these objects will be kept by the linker even
if they are unused.  So this patch saves some RAM when these features are
unused by a board.
2019-01-11 01:52:17 +11:00
Damien George
5b66c7b712 stm32/wdt: Make singleton WDT object const so it goes in ROM. 2019-01-11 01:51:57 +11:00
Damien George
b33f108cde stm32/sdcard: Properly reset SD periph when SDMMC2 is used on H7 MCUs. 2018-12-30 01:28:34 +11:00
roland
4d8504425a stm32/modmachine: Fix reset_cause to correctly give DEEPSLEEP on L4 MCU.
Before this fix it returned SOFT_RESET after waking from a deepsleep
(standby).
2018-12-30 01:11:25 +11:00
Damien George
f334816df0 stm32/uart: Make sure user IRQs are handled even with a keyboard intr. 2018-12-30 01:03:22 +11:00
Damien George
7bdbea9a0c stm32/uart: Clear overrun error flag after reading RX data register.
On MCUs other than F4 the ORE (overrun error) flag needs to be cleared
independently of clearing RXNE, even though both are wired to trigger the
same RXNE IRQ.  In the case that an overrun occurred it's necessary to
explicitly clear the ORE flag or else the RXNE interrupt will keep firing.
2018-12-30 00:59:16 +11:00
Damien George
0d860fdcd0 stm32/uart: Always enable global UART IRQ handler on init.
Otherwise IRQs may not be enabled for the user UART.irq() handler.  In
particular this fixes the user IRQ_RXIDLE interrupt so that it triggers
even when there is no RX buffer.
2018-12-29 22:44:41 +11:00
Damien George
a5f7a3022d stm32/uart: Fix uart_rx_any in case of no buffer to return 0 or 1. 2018-12-29 22:43:35 +11:00
Tobias Badertscher
372e7a4dc6 stm32: Implement UART.irq() method with initial support for RX idle IRQ. 2018-12-29 17:21:37 +11:00
Andrew Leech
ce0c581179 stm32/main: Add board config option to enable/disable mounting SD card.
The new option MICROPY_HW_SDCARD_MOUNT_AT_BOOT can now be defined to 0 in
mpconfigboard.h to allow SD hardware to be enabled but not auto-mounted at
boot.  This feature is enabled by default to retain previous behaviour.

Previously, if an SD card is enabled in hardware it is also used to boot
from.  While this can be disabled with a SKIPSD file on internal flash,
this wont be available at first boot or if the internal flash gets
corrupted.
2018-12-22 01:30:47 +11:00
Damien George
5146e79490 stm32/boards/NUCLEO_L432KC: Specify L4 OpenOCD config file for this MCU. 2018-12-13 13:45:16 +11:00
Damien George
59f409a787 stm32/boards: Allow OpenOCD stm_flash procedure to accept single FW img.
To support deplop-openocd on target boards that use TEXT0_ADDR only and
have their firmware in a single binary image.
2018-12-13 13:43:10 +11:00
Damien George
1db55381b6 stm32/adc: Support 16-bit ADC configuration on H7 MCUs. 2018-12-12 12:51:46 +11:00
Damien George
6cab8daee0 stm32/adc: Increase ADC sampling time for internal sources on H7 MCUs. 2018-12-12 12:51:26 +11:00
Damien George
0555ada277 stm32/adc: Fix calibrated volt/temp readings on H7 by using 16bit scale. 2018-12-12 12:50:37 +11:00
Damien George
1b4031ed64 stm32/extint: Use correct EXTI channels on H7 MCUs for RTC events. 2018-12-12 12:49:23 +11:00
Damien George
dc23978dde stm32/uart: Add ability to have a static built-in UART object.
A static UART is useful for internal peripherals that require a UART and
need to persist outside the soft-reset loop.
2018-12-10 16:21:50 +11:00
Damien George
61ef031687 stm32/uart: Move config of char_width/char_mask to uart.c. 2018-12-10 16:21:50 +11:00
Damien George
6ea45277bf stm32/uart: For UART init, pass in params directly, not via HAL struct.
To provide a cleaner and more abstract C-level interface to the UART.
2018-12-10 16:21:50 +11:00
Damien George
e0c2432503 stm32/uart: Simplify deinit of UART, no need to call HAL.
The HAL just clears UE and then clears all the UART control registers.
2018-12-10 16:21:50 +11:00
Damien George
bc3f0dddac stm32/uart: Remove HAL's UART_HandleTypeDef from UART object struct.
This UART_HandleTypeDef is quite large (around 70 bytes in RAM needed for
each UART object) and is not needed: instead the state of the peripheral
held in its registers provides all the required information.
2018-12-10 16:21:50 +11:00