Commit graph

87524 commits

Author SHA1 Message Date
Flavio Ceolin 1247f8465c xtensa: userspace: Supports tls on userspace
Use thread local storage to check whether or not a thread is running
in user mode. This allows to use threadptr to properly support tls.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung a36e39c2a6 xtensa: dc233c: enable userspace support
This massages kconfig and linker script to enable userspace
support on dc233c core.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 0d79481540 xtensa: userspace: only write 0xAA to stack if INIT_STACKS
Only clear the user stack to 0xAA if CONFIG_INIT_STACKS is
enabled. Otherwise, write 0x00 as if the stack is in BSS.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 0e7def1977 xtensa: selectively init interrupt stack at boot
During arch_kernel_init(), the interrupt stack is being
initialized. However, if the current in-use stack is
the interrupt stack, it would wipe all the data up to
that point in stack, and might result in crash. So skip
initializing the interrupt stack if the current stack
pointer is within the boundary of interrupt stack.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 6252fcfccf xtensa: userspace: simplify syscall helper
Consolidate all syscall helpers into one functions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung d9f643d007 xtensa: mmu: do not map heap if not using heap
Do not map the heap area by default if we are not using
heap at all.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin 9a33c400a1 xtensa: mmu: Fix possible race condition on tlb shootdown
We need to use the mmu spin lock when invalidating the cache during
tlb shootdown, otherwise it is possible that this happens when another
thread is updating the page tables.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin 156f1d4436 xtensa: mmu: Flush cache when altering pages
When the target has a cache way size (cache size / cache wasy) bigger
than the page size we have cache aliasing, since the number of bits
required by the cache index is bigger than the number of bits in the page
offset.

To avoid this problem we flush the whole cache on context switch or when
the current page table is changed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 6c6894c8d8 tests: mem_protect: enable for Xtensa
This enables tests/kernel/mem_protect/mem_protect to be tested
on Xtensa.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin be5eccdd15 tests: userspace: Add xtensa support
This test requires architecture specific code to work.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 7a5d2a2d81 xtensa: userspace: swap page tables at context restore
Swap page tables at exit of exception handler if we are going to
be restored to another thread context. Or else we would be using
the outgoing thread's page tables which is not going to work
correctly due to mapping and permissions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung c9c88a4368 xtensa: mmu: cache and TLB actions when adding thread to domain
When adding a thread to a memory domain, we need to also update
the mapped page table if it is the current running thread on
the same CPU. If it's not on the same CPU, we need to notify
the other CPUs in case the thread is running in one of them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 81ea43692c xtensa: mmu: send IPI to invalidate TLBs on other CPUs
After changing content of page table(s), it is needed to notify
the other CPUs that the page table(s) have been changed so they
can do the necessary steps to use the updated version. Note that
the actual way to send IPI is SoC specific as Xtensa does not
have a common way to do this at the moment.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung eb546a8d87 xtensa: rework kernel oops exception path
When kernel OOPS is raised, we need to actually go through
the process of terminating the offending thread, instead of
simply printing the stack and continue running. This change
employs similar mechanism to xtensa_arch_except() to use
illegal instruction to raise hardware exception, and going
through the fatal exception path.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin 586bb92049 xtensa: userspace: Add syscall for user exception
Trigger exception on Xtensa requires kernel privileges. Add
a new syscall that is used when ARCH_EXCEPT is invoked from userspace.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin 75936d8db2 xtensa: userspace: Implement arch_syscall_oops
This function is needed by userspace.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 716efb2e40 xtensa: extract printing of fatal exception into its own func
This extracts the printing of fatal exception information into
its own function to declutter xtensa_excint1_c().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung e9c449a737 xtensa: mmu: do not fault for known exceptions
There are known exceptions which are not fatal, and we need to
handle them properly by returning to the fixup addresses as
indicated. This adds the code necessary in the exception
handler for this situation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung bc0656a92e xtensa: mmu: allocate scratch registers for MMU
When MMU is enabled, we need some scratch registers to preload
page table entries. So update gen_zsr.py to that.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Daniel Leung c4706a3823 xtensa: mmu: handle page faults in double exception handler
This changes the TLB misses handling back to the assembly
in user exception, and any page faults during TLB misses to be
handled in double exception handler. This should speed up
simple TLB miss handling as we don't have to go all the way to
the C handler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin c53325298d xtensa: userspace: Stack object header
Add a header with architecture specific macros and
definitions that re used on userspace for stack
objects.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin a651862b30 xtensa: Enable userspace
Userspace support for Xtensa architecture using Xtensa MMU.

