Compare commits

...

93 Commits

Author SHA1 Message Date
Fin Maaß
0848eb2f96 mgmt: hawkbit: remove hb_context.status_buffer_size
remove hb_context.status_buffer_size and replace it with
sizeof(hb_context.status_buffer), because hb_context.status_buffer_size
is never set.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
(cherry picked from commit 1bea938c9f)
2024-03-25 13:24:31 -04:00
Flavio Ceolin
76b03fe477 fs: fuse: Avoid possible buffer overflow
Checks path's size before copying it to local variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 3267bdc4b7)
2024-02-27 09:50:02 -08:00
Vinayak Kariappa Chettimada
4826bc1529 tests: bsim: Bluetooth: Mesh: Adjust timeout for Adv Extensions use
Adjust mesh test timing and timeout value for Advertising
Extensions use/fix in Zephyr Controller. The scanning in
Zephyr Controller is delayed when using extended scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit d1e4c17e6d)
2024-01-29 10:40:22 -08:00
Vinayak Kariappa Chettimada
291cef7f4e Bluetooth: Controller: Fix extended scanning assertion
Fix extended scanning assertion after long duration.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit ac39ad7249)
2024-01-29 10:40:22 -08:00
Gustavo Silva
0e631b2b93 drivers: pwm: pwm_mcux: fix for coverity 321142
Fix `PWM_SetupPwm` function being called with `numOfChnls`
argument equal to 2, when in fact only one channel is being set up.

Also add 'U' suffix to `pwmFreq_Hz` unsigned integer argument in
the function call.

Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
(cherry picked from commit 4eedd45c85)
2024-01-22 06:23:24 -08:00
Jukka Rissanen
339194de6e tests: net: ipv6: Adjust the source address of test pkt
We would drop the received packet if the source address is our
address so tweak the test and make source address different.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 155e2149f2)
2024-01-17 11:52:19 -08:00
Jukka Rissanen
0c70910146 net: ipv6: Check that received src address is not mine
Drop received packet if the source address is the same as
the device address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 8d3d48e057)
2024-01-17 11:52:19 -08:00
Jukka Rissanen
7215f3612f net: ipv4: Drop packet if source address is my address
If we receive a packet where the source address is our own
address, then we should drop it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 19392a6d2b)
2024-01-09 13:11:18 -08:00
Jukka Rissanen
955db4508d net: ipv4: Check localhost for incoming packet
If we receive a packet from non localhost interface, then
drop it if either source or destination address is a localhost
address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 6d41e68352)
2024-01-09 13:11:18 -08:00
Jamie McCrae
5e05c01578 sysbuild: kconfig: Unset shield config value variable
Fixes an issue with shields that have Kconfig file fragments when
being used with sysbuild, they would be loaded into sysbuild
itself which would then fail because it does not have the Kconfig
tree that zephyr applications have

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 49f9d8e19c)
2024-01-09 13:10:36 -08:00
Henrik Brix Andersen
d252cc0d05 drivers: spi: mcux: lpspi: fix error on first configure on MKE1xF
Fix error writing to the CR register on the first call to SPI configure on
NXP MKE1xF. On the first call, the module clock is not enabled and writing
to the CR register will fail.

Fixes: #66036

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 7ddc0f713f)
2023-12-20 06:17:31 -08:00
Jamie McCrae
b194315b40 cmake: modules: dts: Fix board revision 0 overlay
Fixes an issue whereby a board revision is 0 and the overlay file
exists but would not be included

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 46889819e6)
2023-12-12 07:35:03 -08:00
Henrik Brix Andersen
38e55542c9 drivers: can: mcan: use __nocache_noinit for MRAM data variables
Use __nocache_noinit for the Bosch M_CAN MRAM data variables on SoCs
without dedicated MRAM.

Fixes: #64691

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 58e1963c6b)
2023-11-21 15:02:34 -05:00
Henrik Brix Andersen
45203b5c20 linker: allow tagging variables with __nocache_noinit
Allow tagging variables with __nocach_noinit.

With CONFIG_NOCACHE_MEMORY=y, this will resolve to __nocache, which implies
__noinit. With CONFIG_NOCACHE_MEMORY=n, this simply resolves to __noinit.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit afe1ca6847)
2023-11-21 15:02:34 -05:00
Henrik Brix Andersen
9242edc16b modules: canopennode: use zephyr/dsp/types.h for float32_t/float64_t
Include the zephyr/dsp/types.h header for float32_t/float64_t type
definitions to avoid conflicts with other subsystems including this header.

Add compile-time asserts to ensure the typedefs meet the requirements of
the CANopenNode module.

Fixes: #63896

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit c9da68290a)
2023-11-21 15:02:13 -05:00
Vinayak Kariappa Chettimada
b3fd79ab76 Bluetooth: Controller: Fix some compiler instruction re-ordering
Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f2069530ee)
2023-11-21 15:01:37 -05:00
Flavio Ceolin
45ca28861c ipm: cavs: Fix possible buffer overflow
A buffer overflow happens in send() when size is negative because
it is promoted to signed when used in memcpy.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit eeea26d206)
2023-10-31 03:03:46 -07:00
Flavio Ceolin
2c33f9553a ipm: imx: Initialize variable before using it
Since the driver is passing the whole buffer, let's zero it to avoid
pass garbage in case of size != buffer's size.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 98857c267d)
2023-10-31 03:03:46 -07:00
Flavio Ceolin
01714076df ipm: imx: Fix possible buffer overflow
It is possible to happen a buffer overflow in ipm_send due the lack
of a checking for negative value.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 0a12a05e63)
2023-10-31 03:03:46 -07:00
Flavio Ceolin
cd90d5ab23 ipm: mcux: Initialize variable before using it
Since the driver is passing the whole buffer, let's zero it to avoid
pass garbage in case of size != buffer's size.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 4ff32d9290)
2023-10-31 03:03:46 -07:00
Flavio Ceolin
d1c7254934 ipm: mcux: Fix possible buffer overflow
It is possible to happen a buffer overflow in ipm_send callback
due a wrong comparison between signed/unsigned types.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 6654d18596)
2023-10-31 03:03:46 -07:00
Jamie McCrae
42689f5aa2 mgmt: mcumgr: transport: Fix UDP user data buffer overflow
Fixes a buffer overflow issue if UDP is enabled for IPv4 only
but IPv6 networking is enabled

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit e3c06c5d8f)
2023-10-31 03:03:05 -07:00
Christopher Friedt
9a6e87a1c0 shell: date_service: conditionally include posix/time.h
When compiling for ARCH_POSIX, include `time.h` rather than
`posix/time.h`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit e6c6d82a00)
2023-10-27 00:37:20 -04:00
Christopher Friedt
81cae389b1 drivers: fpga: ice40: remove unnecessary include
The `<zephyr/posix/time.h>` header was unused in `fpga_ice40.c`
so remove it.

This fixes an error about `pthread_attr_t` not being defined.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 64e6c90fc0)
2023-10-27 00:37:20 -04:00
Christopher Friedt
e587ebc3ee posix: signal: type corrections for sigval, sigevent, notify attr
* `struct sigevent` is not type-defined
* `union sigval` is not type-defined
* `struct sigevent` must include `sigev_notify_attributes`

For more information, see https://bit.ly/3YfnELI

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 9f1e4fa86c)
2023-10-27 00:37:20 -04:00
Robert Lubos
87d5e0d6cf net: iface: Allow NULL pointer to be handled in net_if_is_ip_offloaded
In case native interface is used with NET_OFFLOAD enabled, the
net_if_is_ip_offloaded() could lead to a crash, if called on unbound
net_context (i.e. with no iface assigned to net_context yet).

As since commit 40d2240226 the net_context
allocated on offloaded interface is always assigned with the iface
pointer during its creation, it can be safely assumed that in case of
NULL pointer is provided we deal with a native interface. Therefore
instead of asserting on the iface pointer, indicate that the interface
is native when NULL pointer is provided.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 32bd3aa781)
2023-10-26 11:27:38 -04:00
Henrik Brix Andersen
156bf29c19 drivers: can: be consistent in filter_id checks when removing rx filters
Change the CAN controller driver implementations for the
can_remove_rx_filter() API call to be consistent in their validation of the
supplied filter_id.

Fixes: #64398

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 6c5400d2e1)
2023-10-26 11:27:07 -04:00
Christopher Friedt
520d381585 logging: log_core: correct timeout of -1 ms to K_FOREVER
Many releases ago, specifying to block indefinitely in the log
processing thread would do just that.

However, a subtle bug was introduced  such that specifying -1
for `CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS` would have the
exact opposite effect than what was intended.

As per Kconfig, a value of -1 should translate to a timeout of
`K_FOREVER`. However, conversion via `K_MSEC(-1)` results in
a `k_timeout_t` that is equal to `K_NO_WAIT` rather than the
intent which is `K_FOREVER`.

Add a dedicated check to to ensure that a value of -1 is
correctly interpreted as `K_FOREVER` in `log_core.c`.

For reference, the blocking feature was described in #15196,
added in #16194, and it would appear that the regression
happened in c5f2cdef09.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 137097f5c3)
2023-10-19 10:08:54 -07:00
Jukka Rissanen
9f44a5b76a tests: net: sockets: mgmt: Add tests for too long message
Add test that checks we get proper return code if trying
to copy too much data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 5c6dca3c52)
2023-10-12 11:12:58 -07:00
Jukka Rissanen
6b926bba95 net: socket: mgmt: Check buf size in recvfrom()
Return EMSGSIZE if trying to copy too much data into
user supplied buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 0a16d5c7c3)
2023-10-12 11:12:58 -07:00
Abram Early
0ec96750b6 drivers: can: mcan: Move RF0L and RF1L to line 1
The code is designed to handle RF0L and RF1L in
line 1, but they were being sent to line 0. Becuase
they weren't handled, the interrupts would never
be handled which locked up the chip.

Signed-off-by: Abram Early <abram.early@gmail.com>
(cherry picked from commit 6e789e7492)
2023-10-11 05:32:43 -07:00
Henrik Brix Andersen
daca8f8399 drivers: can: sja1000: do not attempt to sleep in IRQ context
The can_sja1000_handle_error_warning_irq() function should only attempt to
start bus-off recovery, but not wait for the result.

Fixes: #63712

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit fc078f9d02)
2023-10-11 05:32:27 -07:00
Alberto Escolar Piedras
a287c88326 POSIX arch: Fix literal floating comparison in 32bit targets
When building the 32bit native board targets variants
for x86(-64) hosts, gcc will promote float literals to double
(See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92875 )

This can result in unexpected comparison differences.

This is due to the compiler using the 8087 float mode by
default.
Instead let's tell the compiler to use the SSE float path,
which is the default for 64 bit x86-64 builds.

The assumption that any x86 host used for development
will have SSE support should be safe enough.

For more background see
https://github.com/zephyrproject-rtos/zephyr/issues/61345

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
(cherry picked from commit d4e48d5feb)
2023-10-05 03:33:18 -07:00
Christopher Friedt
2d3e58bb3e posix: pthread: do not assert in pthread_exit() on k_thread
If `pthread_exit()` is called from a `k_thread`, then we would
previously trigger an assertion. The problem with that, is that
is POSIX is acting as a compatibility layer.

Given that it is a reasonable expectation to have the calling
thread exit or abort when calling `pthread_exit()`, lets do just
that.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 1731010869)
2023-10-02 16:39:38 -04:00
Henrik Brix Andersen
97a952610d drivers: can: mcux: flexcan: fix initial of CAN-FD timing when using TQs
Fix the assignment of initial CAN bus timing parameters for the CAN-FD data
phase.

Fixes: #62979

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit c1ad82e5fb)
2023-10-02 09:13:15 -07:00
Sylvio Alves
3e75c22183 soc: espressif: provide VMA to rodata and text by default
Flash segments require VMA to proper work. Executing from LMA
is not possible. Current implementation did not take into account
runtime iterable rom sections that any application could implement.
In the above cenario and as reported in the issue below, ESP32 won't run
when those ROM sections are created in application level.

This change make sure all flash segments are properly mapped
accordingly.

Fixes #61834

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
(cherry picked from commit f5fa4b3bcd)
2023-09-19 11:27:37 -07:00
Fabio Baltieri
2dfd91b0e8 can: rework the table lookup code in can_dlc_to_bytes
Rework the can_dlc_to_bytes table lookup code in a way that allow the
compiler to guess the resulting output and somehow fix the build
warning:

zephyr/drivers/can/can_nxp_s32_canxl.c:757:9: warning:
'__builtin___memcpy_chk' forming offset [16, 71] is out of the bounds
[0, 16] of object 'frame' with type 'struct can_frame' [-Warray-bounds]
 757 | memcpy(frame->data, msg_data.data, can_dlc_to_bytes(frame->dlc));

where the compiler detects that frame->data is 8 bytes long but
can_dlc_to_bytes could return more than that.

Can be reproduced with:

west build -p -b s32z270dc2_rtu1_r52 \
	-T samples/net/sockets/can/sample.net.sockets.can.one_socket

Suggested-by: Martin Jäger <martin@libre.solar>
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
(cherry picked from commit 4856fd4cb6)
2023-09-15 06:41:55 -07:00
Max van Kessel
eac490eb69 drivers: can: stm32: fix typo in phy dt assignment
To attach the correct phy, the instance must be givin instead of the id.

Signed-off-by: Max van Kessel <max_van_kessel@msn.com>
(cherry picked from commit efaf4a6b34)
2023-09-05 06:08:31 -07:00
Flavio Ceolin
b68afbdcd4 espi: mchp_xec_v2: Fix possible buffer overflow
Check the packet lenght in flash_write operation beforeSigned-off-by
copying it to an internal buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit c5bb002f77)
2023-08-29 09:22:20 -04:00
Flavio Ceolin
3c089f70c6 espi: mchp_xec: Fix possible buffer overflow
Check the packet lenght in flash_write operation before
copying it to an internal buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 4102179f3f)
2023-08-29 09:22:20 -04:00
Grant Ramsay
8d5fc007e4 kernel: sched: Disable FPU context when thread ends
When `CONFIG_FPU_SHARING` is enabled each `k_thread` struct has a saved
floating point context (`saved_fp_context`). During a context switch, the
current FPU owner's (`_current_cpu->arch.fpu_owner`) registers are saved
to its `saved_fp_context`, and the destination threads FPU registers are
loaded from its `saved_fp_context`.

