Commit graph

16747 commits

Author SHA1 Message Date
Benedikt Schmidt be8408cbac usb: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt c5b252d8f1 testssuite: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt 24de378986 portability: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt d7f0da1c78 net: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Alberto Escolar Piedras 55c59e041e Bluetooth: Controller: Avoid division by 0 with BT_CTLR_THROUGHPUT
With very fast HCI interfaces (for ex. in the simulated nrf5340)
the tx_rate calculation can do a division by 0
(if to packets are enqueued in the same 32KHz clock period).
Let's avoid it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 10:49:51 +01:00
Dawid Niedzwiecki 0aed42f2ee mgmt: ec_host_cmd: improve handling buffer sizes
Add the len_max rx structure member to indicate maximum number of bytes
possible to receive. It is needed to send information about our protocol
parameters to host.

Also, limit the maximum size of request/responses for backends that uses
buffers provided by the handler.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-10-27 13:26:00 -05:00
Krzysztof Chruściński 9470e3d129 logging: Imply strings stripping if dictionary frontend is used
When UART dictionary frontend is used strings can be removed
from the binary.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00
Krzysztof Chruściński 59abf921c1 logging: Add option to remove strings from binary
Add option to remove string literals which are constant and
never touched by the firmware. It can save significant amount
of RO memory.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00
Benjamin Cabé 0fe6c72d40 debug: coredump: guard selection of ADSP memory window backend
Enabling the core dump via memory window backend only makes sense on
Intel ADSP platform wtih memory windows enabled.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-27 10:53:32 +02:00
Benjamin Cabé 9ff60803c4 debug: coredump: logging backend should always select LOG
The DEBUG_COREDUMP_BACKEND_LOGGING option should automatically
select LOG Kconfig instead of just depending on it.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-27 10:53:32 +02:00
Andries Kruithof 8c1513c837 Bluetooth: shell: make behaviour of iso cmd same as bt cmd
When no parameters are given to the 'bt' command it prints
the help message. The 'iso' command responds with 'missing
subcommand'. This commit updates the behaviour of the iso
command so that it behaves the same as the bt command, i.e.
prints a help message

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-27 10:53:25 +02:00
Jukka Rissanen e44de3e381 net: shell: Join IPv6 mcast group if needed
If user adds IPv6 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Jukka Rissanen 1467d7fa7b net: shell: Join IPv4 mcast group if needed
If user adds IPv4 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Fixes #64389

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Chaitanya Tata a1024f6aeb net: zperf: By default bind to any IP address
Default behaviour should only bind to port independent of IP, this
allows even multicast/broadcast L4 traffic to be received.

User can always specify a specific address to bind using shell or
Kconfig or API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Chaitanya Tata dee1f2deaa net: zperf: Set default IP addresses only if configured
If the user has not configured then we see the error prints for the
defaults always.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Chaitanya Tata 6bd47ffb10 net: zperf: Distinguish between IPv4 and IPv6 address set failures
Using a generic IP for address set failures is confusing, esp. two same
prints (one for v4 and the other for v6), so, use explicit version.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Guennadi Liakhovetski 5064df0500 llext: copy complete string sections while parsing ELF
This has several advantages:

1. we don't need any hard assumptions about symbol length. The
current hard-coded limit of 32 characters might well be not true.
2. replaces a lot of code for reading those names with a single
call to a 1-line function to calculate string location.
3. eliminates the need to allocate buffers for exported symbol names
by replacing them with a simple pointer assignment.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-10-27 10:51:49 +02:00
Guennadi Liakhovetski 23472509d3 llext: refactor section copying
Instead of first allocating all sections and then copying then,
create a helper function to allocate and copy a single section and
call it for all appropriate sections. We need to call this function
from another location when copying string sections.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-10-27 10:51:49 +02:00
Krzysztof Chruściński a68cdb0558 logging: Optimize handling of simple and common log messages
Some compilers (e.g. riscv32) does not handle well complex macros
for logging. Generated code is bigger than expected (e.g. riscv32
code is almost twice bigger than cortex-m code). Use of logging can
lead to unexpected code increase.

To handle that an analysis of the zephyr code base was performed and
it shown that 75-80% of logs are simple strings with 0 arguments
(~45%), one 32 bit argument (~26%) or two 32 bit arguments (~6%).
Given that a set of dedicated macro were created which are applied
to those 3 cases which on 32 bit platform create very simple log
messages without padding or alignment needed.