Some considerations:

- Syscalls are not inline functions like in other architectures because
  some compiler issues when using multiple registers to pass parameters
  to the syscall. So here we have a function call so we can use
  registers as we need.
- TLS is not supported by xcc in xtensa and reading PS register is
  a privileged instruction. So, we have to use threadptr to know if a
  thread is an user mode thread.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin fff91cb542 xtensa: mmu: Simplify initialization
Simplify the logic around xtensa_mmu_init.

- Do not have a different path to init part of kernel
- Call xtensa_mmu_init from C

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Flavio Ceolin a1bb2b9c64 xtensa: mmu: Simplify autorefill TLB helpers
Replace all autorefill helpers with only one that invalidates both,
DTLB and ITLB, since that is what is really needed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Andy Ross 3620e6b969 drivers/console: xtensa_sim_console: implement arch_printk_char_out()
This is an older driver and didn't support the weak
arch_printk_char_out() hook, which is a link-time symbol that allows
logging to work from the first instruction.  Some drivers can't do
that because they need an initialization step, but this one works
great.

Signed-off-by: Andy Ross <andyross@google.com>
2023-11-21 15:49:48 +01:00
Andy Ross 080e14f0f4 arch/xtensa: Rename "ALLOCA" ZSR to "A0SAVE"
This register alias was originally introduced to allow A0 to be used
as a scratch register when handling exceptions from MOVSP
instructions. (It replaced some upstream code from Cadence that
hard-coded EXCSAVE1).  Now the MMU code is now using too, and for
exactly the same purpose.

Calling it "ALLOCA" is only confusing.  Rename it to make it clear
what it's doing.

Signed-off-by: Andy Ross <andyross@google.com>
2023-11-21 15:49:48 +01:00
Daniel Leung 5b9605a6a2 xtensa: mmu: implement cached/uncached ptr funcs if !RPO_CACHE
This implements the following functions when
CONFIG_XTENSA_RPO_CACHE is false:

  * arch_xtensa_is_ptr_cached() returns false
  * arch_xtensa_is_ptr_uncached() returns false
  * arch_xtensa_cached_ptr() returns unmodified pointer
  * arch_xtensa_uncached_ptr() returns unmodified pointer

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-21 15:49:48 +01:00
Erwan Gouriou c6bba39f4d dts: stm32wl: Configure LPUART wakeup line
Rather than configuring in serial_wakeup sample, define LPUART1 wakeup
line in wl.dtsi file.

Additionally make few cosmetic changes to nucleo_wl55rj overlay in
serial wakeup sample.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-11-21 14:22:22 +01:00
Erwan Gouriou 6a96ee88b3 samples: boards: stm32: serial_wakeup: Minor changes
Cleanup sample yaml file and code comments.

Enable PM_DEVICE_RUNTIME mode.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-11-21 14:22:22 +01:00
Erwan Gouriou b4fcbc4eb6 samples: boards: stm32: serial_wakeup: Fix nucloe_wb55rg configuration
On STM32WB55 series, wakeup in stop mode is not supported.
Disable this state in order to support this sample.