When a thread ends, it does not release ownership of the FPU
(`_current_cpu->arch.fpu_owner`). This is problematic if the `k_thread`
struct was allocated on the stack. The next context switch will save the
FPU registers into `k_thread -> saved_fp_context` which may now be out of
scope. This will likely (but not always) result in a crash.

Adding `arch_float_disable(thread);` when a thread ends disables
preservation of floating point context information, fixing this issue

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 45701e696a)
2023-08-29 09:20:47 -04:00
Benjamin Cabé
8a703c60be lib: os: doc: Hashmap documentation fixes
Add missing documentation for SYS_HASHMAP_DEFAULT_ALLOCATOR and
sys_hashmap struct.
Fixed minor type in SYS_HASHMAP_DEFINE_STATIC_ADVANCED doc.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit dde023fb8a)
2023-08-29 09:18:11 -04:00
Benjamin Cabé
60f3cd85b4 lib: os: doc: Cleanup doxygen groups
Cleaned up doxygen group for hash_map and hash_map_api
Adding brief/desc to the main group instead of the file to actually
surface them in the documentation

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit ea1e6b59f5)
2023-08-29 09:18:11 -04:00
Benjamin Cabé
1f3dbc41ab lib: os: doc: Show hash implementations in documentation
Added a Doxygen group for Hash implementations

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit 1539c1c094)
2023-08-29 09:18:11 -04:00
Benjamin Cabé
e30da2bd70 lib: os: doc: Show hash functions in documentation
Show hash functions under Hashmap doc entry.
Also fixed minor issue with '.' character ending @brief early.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit b5cf5d1f24)
2023-08-29 09:18:11 -04:00
Grant Ramsay
4852b8134f drivers: can: mcan: fix format string warning
A warning was being produced on compilers where size_t is an unsigned long

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 12c568f43a)
2023-08-29 09:17:07 -04:00
Grant Ramsay
7e02104799 drivers: can: mcan: tidy TX complete semaphore usage
"callback != NULL" is used to determine if the callback is in use.
The TX complete semaphone should only be given back after setting the
callback to NULL.

This would likely only be a race condition if the ISR is processed on a
different core to the TX call.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 12d6e268cd)
2023-08-29 09:17:07 -04:00
Grant Ramsay
535fba08cf drivers: can: mcan: manually track available TX buffers
The MCAN driver operates in TX queue mode (TXBC.TFQM = 1). In this mode
TXFQS.TFQPI returns the first available buffer (usually buffer zero).

Hardware is free to re-use a buffer as soon as TX completes, it does not
have to wait for the matching TX event to be processed.

If a TX completes and that TX buffer is re-used before processing the TX
event, two TX events for the same buffer occur. The first event calls the
second events TX callback, and the second event results in a NULL pointer
exception.

In a "normal" configuration, the TX event ISR will always preempt the
queuing of a TX frame to the same TX buffer.
However, this issue could occur if:
 * Sending a message with ISRs temporarily disabled.
 * The ISR is processed on a different core to the TX call.

The fix is to manually track which TX buffers are available, only freeing
a buffer after the TX event has been processed.

The MCAN user manual states that this is allowed:
"The application may use register TXBRP instead of the Put Index and may
place messages to any Tx Buffer without pending transmission request"

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit e9bc195bf4)
2023-08-29 09:17:07 -04:00
Grant Ramsay
1c75a08301 drivers: can: mcan: fix off-by-one error in assert
Fix off-by-one error in assert

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit cff1496166)
2023-08-29 09:17:07 -04:00
Grant Ramsay
d762e439f1 drivers: can: mcan: clear TX callback on failed TX
Elsewhere, "callback != NULL" is used to determine if the callback is in
use

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 08d19954b9)
2023-08-29 09:17:07 -04:00
Grant Ramsay
589aa11784 drivers: can: mcan: give back semaphore on failed TX
Give back semaphore on failed TX

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit e98f7b8fb7)
2023-08-29 09:17:07 -04:00
Grant Ramsay
3ca90e5438 drivers: can: mcan: unlock mutex on failed TX mram write
Unlock mutex on failed TX mram write

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 58e60a028f)
2023-08-29 09:17:07 -04:00
Marek Pieta
42af315397 mcumgr: img_mgmt: Fix unused "status" variable warning
Changes aligns ifdefs to fix compilation warnings related to unused
"status" variable.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
(cherry picked from commit 6bbd6d3794)
2023-08-29 09:16:51 -04:00
Carles Cufi
60634902e0 Bluetooth: controller: Check minimum sizes of adv PDUs
While the maximum sizes were already correctly checked by the code, the
minimum sizes of the PDUs were not. This meant that PDUs smaller than
the minimum required length (typically 6 bytes for AdvA) were
incorrectly forwarded up to the Host.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
(cherry picked from commit 3f0d7012a6)
2023-08-24 16:06:43 +02:00
Joshua Crawford
5e02c0bd6a drivers: flash: spi_nor: select largest valid erase operation
The spi_nor erase op selection was based on the alignment of the end of
the region to be erased. This prevented larger erase operations being
selected in many cases

Closes #60904

Signed-off-by: Joshua Crawford <joshua.crawford@levno.com>
(cherry picked from commit ea2dd9fc65)
2023-08-22 09:40:51 -04:00
Flavio Ceolin
0b4cd70e5b bt: mesh: shell: Fix possible buffer overflow
Fix possible overflow in rpr_scan_report.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit ddd2bc94e2)
2023-08-22 09:39:39 -04:00
Flavio Ceolin
06ca73dcc6 bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_media_set_search
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit e55af04e65)
2023-08-22 09:39:39 -04:00
Flavio Ceolin
d74d32f644 bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_mcc_send_search_raw
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 02e70f509f)
2023-08-22 09:39:39 -04:00
Flavio Ceolin
af96ed2ddf bt: host: Fix possible buffer overflow
Check in bt_conn_le_start_encryption if the given
ltk fits in bt_conn.ltk before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit fbd56fd920)
2023-08-22 09:39:39 -04:00
Jamie McCrae
1e2850de1c mgmt: mcumgr: transport: udp: Fix non-automatic start
Fixes a stray ifdef which causes a build failure if the automatic
UDP start Kconfig is not enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 8de70bc294)
2023-08-22 09:39:14 -04:00
Thomas Stranger
687f539b67 drivers: can: stm32: correct timing_max parameters
The timing_max parameters defined in the stm32 bxcan driver don't match the
register description in the reference manuals.
- sjw does have only 2 bits representing 1 to 4 tq.
- phase_seg1 and phase_seg2 max is one tq higher.

I have checked the following reference manuals and all match:
- RM0090: STM32F405, F415, F407, F417, F427, F437 AND F429
- RM0008: STM32F101, F102, F103, F105, F107 advanced arm-based mcus
- RM0351, RM0394: all STM32L4
- RM0091: all STM32F0 with CAN support

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
(cherry picked from commit cec279b5b6)
2023-08-22 09:38:43 -04:00
Henrik Brix Andersen
7f4c587b3b canbus: isotp: convert SF length check from ASSERT to runtime check
Convert the ISO-TP SF length check in send_sf() from __ASSERT() to a
runtime check.

Fixes: #61501

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 1b3d1e01de)
2023-08-22 09:38:29 -04:00
Thomas Stranger
422a3d8b4f drivers: can: mcux: flexcan: can_set_mode supports can_mode_3_samples
In case CAN-FD mode is not enabled the mcux flexcan driver supports
CAN_MODE_3_SAMPLES.
This has been removed inadvertently while adding can-fd support.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
(cherry picked from commit 8009ccce43)
2023-08-22 09:38:10 -04:00
Christopher Friedt
61824410a9 dts: vendor-prefixes: deprecate facebook and add meta
Although there are no in-tree users, we will deprecate the
`facebook` vendor prefix and add `meta`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-19 12:31:54 -04:00
Elisabeth Friedrich
0cc164e5b9 drivers: lpadc: fix ADC command chaining
When reading multiple ADC channel in parallel, an ADC command chain will be
build. This is similar to a linked list, as every command references the
next command.

Before this patch every ADC command after the first, would always reference
this initial command. So that during execution only two commands (the last
and first) would be executed which resulted in readout of only two analog
values. As Zephyr expected more to come in, the `read_adc` function would
block endlessly.

The patch fixes the behaviour and allows a correct chain to build up.

Fixes #60277

Signed-off-by: Elisabeth Friedrich <auxsys@flowerpot.me>
2023-08-17 12:57:06 -04:00
Robert Lubos
1611b4c703 drivers: ieee802154_nrf5: Use generic symbols for packet size
Use generic symbols defined in ieee802154.h for packet/FCS size instead
of redefining them in the driver header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 5c5be08ba9)
2023-08-17 12:56:40 -04:00
Robert Lubos
8e62e701aa drivers: ieee802154_nrf5: Add payload length check on TX
In case upper layer does not follow the convention, and the net_pkt
provided to the nRF 15.4 driver had a payload larger than the maximum
payload size of an individual 15.4 frame, the driver would end up with
buffer overflow.

Fix this by adding an extra payload_len check before attempting to copy
the payload to the internal buffer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit cf58d11f8f)
2023-08-17 12:56:40 -04:00
Robert Lubos
1c9b37ade1 net: wifi_shell: Add user input validation for SSID and PSK
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.

For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 30382daf88)
2023-08-17 12:56:16 -04:00
Jamie McCrae
119253c138 west.yaml: MCUboot synchronization from upstream cherry-picks
Cherry-pick some MCUboot updates to Zephyr 3.4-branch.

Brings following Zephyr relevant fixes:

 - 865f1d0 boot_serial: fix image number handle in image upload
           request
 - fb2ff1d boot_serial: fix misuse of 'matched' param from
           zcbor_map_decode_bulk()
 - 7c2cfe6 boot_serial: Fix showing images that are not valid

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-17 12:55:27 -04:00
Jamie McCrae
67ce39b98d mgmt: mcumgt: smp: Fix not checking returned status
Fixes not checking if a zcbor operation was successful.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit c9a4764c10)
2023-08-17 12:54:59 -04:00
Jamie McCrae
22813dda0f doc: services: device_mgmt: smp_groups: Fix OP values
Fixes an issue with the wrong OP values in some parts of the
documentation

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 84e4ffcd56)
2023-08-08 17:19:54 -04:00
Grant Ramsay
05c79b7801 canbus: isotp: Fix context buffer memory leaks
Ensure context buffers are free'd when errors occur

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-08-08 12:27:32 -04:00
Jamie McCrae
85788d2ce3 tests: boot: mcuboot_recovery_retention: Fix configuration issue
Fixes an issue with the tests whereby the RAM memory configuration
files were not being used, and could not be passed to the mcuboot
image.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit a4d56e4f55)
2023-08-07 15:20:45 -04:00
Keith Packard
5952c2275e cmake/linker_script: Fix cmake linker scripts to define _end
The generated scripts don't include a definition for any symbol indicating
the end of statically allocated memory (such as "_end"). Add a shared cmake
fragment, ram-end.cmake, which contains the necessary instructions to
define _end and z_mapped_end consistently to align with the other sample
linker scripts.

Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit bbec614b78)
2023-08-04 09:31:35 -07:00
Keith Packard
f6e73ae3c6 include/zephyr: Fix linker scripts to define _end after all static RAM data
The Zephyr linker scripts have inconsistent ordering of various chunks of
data which lands in RAM at runtime. This leads to the value of _end not
being consistently defined as the maximum address of static variables used
in the application.

Create a helper linker fragment, zephyr/linker/ram-end.ld, which can be
included after the last possible definition of RAM data, that consistently
sets _image_ram_end, _end and z_mapped_end.

Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 710422ec5e)
2023-08-04 09:31:35 -07:00
Henrik Brix Andersen
bd741f2f01 drivers: can: stm32h7: fix message RAM address calculations
Calculate the Bosch M_CAN Message RAM addresses relative to the Message RAM
Base Address (MRBA), not the offset.

Fixes: #59624

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
(cherry picked from commit b809d5ce10)
2023-08-02 08:06:00 -07:00
Henrik Brix Andersen
b5e0af779e drivers: can: mcan: add CAN_MCAN_DT_MRBA() and CAN_MCAN_DT_INST_MRBA()
Add CAN_MCAN_DT_MRBA() and CAN_MCAN_DT_INST_MRBA() macros for retrieving
the Bosch M_CAN Message RAM Base Address (MRBA) and clarify that the
existing CAN_MCAN_DT_MRAM_ADDR() and CAN_MCAN_DT_INST_MRAM_ADDR() macros do
not retrieve the base address, but rather the base address + the offset, if
any.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
(cherry picked from commit 71a7afacbd)
2023-08-02 08:06:00 -07:00
Jamie McCrae
aa3f810bb9 mgmt: mcumgr: grp: fs_mgmt: Fix wrong error checking
Fixes an issue with not properly checking error responses.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 097c568c81)
2023-08-02 08:04:04 -07:00
Mike J. Chen
758ee69c95 drivers: spi: mcux_flexcomm: fix chip select bug w/ dma transfers
Fix for bug:
https://github.com/zephyrproject-rtos/zephyr/issues/59575

The dma version of the version of the driver can
invoke multiple intermediate dma transfers, like
when the spi_buf_set count is greater than one.
However, there is a bug where chip select is not kept
asserted for all intermediate dma transfers required
to process the entire spi_buf_set.

Signed-off-by: Mike J. Chen <mjchen@google.com>
(cherry picked from commit 2a4acb2c42)
2023-07-26 09:14:53 -04:00
Emil Gydesen
8005c9079b Bluetooth: Shell: bt connect-name should only attempt connectable
The auto-connect by name did not verify that the found device
was connectable before attempting to connect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
(cherry picked from commit 118a68518a)
2023-07-26 09:13:45 -04:00
Christopher Friedt
3f3051e9f8 drivers: rtc: mc146818: fix y2k bug
That's correct. We are still fixing the Y2K bug in 2023 \o/

* write century to RAM register 0x32
* ensure year register is in [0,99] (inclusive)

Aside from that, there were a few other errors in the driver.

