Reduce `k_spin_unlock` calls in `k_obj_core_stats_xxx` functions by
consolidating error handling into an `if-else if-else` structure and
using a single return variable `rv`.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
According to the riscv's `arch.h`:
+------------+ <- thread.arch.priv_stack_start
| Guard | } Z_RISCV_STACK_GUARD_SIZE
+------------+
| Priv Stack | } CONFIG_PRIVILEGED_STACK_SIZE
+------------+ <- thread.arch.priv_stack_start +
CONFIG_PRIVILEGED_STACK_SIZE +
Z_RISCV_STACK_GUARD_SIZE
The start of the privilege stack should be:
`thread.arch.priv_stack_start + Z_RISCV_STACK_GUARD_SIZE`
Instead of
`thread.arch.priv_stack_start - CONFIG_PRIVILEGED_STACK_SIZE`
For the `end`, use the same equation of `top_of_priv_stack` in
the `arch_user_mode_enter()`
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
When using SPI-NOR SFDP autodeteection, the flash size printed to
the log is rounded to 1 MiByte. If flash is smaller than 1 MiByte
it is printed as 0 MiByte.
With this patch smaller flash sizes are printed in kiByte, for instance
512 kiByte is printed correctly.
Signed-off-by: Stefan Petersen <spe@ciellt.se>
The broadcast assistant will only be able to send
BT_BAP_BASS_PA_REQ_SYNC_PAST if
CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER is enabled.
Similarly the scan delegator will only set
past_supported = true if
CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER is enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The driver right now only allows inverting the input value, which can be
useful for differential channels but is quite confusing for single ended
ones. Implement a simple output inversion flag instead to make up for
that.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
WIFI_REASON_DISCONN_UNSPECIFIED is 1, when disconnect reason is 0,
wpas_to_wifi_mgmt_disconn_status return the
WIFI_REASON_DISCONN_UNSPECIFIED and print error log "Disconnection
request failed (1)"
Signed-off-by: Gaofeng Zhang <gaofeng.zhang@nxp.com>
Refactors teh BIS bitfield values used for ISO
and BAP.
Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.
Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.
This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current option used as an example, --recover, is actually a separate
option in the runner itself. Instead use --clockspeed as an example,
which is applicable to all nrfjprog commands.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Allow for users to provide a --qspiini parameter that is passed directly to
the nrfjprog executable but only in the --program operation. This is
required since e073210ec2 enabled the
-O/--tool-opt for all operations, but --qspiini is only allowed combined
with --program.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Initialise flashdisk devices in `POST_KERNEL` instead of `APPLICATION`.
This aligns with the other disk drivers, which are all `POST_KERNEL`,
and causes no problems as `disk_access_register` is a purely software
action and does not perform any operations on the underlying device.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use `depends on DT_HAS_* default y` instead of `default y if DT_HAS_*`
as the driver depends on devicetree instance.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Disable the flash disk driver in the RAM driver test to prevent the
test using the wrong disk in the tests.
Signed-off-by: Jordan Yates <jordan@embeint.com>
When --erase was specified, esp32 runner was autodetecting serial port to
be used, regardless of --esp-device argument.
Append '--port SERIAL_DEVICE' parameter earlier, so that erase command
invocation uses explicitly specified serial device.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
The Softdevice Controller now sends the disconnect event only after
receiving all Host Num Completes for the packets it sent to the host.
This is done for security reasons.
In our current reassembly logic, it does not really matter when we
withhold the num complete.
Before this patch, it's the first fragment that is withheld, and after
the patch it will be the last fragment that is withheld until the host
is done processing.
The flow control properties are maintained, just in a different way.
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The functionality is moved in preparation of the next commit which will
re-use this function from somewhere else.
Also add (default-on) asserts that we are able to allocate and send the
command. If that is not the case, we will leak buffers from the PoV of
the controller, leading to a stall in data transfer.
Depending on the error, we could probably recover using a disconnection.
For now, do the safe thing and stop the whole stack.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The spec only guarantees the connection complete event parameters
are valid if the status is BT_HCI_ERR_SUCCESS. When the status is
not BT_HCI_ERR_SUCCESS, the host shall ignore the other parameters.
See Vol 4, Part E, 4.5 Command error handling:
"""
If an error occurs for a command for which an HCI_Command_Complete event
is returned, the Return Parameters field may only contain some of the
return parameters specified for the command.
...
The above also applies to commands that have associated command specific
completion events with a Status parameter in their completion event, with
the exceptions shown in Table 4.1, Event Valid parameters
...
Event | Valid parameters
------------------------------------------------------------
LE_Connection_Complete | none
LE_Enhanced_Connection_Complete | none
"""
Refactor `le_legacy_conn_complete`, `le_enh_conn_complete_v2` and
`le_enh_conn_complete` to check and handle the status before handling
any other parameters.
An issue was seen where SDC returned event with status
`BT_HCI_ERR_UNKNOWN_CONN_ID`, but because adv_handle and sync_handle
were not invalid the event was not handled.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Sometimes, performing a rstact which will reset all devices during init
on the bus may not be ideal. Add a KConfig to easily turn off.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
The default base timeout for pytest is statically set by
the TwisterHarnessConfig class to be 60 seconds. However,
sometimes it takes longer than 60s before the app starts
to run, especially on emulator/simulator where it takes
quite some time to start. So pass the test timeout as
the base timeout via pytest command line argument.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When ubx_m10_ubx_cfg_rst is returning something negative there is a loop
in the code which in turn can easily turn into an endless loop if the
function is never returning something positive or zero.
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
It's not allowed to sleep during initialization of driver as called by
bg_thread_main --> z_sys_init_run_level(INIT_LEVEL_POST_KERNEL)
--> do_device_init --> ubx_m10_init
There is no thread_base.timeout struct setup so far.
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
ubx_m10_init_pipe is calling modem_backend_uart_init which in turn is
memsetting the backend data structure and thus also overwrites the work
queue function pointer in it.
Remove call to ubx_m10_init_pipe as data structures are already set up.
Tested with u-blox NEO M9N.
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
The motion event handler is currently setup to always retrigger until
there's no more motion data from the sensor. Change that to only
retrigger if the motion pin is asserted when the handler has finished
running, this saves a bunch of unnecessary spi transactions.
Ideally this driver would use a level interrupt, but I'd rather avoid
that as that is unsupported by many gpio controllers.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Prior to the fixes in the previous commits, combining a build
for native_sim with
CONFIG_CPP=y
CONFIG_POSIX_API=y
CONFIG_STD_CPP20=y
CONFIG_REQUIRES_FULL_LIBCPP=y
would fail.
It succeeds now.
This change adds a testcase to monitor that scenario in CI.
Note: this was partially necessary because the deprecation of
CONFIG_NET_SOCKETS_POSIX_NAMES is not yet complete, so there
is a dependency cycle, and also because <sys/types.h> was
pulling in the host <sys/types.h> instead of Zephyr's or one
of the embedded OSes we support.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
A number of types such as uid_t, gitd_t, etc, were defined in
sys/stat.h to workaround compatibility issues many years ago.
Since posix_types.h is slated to become equivalent to
sys/types.h in terms of standard headers, move these types
to where they belong.
For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/\
basedefs/sys_types.h.html
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
A corner case involving C++, posix, networking, and native_sim
was causing problems.
Even though C and C++ builds should include zephyr/posix/.. in
the default search path with `CONFIG_POSIX_API=y`, for some
reason, the native compiler pulls in /usr/include first anyway.
The stat.h header pulled in <sys/types.h> (which is normally
fine) but due to the native build, it was pulling in
/usr/include/sys/types.h, from the host toolchain.
Explicitly include <zephyr/posix/posix_types.h> instead of
<sys/types.h> from stat.h, and continue using the workarounds
for native builds (explicitly including zephyr/posix/arpa/net.h
from net/sockets.h .
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Several refactors and improvements for `net_bytes_from_str` as follows:
- Replaced manual hex digit checks with `isxdigit()`.
- Changed variable `i` from unsigned int to size_t for consistency with
the `strlen()` return type.
- Added `src_len` to store the result of `strlen(src)` to avoid
multiple calls to `strlen` in the `for-loop`.
- Ensured casting to `unsigned char` before passing to `isxdigit()` to
prevent undefined behavior.
- Explicitly cast the result of `strtol()` to `uint8_t` to match
the buffer type.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Device drivers should not be calling `pm_device_runtime_enable` on
themselves, it should be left up to the application. If automatic
enablement is desired, `zephyr,pm-device-runtime-auto` exists as a
devicetree property.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The `pm_device_runtime_get` and `pm_device_runtime_put` functions work
correctly regardless of whether `PM_DEVICE_RUNTIME` is enabled or not.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The `count` semaphore was being used as an atomic counter, so replace
it with an atomic variable, which is a simpler solution and enables
removing the conditionals with `PM_DEVICE_RUNTIME`.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The register offset definition of the I/O port Data Base Address
register (0x60, 0x61) and Command/Status Base Address register
(0x62, 0x63) are reversed. This commit fixes it to avoid confusion.
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
NEORV32 doesn't provide platform and model name in it's dts file.
This makes hard for some tools to determine with what board they're
working with. Fixed it by adding model and platform name in it's dts file.
Signed-off-by: Sebastian Kwaśniak <skwasniak@internships.antmicro.com>
Signed-off-by: Mateusz Hołenko <mholenko@antmicro.com>
Was broken after BT_LE_ADV_OPT_USE_NAME and
BT_LE_ADV_OPT_FORCE_NAME_IN_AD were deprecated.
The periodic_adv_rsp sample
looks for the string "PAwR sync sample" and connects based on that.
So, the periodic_sync_rsp sample needs to advertise this string.
Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
Commit 3dbbb73 accidentally changed the MIPI_DBI spi interface from
spi4 to spi2 for this board during conversion to use the MIPI_DBI wrapper.
This does not work, and this change reverts it back to spi4.
Tested on actual boards (bl5340, bl5340pa).
Before this change LVGL demo displays nothing, after this change it works
fine again.
Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
Initialize TCM and SRAM contents only after a destructive reset (e.g.
PoR reset). SRAM retains content during functional reset through a
hardware mechanism, therefore accesses do not cause content
corruption errors.
Fixes#75912
Signed-off-by: Manuel Argüelles <marguelles.dev@gmail.com>
The current implementation is such that if two or more events are
generated in quick succession, only one is handled. This would
have happened as follows.
At the beginning of the ISR, the contents of INTPEND are read.
Then, the ISR unconditionally clears all events that are set.
When two (or more) events are generated in rapid succession,
it may happen that by the time we enter the ISR, INTPEND is set
only for one event, but while we process the ISR, EVENTS_TRIGGERED
will be set for more than just that one event (more events are
generated).
By unconditionally clearing all events, we can potentially lose
all events that are generated during ISR processing.
This patch changes the ISR so that it only clears those events
that have a corresponding bit set in INTPEND at the time it is read.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
- Use references whenever possible instead of literals (e.g. `@c`)
- Remove incorrect usages of `@see`
- Fix incorrect usage of INTERNAL_HIDDEN blocks
- Detail Kconfig-dependent options with `@kconfig{}`
- Other minor enhancements
Ref. https://www.doxygen.nl/manual/autolink.html
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>