Add comments to other sections of the configuration.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-11-21 14:22:22 +01:00
Erwan Gouriou e5ab70b724 drivers: uart: stm32: Complete wakeup feature
Serial wakeup feature was only working whe DBG in Stop mode setting
was enabled.
Add required changes to make it functional also when this configuration
isn't set.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-11-21 14:22:22 +01:00
Erwan Gouriou 0d42acadb4 boards: nucleo_wb55rg: Use stm32cubeprogrammer as default runner
When playing with PM related applications, stm32cubeprogrammer is
useful to allow flashing even when SoC is in Stop mode.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-11-21 14:22:22 +01:00
Alexander Leris 7d63942c31 doc: logging: Fix some grammar issues
Fixes some grammar issues in the documentation.

Signed-off-by: Alexander Leris <alexander.leris@gmail.com>
2023-11-21 14:21:35 +01:00
Adolfo E. García 0bda2169a7 boards: xtensa: add heltec_wireless_stick_lite_v3
Adds support for the Wireless Stick Lite (V3),
a development board from HelTec Automation.

Signed-off-by: Adolfo E. García <aegarcia@cerbo.co>
2023-11-21 14:21:20 +01:00
Andrzej Głąbek 7a9ff701d4 drivers: pinctrl_nrf: Fix pin drive configuration
With the introduction of nrfx 3.0.0, values of `nrf_gpio_pin_drive_t`
constants may be defined differently, depending on the SoC family.
Since the nrf-pinctrl.h file is included also from dts files, it is
not possible to use there different definitions of `NRF_GPIO_PIN_*`
values based on Kconfig symbols that indicate given SoC family (as
Kconfig is processed after devicetree) so that those values could
still match `nrf_gpio_pin_drive_t` constants.
To solve this problem, the pinctrl_nrf driver now uses a lookup table
for mapping `NRF_GPIO_PIN_*` indexes to drive configuration values
required by the GPIO HAL.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:12:26 +01:00
Andrzej Głąbek ea1be7f242 drivers: nrf_qspi_nor: Fix and refactor driver initialization
So far the driver first changed the configuration of the flash chip
and after that checked the signature of that chip. This could lead
to improper change of the chip configuration if the actually found
one was different than that specified in devicetree.
This commit reverses the order of these two initialization steps and
also restructures a bit the initialization code.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:09:54 +01:00
Andrzej Głąbek 8c3df0aa9e drivers: nrf_qspi_nor: Refactor deactivation and locking access to QSPI
After integration of nrfx 3.2.0, it is no longer needed to deinitialize
the nrfx_qspi driver to avoid increased power consumption when the QSPI
peripheral is idle. Now it is enough to call `nrfx_qspi_dectivate()`
when a given operation is done. The driver will automatically activate
the QSPI peripheral again when a next operation is requested.

This commit applies the following changes:
- `qspi_device_init` and `qspi_device_uninit` functions are replaced
  by `qspi_acquire` and `qspi_release`, respectively; those handle
  exclusive access to the QSPI peripheral and deactivation of it or
  runtime device power management
- locking is removed from `qspi_send_cmd` as it is the resposibility
  of the caller of that function
- `trans_lock` and `trans_unlock` functions are removed together with
  the related semaphore as they are no longer needed
- checking of input parameters is moved from `qspi_erase` to its
  caller, `qspi_nor_erase`
- `qspi_nor_pm_action` is refactored to properly handle locking of
  the QSPI peripheral; checking of the `xip_enabled` flag is removed
  from that function as now the call to `pm_device_is_busy()` covers
  that (when XIP is enabled, the device is kept indicated as busy)

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:09:54 +01:00
Andrzej Głąbek 4a45581288 drivers: nrf_qspi_nor: Clean up handling of return values
Consistently use `res` for results of calls to nrfx functions
and `rc` for Zephyr return codes, to avoid mixing up those two
and for example calling `qspi_get_zephyr_ret_code()` for a value
that is already a Zephyr return code. Correct also such call in
`qspi_nor_write()`.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:09:54 +01:00
Andrzej Głąbek b172e5133b boards: nrf52840dk_nrf52840: Fix reserved GPIO lines
This is a follow-up to commit 7a83724e0f.

There is no reason to mark that many GPIO lines as reserved on this
board. And doing so causes several existing tests to fail as they
are configured to use some of those now unavailable GPIO lines.