* translate epoch-centric RTC API year to begin at 1900
* fix off-by-one error with month limit
* fix off-by-one error with wday
* fix off-by-one-hundred error with year limit
* adjust timeptr values in rtc_mc146818_validate_time()
* adjust timeptr values in rtc_mc146818_validate_alarm()

With the above, the testsuite passes!

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit c8e0022d4b)
2023-07-25 09:27:41 -04:00
Peter Mitsis
c228ef08e7 doc: Correct msgq data item size discrepancy
Updates the data passing summary table to indicate that the size of
a message queue data item must be a multiple of its data alignment.
This brings the documentation in both the summary table and the
message queue documentation into alignment.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
(cherry picked from commit 4c7aeb252d)
2023-07-25 09:26:26 -04:00
Théo Battrel
5c04a62d1a Bluetooth: Host: Fix connection reference leak
If connection reference is acquired from `bt_conn_lookup_addr_le` but
`bt_gatt_ccc_cfg_is_matching_conn` return false the connection was not
unreferenced properly. This commit fix the issue by unreferencing the
connection if the condition is false.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
(cherry picked from commit a996159362)
2023-07-25 10:44:13 +02:00
Marcin Niestroj
1f0ec0ddf6 net: context: set default offloaded iface during net_context_get()
Set default offloaded interface during net_context_get() call, so that
net_context_recv() can be called before net_context_connect(). There is
already an assumption about using default network interface, so this should
not be harmful.

Fixes: 2c75070360 ("net: sockets: tcp: Fix possible race between
  connect/recv")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
(cherry picked from commit 40d2240226)
2023-07-18 20:35:10 -04:00
Jamie McCrae
4a02f2965c mgmt: mcumgr: grp: shell_mgmt: Fix issue with unset variable
Fixes an issue where a variable was used without being correctly
set by other parts of the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit fbacedaef8)
2023-07-18 20:22:30 -04:00
Jamie McCrae
eb452c1950 mgmt: mcumgr: grp: img_mgmt: Fix missing define
Fixes a missing define which causes a build failure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 3e71797ba2)
2023-07-18 20:10:23 -04:00
Lingao Meng
4254d9cb68 tests: bluetooth: Add iv[1 0 --> 1 1] test cast
Add testcast for 1, 1 --> 1, 0

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
(cherry picked from commit c16647d02a)
2023-07-18 20:09:44 -04:00
Lingao Meng
8ff61ee596 Bluetooth: Mesh: Discard iv update 1 0 --> 1 1
According spec, for the same iv index, iv update flag
should trans to false, when iv update procedure complete.

When local environment has attack-node
to store old network beacon(1,1), and re-send same
network beacon(1,1) after 192hours, will cause whole
bluetooth mesh network broke.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
(cherry picked from commit 75cfa34481)
2023-07-18 20:09:44 -04:00
Christopher Friedt
6f38106a23 doc: services: posix: pthread_mutexattr_destroy init supported
The functions pthread_mutexattr_destroy()
and pthread_mutexattr_init() are implemented (they just do nothing).

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit b416a90672)
2023-07-18 19:44:02 -04:00
Christopher Friedt
8cc193d6f1 doc: services: posix: pthread_condattr_destroy and init supported
The functions pthread_condattr_destroy()
and pthread_condattr_init() are implemented (they just do nothing).

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 64a477342d)
2023-07-18 19:44:02 -04:00
Christopher Friedt
79eaaae5ea doc: services: posix: _POSIX_THREAD_PRIO_INHERIT unsupported
_POSIX_THREAD_PRIO_INHERIT was mistakenly marked supported in
commit a07774eada presumably because we have prototypes for the
functions below.

pthread_mutexattr_getprotocol()
pthread_mutexattr_setprotocol()

However, the functions are not actually implemented in Zephyr.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 675a660727)
2023-07-18 19:44:02 -04:00
Christopher Friedt
88ceaa6826 doc: services: posix: fix setvbuf typo
Fix a typo in the spelling of `setvbuf()`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 88dd32c38c)
2023-07-18 19:44:02 -04:00
Aleksandr Khromykh
719dc245ef Bluetooth: Mesh: fix provisionee public key usage
Provisionee shall fail if provisioner sent public key
identicall to OOB public key back.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
(cherry picked from commit 10ef3b46d8)
2023-07-11 15:15:19 +02:00
114 changed files with 687 additions and 313 deletions

View File

@@ -3,7 +3,7 @@
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/${CMAKE_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR}.cmake)
# @Intent: Set necessary compiler & linker options for this specific host architecture & OS
include(${CMAKE_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR}.cmake)
else()
else() # Linux.x86_64
if (CONFIG_64BIT)
# some gcc versions fail to build without -fPIC
zephyr_compile_options(-m64 -fPIC)
@@ -11,6 +11,13 @@ else()
else ()
zephyr_compile_options(-m32)
zephyr_link_libraries(-m32)
# When building for 32bits x86, gcc defaults to using the old 8087 float arithmetic
# which causes some issues with literal float comparisons. So we set it
# to use the SSE2 float path instead
# (clang defaults to use SSE, but, setting this option for it is safe)
check_set_compiler_property(APPEND PROPERTY fpsse2 "SHELL:-msse2 -mfpmath=sse")
zephyr_compile_options($<TARGET_PROPERTY:compiler,fpsse2>)
endif ()
endif()

View File

@@ -788,14 +788,9 @@ SECTIONS
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
_image_ram_end = .;
_image_ram_all = (KERNEL_BASE_ADDR + KERNEL_RAM_SIZE) - _image_ram_start;
z_mapped_end = .;
z_mapped_size = z_mapped_end - z_mapped_start;
_end = .; /* end of image */
GROUP_END(RAMABLE_REGION)
#ifndef LINKER_ZEPHYR_FINAL
/* static interrupts */
@@ -823,6 +818,12 @@ SECTIONS
*/
#include <snippets-sections.ld>
#define LAST_RAM_ALIGN MMU_PAGE_ALIGN
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
/DISCARD/ : { *(.note.GNU-stack) }

View File

@@ -135,6 +135,8 @@ if(NOT CONFIG_USERSPACE)
zephyr_linker_section_configure(SECTION .noinit INPUT ".kernel_noinit.*")
endif()
include(${COMMON_ZEPHYR_LINKER_DIR}/ram-end.cmake)
zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_start EXPR "(@__bss_start@)")
zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_end EXPR "(${RAM_ADDR} + ${RAM_SIZE})")
zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_size EXPR "(@__kernel_ram_end@ - @__bss_start@)")

View File

@@ -0,0 +1,7 @@
zephyr_linker_section(NAME .last_ram_section VMA RAM LMA RAM_REGION TYPE BSS)
zephyr_linker_section_configure(
SECTION .last_ram_section
INPUT ""
SYMBOLS _end z_mapped_end
KEEP
)

View File

