Wykres commitów

1373 Commity (cc26bf7406dac7822de347d14a9935c101d7e8aa)

Autor SHA1 Wiadomość Data
yn386 e18e47fa81 stm32/i2c: Add hardware I2C implementation for STM32L4.
For STM32L4, hardware I2C can be implemented by using TIMINGR.
This commit enables:
- Use of hardware I2C in machine.I2C.
- Specifying a frequency greater than or equal to 400KHz with pyb.I2C.
2022-11-18 15:01:13 +11:00
yn386 d0bea69c5e stm32/i2c: Add hardware I2C implementation for STM32L1.
For STM32L1, hardware I2C can be implemented the same as STM32F4 for
machine.I2C.

Tested on NUCLEO-L152RE.
2022-11-18 14:48:49 +11:00
yn386 f6b5d1838b stm32/adc: Fix ADCAll.read_core_temp() on L4 MCUs.
TS_CAL1 and TS_CAL2 of STM32L4 are at VDDA=3.0V, so the reference
correction factor should be updated before reading tempsensor.
2022-11-18 14:46:14 +11:00
yn386 2154ee2163 stm32/adc: Fix reading internal ADC channels on L4 MCUs.
For STM32L4 series, the internal sensors are connected to:
- ADC1_IN0: Internal voltage reference
- ADC1_IN17: Temperature sensor
- ADC1_IN18: VBAT battery voltage monitoring
but ADC_CHANNEL_VREFINT, ADC_CHANNEL_VBAT, ADC_CHANNEL_TEMPSENSOR are not
defined as 0, 17, 18.

This commit converts channel 0, 17, 18 to ADC_CHANNEL_x in
adc_get_internal_channel().
2022-11-18 14:38:58 +11:00
yn386 a74e4fabeb stm32/i2c: Fix I2C frequency calc so it doesn't exceed requested rate.
Prior to this commit, the actual I2C frequency can be faster than specified
one and it may exceed the I2C's specification for Fast Mode.  The frequency
of SCL should be less than or equal to 400KHz in Fast Mode.

This commit fixes this issue for F4 MCUs by rounding up the division in the
frequency calculation.
2022-11-18 14:25:19 +11:00
yn386 65d82066a8 stm32/pyb_i2c: Fix failing pyb.I2C(dma=True) after receiving 1 byte.
Excuting the code:

    i2c = I2C(1, I2C.CONTROLLER, dma=True)
    tmp = i2c.recv(1, i2c_addr)
    recv_data = bytearray(56)
    i2c.recv(recv_data, i2c_addr)

The second i2c.recv() fails with OSError: [Errno 110] ETIMEDOUT.  When
receiving greater than or equal to 2 bytes at first i2c.recv(), the second
i2c.recv() succeeds.  This issue does not occur without DMA.

Details of change: when executing I2C with DMA:

- Bit 11 of I2Cx_CR2 (DMA Request Enable) should be 1 to indicate that DMA
  transfer is enabled.  This bit is set after I2C event interrupt is
  enabled in HAL_I2C_Master_Transmit_DMA()/HAL_I2C_Master_Receive_DMA(), so
  DMA Request Enable bit might be 0 in IRQHandler.

- In case of data receive:
    - When only 1 byte receiption, clear I2Cx_CR1's bit 10 (ACK).
    - When only 2 byte receiption, clear I2Cx_CR1's bit 10 (ACK) and set
      bit 11 (POS).
    - When greater than or equal to 2 byte receiption, bit 12 of I2Cx_CR2
      (DMA Last Transfer) should set to generate NACK when DMA transfer
      completed.

Otherwise, the I2C bus may be busy after received data from peripheral.
2022-11-18 13:55:14 +11:00
Jim Mussared 5ef3aec33c stm32/Makefile: Set MPY_CROSS_FLAGS based on MCU type.
Previously it was hardcoded to armv7m, which would have failed on M0/M0+.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-11-17 22:10:41 +11:00
Koen De Vleeschauwer e7875829c2 stm32/usbd_desc: Support USB strings on CDC interface descriptors.
A board can now name the CDC ports, eg:

    #define MICROPY_HW_USB_CDC_NUM                  (3)
    #define MICROPY_HW_USB_INTERFACE_CDC0_STRING    "REPL"
    #define MICROPY_HW_USB_INTERFACE_CDC1_STRING    "GDB Server"
    #define MICROPY_HW_USB_INTERFACE_CDC2_STRING    "UART Port"