Such dedicated macros save up to 40% of code (riscv32) and also
executes 30% faster (arm cortex and riscv32).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Krzysztof Chruściński 900f9c3b24 logging: log_frontend: Add optional API for common messages
Extend frontend API with optional set of functions which can
be used when simplified log message handling is enabled. If this
mode is enabled then there are dedicated macros for processing the
most common messages (string + 0-2 word arguments). Using this API
can speed up the processing of messages that are the most common.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Krzysztof Chruściński 1a0e8d6f9e logging: log_msg: Add functions for handling simple log messages
In preparation for new feature which optimizes handling of
the most common log messages (0-2 32 bit word arguments) add
functions dedicated for that purpose.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Jeppe Odgaard 530a3092fe debug: coredump: flash backend: print error if write fails
The loop in `coredump_flash_backend_buffer_output` might fail without
any alerts. This could be due to e.g. a too small coredump-partion.

Add a LOG_ERR if an error occurs.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-10-26 07:57:12 -04:00
Tomasz Moń 08bd1c5ec2 usb: device: Fix ZLP write race condition
ZLP packet has to be read and acknowledged by host just like any other
DATA packet. Do not end transfer until the host actually acknowledged
the trailing ZLP. This fixes the race condition between host and Zephyr
application where the next transfer could be lost if host did not issue
IN token (that would read read ZLP) before the application tried to
start new transfer.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-10-26 13:52:31 +02:00
Emil Gydesen 6aea1864c1 Bluetooth: ISO: Minor fixes for ISO shell
If CONFIG_BT_ISO_TEST_PARAMS=y then the CIG and BIG
create params was not properly initialized.

Modified the TX for BIS and CIS to be more similar

Added a timeout on the buffer to avoid any potentional
deadlocks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-26 09:48:54 +02:00
Jukka Rissanen 83c875adab hostap: Move the relevant config options away from hostap
Moving the Zephyr specific config options from
modules/hostap/Kconfig to corresponding Kconfig where the
option is specified.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-26 09:48:47 +02:00
Peter Mitsis 467ce89458 cmsis: resolve undefined reference to k_calloc()
When no heap has been configured, osMessageQueueNew() will no
longer include a call to k_calloc() (which needs the heap).
In such a configuration, if osMessageQueueNew() indicates that
the buffer must be allocated, it will fail and return NULL.

Fixes #61196

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-25 19:54:13 +02:00
Seppo Takalo cf513451eb net: lwm2m: Keep user_data between blocks
CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.

Fixes #64290

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-25 17:36:30 +02:00
Emil Gydesen 34058146a5 Bluetooth: BAP: Shell: Remove unused variable stream_frame_duration_us
The variable was unsused and caused compiler warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-25 17:36:22 +02:00
Anders Storrø d4037ce6a1 Bluetooth: Mesh: Correct pack of net idx hb_status
Ensures correct packing of net idx in Heartbeat Publication Status
messages on the Configuration Server.

Reference to net idx packing format: MshPRTv1.1 section 4.3.1.1

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø 05774c5d76 Bluetooth: Mesh: Fix unpacking of hb_pub status
Fixes incorrect unpacking of Heartbeat Publication status
messages on the Configuration client.

Reference to packing format: MshPRTv1.1 section 4.3.2.63

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø 46d9c97991 Bluetooth: Mesh: HB pub status for unassigned addr
Fixes issue where Heartbeat Publication Status message sends
garbage data when destination field is set to the unassigned address.

MshPRTv1.1, section 4.4.1.2.15:
"When the Destination field is set to the unassigned address, the values
of the CountLog, PeriodLog, TTL, and Features fields shall be set to
0x00 and NetKeyIndex field shall be set to 0x0000."

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø c51bb9c13b Bluetooth: Mesh: Update spec ref 1.0.1->1.1
Updates Bluetooth mesh specification references:

- Change "Profile" to "Protocol" since the main specification has
changed its name.
- Update/align formating of specification references. This will
make it easier to find spec references in the future.
- Change some section references to point to the correct section of the
newest version of the specification (v1.1).

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:14 +02:00
romain pelletant efebb1841f modem_chat: fix hard fault on script stop
Fix fault on modem_cellular disconnection/reconnection
Issue #64291

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-10-25 10:05:45 +02:00
Yong Cong Sin 0e2f5c2dbb shell: print name and prompt when listing backends
The shell name defined with `SHELL_DEFINE` is implicitly
guaranteed to be unique while it is possible that more than one
shell backends can have the same prompt.

