Commit Graph

581 Commits

Author SHA1 Message Date
Damien George 009b1f6559 stm32/boards: Rework all stm32??xx_hal_conf.h files to use common code.
This eliminates a lot of duplicated code in these header files.
2019-06-25 14:18:24 +10:00
Damien George f96f53cd97 stm32/boards: Add stm32??xx_hal_conf_base.h files with common settings.
These are intended to be used by all boards, to reduce the size of a
board's configuration.
2019-06-25 14:18:24 +10:00
Damien George 89ebb3325b stm32/boards/pllvalues.py: Support HSx_VALUE defined without uint32_t. 2019-06-25 14:18:24 +10:00
Damien George 04c7cdb668 stm32: Enter bootloader via a system reset.
Entering a bootloader (ST system bootloader, or custom mboot) from software
by directly branching to it is not reliable, and the reliability of it
working can depend on the peripherals that were enabled by the application
code.  It's also not possible to branch to a bootloader if the WDT is
enabled (unless the bootloader has specific provisions to feed the WDT).

This patch changes the way a bootloader is entered from software by first
doing a complete system reset, then branching to the desired bootloader
early on in the start-up process.  The top two words of RAM (of the stack)
are reserved to store flags indicating that the bootloader should be
entered after a reset.
2019-06-25 14:15:49 +10:00
Damien George 205c6d0dc9 stm32/Makefile: Print info messages about use of mboot/QSPI flash. 2019-06-24 21:59:58 +10:00
Damien George 5da60ff9cb stm32/boards: Enable ussl module via mbedtls for boards with network. 2019-06-24 17:48:28 +10:00
Chris Mason 14cf91f704 stm32: In link script, define start of stack separately from heap end.
Previously the end of the heap was the start (lowest address) of the stack.
With the changes in this commit these addresses are now independent,
allowing a board to place the heap and stack in separate locations.
2019-06-14 15:29:24 +10:00
Damien George 8b18cfedee stm32/usbd_msc: Allow to compile when USB enabled and SD card disabled. 2019-06-11 21:01:14 +10:00
Damien George 53200247b7 stm32/usb: Add "msc" kw-arg to pyb.usb_mode to select MSC logical units.
With this the user can select multiple logical units to expose over USB MSC
at once, eg: pyb.usb_mode('VCP+MSC', msc=(pyb.Flash(), pyb.SDCard())).  The
default behaviour is the original behaviour of just one unit at a time.
2019-06-11 16:22:09 +10:00
Damien George 9e68eec8ea stm32/usb: Use ARG_xxx enums to access kw args in pyb_usb_mode. 2019-06-11 15:50:21 +10:00
Damien George 38bcc99a58 stm32/usbd_msc: Provide Mode Sense response data in MSC interface.
Eventually these responses could be filled in by a function to make their
contents dynamic, depending on the attached logical units.  But for now
they are fixed, and this patch fixes the MODE SENSE(6) responses so it is
the correct length with the correct header.
2019-06-11 15:43:59 +10:00
Damien George 829aa58c5c stm32/usbd_msc: Provide custom irquiry processing by MSC interface.
So the MSC interface can customise the inquiry response based on the
attached logical units.
2019-06-11 15:43:58 +10:00
Damien George 518aa571ab stm32/usbd_msc: Rework USBD MSC code to support multiple logical units.
SCSI can support multiple logical units over the one interface (in this
case over USBD MSC) and here the MSC code is reworked to support this
feature.  At this point only one LU is used and the behaviour is mostly
unchanged from before, except the INQUIRY result is different (it will
report "Flash" for both flash and SD card).
2019-06-11 15:43:15 +10:00
Damien George 62f004ba42 stm32/lwip_inc: Update to enable mDNS, TCP listen backlog, faster DHCP. 2019-06-05 16:14:45 +10:00
Damien George 9e4b3681fd stm32: Support optional lwIP mDNS responder. 2019-06-05 16:14:09 +10:00
Damien George fd839221fd stm32/boards/PYBD_SFx: Enable ussl module using mbedTLS. 2019-06-05 15:38:01 +10:00
Damien George fed4c23590 stm32: Integrate optional mbedTLS component for ussl module.
To use it a board should define MICROPY_PY_USSL=1 and MICROPY_SSL_MBEDTLS=1
at the Makefile level.  With the provided configuration it adds about 64k
to the build.
2019-06-05 15:37:31 +10:00
Damien George ce8262a164 stm32/modnetwork: Replace generic netif NIC polling with specific code.
It doesn't work to tie the polling of an underlying NIC driver (eg to check
the NIC for pending Ethernet frames) with its associated lwIP netif.  This
is because most NICs are implemented with IRQs and don't need polling,
because there can be multiple lwIP netif's per NIC driver, and because it
restricts the use of the netif->state variable.  Instead the NIC should
have its own specific way of processing incoming Ethernet frame.