Signed-off-by: Damien George <damien@micropython.org>
2022-11-15 16:23:42 +11:00
iabdalkader 8ddb4567ff stm32/boards/ARDUINO_PORTENTA_H7: Add more modules, I2C1 and SE pin.
Changes in this commit are:
- Increase CDC buffer size.
- Define I2C1 SCL/SDA pins.
- Add crypto device enable pin to board pins.
- Update deploy instructions.
- Add ntptime, urequests and logging to manifest.
2022-11-14 18:59:17 +11:00
Angus Gratton b3e38ac632 stm32/spi: Downgrade SPIHandle definitions to static.
Seems unused outside of spi.c, spi_obj[] array is the expected way to
iterate these.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-11-11 13:23:24 +11:00
iabdalkader 71881116e6 extmod/extmod.mk: Set default mbedtls config file in extmod Makefile. 2022-11-09 18:43:13 +01:00
robert-hh 2426ddb575 stm32/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:57:46 +11:00
iabdalkader ebb1a4ecb0 stm32/boards/ARDUINO_PORTENTA_H7: Add custom mbedtls config. 2022-11-08 23:46:06 +11:00
iabdalkader d2c2846820 stm32/Makefile: Allow overriding the default MBEDTLS_CONFIG_FILE. 2022-11-08 23:43:43 +11:00
iabdalkader efe7dac0aa stm32/mbedtls: Enable mbedtls certificate time validation.
This is a reimplementation of b560b9fe71 for
the stm32 port.
2022-11-08 23:41:03 +11:00
Damien George cd35b8a2a3 extmod/machine_timer: Move stm32's implementation of machine.Timer here.
So it can be reused by other ports.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-27 14:32:43 +11:00
Jim Mussared 5ee1cb2771 stm32/boards/ARDUINO_PORTENTA_H7: Revert to single-precision float.
Using repr C is incompatible with double-precision floats on 32-bit arch.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-25 14:46:04 +11:00
Damien George 8874a09119 extmod/mbedtls: Enable elliptic curve DH and DSA cryptography.
This is necessary to access sites that only support these protocols.

The rp2 port already has ECDH enabled, so this just adds ECDSA there.  The
other ports now gain both ECDH and ECDSA.  The code size increase is:

- rp2 (PICO_W): +2916 bytes flash, +24 bytes BSS
- stm32 (PYBD_SF6): +20480 bytes flash, +32 bytes data, +48 bytes BSS
- mimxrt (TEENSY41): +20708 bytes flash, +32 bytes data, +48 bytes BSS
- unix (standard x86-64): +39344 executable, +1744 bytes data, +96 BSS

This is obviously a large increase in code size.  But there doesn't seem to
be any other option because without elliptic curve cryptography devices are
partially cut off from the internet.  For use cases that require small
firmware size, they'll need to build custom firmware with a custom mbedtls
config.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 19:08:21 +11:00
Damien George 9347545f9e extmod/mbedtls: Enable MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE.
This was already enabled on all ports except mimxrt.  Now it's enabled on
all of them.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 19:06:21 +11:00
Damien George b337678964 extmod/mbedtls: Add common configuration file, and use it in all ports.
This is a no-op change.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 19:06:21 +11:00
Damien George 67f98ba10c extmod/btstack: Update BTstack bindings to work with latest BTstack.
The following multi-tests pass (eg with PYBD_SF6+LEGO_HUB_NO6):

    ble_gap_advertise.py
    ble_gap_connect.py
    ble_gap_device_name.py
    ble_gattc_discover_services.py
    ble_gatt_data_transfer.py
    perf_gatt_char_write.py
    perf_gatt_notify.py
    stress_log_filesystem.py

These are the same tests that passed prior to this BTstack update.

Also tested on the unix port using H4 transport.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 14:28:25 +11:00
iabdalkader af4ba6d1b4 stm32: Rename machine I2C and SPI types consistently across ports.
This renames:
- machine_hard_i2c_type -> machine_i2c_type
- machine_hard_spi_type -> machine_spi_type
2022-10-22 12:54:42 +11:00
Jim Mussared d6d8722558 extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.

Make all extmod variables (src, flags, etc) private to extmod.mk.

Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.

Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:31:49 +11:00
Jim Mussared 87011f6353 extmod/extmod.mk: Make extmod.mk handle GIT_SUBMODULES.
This applies to nimble, btstack, axtls, mbedtls, lwip.