Limit reservation to the lines that actually cannot be used as
GPIOs without changes in the default configuration of the board
or its physical modification (via solder bridges), i.e.:
- XL1 and XL2 (connections for the 32.768 kHz crystal)
- NFC1 and NFC2 (NFC antenna connections)
- RESET
- TXD and RXD (lines used by the console UART)
- QSPI lines: CS, CLK, and DIO0-3

Provide names for all the GPIO lines that are described on the board.
Even for the reserved ones, so that it is clear why they are reserved.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:08:42 +01:00
Andrzej Głąbek 1727bbcc70 drivers: nrf_qspi_nor: Prevent reading status before sending RDPD
After entering the Deep Power-down mode, some flash chips ignore all
commands except from the one that releases the chip from the DP mode
and it is not possible to successfully read their Status Register then.
Since the QSPI peripheral tries to read this register when it is being
activated, it consequently fails to send the actual command that would
release the flash chip from the DP mode if that is to be done right
after QSPI initialization.
Prevent this problem by performing the QSPI activation with all pins
disconnected. This causes that the Status Register value is read as
all zeros and allows the activation to always finish successfully,
and the RDPD command to be properly sent.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 13:08:33 +01:00
Andrzej Głąbek 23cf38934c manifest: Update hal_nordic revision
Pull in a fix in the watchdog driver initialization.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-11-21 11:09:29 +01:00
Jonathan Rico 934a09550d samples: Bluetooth: Make broadcaster_multiple run on other controllers
`CONFIG_BT_CTLR_ADV_DATA_CHAIN` is a Zephyr Controller exclusive.
Use the max length instead to decide if we should add more data.

The motivation for the change is that tests/bsim/bluetooth/host/adv/chain
does not pass with Nordic's Softdevice Controller because of this.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-21 09:56:02 +01:00
Grzegorz Chwierut 32c3173fab tests: mcuboot: Enable mcuboot shell command
Some shell modules were disabled in one of previous commits.
Tests in this folder requires mcuboot shell command.
Enable it with CONFIG_MCUBOOT_SHELL.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-11-21 09:55:44 +01:00
Joakim Andersson 3467a25fff tfm: Change SFN and FP_HARDABI dependency
TF-M only suports floating point in IPC model, not the SFN model.
Since floating point is a basic feature of the architecture and TF-M
has the limitation it makes more sense for the dependency to exist in
TF-M and and limit the TF-M model choice instead of limiting the
option to enable floating point.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-11-21 09:55:24 +01:00
Andreas Sandberg b544855ba5 samples: usb-c: sink: Add support for WeAct STM32G431 core
Add support for the WeAct Studio STM32G431 Core board. Note that this
board does not support USB-C PD in its default configuration. See the
board documentation for the necessary hardware reconfiguration.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
2023-11-21 09:54:02 +01:00
Andreas Sandberg 84d588e013 boards: arm: add support for WeAct STM32G431 Core
Add support for the WeAct Studio STM32G431 Core Board.

Tested with:
 - `samples/basic/blinky`
 - `samples/basic/button`

Flashed samples using dfu-util.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
2023-11-21 09:54:02 +01:00
Marcin Niestroj 81c5727f27 drivers: wifi: airoc: drop default shell and sysworkq stack sizes
Those configuration settings should never be part of driver Kconfig file.
Drop them, since they can easily result in Kconfig symbol circular
dependency error.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-11-21 08:48:40 +00:00
Declan Snyder 4cc80097d3 drivers: wifi: include sockets headers
Some wifi drivers need internal sockets headers
included to build, put this in CMakeLists

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-11-21 08:48:04 +00:00
Jukka Rissanen f70e4c0f68 drivers: modem: Fix include paths
Set the include paths properly and unconditionally to needed
networking directories.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-21 08:48:04 +00:00
Jukka Rissanen bc8b5b3813 mgmt: updatehub: Fix CMakeLists.txt file
Fix the CMakeLists of the updatehub to link with mbedtls.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-21 08:48:04 +00:00