Print the name of the shell backend alongside with its prompt
to differentiate between the backends.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Yong Cong Sin a068288091 shell: add new APIs to get the backend instances
Added some new APIs to get the backend instances more easily,
so that dev does not need to rely on `shell_backend_*_get_ptr`,
which looks more like a hack to access a local variable.

These APIs are basically copied from the log backend
implementation.

Added testcase for the APIs.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Yong Cong Sin dd154406ba shell: make the backend thread name variable generic
Rename the shell backend `thread_name` variable to just `name`,
to be used for other things not specific to thread later.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Piotr Kosycarz bc8b7dd6dd testsuite: coverage: allow gcov data dump directly on console
When there is no buffer for gcov hex data,
dump them directly to console.
This saves RAM which can be used to hold more gcov data.

Reduce number of gcov hex data send by console -
do not send space between every two digits.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2023-10-25 09:57:15 +02:00
Bjarki Arge Andreasen b4f3150592 modem: cmux: Optimize log message to save ROM
This commit reuses the string "Unknown %s frame type" for two
log messages, as suggested by ycsin.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen ee44357cfb modem: modem_cellular: Reset receive state on attach
This commit resets the state of the CMUX receive state
machine when the CMUX instance is attached to a pipe.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen b495fda6a1 modem: modem_cmux: Improve logging
This commit adds logging for CMUX frames and commands and
their data, for both transmit and receive. It also removes
the superseded LOG_DBG() lines like "Received frame".

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen 0f38136431 modem: modem_cmux: Clear DLCI pipes on open
This commit resets the receive ring buffer for each DLCI
pipe when they are opened. They may have old data stored
from last time they where opened.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen 92ad351e2a modem: modem_cmux: Use k_event_test instead of K_NO_WAIT
This commit replaces the k_event_wait calls using K_NO_WAIT
with k_event_test.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen 79e6c8411f modem: modem_cmux: Reset CMUX events on release
This commit resets the CMUX events to match the
initial value of disconnected.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen 7fe491c050 modem: modem_cmux: Make async connect/disconnect stateful
This commit adds a check to the async connect and disconnect
functions to validate the CMUX is not already connected
or disconnected respectively. This was already part of the
sync connect and disconnect functions, so the sync functions
now simply wrap the async functions to avoid duplicate code.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Vinayak Kariappa Chettimada f64d123a3d Bluetooth: Controller: Fix missing ext adv terminate event
Fix missing Extended Advertising terminate event and
advertising scheduling not being stopped.

Under race conditions, auxiliary event is aborted without
the generation  of done extra event which is suppose to
stop the scheduling when max events count is used.

The fix now generates the done extra event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Vinayak Kariappa Chettimada 05c85ddbcf Bluetooth: Controller: Fix periodic advertising sync window
Fix periodic advertising sync window calculation to include
the scheduling resolution margin, i.e. be double as with
the event jitter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Jukka Rissanen 8a58104396 net: shell: Add net-sockets command
The new "net sockets" command will utilize the object core
support to track and show information about BSD sockets that
are created in the system. This command is able to show info
for all network sockets (native, offloaded etc) in the system.

Example of the output of the new command:

uart:~$ net sockets
 Creator  Name       Flags  FD   Lifetime (ms) Sent  Received

    main  af_inet46  6ST    0    3260          819   498
    main  af_inet46  4ST    1    2110          469   142
    main  af_inet46  6DU    2    2110          9941  9941
    main  af_inet46  4DU    3    2110          1375  621

4 active sockets found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Jukka Rissanen 7d9f2ad2ca net: sockets: Add object core support to sockets
Use the generic object core support to track network sockets
and their statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Jukka Rissanen 5bf18e39ad net: sockets: Set writefds in case of error in select()
The writefds is typically set if there is an error while
waiting for example the connect() to finish. So check if
the user supplied the writefds and update it accordingly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen ec4973dd15 net: tcp: Set errno properly if connecting to non listening port
If we try to connect to a port which no socket is listening to,
we will get a packet with "ACK | RST" flags set. In this case
the errno should be ECONNREFUSED instead of ETIMEDOUT like we
used to return earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00