This patch removes this generic NIC polling feature, and for the only
driver that uses it (Wiznet5k) replaces it with an explicit call to the
poll function (which could eventually be improved by using a proper
external interrupt).
2019-06-03 17:14:34 +10:00
Damien George 62fe47aa3a stm32/boards/PYBD_SFx: Enable CYW43 WLAN driver. 2019-06-03 17:14:34 +10:00
Damien George 8b7409c295 stm32: Integrate in the cyw43 driver and network.WLAN class.
Enable it by setting MICROPY_PY_NETWORK_CYW43=1 at the Makefile level.
2019-06-03 17:14:34 +10:00
Damien George 12ed6f91ee stm32: Add low-level SDIO interface for cyw43 driver. 2019-06-03 16:53:46 +10:00
Damien George 370a8116c4 stm32/mphalport: Add support for having MAC in OTP region. 2019-06-03 16:47:35 +10:00
Damien George 10e173aaea stm32/extint: Add extint_set() function for internal C access to EXTI. 2019-06-03 16:47:35 +10:00
Damien George 345e9864aa stm32/modpyb: Add pyb.country() function to set the country.
To be used for peripherals (like radio) that must be location aware.
2019-06-03 16:47:35 +10:00
Damien George 8f55c74533 stm32/boards: Add board definition files for PYBD -SF2, -SF3, -SF6.
These are core configurations providing PYBv1.x-level features.
2019-05-31 22:44:25 +10:00
Damien George 34cae24e30 stm32/boards/pllvalues.py: Search nested headers for HSx_VALUE defines. 2019-05-31 21:44:53 +10:00
Damien George f8274d5e7d stm32/boards/make-pins.py: Allow pins.csv to skip or hide board-pin name
If the board-pin name is left empty then only the cpu-pin name is used, eg
",PA0".  If the board-pin name starts with a hyphen then it's available as
a C definition but not in the firmware, eg "-X1,PA0".
2019-05-31 21:41:30 +10:00
Damien George 3fc7c8e35c stm32/usb: Include py/mpconfig.h instead of mpconfigboard.h.
Because py/mpconfig.h has header include guards.
2019-05-31 21:39:34 +10:00
Damien George ff91b05cfa stm32/usb: Support up to 3 VCP interfaces on USB device peripheral.
To enable define MICROPY_HW_USB_CDC_NUM to 3.
2019-05-31 11:35:42 +10:00
Damien George 0c29502ad9 stm32/usb: Refactor CDC VCP code to enable N CDC interfaces.
The board config option MICROPY_HW_USB_ENABLE_CDC2 is now changed to
MICROPY_HW_USB_CDC_NUM, and the latter should be defined to the maximum
number of CDC interfaces to support (defaults to 1).
2019-05-30 21:11:04 +10:00
Damien George 0bb6b63e66 stm32/mboot/README: Fix some typos, describe bootloader and fwupdate.py. 2019-05-29 16:26:02 +10:00
Andrew Leech 66bcb5596a stm32/modmachine: In bootloader() disable caches before reset of periphs
Otherwise flushing and disabling the D-cache will give a hard-fault when
SDRAM is used.

Fixes #4818.
2019-05-29 15:50:17 +10:00
Andrew Leech 1470184bdd stm32/sdram: Update MPU settings to block invalid region, change attrs.
Set the active MPU region to the actual size of SDRAM configured and
invalidate the rest of the memory-mapped region, to prevent errors due to
CPU speculation.  Also update the attributes of the SDRAM region as per ST
recommendations, and change region numbers to avoid conflicts elsewhere in
the codebase (see eth usage).
2019-05-24 15:55:00 +10:00
Andrew Leech 4f44778728 stm32/sdcard: Add switch break to ensure only correct SD/MMC IRQ is run. 2019-05-23 21:55:31 +10:00
Damien George c769da1aaa stm32/i2c: Support setting the I2C TIMINGR value via keyword arg.
On MCUs that have an I2C TIMINGR register, this can now be explicitly set
via the "timingr" keyword argument to the I2C constructor, for both
machine.I2C and pyb.I2C.  This allows to configure precise timing values
when the defaults are inadequate.
2019-05-21 13:45:17 +10:00
Damien George ddc657658a stm32/machine_i2c: Simplify ROM initialisation of static HW I2C objects. 2019-05-21 12:38:34 +10:00
Andrew Leech ed2b6ea0a8 stm32/i2c: Make timeout for hardware I2C configurable.
Previously the hardware I2C timeout was hard coded to 50ms which isn't
guaranteed to be enough depending on the clock stretching specs of the I2C
device(s) in use.