Rather than having the ports individually manage GIT_SUBMODULES for these
components, make extmod.mk append them when the relevant feature is
enabled.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:29:09 +11:00
Jim Mussared 3cc6decfc4 py/py.mk: Make user-C-module handling self-contained in py.mk.
Removes the need for the port to add anything to OBJS or SRC_QSTR.

Also makes it possible for user-C-modules to differentiate between code
that should be processed for QSTR vs other files (e.g. helpers and
libraries).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:23:18 +11:00
Jim Mussared 67d05ed02b ports: Make generated pin.c handling more consistent across ports.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:18:46 +11:00
Jim Mussared 17f2783e4a all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS.
This avoids a surprise where an = can cancel out an earlier +=.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:17:41 +11:00
yn386 e6d3513187 stm32/boards/NUCLEO_L152RE: Add NUCLEO-L152RE board support.
This change adds NUCLEO-L152RE support to the STM32 port.
NUCLEO-L152RE: https://www.st.com/en/evaluation-tools/nucleo-l152re.html
This board use STM32L152RE:
https://www.st.com/en/microcontrollers-microprocessors/stm32l152re.html
2022-09-25 23:56:41 +10:00
yn386 427d72667f stm32: Add support for STM32L1 MCUs.
This change adds STM32L1 support to the STM32 port.
2022-09-25 23:56:41 +10:00
Jatty_ 30e50ab195 stm32/make-stmconst.py: Support TypeDef's with a single char prefix.
Update the regex to support parsing files from the STM32CubeU5 library.
2022-09-23 16:09:38 +10:00
Jim Mussared 94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared 6da41b5900 py/obj: Merge getiter and iternext mp_obj_type_t slots.
The goal here is to remove a slot (making way to turn make_new into a slot)
as well as reduce code size by the ~40 references to mp_identity_getiter
and mp_stream_unbuffered_iter.

This introduces two new type flags:
- MP_TYPE_FLAG_ITER_IS_ITERNEXT: This means that the "iter" slot in the
  type is "iternext", and should use the identity getiter.
- MP_TYPE_FLAG_ITER_IS_CUSTOM: This means that the "iter" slot is a pointer
  to a mp_getiter_iternext_custom_t instance, which then defines both
  getiter and iternext.

And a third flag that is the OR of both, MP_TYPE_FLAG_ITER_IS_STREAM: This
means that the type should use the identity getiter, and
mp_stream_unbuffered_iter as iternext.

Finally, MP_TYPE_FLAG_ITER_IS_GETITER is defined as a no-op flag to give
the default case where "iter" is "getiter".

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:13 +10:00
Jim Mussared 9dce82776d all: Remove unnecessary locals_dict cast.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 6e75d177e7 stm32/boards/PYB: Fix handling of BOARD_VARIANT selection.
The matches should not have been quoted.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08 14:54:48 +10:00
Jim Mussared d84c6ef0e8 ports: Use micropython-lib version of drivers in manifests. 2022-09-08 11:27:05 +10:00
yn386 719dbbf563 stm32/boards: Add alternate function list for STM32F446RE.
Signed-off-by: Damien George <damien@micropython.org>
2022-09-06 16:55:24 +10:00
yn386 989b8c728b stm32/timer: Fix use of timer channel callback() method on L4 MCUs.
Since L4 HAL version 1.17.0, HAL_TIM_IC_Start_IT() checks whether specified
channel of timer is busy or not, which is the case if this function is
called more than once without first calling HAL_TIM_IC_Stop_IT().  The fix
in this commit is to call the stop function before calling start.  The PWM
and OC modes have the same issue with the same fix.

Fixes issue #8732.
2022-09-06 16:35:46 +10:00
yn386 da50827657 stm32/pyb_i2c: Fix pyb.I2C to work with dma=True on F4 MCUs.
Prior to this commit, excuting this code:

    i2c = I2C(1, I2C.CONTROLLER, dma=True)
    i2c.send(data, addr=i2c_addr)

the call to i2c.send() does not return and the board needs a reset.  This
code works when dma=False.

According to the specification, I2Cx_EV_IRQHandler should:
- Write DR to address when Start condition generated.
- Clear ADDR by reading SR2 after reading SR2 when address sent.

These processes are included in HAL_I2C_EV_IRQHandler(), however the
firmware size increses about 2KB if HAL_I2C_EV_IRQHandler is called.  This
commit adds above processes to i2c_ev_irq_handler, and increases firmware
by less than 100 bytes.