@@ -134,7 +134,7 @@ set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt)
set_ifndef(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)
if(EXISTS ${DTS_SOURCE})
# We found a devicetree. Check for a board revision overlay.
if(BOARD_REVISION AND EXISTS ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
if(DEFINED BOARD_REVISION AND EXISTS ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
list(APPEND DTS_SOURCE ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
endif()
else()

View File

@@ -59,7 +59,7 @@ Object Bidirectional? Data structure Data item size
FIFO No Queue Arbitrary [1] 4 B [2] Yes [3] Yes N/A
LIFO No Queue Arbitrary [1] 4 B [2] Yes [3] Yes N/A
Stack No Array Word Word Yes [3] Yes Undefined behavior
Message queue No Ring buffer Power of two Power of two Yes [3] Yes Pend thread or return -errno
Message queue No Ring buffer Arbitrary [6] Power of two Yes [3] Yes Pend thread or return -errno
Mailbox Yes Queue Arbitrary [1] Arbitrary No No N/A
Pipe No Ring buffer [4] Arbitrary Arbitrary Yes [5] Yes [5] Pend thread or return -errno
=============== ============== =================== ============== ============== ================= ============== ===============================
@@ -79,6 +79,8 @@ argument.
[5] ISRS can send and/or receive only when passing K_NO_WAIT as the
timeout argument.
[6] Data item size must be a multiple of the data alignment.
.. toctree::
:maxdepth: 1

View File

@@ -16,7 +16,7 @@ OS management group defines following commands:
| ``1`` | Console/Terminal echo control; |
| | unimplemented by Zephyr |
+-------------------+-----------------------------------------------+
| ``2`` | Statistics |
| ``2`` | Task Statistics |
+-------------------+-----------------------------------------------+
| ``3`` | Memory pool statistics |
+-------------------+-----------------------------------------------+
@@ -410,7 +410,7 @@ Date-time set response header fields:
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``1`` | ``0`` | ``4`` |
| ``3`` | ``0`` | ``4`` |
+--------+--------------+----------------+
The command sends an empty CBOR map as data if successful. In case of error the
@@ -543,7 +543,7 @@ MCUmgr parameters response header fields
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``2`` | ``0`` | ``6`` |
| ``1`` | ``0`` | ``6`` |
+--------+--------------+----------------+
CBOR data of successful response:
@@ -646,7 +646,7 @@ OS/Application info response header fields
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``2`` | ``0`` | ``7`` |
| ``1`` | ``0`` | ``7`` |
+--------+--------------+----------------+
CBOR data of response:

View File

@@ -219,7 +219,6 @@ Set state of image request header fields:
CBOR data of request:
.. code-block:: none
{

View File

@@ -97,7 +97,7 @@ Zephyr.
_POSIX_THREAD_ATTR_STACKADDR,yes
_POSIX_THREAD_ATTR_STACKSIZE,yes
_POSIX_THREAD_CPUTIME,
_POSIX_THREAD_PRIO_INHERIT,yes
_POSIX_THREAD_PRIO_INHERIT,
_POSIX_THREAD_PRIO_PROTECT,
_POSIX_THREAD_PRIORITY_SCHEDULING,yes
_POSIX_THREAD_SPORADIC_SERVER,
@@ -151,8 +151,8 @@ multiple processes.
pthread_cond_signal(),yes
pthread_cond_timedwait(),yes
pthread_cond_wait(),yes
pthread_condattr_destroy(),
pthread_condattr_init(),
pthread_condattr_destroy(),yes
pthread_condattr_init(),yes
pthread_create(),yes
pthread_detach(),yes
pthread_equal(),
@@ -167,8 +167,8 @@ multiple processes.
pthread_mutex_lock(),yes
pthread_mutex_trylock(),yes
pthread_mutex_unlock(),yes
pthread_mutexattr_destroy(),
pthread_mutexattr_init(),
pthread_mutexattr_destroy(),yes
pthread_mutexattr_init(),yes
pthread_once(),yes
pthread_self(),yes
pthread_setcancelstate(),yes
@@ -430,7 +430,7 @@ POSIX_DEVICE_IO
read(),yes
scanf(),
setbuf(),
etvbuf(),
setvbuf(),
stderr,yes
stdin,yes
stdout,yes

View File

@@ -238,8 +238,8 @@ static int mcux_lpadc_start_read(const struct device *dev,
} else {
/* End of chain */
data->cmd_config[channel].chainedNextCommandNumber = 0;
last_enabled = channel;
}
last_enabled = channel;
LPADC_SetConvCommandConfig(config->base,
channel + 1, &data->cmd_config[channel]);
}

View File

@@ -211,7 +211,7 @@ static void can_loopback_remove_rx_filter(const struct device *dev, int filter_i
{
struct can_loopback_data *data = dev->data;
if (filter_id >= ARRAY_SIZE(data->filters)) {
if (filter_id < 0 || filter_id >= ARRAY_SIZE(data->filters)) {
LOG_ERR("filter ID %d out-of-bounds", filter_id);
return;
}

View File

@@ -477,6 +477,7 @@ static void can_mcan_tx_event_handler(const struct device *dev)
struct can_mcan_data *data = dev->data;
struct can_mcan_tx_event_fifo tx_event;
can_tx_callback_t tx_cb;
void *user_data;
uint32_t event_idx;
uint32_t tx_idx;
uint32_t txefs;
@@ -507,12 +508,14 @@ static void can_mcan_tx_event_handler(const struct device *dev)
return;
}
k_sem_give(&data->tx_sem);
__ASSERT_NO_MSG(tx_idx <= cbs->num_tx);
tx_cb = cbs->tx[tx_idx].function;
user_data = cbs->tx[tx_idx].user_data;
cbs->tx[tx_idx].function = NULL;
tx_cb(dev, 0, cbs->tx[tx_idx].user_data);
k_sem_give(&data->tx_sem);
tx_cb(dev, 0, user_data);
err = can_mcan_read_reg(dev, CAN_MCAN_TXEFS, &txefs);
if (err != 0) {
@@ -822,11 +825,11 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim
#endif /* !CONFIG_CAN_FD_MODE */
.efc = 1U,
};
uint32_t put_idx;
uint32_t put_idx = -1;
uint32_t reg;
int err;
LOG_DBG("Sending %d bytes. Id: 0x%x, ID type: %s %s %s %s", data_length, frame->id,
LOG_DBG("Sending %zu bytes. Id: 0x%x, ID type: %s %s %s %s", data_length, frame->id,
(frame->flags & CAN_FRAME_IDE) != 0U ? "extended" : "standard",
(frame->flags & CAN_FRAME_RTR) != 0U ? "RTR" : "",
(frame->flags & CAN_FRAME_FDF) != 0U ? "FD frame" : "",
@@ -888,16 +891,16 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim
return -EAGAIN;
}
err = can_mcan_read_reg(dev, CAN_MCAN_TXFQS, &reg);
if (err != 0) {
return err;
}
__ASSERT_NO_MSG((reg & CAN_MCAN_TXFQS_TFQF) != CAN_MCAN_TXFQS_TFQF);
k_mutex_lock(&data->tx_mtx, K_FOREVER);
put_idx = FIELD_GET(CAN_MCAN_TXFQS_TFQPI, reg);
/* Acquire a free TX buffer */
for (int i = 0; i < cbs->num_tx; i++) {
if (cbs->tx[i].function == NULL) {
put_idx = i;
break;
}
}
tx_hdr.mm = put_idx;
if ((frame->flags & CAN_FRAME_IDE) != 0U) {
@@ -912,7 +915,7 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim
&tx_hdr, sizeof(struct can_mcan_tx_buffer_hdr));
if (err != 0) {
LOG_ERR("failed to write Tx Buffer header (err %d)", err);
return err;
goto err_unlock;
}
err = can_mcan_write_mram(dev, config->mram_offsets[CAN_MCAN_MRAM_CFG_TX_BUFFER] + put_idx *
@@ -921,20 +924,25 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim
&frame->data_32, ROUND_UP(data_length, sizeof(uint32_t)));
if (err != 0) {
LOG_ERR("failed to write Tx Buffer data (err %d)", err);
return err;
goto err_unlock;
}
__ASSERT_NO_MSG(put_idx <= cbs->num_tx);
__ASSERT_NO_MSG(put_idx < cbs->num_tx);
cbs->tx[put_idx].function = callback;
cbs->tx[put_idx].user_data = user_data;
err = can_mcan_write_reg(dev, CAN_MCAN_TXBAR, BIT(put_idx));
if (err != 0) {
goto unlock;
cbs->tx[put_idx].function = NULL;
goto err_unlock;
}
unlock:
k_mutex_unlock(&data->tx_mtx);
return 0;
err_unlock:
k_mutex_unlock(&data->tx_mtx);
k_sem_give(&data->tx_sem);
return err;
}
@@ -1102,12 +1110,17 @@ void can_mcan_remove_rx_filter(const struct device *dev, int filter_id)
struct can_mcan_data *data = dev->data;
int err;
if (filter_id < 0) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
k_mutex_lock(&data->lock, K_FOREVER);
if (filter_id >= cbs->num_std) {
filter_id -= cbs->num_std;
if (filter_id >= cbs->num_ext) {
LOG_ERR("Wrong filter id");
LOG_ERR("filter ID %d out of bounds", filter_id);
k_mutex_unlock(&data->lock);
return;
}
@@ -1454,7 +1467,7 @@ int can_mcan_init(const struct device *dev)
return err;
}
reg = CAN_MCAN_ILS_RF0NL | CAN_MCAN_ILS_RF1NL;
reg = CAN_MCAN_ILS_RF0NL | CAN_MCAN_ILS_RF1NL | CAN_MCAN_ILS_RF0LL | CAN_MCAN_ILS_RF1LL;
err = can_mcan_write_reg(dev, CAN_MCAN_ILS, reg);
if (err != 0) {
return err;

View File

@@ -673,6 +673,11 @@ static void mcp2515_remove_rx_filter(const struct device *dev, int filter_id)
{
struct mcp2515_data *dev_data = dev->data;
if (filter_id < 0 || filter_id >= CONFIG_CAN_MAX_FILTER) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
k_mutex_lock(&dev_data->mutex, K_FOREVER);
dev_data->filter_usage &= ~BIT(filter_id);
k_mutex_unlock(&dev_data->mutex);

View File

@@ -426,7 +426,7 @@ static int mcux_flexcan_stop(const struct device *dev)
static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
{
can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY;
can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_3_SAMPLES;
const struct mcux_flexcan_config *config = dev->config;
struct mcux_flexcan_data *data = dev->data;
uint32_t ctrl1;
@@ -921,9 +921,8 @@ static void mcux_flexcan_remove_rx_filter(const struct device *dev, int filter_i
{
struct mcux_flexcan_data *data = dev->data;
if (filter_id >= MCUX_FLEXCAN_MAX_RX) {
LOG_ERR("Detach: Filter id >= MAX_RX (%d >= %d)", filter_id,
MCUX_FLEXCAN_MAX_RX);
if (filter_id < 0 || filter_id >= MCUX_FLEXCAN_MAX_RX) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
@@ -1222,9 +1221,9 @@ static int mcux_flexcan_init(const struct device *dev)
data->timing_data.phase_seg2);
LOG_DBG("Sample-point err : %d", err);
} else {
data->timing_data.prop_seg = config->prop_seg;
data->timing_data.phase_seg1 = config->phase_seg1;
data->timing_data.phase_seg2 = config->phase_seg2;
data->timing_data.prop_seg = config->prop_seg_data;
data->timing_data.phase_seg1 = config->phase_seg1_data;
data->timing_data.phase_seg2 = config->phase_seg2_data;
err = can_calc_prescaler(dev, &data->timing_data, config->bitrate_data);
if (err) {
LOG_WRN("Bitrate error: %d", err);

View File

@@ -239,6 +239,7 @@ static void can_npl_remove_rx_filter(const struct device *dev, int filter_id)
struct can_npl_data *data = dev->data;
if (filter_id < 0 || filter_id >= ARRAY_SIZE(data->filters)) {
LOG_ERR("filter ID %d out of bounds");
return;
}

View File

@@ -396,7 +396,10 @@ static void can_nxp_s32_remove_rx_filter(const struct device *dev, int filter_id
struct can_nxp_s32_data *data = dev->data;
int mb_indx = ALLOC_IDX_TO_RXMB_IDX(filter_id);
__ASSERT_NO_MSG(filter_id >= 0 && filter_id < CONFIG_CAN_NXP_S32_MAX_RX);
if (filter_id < 0 || filter_id >= CONFIG_CAN_NXP_S32_MAX_RX) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
k_mutex_lock(&data->rx_mutex, K_FOREVER);

View File

@@ -973,7 +973,8 @@ static void can_rcar_remove_rx_filter(const struct device *dev, int filter_id)
{
struct can_rcar_data *data = dev->data;
if (filter_id >= CONFIG_CAN_RCAR_MAX_FILTER) {
if (filter_id < 0 || filter_id >= CONFIG_CAN_RCAR_MAX_FILTER) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}

View File

@@ -58,6 +58,14 @@ static inline int can_sja1000_enter_reset_mode(const struct device *dev)
return 0;
}
static inline void can_sja1000_leave_reset_mode_nowait(const struct device *dev)
{
uint8_t mod;
mod = can_sja1000_read_reg(dev, CAN_SJA1000_MOD);
can_sja1000_write_reg(dev, CAN_SJA1000_MOD, mod & ~(CAN_SJA1000_MOD_RM));
}
static inline int can_sja1000_leave_reset_mode(const struct device *dev)
{
int retries = CAN_SJA1000_RESET_MODE_RETRIES;
@@ -609,7 +617,7 @@ static void can_sja1000_handle_error_warning_irq(const struct device *dev)
can_sja1000_tx_done(dev, -ENETUNREACH);
#ifdef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
if (data->started) {
(void)can_sja1000_leave_reset_mode(dev);
can_sja1000_leave_reset_mode_nowait(dev);
}
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
} else if ((sr & CAN_SJA1000_SR_ES) != 0) {

View File

@@ -990,7 +990,10 @@ static void can_stm32_remove_rx_filter(const struct device *dev, int filter_id)
int bank_num;
bool bank_unused;
__ASSERT_NO_MSG(filter_id >= 0 && filter_id < CAN_STM32_MAX_FILTER_ID);
if (filter_id < 0 || filter_id >= CAN_STM32_MAX_FILTER_ID) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
k_mutex_lock(&filter_mutex, K_FOREVER);
k_mutex_lock(&data->inst_mutex, K_FOREVER);
@@ -1069,10 +1072,10 @@ static const struct can_driver_api can_api_funcs = {
.prescaler = 0x01
},
.timing_max = {
.sjw = 0x07,
.sjw = 0x04,
.prop_seg = 0x00,
.phase_seg1 = 0x0F,
.phase_seg2 = 0x07,
.phase_seg1 = 0x10,
.phase_seg2 = 0x08,
.prescaler = 0x400
}
};
@@ -1134,8 +1137,8 @@ static const struct can_stm32_config can_stm32_cfg_##inst = { \
}, \
.config_irq = config_can_##inst##_irq, \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
.phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(id, phys)), \
.max_bitrate = DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(id, 1000000), \
.phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, phys)), \
.max_bitrate = DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, 1000000), \
};
#define CAN_STM32_DATA_INST(inst) \

View File

@@ -21,6 +21,7 @@ LOG_MODULE_REGISTER(can_stm32h7, CONFIG_CAN_LOG_LEVEL);
struct can_stm32h7_config {
mm_reg_t base;
mem_addr_t mrba;
mem_addr_t mram;
void (*config_irq)(void);
const struct pinctrl_dev_config *pcfg;
@@ -132,7 +133,7 @@ static int can_stm32h7_init(const struct device *dev)
return ret;
}
ret = can_mcan_configure_mram(dev, stm32h7_cfg->mram, stm32h7_cfg->mram);
ret = can_mcan_configure_mram(dev, stm32h7_cfg->mrba, stm32h7_cfg->mram);
if (ret != 0) {
return ret;
}
@@ -205,6 +206,7 @@ static const struct can_mcan_ops can_stm32h7_ops = {
\
static const struct can_stm32h7_config can_stm32h7_cfg_##n = { \
.base = CAN_MCAN_DT_INST_MCAN_ADDR(n), \
.mrba = CAN_MCAN_DT_INST_MRBA(n), \
.mram = CAN_MCAN_DT_INST_MRAM_ADDR(n), \
.config_irq = stm32h7_mcan_irq_config_##n, \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \

View File

@@ -647,6 +647,11 @@ static int espi_xec_flash_write(const struct device *dev,
LOG_DBG("%s", __func__);
if (sizeof(target_mem) < pckt->len) {
LOG_ERR("Packet length is too big");
return -ENOMEM;
}
if (!(ESPI_FC_REGS->STS & MCHP_ESPI_FC_STS_CHAN_EN)) {
LOG_ERR("Flash channel is disabled");
return -EIO;

View File

@@ -524,6 +524,11 @@ static int espi_xec_flash_write(const struct device *dev,
LOG_DBG("%s", __func__);
if (sizeof(target_mem) < pckt->len) {
LOG_ERR("Packet length is too big");
return -ENOMEM;
}
if (!(regs->FCSTS & MCHP_ESPI_FC_STS_CHAN_EN)) {
LOG_ERR("Flash channel is disabled");
return -EIO;

View File

@@ -774,7 +774,7 @@ static int spi_nor_erase(const struct device *dev, off_t addr, size_t size)
if ((etp->exp != 0)
&& SPI_NOR_IS_ALIGNED(addr, etp->exp)
&& SPI_NOR_IS_ALIGNED(size, etp->exp)
&& (size >= BIT(etp->exp))
&& ((bet == NULL)
|| (etp->exp > bet->exp))) {
bet = etp;

View File

@@ -18,7 +18,6 @@
#include <zephyr/drivers/spi.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/posix/time.h>
#include <zephyr/sys/crc.h>
/*

View File

@@ -150,7 +150,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
pkt_len = rx_frame->psdu[0];
} else {
pkt_len = rx_frame->psdu[0] - NRF5_FCS_LENGTH;
pkt_len = rx_frame->psdu[0] - IEEE802154_FCS_LENGTH;
}
#if defined(CONFIG_NET_BUF_DATA_SIZE)
@@ -377,7 +377,7 @@ static int handle_ack(struct nrf5_802154_data *nrf5_radio)
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
ack_len = nrf5_radio->ack_frame.psdu[0];
} else {
ack_len = nrf5_radio->ack_frame.psdu[0] - NRF5_FCS_LENGTH;
ack_len = nrf5_radio->ack_frame.psdu[0] - IEEE802154_FCS_LENGTH;
}
ack_pkt = net_pkt_rx_alloc_with_buffer(nrf5_radio->iface, ack_len,
@@ -577,9 +577,14 @@ static int nrf5_tx(const struct device *dev,
uint8_t *payload = frag->data;
bool ret = true;
if (payload_len > IEEE802154_MTU) {
LOG_ERR("Payload too large: %d", payload_len);
return -EMSGSIZE;
}
LOG_DBG("%p (%u)", payload, payload_len);
nrf5_radio->tx_psdu[0] = payload_len + NRF5_FCS_LENGTH;
nrf5_radio->tx_psdu[0] = payload_len + IEEE802154_FCS_LENGTH;
memcpy(nrf5_radio->tx_psdu + 1, payload, payload_len);
/* Reset semaphore in case ACK was received after timeout */

View File

@@ -10,8 +10,6 @@
#include <zephyr/net/ieee802154_radio.h>
#define NRF5_FCS_LENGTH (2)
#define NRF5_PSDU_LENGTH (125)
#define NRF5_PHR_LENGTH (1)
struct nrf5_802154_rx_frame {
@@ -61,7 +59,7 @@ struct nrf5_802154_data {
/* TX buffer. First byte is PHR (length), remaining bytes are
* MPDU data.
*/
uint8_t tx_psdu[NRF5_PHR_LENGTH + NRF5_PSDU_LENGTH + NRF5_FCS_LENGTH];
uint8_t tx_psdu[NRF5_PHR_LENGTH + IEEE802154_MAX_PHY_PACKET_SIZE];
/* TX result, updated in radio transmit callbacks. */
uint8_t tx_result;

View File

@@ -56,7 +56,7 @@ static int send(const struct device *dev, int wait, uint32_t id,
return -EBUSY;
}
if (size > MAX_MSG) {
if ((size < 0) || (size > MAX_MSG)) {
return -EMSGSIZE;
}

View File

@@ -165,7 +165,7 @@ static int imx_mu_ipm_send(const struct device *dev, int wait, uint32_t id,
{
const struct imx_mu_config *config = dev->config;
MU_Type *base = MU(config);
uint32_t data32[IMX_IPM_DATA_REGS];
uint32_t data32[IMX_IPM_DATA_REGS] = {0};
#if !IS_ENABLED(CONFIG_IPM_IMX_REV2)
mu_status_t status;
#endif
@@ -175,7 +175,7 @@ static int imx_mu_ipm_send(const struct device *dev, int wait, uint32_t id,
return -EINVAL;
}
if (size > CONFIG_IPM_IMX_MAX_DATA_SIZE) {
if ((size < 0) || (size > CONFIG_IPM_IMX_MAX_DATA_SIZE)) {
return -EMSGSIZE;
}

View File

@@ -81,9 +81,8 @@ static int mcux_mailbox_ipm_send(const struct device *d, int wait,
{
const struct mcux_mailbox_config *config = d->config;
MAILBOX_Type *base = config->base;
uint32_t data32[MCUX_IPM_DATA_REGS]; /* Until we change API
* to uint32_t array
*/
/* Until we change API to uint32_t array */
uint32_t data32[MCUX_IPM_DATA_REGS] = {0};
unsigned int flags;
int i;
@@ -93,7 +92,7 @@ static int mcux_mailbox_ipm_send(const struct device *d, int wait,
return -EINVAL;
}
if (size > MCUX_IPM_DATA_REGS * sizeof(uint32_t)) {
if ((size < 0) || (size > MCUX_IPM_DATA_REGS * sizeof(uint32_t))) {
return -EMSGSIZE;
}

View File

@@ -96,8 +96,8 @@ static int mcux_pwm_set_cycles(const struct device *dev, uint32_t channel,
data->channel[channel].level = level;
status = PWM_SetupPwm(config->base, config->index,
&data->channel[channel], CHANNEL_COUNT,
config->mode, 1, clock_freq);
&data->channel[channel], 1U,
config->mode, 1U, clock_freq);
if (status != kStatus_Success) {
LOG_ERR("Could not set up pwm");
return -ENOTSUP;

View File

@@ -34,6 +34,9 @@
#define RTC_MONTH 0x08
#define RTC_YEAR 0x09
/* Y2K Bugfix */
#define RTC_CENTURY 0x32
/* Alarm time indices in RTC RAM */
#define RTC_ALARM_SEC 0x01
#define RTC_ALARM_MIN 0x03
@@ -106,10 +109,10 @@
#define MIN_WDAY 1
#define MAX_MDAY 31
#define MIN_MDAY 1
#define MAX_MON 11
#define MIN_MON 0
#define MAX_MON 12
#define MIN_MON 1
#define MIN_YEAR_DIFF 0 /* YEAR - 1900 */
#define MAX_YEAR_DIFF 199 /* YEAR - 1900 */
#define MAX_YEAR_DIFF 99 /* YEAR - 1999 */
struct rtc_mc146818_data {
struct k_spinlock lock;
@@ -149,16 +152,16 @@ static bool rtc_mc146818_validate_time(const struct rtc_time *timeptr)
if (timeptr->tm_hour < MIN_HOUR || timeptr->tm_hour > MAX_HOUR) {
return false;
}
if (timeptr->tm_wday < MIN_WDAY || timeptr->tm_wday > MAX_WDAY) {
if (timeptr->tm_wday + 1 < MIN_WDAY || timeptr->tm_wday + 1 > MAX_WDAY) {
return false;
}
if (timeptr->tm_mday < MIN_MDAY || timeptr->tm_mday > MAX_MDAY) {
return false;
}
if (timeptr->tm_mon < MIN_MON || timeptr->tm_mon > MAX_MON) {
if (timeptr->tm_mon + 1 < MIN_MON || timeptr->tm_mon + 1 > MAX_MON) {
return false;
}
if (timeptr->tm_year < MIN_YEAR_DIFF || timeptr->tm_year > MAX_YEAR_DIFF) {
if (timeptr->tm_year - 70 < MIN_YEAR_DIFF || timeptr->tm_year - 70 > MAX_YEAR_DIFF) {
return false;
}
return true;
@@ -168,6 +171,8 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time
{
struct rtc_mc146818_data * const dev_data = dev->data;
uint8_t value;
int year;
int cent;
int ret;
k_spinlock_key_t key = k_spin_lock(&dev_data->lock);
@@ -186,6 +191,9 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time
value = rtc_read(RTC_DATA);
rtc_write(RTC_DATA, value | RTC_UCI_BIT);
year = (1970 + timeptr->tm_year) % 100;
cent = (1970 + timeptr->tm_year) / 100;
if (!(rtc_read(RTC_DATA) & RTC_DMODE_BIT)) {
rtc_write(RTC_SEC, (uint8_t)bin2bcd(timeptr->tm_sec));
rtc_write(RTC_MIN, (uint8_t)bin2bcd(timeptr->tm_min));
@@ -193,7 +201,8 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time
rtc_write(RTC_WDAY, (uint8_t)bin2bcd(timeptr->tm_wday));
rtc_write(RTC_MDAY, (uint8_t)bin2bcd(timeptr->tm_mday));
rtc_write(RTC_MONTH, (uint8_t)bin2bcd(timeptr->tm_mon + 1));
rtc_write(RTC_YEAR, (uint8_t)bin2bcd(timeptr->tm_year));
rtc_write(RTC_YEAR, (uint8_t)bin2bcd(year));
rtc_write(RTC_CENTURY, (uint8_t)bin2bcd(cent));
} else {
rtc_write(RTC_SEC, (uint8_t)timeptr->tm_sec);
rtc_write(RTC_MIN, (uint8_t)timeptr->tm_min);
@@ -201,7 +210,8 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time
rtc_write(RTC_WDAY, (uint8_t)timeptr->tm_wday);
rtc_write(RTC_MDAY, (uint8_t)timeptr->tm_mday);
rtc_write(RTC_MONTH, (uint8_t)timeptr->tm_mon + 1);
rtc_write(RTC_YEAR, (uint8_t)timeptr->tm_year);
rtc_write(RTC_YEAR, year);
rtc_write(RTC_CENTURY, cent);
}
if (timeptr->tm_isdst == 1) {
@@ -221,6 +231,8 @@ static int rtc_mc146818_get_time(const struct device *dev, struct rtc_time *tim
{
struct rtc_mc146818_data * const dev_data = dev->data;
int ret;
uint8_t cent;
uint8_t year;
uint8_t value;
k_spinlock_key_t key = k_spin_lock(&dev_data->lock);
@@ -239,16 +251,18 @@ static int rtc_mc146818_get_time(const struct device *dev, struct rtc_time *tim
while (rtc_read(RTC_UIP) & RTC_UIP_BIT) {
continue;
}
timeptr->tm_year = rtc_read(RTC_YEAR);
cent = rtc_read(RTC_CENTURY);
year = rtc_read(RTC_YEAR);
timeptr->tm_mon = rtc_read(RTC_MONTH) - 1;
timeptr->tm_mday = rtc_read(RTC_MDAY);
timeptr->tm_wday = rtc_read(RTC_WDAY);
timeptr->tm_wday = rtc_read(RTC_WDAY) - 1;
timeptr->tm_hour = rtc_read(RTC_HOUR);
timeptr->tm_min = rtc_read(RTC_MIN);
timeptr->tm_sec = rtc_read(RTC_SEC);
if (!(rtc_read(RTC_DATA) & RTC_DMODE_BIT)) {
timeptr->tm_year = bcd2bin(timeptr->tm_year);
year = bcd2bin(year);
cent = bcd2bin(cent);
timeptr->tm_mon = bcd2bin(timeptr->tm_mon);
timeptr->tm_mday = bcd2bin(timeptr->tm_mday);
timeptr->tm_wday = bcd2bin(timeptr->tm_wday);
@@ -257,6 +271,8 @@ static int rtc_mc146818_get_time(const struct device *dev, struct rtc_time *tim
timeptr->tm_sec = bcd2bin(timeptr->tm_sec);
}
timeptr->tm_year = 100 * (int)cent + year - 1970;
timeptr->tm_nsec = 0;
timeptr->tm_yday = 0;
value = rtc_read(RTC_DATA);
@@ -296,7 +312,7 @@ static bool rtc_mc146818_validate_alarm(const struct rtc_time *timeptr, uint32_t
}
if ((mask & RTC_ALARM_TIME_MASK_MONTH) &&
(timeptr->tm_mon < MIN_WDAY || timeptr->tm_mon > MAX_WDAY)) {
(timeptr->tm_mon + 1 < MIN_WDAY || timeptr->tm_mon + 1 > MAX_WDAY)) {
return false;
}
@@ -306,7 +322,7 @@ static bool rtc_mc146818_validate_alarm(const struct rtc_time *timeptr, uint32_t
}
if ((mask & RTC_ALARM_TIME_MASK_YEAR) &&
(timeptr->tm_year < MIN_YEAR_DIFF || timeptr->tm_year > MAX_YEAR_DIFF)) {
(timeptr->tm_year - 70 < MIN_YEAR_DIFF || timeptr->tm_year - 70 > MAX_YEAR_DIFF)) {
return false;
}

View File

@@ -610,6 +610,10 @@ static int transceive_dma(const struct device *dev,
while (data->ctx.rx_len > 0 || data->ctx.tx_len > 0) {
size_t dma_len;
/* last is used to deassert chip select if this
* is the last transfer in the set.
*/
bool last = false;
if (data->ctx.rx_len == 0) {
@@ -626,6 +630,34 @@ static int transceive_dma(const struct device *dev,
last = false;
}
/* at this point, last just means whether or not
* this transfer will completely cover
* the current tx/rx buffer in data->ctx
* or require additional transfers because the
* the two buffers are not the same size.
*
* if it covers the current ctx tx/rx buffers, then
* we'll move to the next pair of buffers (if any)
* after the transfer, but if there are
* no more buffer pairs, then this is the last
* transfer in the set and we need to deassert CS.
*/
if (last) {
/* this dma transfer should cover
* the entire current data->ctx set
* of buffers. if there are more
* buffers in the set, then we don't
* want to deassert CS.
*/
if ((data->ctx.tx_count > 1) ||
(data->ctx.rx_count > 1)) {
/* more buffers to transfer so
* this isn't last
*/
last = false;
}
}
data->status_flags = 0;
ret = spi_mcux_dma_move_buffers(dev, dma_len, spi_cfg, last);

View File

@@ -222,13 +222,18 @@ static int spi_mcux_configure(const struct device *dev,
return -EINVAL;
}
/* Setting the baud rate in LPSPI_MasterInit requires module to be disabled */
LPSPI_Enable(base, false);
while ((base->CR & LPSPI_CR_MEN_MASK) != 0U) {
/* Wait until LPSPI is disabled. Datasheet:
* After writing 0, MEN (Module Enable) remains set until the LPSPI has completed
* the current transfer and is idle.
if (data->ctx.config != NULL) {
/* Setting the baud rate in LPSPI_MasterInit requires module to be disabled. Only
* disable if already configured, otherwise the clock is not enabled and the
* CR register cannot be written.
*/
LPSPI_Enable(base, false);
while ((base->CR & LPSPI_CR_MEN_MASK) != 0U) {
/* Wait until LPSPI is disabled. Datasheet:
* After writing 0, MEN (Module Enable) remains set until the LPSPI has
* completed the current transfer and is idle.
*/
}
}
LPSPI_MasterInit(base, &master_config, clock_freq);

View File

@@ -202,7 +202,7 @@ evervision Evervision Electronics Co. Ltd.
exar Exar Corporation
excito Excito
ezchip EZchip Semiconductor
facebook Facebook
facebook Facebook (deprecated, use meta)
fairphone Fairphone B.V.
faraday Faraday Technology Corporation
fastrax Fastrax Oy
@@ -371,6 +371,7 @@ menlo Menlo Systems GmbH
mentor Mentor Graphics
meraki Cisco Meraki, LLC
merrii Merrii Technology Co., Ltd.
meta Meta Platforms, Inc.
micrel Micrel Inc.
microbit Micro:bit Educational Foundation
microchip Microchip Technology Inc.

View File

@@ -246,8 +246,6 @@ SECTIONS {
MPU_MIN_SIZE_ALIGN
/* Define linker symbols */
_image_ram_end = .;
_end = .; /* end of image */
__kernel_ram_end = .;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
@@ -278,13 +276,15 @@ SECTIONS {
} GROUP_DATA_LINK_IN(YCCM, RAMABLE_REGION)
#endif
GROUP_END(RAMABLE_REGION)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
SECTION_PROLOGUE(.ARC.attributes, 0,) {

View File

@@ -332,16 +332,9 @@ SECTIONS
/* Define linker symbols */
. = ALIGN(_region_min_align);
_image_ram_end = .;
_end = .; /* end of image */
z_mapped_end = .;
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
GROUP_END(RAMABLE_REGION)
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ocm), okay)
GROUP_START(OCM)
@@ -373,6 +366,12 @@ GROUP_END(OCM)
*/
#include <snippets-sections.ld>
#define LAST_RAM_ALIGN . = ALIGN(_region_min_align);
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
SECTION_PROLOGUE(.ARM.attributes, 0,)

View File

@@ -361,14 +361,9 @@ SECTIONS
/* Define linker symbols */
_image_ram_end = .;
_end = .; /* end of image */
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
GROUP_END(RAMABLE_REGION)
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay)
GROUP_START(ITCM)
@@ -426,6 +421,10 @@ GROUP_END(DTCM)
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
/DISCARD/ : { *(.note.GNU-stack) }

View File

@@ -295,21 +295,21 @@ SECTIONS
/* Define linker symbols */
MMU_ALIGN;
_image_ram_end = .;
_end = .; /* end of image */
z_mapped_end = .;
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
GROUP_END(RAMABLE_REGION)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#define LAST_RAM_ALIGN MMU_ALIGN;
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
SECTION_PROLOGUE(.ARM.attributes, 0,)

View File

@@ -181,14 +181,15 @@ SECTIONS
#include <zephyr/linker/cplusplus-ram.ld>
_image_ram_end = .;
_end = .; /* end of image */
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
.mdebug.abi32 : {

View File

@@ -259,17 +259,15 @@ SECTIONS
#include <zephyr/linker/common-noinit.ld>
/* Define linker symbols */
_image_ram_end = .;
_end = .; /* end of image */
GROUP_END(RAMABLE_REGION)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
}

View File

@@ -305,11 +305,6 @@ SECTIONS
__data_region_end = .;
MPU_MIN_SIZE_ALIGN
_image_ram_end = .;
_end = .; /* end of image */
__kernel_ram_end = .;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
@@ -370,7 +365,11 @@ GROUP_END(DTCM)
*/
#include <snippets-sections.ld>
GROUP_END(RAMABLE_REGION)
#define LAST_RAM_ALIGN MPU_MIN_SIZE_ALIGN
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>

View File

@@ -154,14 +154,15 @@ SECTIONS
#include <zephyr/linker/cplusplus-ram.ld>
_image_ram_end = .;
_end = .; /* end of image */
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
/DISCARD/ : { *(.note.GNU-stack) }

View File

@@ -503,14 +503,10 @@ SECTIONS
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
_image_ram_end = .;
_image_ram_all = (KERNEL_BASE_ADDR + KERNEL_RAM_SIZE) - _image_ram_start;
z_mapped_end = .;
z_mapped_size = z_mapped_end - z_mapped_start;
_end = .; /* end of image */
GROUP_END(RAMABLE_REGION)
#ifndef LINKER_ZEPHYR_FINAL
/* static interrupts */
@@ -538,6 +534,10 @@ SECTIONS
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>
/DISCARD/ : { *(.note.GNU-stack) }

View File

@@ -192,10 +192,12 @@ SECTIONS
/* Must be last in RAM */
#include <zephyr/linker/kobject-data.ld>
MMU_PAGE_ALIGN
_image_ram_end = .;
z_mapped_end = .;
_end = .;
#define LAST_RAM_ALIGN MMU_PAGE_ALIGN
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
/* All unused memory also owned by the kernel for heaps */
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;

View File

@@ -1360,7 +1360,7 @@ static inline uint8_t can_dlc_to_bytes(uint8_t dlc)
static const uint8_t dlc_table[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12,
16, 20, 24, 32, 48, 64};
return dlc > 0x0F ? 64 : dlc_table[dlc];
return dlc_table[MIN(dlc, ARRAY_SIZE(dlc_table) - 1)];
}
/**

View File

@@ -573,13 +573,25 @@
* @brief Get the Bosch M_CAN Message RAM base address
*
* For devicetree nodes with dedicated Message RAM area defined via devicetree, this macro returns
* the base address of the Message RAM, taking in the Message RAM offset into account.
* the base address of the Message RAM.
*
* @param node_id node identifier
* @return the Bosch M_CAN Message RAM base address
* @return the Bosch M_CAN Message RAM base address (MRBA)
*/
#define CAN_MCAN_DT_MRBA(node_id) \
(mem_addr_t)DT_REG_ADDR_BY_NAME(node_id, message_ram)
/**
* @brief Get the Bosch M_CAN Message RAM address
*
* For devicetree nodes with dedicated Message RAM area defined via devicetree, this macro returns
* the address of the Message RAM, taking in the Message RAM offset into account.
*
* @param node_id node identifier
* @return the Bosch M_CAN Message RAM address
*/
#define CAN_MCAN_DT_MRAM_ADDR(node_id) \
(mem_addr_t)(DT_REG_ADDR_BY_NAME(node_id, message_ram) + CAN_MCAN_DT_MRAM_OFFSET(node_id))
(mem_addr_t)(CAN_MCAN_DT_MRBA(node_id) + CAN_MCAN_DT_MRAM_OFFSET(node_id))
/**
* @brief Get the Bosch M_CAN Message RAM size
@@ -617,7 +629,7 @@
*/
#define CAN_MCAN_DT_MRAM_DEFINE(node_id, _name) \
BUILD_ASSERT(CAN_MCAN_DT_MRAM_OFFSET(node_id) == 0, "offset must be 0"); \
static char __noinit __nocache __aligned(4) _name[CAN_MCAN_DT_MRAM_ELEMENTS_SIZE(node_id)];
static char __nocache_noinit __aligned(4) _name[CAN_MCAN_DT_MRAM_ELEMENTS_SIZE(node_id)];
/**
* @brief Assert that the Message RAM configuration meets the Bosch M_CAN IP core restrictions
@@ -782,10 +794,18 @@
*/
#define CAN_MCAN_DT_INST_MCAN_ADDR(inst) CAN_MCAN_DT_MCAN_ADDR(DT_DRV_INST(inst))
/**
* @brief Equivalent to CAN_MCAN_DT_MRBA(DT_DRV_INST(inst))
* @param inst DT_DRV_COMPAT instance number
* @return the Bosch M_CAN Message RAM Base Address (MRBA)
* @see CAN_MCAN_DT_MRBA()
*/
#define CAN_MCAN_DT_INST_MRBA(inst) CAN_MCAN_DT_MRBA(DT_DRV_INST(inst))
/**
* @brief Equivalent to CAN_MCAN_DT_MRAM_ADDR(DT_DRV_INST(inst))
* @param inst DT_DRV_COMPAT instance number
* @return the Bosch M_CAN Message RAM base address
* @return the Bosch M_CAN Message RAM address
* @see CAN_MCAN_DT_MRAM_ADDR()
*/
#define CAN_MCAN_DT_INST_MRAM_ADDR(inst) CAN_MCAN_DT_MRAM_ADDR(DT_DRV_INST(inst))

View File

@@ -0,0 +1,14 @@
/*
* Added after the very last allocation that might land in RAM to define the various
* end-of-used-memory symbols
*/
SECTION_PROLOGUE(.last_ram_section,,)
{
#ifdef LAST_RAM_ALIGN
LAST_RAM_ALIGN
#endif
_image_ram_end = .;
_end = .; /* end of image */
z_mapped_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)

View File

@@ -45,8 +45,10 @@
#if defined(CONFIG_NOCACHE_MEMORY)
#define __nocache __in_section_unique(_NOCACHE_SECTION_NAME)
#define __nocache_noinit __nocache
#else
#define __nocache
#define __nocache_noinit __noinit
#endif /* CONFIG_NOCACHE_MEMORY */
#if defined(CONFIG_KERNEL_COHERENCE)

View File

@@ -755,10 +755,8 @@ void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt);
static inline bool net_if_is_ip_offloaded(struct net_if *iface)
{
#if defined(CONFIG_NET_OFFLOAD)
NET_ASSERT(iface);
NET_ASSERT(iface->if_dev);
return (iface->if_dev->offload != NULL);
return (iface != NULL && iface->if_dev != NULL &&
iface->if_dev->offload != NULL);
#else
ARG_UNUSED(iface);

View File

@@ -123,7 +123,9 @@ static inline const char *wifi_band_txt(enum wifi_frequency_bands band)
}
#define WIFI_SSID_MAX_LEN 32
#define WIFI_PSK_MIN_LEN 8
#define WIFI_PSK_MAX_LEN 64
#define WIFI_SAE_PSWD_MAX_LEN 128
#define WIFI_MAC_ADDR_LEN 6
#define WIFI_CHANNEL_MAX 233

View File

@@ -35,7 +35,6 @@ typedef uint32_t clockid_t;
typedef unsigned long timer_t;
#endif
#ifdef CONFIG_PTHREAD_IPC
/* Thread attributes */
struct pthread_attr {
int priority;
@@ -99,8 +98,6 @@ typedef struct pthread_rwlock_obj {
k_tid_t wr_owner;
} pthread_rwlock_t;
#endif /* CONFIG_PTHREAD_IPC */
#ifdef __cplusplus
}
#endif

View File

@@ -24,20 +24,20 @@ extern "C" {
#define SIGEV_THREAD 3
#endif
typedef union sigval {
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
union sigval {
int sival_int;
void *sival_ptr;
} sigval;
};
typedef struct sigevent {
struct sigevent {
int sigev_notify;
int sigev_signo;
sigval sigev_value;
void (*sigev_notify_function)(sigval val);
#ifdef CONFIG_PTHREAD_IPC
union sigval sigev_value;
void (*sigev_notify_function)(union sigval val);
pthread_attr_t *sigev_notify_attributes;
#endif
} sigevent;
};
#ifdef __cplusplus
}

View File

@@ -17,6 +17,12 @@
extern "C" {
#endif
/**
* @ingroup hashmap_apis
* @defgroup hash_functions Hash Functions
* @{
*/
/**
* @brief 32-bit Hash function interface
*
@@ -70,7 +76,7 @@ static inline uint32_t sys_hash32_identity(const void *str, size_t n)
}
/**
* @brief Daniel J. Bernstein's hash function
* @brief Daniel J.\ Bernstein's hash function
*
* Some notes:
* - normally, this hash function is used on NUL-terminated strings
@@ -129,6 +135,10 @@ static inline uint32_t sys_hash32(const void *str, size_t n)
return 0;
}
/**
* @}
*/
#ifdef __cplusplus
}
#endif

View File

@@ -6,10 +6,8 @@
/**
* @file
* @brief Hashmap (Hash Table) API
*
* Hashmaps (a.k.a Hash Tables) sacrifice space for speed. All operations
* on a Hashmap (insert, delete, search) are O(1) complexity (on average).
* @addtogroup hashmap_apis
* @{
*/
#ifndef ZEPHYR_INCLUDE_SYS_HASH_MAP_H_
@@ -29,11 +27,6 @@
extern "C" {
#endif
/**
* @ingroup hashmap_apis
* @{
*/
/**
* @brief Declare a Hashmap (advanced)
*
@@ -63,9 +56,9 @@ extern "C" {
}
/**
* @brief Declare a Hashmap (advanced)
* @brief Declare a Hashmap statically (advanced)
*
* Declare a Hashmap with control over advanced parameters.
* Declare a Hashmap statically with control over advanced parameters.
*
* @note The allocator @p _alloc is used for allocating internal Hashmap
* entries and does not interact with any user-provided keys or values.
@@ -121,6 +114,7 @@ static inline void *sys_hashmap_default_allocator(void *ptr, size_t size)
return realloc(ptr, size);
}
/** @brief The default Hashmap allocator */
#define SYS_HASHMAP_DEFAULT_ALLOCATOR sys_hashmap_default_allocator
/** @brief The default Hashmap load factor (in hundredths) */
@@ -128,10 +122,15 @@ static inline void *sys_hashmap_default_allocator(void *ptr, size_t size)
/** @brief Generic Hashmap */
struct sys_hashmap {
/** Hashmap API */
const struct sys_hashmap_api *api;
/** Hashmap configuration */
const struct sys_hashmap_config *config;
/** Hashmap data */
struct sys_hashmap_data *data;
/** Hash function */
sys_hash_func32_t hash_func;
/** Allocator */
sys_hashmap_allocator_t alloc_func;
};

View File

@@ -4,14 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Hashmap (Hash Table) API
*
* Hashmaps (a.k.a Hash Tables) sacrifice space for speed. All operations
* on a Hashmap (insert, delete, search) are O(1) complexity (on average).
*/
#ifndef ZEPHYR_INCLUDE_SYS_HASHMAP_API_H_
#define ZEPHYR_INCLUDE_SYS_HASHMAP_API_H_
@@ -27,8 +19,19 @@ extern "C" {
#endif
/**
* @file
* @defgroup hashmap_apis Hashmap
* @ingroup datastructure_apis
*
* @brief Hashmap (Hash Table) API
*
* Hashmaps (a.k.a Hash Tables) sacrifice space for speed. All operations
* on a Hashmap (insert, delete, search) are O(1) complexity (on average).
*
* @defgroup hashmap_implementations Hashmap Implementations
* @ingroup hashmap_apis
*
* @addtogroup hashmap_apis
* @{
*/

View File

@@ -6,6 +6,7 @@
/**
* @file
* @ingroup hashmap_implementations
* @brief C++ Hashmap
*
* This is a C wrapper around `std::unordered_map`. It is mainly used for

View File

@@ -6,6 +6,7 @@
/**
* @file
* @ingroup hashmap_implementations
* @brief Open-Addressing / Linear Probe Hashmap Implementation
*
* @note Enable with @kconfig{CONFIG_SYS_HASH_MAP_OA_LP}

View File

@@ -6,6 +6,7 @@
/**
* @file
* @ingroup hashmap_implementations
* @brief Separate Chaining Hashmap Implementation
*
* @note Enable with @kconfig{CONFIG_SYS_HASH_MAP_SC}

View File

@@ -1712,6 +1712,10 @@ static void end_thread(struct k_thread *thread)
unpend_all(&thread->join_queue);
update_cache(1);
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
arch_float_disable(thread);
#endif
SYS_PORT_TRACING_FUNC(k_thread, sched_abort, thread);
z_thread_monitor_exit(thread);

View File

@@ -534,7 +534,6 @@ void pthread_exit(void *retval)
self = to_posix_thread(pthread_self());
if (self == NULL) {
/* not a valid posix_thread */
__ASSERT_NO_MSG(self != NULL);
k_thread_abort(k_current_get());
}

View File

@@ -7,6 +7,7 @@
#include <errno.h>
#include <string.h>
#include <zephyr/sys/printk.h>
#include <zephyr/posix/signal.h>
#include <zephyr/posix/time.h>
#define ACTIVE 1
@@ -16,8 +17,8 @@ static void zephyr_timer_wrapper(struct k_timer *ztimer);
struct timer_obj {
struct k_timer ztimer;
void (*sigev_notify_function)(sigval val);
sigval val;
void (*sigev_notify_function)(union sigval val);
union sigval val;
struct timespec interval; /* Reload value */
uint32_t reload; /* Reload value in ms */
uint32_t status;

View File

@@ -22,6 +22,7 @@ extern "C" {
#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/toolchain.h>
#include <zephyr/dsp/types.h> /* float32_t, float64_t */
/* Use static variables instead of calloc() */
#define CO_USE_GLOBALS
@@ -46,12 +47,13 @@ extern "C" {
#endif
typedef bool bool_t;
typedef float float32_t;
typedef long double float64_t;
typedef char char_t;
typedef unsigned char oChar_t;
typedef unsigned char domain_t;
BUILD_ASSERT(sizeof(float32_t) >= 4);
BUILD_ASSERT(sizeof(float64_t) >= 8);
typedef struct canopen_rx_msg {
uint8_t data[8];
uint16_t ident;

View File

@@ -66,6 +66,9 @@ if(DEFINED BOARD_REVISION)
set(BOARD_REVISION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/empty.conf")
endif()
# Unset shield configuration files if set to prevent including in sysbuild
set(shield_conf_files)
list(APPEND ZEPHYR_KCONFIG_MODULES_DIR BOARD=${BOARD})
set(KCONFIG_NAMESPACE SB_CONFIG)

View File

@@ -312,21 +312,20 @@ SECTIONS
/* Define linker symbols */
MMU_ALIGN;
_image_ram_end = .;
_end = .; /* end of image */
z_mapped_end = .;
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
GROUP_END(RAMABLE_REGION)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#define LAST_RAM_ALIGN MMU_ALIGN;
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
#include <zephyr/linker/debug-sections.ld>
SECTION_PROLOGUE(.ARM.attributes, 0,)

View File

@@ -47,6 +47,11 @@
#define IROM_SEG_ALIGN 0x10000
#endif
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
/* Global symbols required for espressif hal build */
MEMORY
{
@@ -183,11 +188,6 @@ SECTIONS
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION)
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#pragma push_macro("GROUP_ROM_LINK_IN")
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
#include <zephyr/linker/common-rom/common-rom-ztest.ld>
@@ -195,7 +195,6 @@ SECTIONS
#include <zephyr/linker/common-rom/common-rom-bt.ld>
#include <zephyr/linker/common-rom/common-rom-debug.ld>
#include <zephyr/linker/common-rom/common-rom-misc.ld>
#pragma pop_macro("GROUP_ROM_LINK_IN")
/* Create an explicit section at the end of all the data that shall be mapped into drom.
* This is used to calculate the size of the _image_drom_size variable */

View File

@@ -233,16 +233,15 @@ SECTIONS
*/
#include <snippets-ram-sections.ld>
_image_ram_end = .;
_end = .; /* end of image */
GROUP_END(RAM)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#ifdef CONFIG_GEN_ISR_TABLES
/* Bogus section, post-processed during the build to initialize interrupts. */
#include <zephyr/linker/intlist.ld>

View File

@@ -356,11 +356,6 @@ SECTIONS
__data_region_end = .;
MPU_MIN_SIZE_ALIGN
_image_ram_end = .;
_end = .; /* end of image */
__kernel_ram_end = .;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
@@ -369,7 +364,11 @@ SECTIONS
*/
#include <snippets-sections.ld>
GROUP_END(RAMABLE_REGION)
#define LAST_RAM_ALIGN MPU_MIN_SIZE_ALIGN
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>

View File

@@ -274,11 +274,6 @@ SECTIONS
__data_region_end = .;
MPU_MIN_SIZE_ALIGN
_image_ram_end = .;
_end = .; /* end of image */
__kernel_ram_end = .;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
@@ -339,7 +334,11 @@ GROUP_END(DTCM)
*/
#include <snippets-sections.ld>
GROUP_END(RAMABLE_REGION)
#define LAST_RAM_ALIGN MPU_MIN_SIZE_ALIGN
#include <zephyr/linker/ram-end.ld>
GROUP_END(RAMABLE_REGION)
#include <zephyr/linker/debug-sections.ld>

View File

@@ -47,6 +47,11 @@
#define IRAM_SEG_LEN 0x13000
#endif
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
MEMORY
{
mcuboot_hdr (RX): org = 0x0, len = 0x20
@@ -210,11 +215,6 @@ SECTIONS
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION)
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#pragma push_macro("GROUP_ROM_LINK_IN")
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
#include <zephyr/linker/common-rom/common-rom-ztest.ld>
@@ -222,7 +222,6 @@ SECTIONS
#include <zephyr/linker/common-rom/common-rom-bt.ld>
#include <zephyr/linker/common-rom/common-rom-debug.ld>
#include <zephyr/linker/common-rom/common-rom-misc.ld>
#pragma pop_macro("GROUP_ROM_LINK_IN")
/* Create an explicit section at the end of all the data that shall be mapped into drom.
* This is used to calculate the size of the _image_drom_size variable */

View File

@@ -26,6 +26,11 @@
#define ROMABLE_DATA_REGION dram0_1_seg
#define dram0_0_seg dram0_1_seg
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
MEMORY
{
iram0_0_seg(RX): org = 0x40080000 + 0x08000, len = 0x18000
@@ -200,11 +205,6 @@ SECTIONS
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_DATA_REGION)
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#pragma push_macro("GROUP_ROM_LINK_IN")
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
#include <zephyr/linker/common-rom/common-rom-ztest.ld>
@@ -212,7 +212,6 @@ SECTIONS
#include <zephyr/linker/common-rom/common-rom-bt.ld>
#include <zephyr/linker/common-rom/common-rom-debug.ld>
#include <zephyr/linker/common-rom/common-rom-misc.ld>
#pragma pop_macro("GROUP_ROM_LINK_IN")
/* Create an explicit section at the end of all the data that shall be mapped into drom.
* This is used to calculate the size of the _image_drom_size variable */

View File

@@ -51,6 +51,11 @@
#define IROM_SEG_ALIGN 0x10000
#endif
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
MEMORY
{
mcuboot_hdr (RX): org = 0x0, len = 0x20
@@ -179,18 +184,12 @@ SECTIONS
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION)
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#pragma push_macro("GROUP_ROM_LINK_IN")
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
#include <zephyr/linker/common-rom/common-rom-ztest.ld>
#include <zephyr/linker/common-rom/common-rom-net.ld>
#include <zephyr/linker/common-rom/common-rom-debug.ld>
#include <zephyr/linker/common-rom/common-rom-misc.ld>
#pragma pop_macro("GROUP_ROM_LINK_IN")
/* Create an explicit section at the end of all the data that shall be mapped into drom.
* This is used to calculate the size of the _image_drom_size variable */

View File

@@ -55,6 +55,11 @@
#define IROM_SEG_ALIGN 0x10000
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
MEMORY
{
mcuboot_hdr (RX): org = 0x0, len = 0x20
@@ -197,11 +202,6 @@ SECTIONS
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION)
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
* Executing directly from LMA is not possible. */
#pragma push_macro("GROUP_ROM_LINK_IN")
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
#include <zephyr/linker/common-rom/common-rom-ztest.ld>
@@ -209,7 +209,6 @@ SECTIONS
#include <zephyr/linker/common-rom/common-rom-bt.ld>
#include <zephyr/linker/common-rom/common-rom-debug.ld>
#include <zephyr/linker/common-rom/common-rom-misc.ld>
#pragma pop_macro("GROUP_ROM_LINK_IN")
/* Create an explicit section at the end of all the data that shall be mapped into drom.
* This is used to calculate the size of the _image_drom_size variable */

View File

@@ -403,6 +403,8 @@ SECTIONS {
_unused_ram_start_marker = .;
*(.unused_ram_start_marker)
*(.unused_ram_start_marker.*)
_end = .;
z_mapped_end = .;
} >ram
. = L2_SRAM_BASE + L2_SRAM_SIZE;

View File

@@ -1448,9 +1448,16 @@ static int cmd_mcc_send_search_raw(const struct shell *sh, size_t argc,
char *argv[])
{
int result;
size_t len;
struct mpl_search search;
search.len = strlen(argv[1]);
len = strlen(argv[1]);
if (len > sizeof(search.search)) {
shell_print(sh, "Fail: Invalid argument");
return -EINVAL;
}
search.len = len;
memcpy(search.search, argv[1], search.len);
LOG_DBG("Search string: %s", argv[1]);

View File

@@ -1230,9 +1230,16 @@ static int cmd_media_set_search(const struct shell *sh, size_t argc, char *argv[
*/
struct mpl_search search;
size_t len;
int err;
search.len = strlen(argv[1]);
len = strlen(argv[1]);
if (len > sizeof(search.search)) {
shell_print(sh, "Fail: Invalid argument");
return -EINVAL;
}
search.len = len;
memcpy(search.search, argv[1], search.len);
LOG_DBG("Search string: %s", argv[1]);

View File

@@ -921,11 +921,11 @@ static void isr_window(void *param)
}
lll_chan_set(37 + lll->chan);
#if defined(CONFIG_BT_CENTRAL) || defined(CONFIG_BT_CTLR_ADV_EXT)
#if defined(CONFIG_BT_CENTRAL)
bool is_sched_advanced = IS_ENABLED(CONFIG_BT_CTLR_SCHED_ADVANCED) &&
lll->conn && lll->conn_win_offset_us;
uint32_t ticks_anchor_prev;
uint32_t ticks_at_start;
if (is_sched_advanced) {
/* Get the ticks_anchor when the offset to free time space for
@@ -938,14 +938,17 @@ static void isr_window(void *param)
} else {
ticks_anchor_prev = 0U;
}
#endif /* CONFIG_BT_CENTRAL */
uint32_t ticks_at_start;
ticks_at_start = ticker_ticks_now_get() +
HAL_TICKER_CNTR_CMP_OFFSET_MIN;
remainder_us = radio_tmr_start_tick(0, ticks_at_start);
#else /* !CONFIG_BT_CENTRAL */
#else /* !CONFIG_BT_CENTRAL && !CONFIG_BT_CTLR_ADV_EXT */
remainder_us = radio_tmr_start_now(0);
#endif /* !CONFIG_BT_CENTRAL */
#endif /* !CONFIG_BT_CENTRAL && !CONFIG_BT_CTLR_ADV_EXT */
/* capture end of Rx-ed PDU, for initiator to calculate first
* central event.
@@ -1273,6 +1276,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
/* Active scanner */
} else if (((pdu_adv_rx->type == PDU_ADV_TYPE_ADV_IND) ||
(pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_IND)) &&
(pdu_adv_rx->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
(pdu_adv_rx->len <= sizeof(struct pdu_adv_adv_ind)) &&
lll->type && !lll->state &&
#if defined(CONFIG_BT_CENTRAL)
@@ -1365,6 +1369,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
else if (((((pdu_adv_rx->type == PDU_ADV_TYPE_ADV_IND) ||
(pdu_adv_rx->type == PDU_ADV_TYPE_NONCONN_IND) ||
(pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_IND)) &&
(pdu_adv_rx->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
(pdu_adv_rx->len <= sizeof(struct pdu_adv_adv_ind))) ||
((pdu_adv_rx->type == PDU_ADV_TYPE_DIRECT_IND) &&
(pdu_adv_rx->len == sizeof(struct pdu_adv_direct_ind)) &&
@@ -1379,6 +1384,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
&dir_report)) ||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
((pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_RSP) &&
(pdu_adv_rx->len >= offsetof(struct pdu_adv_scan_rsp, data)) &&
(pdu_adv_rx->len <= sizeof(struct pdu_adv_scan_rsp)) &&
(lll->state != 0U) &&
isr_scan_rsp_adva_matches(pdu_adv_rx))) &&
@@ -1429,6 +1435,7 @@ static inline bool isr_scan_init_check(const struct lll_scan *lll,
lll_scan_adva_check(lll, pdu->tx_addr, pdu->adv_ind.addr,
rl_idx)) &&
(((pdu->type == PDU_ADV_TYPE_ADV_IND) &&
(pdu->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
(pdu->len <= sizeof(struct pdu_adv_adv_ind))) ||
((pdu->type == PDU_ADV_TYPE_DIRECT_IND) &&
(pdu->len == sizeof(struct pdu_adv_direct_ind)) &&

View File

@@ -9,6 +9,7 @@
#include <zephyr/types.h>
#include <soc.h>
#include "hal/cpu.h"
#include "hal/cntr.h"
#include "hal/ticker.h"
@@ -3137,6 +3138,7 @@ void ticker_job(void *param)
instance->job_guard = 0U;
/* trigger worker if deferred */
cpu_dmb();
if (instance->worker_trigger || compare_trigger) {
instance->sched_cb(TICKER_CALL_ID_JOB, TICKER_CALL_ID_WORKER, 1,
instance);

View File

@@ -6,8 +6,13 @@
*/
#include <stddef.h>
#include <soc.h>
#include <zephyr/types.h>
#include <zephyr/sys/printk.h>
#include "hal/cpu.h"
#include "memq.h"
#include "mayfly.h"
@@ -154,10 +159,12 @@ static void dequeue(uint8_t callee_id, uint8_t caller_id, memq_link_t *link,
m->_link = link;
/* reset mayfly state to idle */
cpu_dmb();
ack = m->_ack;
m->_ack = req;
/* re-insert, if re-pended by interrupt */
cpu_dmb();
if (((m->_req - ack) & 0x03) == 1U) {
#if defined(MAYFLY_UT)
printk("%s: RACE\n", __func__);

View File

@@ -2159,6 +2159,10 @@ int bt_conn_le_start_encryption(struct bt_conn *conn, uint8_t rand[8],
struct bt_hci_cp_le_start_encryption *cp;
struct net_buf *buf;
if (len > sizeof(cp->ltk)) {
return -EINVAL;
}
buf = bt_hci_cmd_create(BT_HCI_OP_LE_START_ENCRYPTION, sizeof(*cp));
if (!buf) {
return -ENOBUFS;

View File

@@ -2105,9 +2105,12 @@ static struct bt_conn *bt_gatt_ccc_cfg_conn_lookup(const struct bt_gatt_ccc_cfg
struct bt_conn *conn;
conn = bt_conn_lookup_addr_le(cfg->id, &cfg->peer);
if (conn) {
if (bt_gatt_ccc_cfg_is_matching_conn(conn, cfg)) {
return conn;
}
if (bt_gatt_ccc_cfg_is_matching_conn(conn, cfg)) {
return conn;
bt_conn_unref(conn);
}
return NULL;

View File

@@ -284,6 +284,12 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update)
return false;
}
/* Discard [iv, false] --> [iv, true] */
if (iv_index == bt_mesh.iv_index && iv_update) {
LOG_DBG("Ignore previous IV update procedure");
return false;
}
if ((iv_index > bt_mesh.iv_index + 1) ||
(iv_index == bt_mesh.iv_index + 1 &&
(atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) || !iv_update))) {

View File

@@ -357,6 +357,13 @@ static void prov_pub_key(const uint8_t *data)
return;
}
if (!memcmp(bt_mesh_prov->public_key_be,
bt_mesh_prov_link.conf_inputs.pub_key_provisioner, PDU_LEN_PUB_KEY)) {
LOG_ERR("Public keys are identical");
prov_fail(PROV_ERR_NVAL_FMT);
return;
}
/* No swap needed since user provides public key in big-endian */
memcpy(bt_mesh_prov_link.conf_inputs.pub_key_device, bt_mesh_prov->public_key_be,
PDU_LEN_PUB_KEY);

View File

@@ -38,9 +38,26 @@ static void rpr_scan_report(struct bt_mesh_rpr_cli *cli,
uint8_t len, type;
uint8_t data[31];
len = net_buf_simple_pull_u8(adv_data) - 1;
len = net_buf_simple_pull_u8(adv_data);
if (len == 0) {
/* No data in this AD Structure. */
continue;
}
if (len > adv_data->len) {
/* Malformed AD Structure. */
break;
}
type = net_buf_simple_pull_u8(adv_data);
memcpy(data, net_buf_simple_pull_mem(adv_data, len), len);
if ((--len) > 0) {
uint8_t dlen;
/* Pull all length, but print only what fits into `data` array. */
dlen = MIN(len, sizeof(data) - 1);
memcpy(data, net_buf_simple_pull_mem(adv_data, len), dlen);
len = dlen;
}
data[len] = '\0';
if (type == BT_DATA_URI) {

View File

@@ -410,7 +410,7 @@ static void scan_recv(const struct bt_le_scan_recv_info *info,
bt_addr_le_copy(&auto_connect.addr, info->addr);
/* Use the above auto_connect.addr address to automatically connect */
if (auto_connect.connect_name) {
if ((info->adv_props & BT_GAP_ADV_PROP_CONNECTABLE) != 0U && auto_connect.connect_name) {
auto_connect.connect_name = false;
cmd_scan_off(ctx_shell);

View File

@@ -882,7 +882,11 @@ static inline int send_sf(struct isotp_send_ctx *ctx)
frame.data[index++] = ISOTP_PCI_TYPE_SF | len;
__ASSERT_NO_MSG(len <= ISOTP_CAN_DL - index);
if (len > ISOTP_CAN_DL - index) {
LOG_ERR("SF len does not fit DL");
return -ENOSPC;
}
memcpy(&frame.data[index], data, len);
#ifdef CONFIG_ISOTP_ENABLE_TX_PADDING
@@ -1179,6 +1183,7 @@ static int send(struct isotp_send_ctx *ctx, const struct device *can_dev,
ret = attach_fc_filter(ctx);
if (ret) {
LOG_ERR("Can't attach fc filter: %d", ret);
free_send_ctx(&ctx);
return ret;
}
@@ -1190,6 +1195,7 @@ static int send(struct isotp_send_ctx *ctx, const struct device *can_dev,
ctx->filter_id = -1;
ret = send_sf(ctx);
if (ret) {
free_send_ctx(&ctx);
return ret == -EAGAIN ?
ISOTP_N_TIMEOUT_A : ISOTP_N_ERROR;
}

View File

@@ -65,8 +65,15 @@ static void release_file_handle(size_t handle)
static bool is_mount_point(const char *path)
{
char dir_path[PATH_MAX];
size_t len;
sprintf(dir_path, "%s", path);
len = strlen(path);
if (len >= sizeof(dir_path)) {
return false;
}
memcpy(dir_path, path, len);
dir_path[len] = '\0';
return strcmp(dirname(dir_path), "/") == 0;
}

View File

@@ -596,8 +596,11 @@ static struct log_msg *msg_alloc(struct mpsc_pbuf_buffer *buffer, uint32_t wlen)
return NULL;
}
return (struct log_msg *)mpsc_pbuf_alloc(buffer, wlen,
K_MSEC(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS));
return (struct log_msg *)mpsc_pbuf_alloc(
buffer, wlen,
(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS == -1)
? K_FOREVER
: K_MSEC(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS));
}
struct log_msg *z_log_msg_alloc(uint32_t wlen)

View File

@@ -81,7 +81,6 @@ static struct hawkbit_context {
uint8_t *response_data;
int32_t json_action_id;
size_t url_buffer_size;
size_t status_buffer_size;
struct hawkbit_download dl;
struct http_request http_req;
struct flash_img_context flash_ctx;
@@ -845,7 +844,7 @@ static bool send_request(enum http_method method, enum hawkbit_http_request type
ret = json_obj_encode_buf(json_cfg_descr, ARRAY_SIZE(json_cfg_descr), &cfg,
hb_context.status_buffer,
hb_context.status_buffer_size - 1);
sizeof(hb_context.status_buffer));
if (ret) {
LOG_ERR("Can't encode the JSON script (HAWKBIT_CONFIG_DEVICE): %d", ret);
return false;
@@ -875,7 +874,7 @@ static bool send_request(enum http_method method, enum hawkbit_http_request type
ret = json_obj_encode_buf(json_close_descr, ARRAY_SIZE(json_close_descr), &close,
hb_context.status_buffer,
hb_context.status_buffer_size - 1);
sizeof(hb_context.status_buffer));
if (ret) {
LOG_ERR("Can't encode the JSON script (HAWKBIT_CLOSE): %d", ret);
return false;
@@ -922,7 +921,7 @@ static bool send_request(enum http_method method, enum hawkbit_http_request type
ret = json_obj_encode_buf(json_dep_fbk_descr, ARRAY_SIZE(json_dep_fbk_descr),
&feedback, hb_context.status_buffer,
hb_context.status_buffer_size - 1);
sizeof(hb_context.status_buffer));
if (ret) {
LOG_ERR("Can't encode the JSON script (HAWKBIT_REPORT): %d", ret);
return ret;

View File

@@ -280,9 +280,9 @@ static int fs_mgmt_file_download(struct smp_streamer *ctxt)
rc = fs_open(&fs_mgmt_ctxt.file, path, FS_O_READ);
if (rc != 0) {
if (rc == EINVAL) {
if (rc == -EINVAL) {
rc = FS_MGMT_RET_RC_FILE_INVALID_NAME;
} else if (ENOENT) {
} else if (rc == -ENOENT) {
rc = FS_MGMT_RET_RC_FILE_NOT_FOUND;
} else {
rc = FS_MGMT_RET_RC_UNKNOWN;
@@ -422,9 +422,9 @@ static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
rc = fs_open(&fs_mgmt_ctxt.file, file_name, FS_O_CREATE | FS_O_WRITE);
if (rc != 0) {
if (rc == EINVAL) {
if (rc == -EINVAL) {
rc = FS_MGMT_RET_RC_FILE_INVALID_NAME;
} else if (ENOENT) {
} else if (rc == -ENOENT) {
rc = FS_MGMT_RET_RC_FILE_NOT_FOUND;
} else {
rc = FS_MGMT_RET_RC_UNKNOWN;
@@ -741,9 +741,9 @@ static int fs_mgmt_file_hash_checksum(struct smp_streamer *ctxt)
rc = fs_open(&file, path, FS_O_READ);
if (rc != 0) {
if (rc == EINVAL) {
if (rc == -EINVAL) {
rc = FS_MGMT_RET_RC_FILE_INVALID_NAME;
} else if (ENOENT) {
} else if (rc == -ENOENT) {
rc = FS_MGMT_RET_RC_FILE_NOT_FOUND;
} else {
rc = FS_MGMT_RET_RC_UNKNOWN;

View File

@@ -426,8 +426,13 @@ img_mgmt_upload(struct smp_streamer *ctxt)
bool data_match = false;
#endif
#if defined(CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK) || defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
#if defined(CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK)
enum mgmt_cb_return status;
#endif
#if defined(CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK) || \
defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS) || \
defined(CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS)
int32_t ret_rc;
uint16_t ret_group;
#endif

View File

@@ -83,9 +83,6 @@ shell_mgmt_exec(struct smp_streamer *ctxt)
ok = zcbor_tstr_decode(zsd, &value);
if (ok) {
/* TODO: This is original error when failed to collect command line
* to buffer, but should be rather MGMT_ERR_ENOMEM.
*/
if ((len + value.len) >= (ARRAY_SIZE(line) - 1)) {
ok = smp_add_cmd_ret(zse, MGMT_GROUP_ID_SHELL,
SHELL_MGMT_RET_RC_COMMAND_TOO_LONG);
@@ -95,7 +92,7 @@ shell_mgmt_exec(struct smp_streamer *ctxt)
memcpy(&line[len], value.value, value.len);
len += value.len + 1;
line[len - 1] = ' ';
} else {
} else if (len > 0) {
line[len - 1] = 0;
/* Implicit break by while condition */
}

View File

@@ -225,9 +225,15 @@ static int smp_handle_single_payload(struct smp_streamer *cbuf, const struct smp
}
if (handler_fn) {
bool ok;
*handler_found = true;
zcbor_map_start_encode(cbuf->writer->zs,
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES);
ok = zcbor_map_start_encode(cbuf->writer->zs,
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES);
if (!ok) {
return MGMT_ERR_EMSGSIZE;
}
#if defined(CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS)
cmd_recv.group = req_hdr->nh_group;

View File

@@ -48,19 +48,26 @@ config MCUMGR_TRANSPORT_NETBUF_SIZE
In case when MCUMGR_TRANSPORT_SHELL is enabled this value should be set to
at least MCUMGR_GRP_SHELL_BACKEND_DUMMY_BUF_SIZE + 32.
config MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE
int "Size of mcumgr buffer user data"
default 24 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV6
config MCUMGR_TRANSPORT_NETBUF_MIN_USER_DATA_SIZE
int
default 24 if MCUMGR_TRANSPORT_UDP && NET_IPV6
default 8 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV4
default 8 if MCUMGR_TRANSPORT_BT
default 4
help
Hidden option to determine minimum user data size.
config MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE
int "Size of mcumgr buffer user data"
range MCUMGR_TRANSPORT_NETBUF_MIN_USER_DATA_SIZE 128
default MCUMGR_TRANSPORT_NETBUF_MIN_USER_DATA_SIZE
help
The size, in bytes, of user data to allocate for each mcumgr buffer.
Different mcumgr transports impose different requirements for this
setting. A value of 4 is sufficient for UART and shell, a value of 8
is sufficient for Bluetooth. For UDP, the userdata must be large
enough to hold a IPv4/IPv6 address.
enough to hold IPv4/IPv6 addresses.
module = MCUMGR_TRANSPORT
module-str = mcumgr_transport

View File

@@ -42,6 +42,9 @@ BUILD_ASSERT(0, "Either IPv4 or IPv6 SMP must be enabled for the MCUmgr UDP SMP
"CONFIG_MCUMGR_TRANSPORT_UDP_IPV4 or CONFIG_MCUMGR_TRANSPORT_UDP_IPV6");
#endif
BUILD_ASSERT(sizeof(struct sockaddr) <= CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE,
"CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE must be >= sizeof(struct sockaddr)");
#define IS_THREAD_RUNNING(thread) \
(thread.base.thread_state & (_THREAD_PENDING | \
_THREAD_PRESTART | \
@@ -87,9 +90,7 @@ static struct configs configs = {
#endif
};
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_AUTOMATIC_INIT
static struct net_mgmt_event_callback smp_udp_mgmt_cb;
#endif
static const char *smp_udp_proto_to_name(enum proto_type proto)
{

View File

@@ -219,7 +219,7 @@ int net_ipv4_parse_hdr_options(struct net_pkt *pkt,
}
#endif
enum net_verdict net_ipv4_input(struct net_pkt *pkt)
enum net_verdict net_ipv4_input(struct net_pkt *pkt, bool is_loopback)
{
NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(ipv4_access, struct net_ipv4_hdr);
NET_PKT_DATA_ACCESS_DEFINE(udp_access, struct net_udp_hdr);
@@ -280,6 +280,19 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt)
net_pkt_update_length(pkt, pkt_len);
}
if (!is_loopback) {
if (net_ipv4_is_addr_loopback((struct in_addr *)hdr->dst) ||
net_ipv4_is_addr_loopback((struct in_addr *)hdr->src)) {
NET_DBG("DROP: localhost packet");
goto drop;
}
if (net_ipv4_is_my_addr((struct in_addr *)hdr->src)) {
NET_DBG("DROP: src addr is %s", "mine");
goto drop;
}
}
if (net_ipv4_is_addr_mcast((struct in_addr *)hdr->src)) {
NET_DBG("DROP: src addr is %s", "mcast");
goto drop;

View File

@@ -502,6 +502,11 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
NET_DBG("DROP: invalid scope multicast packet");
goto drop;
}
if (net_ipv6_is_my_addr((struct in6_addr *)hdr->src)) {
NET_DBG("DROP: src addr is %s", "mine");
goto drop;
}
}
/* Reconstruct TC field. */

View File

@@ -337,6 +337,8 @@ int net_context_get(sa_family_t family, enum net_sock_type type, uint16_t proto,
*context = NULL;
return ret;
}
net_context_set_iface(*context, net_if_get_default());
}
return 0;

View File

@@ -135,7 +135,7 @@ static inline enum net_verdict process_data(struct net_pkt *pkt,
if (IS_ENABLED(CONFIG_NET_IPV6) && vtc_vhl == 0x60) {
return net_ipv6_input(pkt, is_loopback);
} else if (IS_ENABLED(CONFIG_NET_IPV4) && vtc_vhl == 0x40) {
return net_ipv4_input(pkt);
return net_ipv4_input(pkt, is_loopback);
}
NET_DBG("Unknown IP family packet (0x%x)", NET_IPV6_HDR(pkt)->vtc & 0xf0);

View File

@@ -72,12 +72,14 @@ static inline const char *net_context_state(struct net_context *context)
#endif
#if defined(CONFIG_NET_NATIVE)
enum net_verdict net_ipv4_input(struct net_pkt *pkt);
enum net_verdict net_ipv4_input(struct net_pkt *pkt, bool is_loopback);
enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback);
#else
static inline enum net_verdict net_ipv4_input(struct net_pkt *pkt)
static inline enum net_verdict net_ipv4_input(struct net_pkt *pkt,
bool is_loopback)
{
ARG_UNUSED(pkt);
ARG_UNUSED(is_loopback);
return NET_CONTINUE;
}

View File

@@ -326,6 +326,9 @@ static int __wifi_args_to_params(size_t argc, char *argv[],
/* SSID */
params->ssid = argv[0];
params->ssid_length = strlen(params->ssid);
if (params->ssid_length > WIFI_SSID_MAX_LEN) {
return -EINVAL;
}
/* Channel (optional) */
if ((idx < argc) && (strlen(argv[idx]) <= 3)) {
@@ -371,6 +374,14 @@ static int __wifi_args_to_params(size_t argc, char *argv[],
idx++;
}
}
if (params->psk_length < WIFI_PSK_MIN_LEN ||
(params->security != WIFI_SECURITY_TYPE_SAE &&
params->psk_length > WIFI_PSK_MAX_LEN) ||
(params->security == WIFI_SECURITY_TYPE_SAE &&
params->psk_length > WIFI_SAE_PSWD_MAX_LEN)) {
return -EINVAL;
}
} else {
params->security = WIFI_SECURITY_TYPE_NONE;
}

Some files were not shown because too many files have changed in this diff Show More