This patch ensures the hardware I2C implementation honors the existing
timeout argument passed to the machine.I2C constructor.  The default
timeout for software and hardware I2C is now 50ms.
2019-05-21 12:20:19 +10:00
Damien George 38ac697b45 stm32/machine_i2c: Update to support new C-level I2C API. 2019-05-20 15:04:29 +10:00
Damien George 1f63e9b701 stm32/adc: Fix VBAT_DIV to be 4 for STM32F411.
Fixes issue #4794.
2019-05-20 14:37:28 +10:00
Damien George e1e3704aa1 stm32/modmachine: Create dedicated asm function to branch to bootloader.
Recent gcc versions (at least 9.1) give a warning about using "sp" in the
clobber list.  Such code is removed by this patch.  A dedicated function is
instead used to set SP and branch to the bootloader so the code has full
control over what happens.

Fixes issue #4785.
2019-05-17 17:20:43 +10:00
iabdalkader 746fcea7f8 stm32/boards/NUCLEO_H743ZI: Enable SPI3 on this board. 2019-05-15 16:08:10 +10:00
iabdalkader 1646eff864 stm32/irq: Fix IRQ_ENABLE_STATS stats config to work on all MCUs.
Only the M4 and M7 MCUs have an FPU and FPU_IRQn, and FPU_IRQn is not
always the last entry/IRQ number.
2019-05-15 16:04:01 +10:00
iabdalkader 07af74daef stm32/spi: Enable SPI IRQs and add IRQHandlers for H7 MCUs.
The H7 HAL uses SPI IRQs when the SPI is running in DMA mode.
2019-05-15 15:59:25 +10:00
iabdalkader 123c065131 stm32/dma: Always reset and configure the H7 DMA peripheral.
This is required for the H7 DMA to work.
2019-05-15 15:55:41 +10:00
iabdalkader 7359a9e2f2 stm32/dma: Initialise all members of DMA structs for H7 MCUs. 2019-05-13 12:57:44 +10:00
Andrew Leech 29865e3e58 stm32/rtc: Allow overriding startup timeouts from mpconfigboard. 2019-05-09 12:08:43 +10:00
Damien George b8c74014e4 stm32/usbd_cdc_interface: Don't retransmit chars if USB is reconnected.
Before this change, if the USB was reconnected it was possible that some
characters in the TX buffer were retransmitted because tx_buf_ptr_out and
tx_buf_ptr_out_shadow were reset while tx_buf_ptr_in wasn't.  That
behaviour is fixed here by retaining the TX buffer state across reconnects.

Fixes issue #4761.
2019-05-08 12:45:24 +10:00
Damien George 97753a1bbc stm32: Move factory reset files and code to separate source file.
The new function factory_reset_make_files() populates the given filesystem
with the default factory files.  It is defined with weak linkage so it can
be overridden by a board.

This commit also brings some minor user-facing changes:

- boot.py is now no longer created unconditionally if it doesn't exist, it
  is now only created when the filesystem is formatted and the other files
  are populated (so, before, if the user deleted boot.py it would be
  recreated at next boot; now it won't be).

- pybcdc.inf and README.txt are only created if the board has USB, because
  they only really make sense if the filesystem is exposed via USB.
2019-05-07 13:59:51 +10:00
Damien George 34942d0a72 stm32/machine_uart: Change default UART timeout to 0, for non blocking.
It's more common to need non-blocking behaviour when reading from a UART,
rather than having a large timeout like 1000ms (the original behaviour).
With a large timeout it's 1) likely that the function will read forever if
characters keep trickling it; or 2) the function will unnecessarily wait
when characters come sporadically, eg at a REPL prompt.
2019-05-07 13:56:42 +10:00
Chris Mason 2a791170ce stm32/boards: Add NUCLEO_F413ZH board configuration.
The alternate function pin allocations are different to other NUCLEO-144
boards.  This is because the STM32F413 has a very high peripheral count:
10x UART, 5x SPI, 3x I2C, 3x CAN.  The pinout was chosen to expose all
these devices on separate pins except CAN3 which shares a pin with UART1
and SPI1 which shares pins with DAC.
2019-05-02 16:33:30 +10:00