Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: serial: Rework nrfx_uarte shim to support nrf54x platforms #2041

Closed
wants to merge 1,784 commits into from

Conversation

nordic-krch
Copy link
Contributor

Set of commits cherry-picked from upstream and from upstream PR (zephyrproject-rtos/zephyr#75462) which enable use of legacy shim on nrf54x.
PR introduces:

  • support for new UARTE HW features - frame timeout, ENDTX_STOPTX short
  • support for memory and cache management (DMM)
  • support for fast instance (UARTE120)

nordicjm and others added 19 commits October 4, 2024 14:12
fixup! [nrf noup] tree-wide: support NCS Partition Manager (PM) definitions

Allows overriding the variable used for specifying how much SRAM a
device has in partition manager by using the Kconfig value rather
than the PM-generated config value

Signed-off-by: Jamie McCrae <[email protected]>
Allows selecting the forward GPIO pins to network core Kconfig
option and enables it by default if the node exists in devicetree

(cherry picked from commit 07f96b8)

Signed-off-by: Jamie McCrae <[email protected]>
The list of reserved PPIs by MPSL should be kept if MPSL is enabled.
The 802154 radio driver is not the only user of MPSL.

This commit has been converted from a fromlist to noup.

Signed-off-by: Jonathan Rico <[email protected]>
Signed-off-by: Bjarki Arge Andreasen <[email protected]>
…neric

-This commit prevents legacy mbed TLS configurations from being in
 conflict with PSA Configurations while using nrf_security.
-This [nrf noup] is reworked from an earlier cherry-pick of
 commit d8c96cf, but has the following
 changes:
 - Endif's relevant that is using our pattern for masking
   configs duplicated or in conflict in nrf_security
  (by using if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND)) is
  made clearer by adding a comment at their corresponding endif
  (# !(NRF_SECURITY || NORDIC_SECURITY_BACKEND))
 - Changes to zephyr_init.c for entropy_dev checking for
   CONFIG_NRF_CC3XX_PLATFORM is removed as the symbol entropy_dev
   doesn't exist in this file anymore

ref: NCSDK-13503

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This is a [nrf noup] because PSA_WANT_GENERATE_RANDOM is a Nordic
 configuration that is not found upstream. This was previously in
 commit 5cfe575 but has been split out

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This commit is a [nrf noup] because it removes configuration options
 for cryptographic algortihms available in Mbed TLS but which is not
 actively supported in nRF Connect SDK.
 The list of algorithms removed:
 - AES CFB - Cipher Feedback block cipher
 - AES OFB - Output Feedback block cipher
 - FFDH
 - RIPEMD160
 - Aria
 - Camellia
 - DES

 The removal of these algorithms is based both on a wish to remove
 weaker cryptography and unsupported features in the products we have
 today.

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This is a [nrf noup] as this the upstream version of PSA crypto configs
 is generated by tooling, and there is no mechanisms to qualify
 that dependent configurations are enabled (by depends or select).
-This adds dependency-mapping between configurations in the Kconfigs
 added for PSA crypto in upstream.

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This commit is a [nrf noup] because PSA crypto configs in upstream
 Zephyr doesn't have help-text in their configurations and we don't
 want to duplicate configurations to control the value
-This adds warning for SHA-1 and MD5 usage

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This is a [nrf noup] because the upstream Zephyr is generated using
 a script and is not committed as-is as source-code. The relevant
 responsible person for this feature has received information about
 the missing configuration and this will be resolved upstream in
 Mbed TLS and will propagate down to zephyr. Once this has happened,
 this [nrf noup] can be dropped.
-Add missing PSA_WANT_KEY_TYPE_RSA_KEY_DERIVE

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This commit contains all Nordic-specific configurations for PSA crypto
 These have been separated from Kconfig.psa, as this file is now
 auto-generated in the upstream project. This commit may be
 reworked later, in case more features are supported in Kconfig.psa
-Add Kconfig.psa.nordic containing Nordics PSA crypto addition
-Add reading this file from modules/mbedtls/Kconfig

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-This commit is a [nrf noup] as Kconfig.psa is an auto-generated
 file. The changes reflected here has been reported to maintainers
 in upstream Zephyr.
 Change: Mbed TLS resolves PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC and
 PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT internally from the other
 types.

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
-PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC is internally resolved by
 Mbed TLS. It has been made promptless in a previous commit.
 Keeping this change separated since the Kconfig.psa is auto-generated
 and it would likely be a bit more complex to handle this in a
 single commit. Upstream maintainers have been notified about this
 mismatch in configurations.

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
Update path for autoconf.h which is now in zephyr/autoconf.h

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
Add board support for the nrf7002eb shield. This shield uses the
nordic edge-connector to be compatible with multiple boards.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>

Upstream PR: zephyrproject-rtos/zephyr#78330
Add build for nrf7002eb shield on thingy53 board.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>

Upstream PR: zephyrproject-rtos/zephyr#78330
Makes the boot banner function weak, this resolves an issue when
building with llext enabled which uses different build options
than a normal zephyr build

Signed-off-by: Jamie McCrae <[email protected]>
…ken from dt

Currently a user, or a shield definition, must select a Kconfig to
signal that the iovdd_ctrl and bucken GPIOs are connected to the same
pin. We can instead check this in the driver by simply checking if
the iovdd_ctrl_spec and bucken_spec are the same pin.

Update the nrfwifi driver and remove the redundant
NRF_WIFI_COMBINED_BUCKEN_IOVDD_GPIO config.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>

Upstream PR: zephyrproject-rtos/zephyr#78485
In NCS to leverage HW acceleration, use nRF security.

Also, fix Kconfig warnings in NCS compliance for CRYPTO_ALT.

Signed-off-by: Chaitanya Tata <[email protected]>
External flash support is still WIP, so, to get sysbuild working add
dummy Kconfig options.

Signed-off-by: Chaitanya Tata <[email protected]>
adamkondraciuk and others added 7 commits October 21, 2024 15:42
…e PM

Enable the device runtime power management on the SPIM shim.

Upstream PR: zephyrproject-rtos/zephyr#75715

Signed-off-by: Adam Kondraciuk <[email protected]>
Add configuration for testing SPI with device runtime PM enabled
for nRF platforms.

Upstream PR: zephyrproject-rtos/zephyr#75715

Signed-off-by: Adam Kondraciuk <[email protected]>
Some devices, e.g. SoC level devices like I2C peripheral, can never be
powerd off as they are always energized. Such devices can only go from an
active state or to a low power state (suspended). Allow them to simply
return -ENOTSUP when called with TURN_ON (or TURN_OFF).

Signed-off-by: Gerard Marull-Paretas <[email protected]>
(cherry picked from commit 740eba1)
Use NRFX_FOREACH_PRESENT macro to iterate over all PWM instances
and create device only for those enabled in the devicetree.
This approach removes need of changing driver code when new
instance id is added.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 0ab86c4)
Shim was not correctly disabling PWM when it was not used. Task
STOP was triggered but PWM->ENABLE remained set which caused
increased current. Added interrupt and enabled event handler in
the nrfx driver to allow disabling PWM on STOPPED event.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit c3a33cf)
Rework PM handling to use pm_device_driver_init(). Shim is not using
put and get internally as there is no api that disables or stops
pwm so it is hard to determine when to put the device. There are cases
when PWM peripheral is stopped but PWM is still active because
duty cycle is 100% or 0% and pin is driven by GPIO and not PWM.