Fixes issue #2643.
2022-09-06 16:13:47 +10:00
yn386 8770cd2f4d stm32/adc: Make ADCAll.read_channel reject invalid channels.
pyb.ADC(channel) checks whether specified channel is valid or have ADC
capability but pyb.ADCAll().read_channel() does not.

This change adds checking whether specified channel is valid and throw
ValueError if channel is invalid.  This is same as pyb.ADC().
2022-09-06 15:22:16 +10:00
Damien George 4e4c28bf27 stm32/boards: Only freeze LCD160CR driver in PYB board firmware.
Although this driver and associated hardware can be used on any board, it
makes to only freeze it for PYB and PYBD boards.  It can be easily copied
to any board if needed.

Fixes issue #8056.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-06 12:53:46 +10:00
Jim Mussared fb20dbe4d1 stm32/boards/LEGO_HUB_NO6: Update manifest to new format.
This was added after 203dae41f and missed in the rebase.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-06 10:57:33 +10:00
Jim Mussared 203dae41fb all: Update all manifest.py files to use new features.
Changes in this commit:
- Manifest include's now use the directory path where possible (no longer
  necessary to include the manifest.py file explicitly).
- Add manifest.py for all drivers and components that are referenced by
  port/board manifests.
- Replace all uses of freeze() with package()/module(), except for port and
  board modules.
- Use opt=3 everywhere, for consistency and to reduce code size.
- Use require() instead of include() for all micropython-lib references.
- Remove support for optional board-level manifest.py in mimxrt port, to
  make it behave the same as other ports (the board must set
  FROZEN_MANIFEST to a custom manifest.py, which can optionally include the
  default, port-level manifest).
- Also reinstates modules that were accidentally removed from the esp8266
  512k build in fbe9417b90.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-09-05 18:43:18 +10:00
robert-hh 8ea6fefc6d stm32/machine_uart: Implement uart.flush() and uart.txdone().
Since uart.write() of the STM32 port waits until all bytes have
been sent, uart.flush() and uart.txdone() are implemented as empty
functions to provide API consistency.

uart.flush()

flush() will always return immediately.

ret = uart.txdone()

uart.txdone() will always return True.
2022-08-31 00:18:35 +10:00
Jim Mussared 8a0ee5a5c0 py/objstr: Split mp_obj_str_from_vstr into bytes/str versions.
Previously the desired output type was specified.  Now make the type part
of the function name.  Because this function is used in a few places this
saves code size due to smaller call-site.

This makes `mp_obj_new_str_type_from_vstr` a private function of objstr.c
(which is almost the only place where the output type isn't a compile-time
constant).

This saves ~140 bytes on PYBV11.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-26 16:43:55 +10:00
Damien George 1855df6361 stm32: Remove support for CC3000 WiFi driver.
It has been about 8 years since support for this chip was added.  Reasons
to remove it are:
- It is no longer easy to obtain this part.
- There are now many other options for WiFi.
- It's not a good use of developer time to maintain it.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-26 12:51:37 +10:00
Jim Mussared 986ad6bf1d stm32/boardctrl: Use HAL_Delay instead of mp_hal_delay_ms.
Not safe to use mp_hal_delay_ms before boot if threading is enabled,
because threading will not have been initialised, and
MICROPY_EVENT_POLL_HOOK assumes threading is initialised.

HAL_Delay doesn't call MICROPY_EVENT_POLL_HOOK, but is still
power-efficient like mp_hal_delay_ms (unlike mp_hal_delay_us).

Fixes #7816.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-26 12:48:04 +10:00
Jim Mussared 492ba5eaf2 stm32: Move board variant config to mpconfigboard.mk.
Rather than having the autobuild know about the particular variants, have
the mpconfigboard.mk describe them and make autobuild discover them
automatically.

Adds a "query-variants" target to stm32/Makefile to allow the set of
possible variants to be queried.

Removes pybv3 from the autobuild as this isn't use by the downloads page.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-26 09:38:38 +10:00
Andrew Leech 923375380b stm32/boards: Increase mboot region to 32k for WB55 boards.
If mboot is built with support for packing (signing/encryption) it needs up
to 32KiB.  So for simplicity increase the mboot region to 32KiB
unconditionally for WB55 boards (custom WB55 board configurations can still
provide their own linker scripts to override this).
2022-08-25 17:02:56 +10:00
Damiano Mazzella 1fbf0efaeb stm32/sdram: Enable MPU for unaligned access on H7 MCUs.
So that SDRAM can be used as the heap on ARDUINO_PORTENTA_H7, for example.

Fixes issue #9087.
2022-08-25 16:20:51 +10:00