If user want to use runtime PM with PWM it is possible and getting
the device will initialize internal data and putting will suspend
by forcing PWM stop if used and setting pins to sleep state. However,
from power consumption perspective it is enough to set 0% or 100%
duty cycle on all channels.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit e11d050)
@nordic-krch nordic-krch force-pushed the ncs/uart_legacy_rework branch 2 times, most recently from e2c5491 to 024867a Compare October 22, 2024 06:44
Like in all other legacy boards, hw-flow-control should not be
enabled for console UART. With hw-flow-control sample stuck
during printing some initial information and sample appears to
be not working correctly unless com port is opened.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 01f2740)
… structure

Split async control block structure into tx and rx structures.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 701beec)
…operty

Add property which indicates that UARTE support frame timeout
feature. Property is added to nrf54h20, nrf9280, nrf54l20 and
nrf54l15.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit ac1cc17)
…_MANAGEMENT

This is a leftover from pre-pinctrl era and no longer makes sense.
Driver always manages gpio through pinctrl.

Support removed from uart and uarte shims.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 76db5b2)
…O_MANAGEMENT

Remove Kconfig option that no longer has any use after pinctrl
driver is introduced.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit cae53af)
…MENT removal

Add note that those Kconfig options were removed from Nordic UART driver
configuration.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 3a4c5a9)
Use nrfx_gppi as abstraction over (D)PPI.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 2668476)
…struct pointer

Refactor RX asynchronous API function to use a pointer to the RX
async data structure instead of top level data structure pointer.
It improves readability with more concise code.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit d82808e)
…new features

Rework driver to support new way of asynchronous RX handling.
Previously RX was handled in two modes: using RXDRDY interrupt for byte
counting or TIMER + PPI. Both modes had flaws. RXDRDY interrupt mode
could miscalculated amount of received bytes when interrupt was not
handled on time. Data was not lost but was not reported on time that
could lead to issues. PPI+TIMER mode requires additional resources
thus it was not the default mode. Often user was not aware of that
option and was expiriencing driver RX faults.

New RX mode is switching buffers when there is new data (RXDRDY event
not set for given amount of time). It does not require additional
resources to get precise byte counting. Additionally, this is in line
with new UARTE feature (RX frame timeout) which is present in nRF54X
devices. The behavior of the driver is the same for legacy devices
and new one. For legacy devices k_timer periodic interrupts are used
to check if there are any new bytes and it is not needed when RX frame
timeout is present.

Improved RX mode is enabled by default
(CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) but legacy modes are still
available though not recommended to be used.

Note that new RX mode (CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) behaves
a bit different because timeout always triggers switch of buffers
which means that there will be no UART_RX_RDY events with non-zero
offset. It also means that every UART_RX_RDY will be followed by
UART_RX_BUF_RELEASED.

After rework, driver is recommended to be used for all platforms as it
performs much better and takes much less code than the second UART shim
available for Nordic devices.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 399a235)
…eout

Frame timeout is a hardware feature present in newer versions
of UARTE (e.g. in NRF54X platforms) for detecting idle state
on RX line and ending RX after configurable timeout.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 1f96e62)
…ache

Add support for DMM which manages cache and dedicated memory spaces.
Added support for data cache for buffers which are not DMM managed.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 9517106)
…karound

Add configurable magic byte instead of fixed 0xAA. In some cases, it
is known that certain bytes are less likely in the transmission and
picking specific magic byte may reduce probability of failure of
detection of the correct amount of flushed data.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 7735302)
…TE register

On uart120 BAUDRATE register is not retained when ENABLE=0 and
because of that BAUDRATE must be set after enabling. Add workaround
to the driver.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 5eaafba)
Add lock to fix race when uart_rx_disable is interrupted by RXTO
event which lead to driver state corruption.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 317de0c)
@nordic-krch
Copy link
Contributor Author

superseded by #2146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.