Compare commits

...

124 Commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
ac9c9d2c8d Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit d6f2bc9669)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Vinayak Kariappa Chettimada
f780ff8154 Bluetooth: Controller: Use BT_HCI_ERR_UNSPECIFIED as needed
A Host shall consider any error code that it does not
explicitly understand equivalent to the error code
Unspecified Error (0x1F).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 78466c8f52)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Vinayak Kariappa Chettimada
acfd2b279d Bluetooth: Controller: Refactor BT_CTLR_LE_ENC implementation
Refactor reused function in BT_CTLR_LE_ENC feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit fe205a598e)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Vinayak Kariappa Chettimada
636d73e67a Bluetooth: Controller: Fix missing conn update ind PDU validation
Fix missing validation of Connection Update Ind PDU. Ignore
invalid connection update parameters and force a silent
local connection termination.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 4b6d3f1e16)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Erik Brockhoff
0ea4e22c6a Bluetooth: controller: minor cleanup and a fix-up re. LLCP
Only perform retention if not already done.
Ensure 'sched' is performed on phy ntf even if dle is not.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
(cherry picked from commit 9d8059b6e5)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Erik Brockhoff
e267abdc5d Bluetooth: controller: fix node_rx retention mechanism
Ensure that in LLCP reference to node_rx is cleared when
retention is NOT used, to avoid corruption of node_rx later
re-allocated

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
(cherry picked from commit 806a4fcf92)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Erik Brockhoff
3ddd2734a9 Bluetooth: controller: fixing rx node leak on CPR reject of parallel CPR
In case a CPR is intiated but rejected due to CPR active on
other connection, rx nodes are leaked due to retained node not
being properly released.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
(cherry picked from commit edef1b7cf4)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Morten Priess
6b2e403a75 Bluetooth: controller: Prevent invalid compiler code reordering
In ull_disable, it is imperative that the callback is set up before a
second reference counter check, otherwise it may happen that an LLL done
event has already passed when the disable callback and semaphore is
assigned.

This causes the HCI thread to wait until timeout and assert after
ull_ticker_stop_with_mark.

For certain compilers, due to compiler optimizations, it can be seen
from the assembler code that the callback is assigned after the second
reference counter check.

By adding memory barriers, the code correctly reorders code to the
expected sequence.

Signed-off-by: Morten Priess <mtpr@oticon.com>
(cherry picked from commit 7f82b6a219)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-22 10:35:25 +03:00
Robert Lubos
fcd271d0dc net: mqtt: Fix possible socket leak with websocket transport
In case underlying TCP/TLS connection is already down, the
websocket_disconnect() call is expected to fail, as it involves
communication. Therefore, mqtt_client_websocket_disconnect() should not
quit early in such cases, as it could lead to an underlying socket leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 4625fa713f)
2024-07-09 11:50:32 +01:00
Jared Kangas
b5d53e922f drivers: adc: lmp90xxx: fix checksum mismatch return value
During channel reads, zero is returned on CRC mismatches: the returned
error variable is not written to after a previous non-zero check. Return
-EIO to mirror other drivers' checksum validation behaviors.

Signed-off-by: Jared Kangas <kangas.jd@gmail.com>
(cherry picked from commit 8ec3c045f8)
2024-07-08 19:16:28 +03:00
Jamie McCrae
aa96c4d3cb cmake: modules: extensions: Fix dts watch file processing
Fixes and simplifies the handling of how the dts watch file is
processed

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 11c1f3de61)
2024-07-01 10:59:51 +01:00
Jamie McCrae
d32ad62356 cmake: modules: extension: Fix dts file watch
Fixes an issue in the code that processes the output file of a
compiler to see which files should be watched, the compiler can
combine multiple files into a single line instead of putting them
each on separate lines if the length of the file paths is short,
therefore account for this and split it up into multiple elements

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit f4cfb8cd96)
2024-07-01 10:59:51 +01:00
Johan Hedberg
1424b494cd Bluetooth: Host: Avoid processing "no change" encryption changes
If the new encryption state is the same as the old one, there's no point in
doing additional processing or callbacks. Simply log a warning and ignore
the HCI event in such a case.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
(cherry picked from commit bf363d7c3e)
2024-06-25 14:18:44 +01:00
Stephanos Ioannidis
48ba8b406e tests: kernel: thread_runtime_stats: Relax precision test for QEMU
This commit relaxes the idle event statistics test precision requirement
for emulated QEMU targets because the cycle counts may be inaccurate when
the host CPU is overloaded (e.g. when running tests with twister) and a
high failure rate is observed for this test in the CI.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 2b2dd01c38)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
75f737a5cc testsuite: ztest: Increase ZTEST_TEST_DELAY_MS to 5000
This commit increases the default value of `ZTEST_TEST_DELAY_MS` from 3000
to 5000 milliseconds because the current value of 3000ms may not be
sufficient for the hosts with lower CPU clock frequency (e.g. new Zephyr CI
runners with cost-effective processors).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 1bf751074d)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
316637f865 ci: footprint: Use zephyr-runner v2
This commit updates the footprint workflow to use the new zephyr-runner v2
CI runner deployment.

It also updates the workflow to use the `ci-repo-cache` Docker image, which
includes the Zephyr repository cache, because the node level repository
cache is no longer available in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
68b759a214 ci: bsim-tests: Use zephyr-runner v2
This commit updates the bsim-tests workflow to use the new zephyr-runner v2
CI runner deployment.

It also updates the workflow to use the `ci-repo-cache` Docker image, which
includes the Zephyr repository cache, because the node level repository
cache is no longer available in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 9f9a6c547b)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
3366400449 ci: clang: Prioritise remote Redis cache storage
This commit updates the clang workflow such that ccache only uses remote
Redis cache storage when available.

The purpose of this to reduce the individual runner local disk IOPS
requirement; thereby, reducing the overall load on the SAN.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 95e7eb31e6)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
a8ac372cee ci: clang: Use Redis remote storage for ccache
This commit updates the clang workflow to, when available, use Redis remote
storage backend for the ccache compilation cache data.

The Redis cache server is hosted in the Kubernetes cluster in which the
zephyr-runner pods run -- the Redis remote storage backend will be ignored
if the server is unavailable.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 4a2884c652)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
eb8acf9d37 ci: clang: Store ccache data in node cache
This commit updates the clang workflow to store ccache data in the
zephyr-runner v2 node cache.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit cd83f0724b)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
c1298b7af0 ci: clang: Use zephyr-runner v2
This commit updates the clang workflow to use the new zephyr-runner v2 CI
runner deployment.

It also updates the workflow to use the `ci-repo-cache` Docker image, which
includes the Zephyr repository cache, because the node level repository
cache is no longer available in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 64ca699fc8)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
c34def10af ci: codecov: Set twister timeout multiplier to 2
This commit sets the codecov workflow twister timeout multiplier to 2,
which effectively increases the default test timeout from 60 to 120
seconds, because the new cost-effective Zephyr runners may take longer to
execute tests and the default timeout is not sufficient for some tests to
complete.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 550bb4e4a6)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
d54f5337e3 ci: codecov: Prioritise remote Redis cache storage
This commit updates the codecov workflow such that ccache only uses remote
Redis cache storage when available.

The purpose of this to reduce the individual runner local disk IOPS
requirement; thereby, reducing the overall load on the SAN.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit a636c52b6a)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
43c538e8cc ci: codecov: Add --specs to ccache ignore option list
This commit adds the compiler `--specs=*` flag to the ccache ignore option
list because ccache is unable to resolve the toolchain-provided specs file
path and will consider source files to be uncacheable if it is unable to
read the specified specs file.

Note that adding `--specs=*` to the ignore option list is not a problem
because it is unlikely for the content of the toolchain libc spec file to
change without the compiler executable itself changing.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit ab9f6b456b)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
207639a3fd ci: codecov: Use Redis remote storage for ccache
This commit updates the codecov workflow to, when available, use Redis
remote storage backend for the ccache compilation cache data.

The Redis cache server is hosted in the Kubernetes cluster in which the
zephyr-runner pods run -- the Redis remote storage backend will be ignored
if the server is unavailable.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit b57f1b5a15)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
c641a3e2d0 ci: codecov: Store ccache data in node cache
This commit updates the codecov workflow to store ccache data in the
zephyr-runner v2 node cache.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 36b0b101d4)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
91a8ed6064 ci: codecov: Use zephyr-runner v2
This commit updates the codecov workflow to use the new zephyr-runner v2 CI
runner deployment.

It also updates the workflow to use the `ci-repo-cache` Docker image, which
includes the Zephyr repository cache, because the node level repository
cache is no longer available in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 354e290a23)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
a0aef88ee2 ci: codecov: Run on all zephyrproject-rtos organisation repositories
This commit updates the codecov workflow to run on all forks under the
zephyrproject-rtos organisation.

The purpose of this is mainly to simplify the process of testing of this
workflow under the zephyr-testing repository.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit c1bd5a613f)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
96c278e008 ci: footprint-tracking: Use zephyr-runner v2
This commit updates the bsim-tests workflow to use the new zephyr-runner v2
CI runner deployment.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 9838633c0e)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
dff8361d9a ci: doc-build: Use zephyr-runner v2
This commit updates the doc-build workflow to use the new zephyr-runner v2
CI runner deployment.

It also installs additional system packages that are not available by
default in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 2819c3526a)
2024-06-11 02:40:49 +09:00
Anas Nashif
24b9511fa5 ci: twister: increase matrix size for push jobs
Increase matrix size to 20 from 15 on push events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
(cherry picked from commit 9970724652)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
012e361818 ci: twister: Set build job timeout to 24 hours
This commit increases the twister build job timeout from the default value
of 6 hours to 24 hours because scheduled (weekly) build runs take longer
than 6 hours to complete.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 7df7e834d9)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
399f06e287 ci: twister: Set twister timeout multiplier to 2
This commit sets the twister timeout multiplier to 2, which effectively
increases the default test timeout from 60 to 120 seconds, because the new
cost-effective Zephyr runners may take longer to execute tests and the
default timeout is not sufficient for some tests to complete.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit de68ea7ce0)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
ab6606312d ci: twister: Prioritise remote Redis cache storage
This commit updates the twister workflow such that ccache only uses remote
Redis cache storage when available.

The purpose of this to reduce the individual runner local disk IOPS
requirement; thereby, reducing the overall load on the SAN.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 527435d642)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
0bc62cc4bc ci: twister: Add --specs to ccache ignore option list
This commit adds the compiler `--specs=*` flag to the ccache ignore option
list because ccache is unable to resolve the toolchain-provided specs file
path and will consider source files to be uncacheable if it is unable to
read the specified specs file.

Note that adding `--specs=*` to the ignore option list is not a problem
because it is unlikely for the content of the toolchain libc spec file to
change without the compiler executable itself changing.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit d3f9f391ad)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
491acd95c1 ci: twister: Use Redis remote storage for ccache
This commit updates the twister workflow to, when available, use Redis
remote storage backend for the ccache compilation cache data.

The Redis cache server is hosted in the Kubernetes cluster in which the
zephyr-runner pods run -- the Redis remote storage backend will be ignored
if the server is unavailable.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 3823f1f0db)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
4728630fe5 ci: twister: Store ccache data in node cache
This commit updates the twister workflow to store ccache data in the
zephyr-runner v2 node cache.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 1be3aacad3)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
411c7eb494 ci: twister: Print cloud service information
This commit updates the twister workflow jobs that run on the zephyr-runner
v2 to print the underlying cloud service information in the logs to help
trace and debug potential runner issues.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 9a9bebb9f9)
2024-06-11 02:40:49 +09:00
Stephanos Ioannidis
fd1972be62 ci: twister: Use zephyr-runner v2
This commit updates the twister workflow to use the new zephyr-runner v2 CI
runner deployment.

It also updates the workflow to use the `ci-repo-cache` Docker image, which
includes the Zephyr repository cache, because the node level repository
cache is no longer available in the zephyr-runner v2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
(cherry picked from commit 7c19bc70bf)
2024-06-11 02:40:49 +09:00
Sean Nyekjaer
af85375f11 dts: arm: st: mp1: fix exti interrupt numbering
Align interrupt numbering with RM0436 for STM32MP157.
This will allow EXTI interrupt for line 6, 7, 8, 9, 10 and 11.

Fixes: ff231fa20a ("dts: stm32: Populate new properties for exti nodes")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
(cherry picked from commit ede866440d)
2024-06-07 15:47:08 +03:00
Gerson Fernando Budke
77df4454f8 mgmt: updatehub: Fix mark for update
This fixes compatibility with recent bootutils API.

Fixes #69297

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
(cherry picked from commit 94cd46d6ef)
2024-06-02 20:58:00 +03:00
Gerson Fernando Budke
4507175d61 mgmt: updatehub: Fix json arrays
After the changes introduced by #50816 the UpdateHub could not decode
anymore the JSON object. This introduce missing parsing definitions
to allow JSON parser undertood the correct UpdateHub probe object.

Fixes #69297

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
(cherry picked from commit 5fb62ca960)
2024-06-02 20:58:00 +03:00
Henrik Brix Andersen
d3f72d7072 drivers: can: shell: print raw DLC when sending frame, not bytes
Print the raw DLC when enqueuing a CAN frame for sending, not the
corresponding number of bytes.

Fixes: #73309

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 6a070ee165)
2024-06-02 20:56:50 +03:00
Henrik Brix Andersen
76a15672e6 drivers: can: shell: fully initialize frame before sending
Zerorise the CAN frame before filling in data to ensure all data bytes are
initialized.

Fixes: #73309

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit fb4f67b775)
2024-06-02 20:56:50 +03:00
Henrik Brix Andersen
d47129f0f7 drivers: sensor: nxp: kinetis: temp: fix memset() length
Use the correct buffer size when calling memset().

Fixes: #73093

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 59402fd82e)
2024-05-25 11:21:42 +03:00
Henrik Brix Andersen
b3dc1ff89d drivers: sensors: nxp: kinetis: temp: select CONFIG_ADC
The NXP Kinetis temperature sensor depends on CONFIG_ADC. Make the driver
Kconfig select CONFIG_ADC to get better CI coverage (enabling the driver
when CONFIG_SENSOR is enabled without depending on CONFIG_ADC=y).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 0a49b788a4)
2024-05-25 11:21:42 +03:00
Henrik Brix Andersen
0e0cd2a0d7 drivers: can: mcan: enable transmitter delay compensation when possible
Enable Transmitter Delay Compensation whenever the data phase timing
parameters allow it.

Fixes: #70447

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit bfad7bc00e)
2024-04-05 00:00:48 +03:00
Henrik Brix Andersen
ee3fab469d drivers: can: add utility macro for calculating TDC offset
Add a utility macro for calculating the Transmitter Delay Compensation
(TDC) Offset using the sample point and CAN core clock prescaler specified
by a set of data phase timing parameters.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit a3631264d1)
2024-04-05 00:00:48 +03:00
Henrik Brix Andersen
927ab297ef dts: bindings: can: can-fd-controller: remove tx-delay-comp-offset prop
Remove the unused "tx-delay-comp-offset" property from the base CAN FD
controller devicetree binding.

Having a static Transmitter Delay Compensation (TDC) offset is useless.
The offset needs to match the data phase timing parameters in order to
properly configure the second sample point when transmitting CAN FD frames
with BRS enabled.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 744f20d005)
2024-04-05 00:00:48 +03:00
Henrik Brix Andersen
e6f480fc89 drivers: can: mcan: remove broken transmitter delay compensation support
Remove broken support for Transmitter Delay Compensation from the Bosch
M_CAN backend driver.

Even if this was enabled via Kconfig, the TDC bit in the DBTP register set
during driver initialization is overwritten in can_mcan_set_timing_data(),
turning TDC off.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit ec75dc2232)
2024-04-05 00:00:48 +03:00
Flavio Ceolin
d0d9125eec 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-04-05 00:00:12 +03:00
Fin Maaß
2c700c1b5e 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-27 10:46:50 +02:00
Yasushi SHOJI
e486e6ce62 drivers: sensor: ams_as5600: Fix calculation of fractional part
commit 98903d48c3 upstream.

The original calculation has two bugs. One is the calculated value, and the
other is that the value is not in one-millionth parts.

What the original calculation does is compute a scaled position value by
multiplying the raw sensor value (`dev_data->position`) by
`AS5600_FULL_ANGLE`, which represents a full rotation in degrees. It then
subtracts the product of the whole number of pulses (`val->val1`) and
`AS5600_PULSES_PER_REV` from this scaled position value.

    ((int32_t)dev_data->position * AS5600_FULL_ANGLE)
    - (val->val1 * AS5600_PULSES_PER_REV);

What you actually need is to extract the fractional part of the value by
taking the modulo of AS5600_PULSES_PER_REV from the scaled value of the
position.

   (((int32_t)dev_data->position * AS5600_FULL_ANGLE)
   % AS5600_PULSES_PER_REV)

Then convert the value to one-millionth part.

   * (AS5600_MILLION_UNIT / AS5600_PULSES_PER_REV);

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2024-03-18 18:34:16 +00:00
Jamie McCrae
cf24d48c52 scripts: snippets: Fix path output on windows
Fixes an issue with paths being output in windows-style with back
slashes, this causes issues for certain escape sequences when
cmake interprets them. Replace these paths with posix paths so
that they are not treated as possible escape sequences.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit b680a6ec72)
2024-03-13 18:35:16 +02:00
Marcin Gasiorek
95b772f231 net: ip: Fix for improper offset return by net_pkt_find_offset()
The original packet's link-layer destination and source address can be
stored in separately allocated memory. This allocated memory can be
placed just after pkt data buffers.
In case when `net_pkt_find_offset()` uses condition:
`if (buf->data <= ptr && ptr <= (buf->data + buf->len)) {`
the offset is set outside the packet's buffer and the function returns
incorrect offset instead of error code.
Finally the offset is used to set ll address in cloned packet, and
this can have unexpected behavior (e.g. crash when cursor will be set
to empty memory).

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
(cherry picked from commit fb99f65fe9)
2024-03-11 17:54:07 +00:00
Abram Early
0de7085475 scripts/requirements: bump imgtool to 2.0.0
Resolves incorrectly located `image_ok` tag in generated hex files when
CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE is used.

Fixes #64098

Signed-off-by: Abram Early <abram.early@gmail.com>
(cherry picked from commit 5dec4fcab8)
2024-03-05 17:35:07 +00:00
Henrik Brix Andersen
002392c646 drivers: can: mcan: fix handling of bus-off status events
Fix handling bus-off events in the Bosch M_CAN driver backend:
- Cancel all pending TX buffers when entering bus-off state
- Call all pending TX buffer callbacks with -ENETUNREACH when entering
  bus-off
- Automatically initiate bus-off recovery if
  CONFIG_CAN_AUTO_BUS_OFF_RECOVERY=y

Fixes: #68953

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 6e5c1ba3c1)
2024-03-05 17:35:00 +00:00
Vinayak Kariappa Chettimada
e867618593 Bluetooth: Controller: Fix extended scanning data length assertion
Fix assertion due to LLL scheduling of auxiliary PDU
reception was not considered in the ULL when checking for
accumulated data length exceeding the supported maximum scan
data length. This caused the auxiliary context to be release
while LLL was still active with scheduled PDU reception.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 4158d9523e)
2024-02-01 10:16:43 +02:00
Guillaume Gautier
48e9a63446 drivers: adc: stm32: do not disable adc after measurement
Do not disable the ADC after the end of the measurement to avoid systematic
enabling which is time-consuming in case the configuration is unchanged.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
(cherry picked from commit 62f1105550)
2024-02-01 10:05:13 +02:00
Jamie McCrae
bc7d3dcc25 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:09:52 -08:00
Jukka Rissanen
62e3c7d871 tests: net: dhcpv6: 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 fa0e04e2ed)
2024-01-09 13:09:33 -08:00
Jukka Rissanen
bc69b8054b 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-09 13:09:33 -08:00
Jukka Rissanen
a6f82ce330 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-09 13:09:33 -08:00
Jukka Rissanen
f5f896f5c9 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)
2023-12-29 10:50:03 +00:00
Jukka Rissanen
325c922846 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)
2023-12-29 10:50:03 +00:00
Yong Cong Sin
5b999233ef scripts: build: gen_isr_tables: add some debug prints
Add some debug prints for the interrupts bits and bitmasks
in each level.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
(cherry picked from commit 0884a33ee3)
2023-12-27 16:04:50 +00:00
Yong Cong Sin
e231b667aa scripts: build: gen_isr_tables: change naming of bitmask variables
Rename the bitmask variables from `*_LVL_INTERRUPTS` to
`INTERRUPT_LVL_BITMASK[]` array to be consistent with
`INTERRUPT_BITS`, making it easier to loop over the bitmasks.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
(cherry picked from commit b4db285c1f)
2023-12-27 16:04:50 +00:00
Yong Cong Sin
db5475da27 scripts: build: gen_isr_tables: fix calculation of THIRD_LVL_INTERRUPTS
The calculation of `THIRD_LVL_INTERRUPTS` bitmask in the
`update_masks()` function is wrong, the number of bits to shift
should be the sum of the first two levels.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
(cherry picked from commit 56570cc8c1)
2023-12-27 16:04:50 +00:00
Flavio Ceolin
64e2ec47cb settings: shell: Fix possible buffer overflow
Checks the size of the given string before copying it to internal
buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 8977784afe)
2023-12-21 10:00:28 +00:00
Henrik Brix Andersen
b7dae51454 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-21 10:00:16 +00:00
Yuval Peress
e9f997e2a1 llvm: Allow llvm-readelf
Enable multiple names for the readelf program under llvm

Signed-off-by: Yuval Peress <peress@google.com>
(cherry picked from commit 3ddd36ff77)
2023-12-21 10:00:07 +00:00
Yong Cong Sin
f91ebabb28 boards: arm: Add RTC clock source for mikroe_mini_m4_for_stm32
The `mikroe_mini_m4_for_stm32` board doesn't have its RTC node
enabled, and is failing the following test:

`tests/benchmarks/footprints/benchmark.kernel.footprints.pm`

This board seems to have been missed out from 44b8370, let's
enable the rtc & clk_lsi here.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
(cherry picked from commit 54573e7c4c)
2023-12-18 17:27:00 +00:00
Christopher Friedt
15ada1522f doc: posix: structural reorganization of posix docs
Revise the structure of the POSIX API docs. This separates
related items out to dedicated pages. Further improvements
could yet be made - e.g. using the 'collapse' feature to
expand and collapse large sections of text or tables.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 3b45235887)
2023-12-07 16:15:03 +00:00
Grant Ramsay
2d8508ba32 drivers: ethernet: Fix eth_ivshmem shared memory mapping
This driver assumed the ivshmem-v2 output sections would be mapped
contiguously, which is no longer true.

Modify eth_ivshmem to treat each output section independently

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 82644a31c2)
2023-12-04 14:27:26 +02:00
Grant Ramsay
469b2051ab drivers: virtualization: Map ivshmem-v2 sections individually
Recent changes to the arm64 MMU code mean that you can no longer map
R/O memory as R/W. Mapping R/W memory now causes a cache invalidation
instruction (DC IVAC) that requires write permissions or else a fault
is generated.

Modify ivshmem-v2 to map each R/O and R/W section individually

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
(cherry picked from commit 64cc0764ee)
2023-12-04 14:27:26 +02:00
Yong Cong Sin
6e4539f924 driver: intc: plic: fix trigger type register bit calculation
The bit position calculation for the trigger type is wrong,
fix that.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-04 14:26:21 +02:00
Pieter De Gendt
60c661dfc8 net: ip: icmp: Cleanup packet on failed priority check
A network memory leak would occur if the priority check fails.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
(cherry picked from commit 473cc03c38)
2023-12-01 11:00:22 +02:00
Christopher Friedt
edad58e168 tests: posix: add tests to ensure pthread_key_delete() works
Ensure that the correct key is deleted via pthread_key_delete().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit 0e11bcf5a0)
2023-11-28 20:11:17 +02:00
Christopher Friedt
8a911d6bdd posix: pthread: ensure pthread_key_delete() removes correct key
Previously, `pthread_key_delete()` was only ever deleting key 0
rather than the key corresponding to the provided argument.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
(cherry picked from commit a89fa32dac)
2023-11-28 20:11:17 +02:00
Jamie McCrae
014571b046 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-11-28 20:10:30 +02:00
Jonathan Rico
49f04fd840 Revert "Bluetooth: att: use a dedicated metadata struct for RSP PDUs"
This reverts commit 14858d96d8.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
(cherry picked from commit dfd7624270)
2023-11-24 14:16:24 +02:00
Jonathan Rico
456496efa6 Revert "Bluetooth: att: re-use REQ buf for RSP"
This reverts commit aa7954bd47.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
(cherry picked from commit bd9c35b496)
2023-11-24 14:16:24 +02:00
Jonathan Rico
7eb8be25e3 Revert "Bluetooth: att: don't re-use the ATT buffer for confirmations"
This reverts commit 4cd0748a40.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
(cherry picked from commit 530e845f92)
2023-11-24 14:16:24 +02:00
Henrik Brix Andersen
8415778a1a 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 08:47:06 +00:00
Henrik Brix Andersen
aff7cbe65e 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 08:47:06 +00:00
Henrik Brix Andersen
54c11a17f5 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 08:46:56 +00:00
Declan Snyder
86517b3353 soc: lpc55xxx: Fix system hw clock cycle rate
Commit c6e3bac4f changed the core clock frequency of LPC55XXX series.
That clock is used by the cortex-m systick timer, which is the
default timer used for system time in zephyr on this series.
The bug is that the config SYS_CLOCK_HW_CYCLES_PER_SEC default was not
updated on the affected platforms to account for this change, so system
time is currently recorded as 150% of reality. Fix this by changing the
kconfig to be set automatically at SOC level and remove board defaults.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
(cherry picked from commit 4d654250a5)
2023-11-13 16:13:06 +02:00
Mykola Kvach
214b74e103 arch: arm64: avoid invalidating of RO mem after mem map
The Cortex ARM documentation states that the DC IVAC instruction
requires write access permission to the virtual address (VA);
otherwise, it may generate a permission fault.

Therefore, it is needed to avoid invalidating read-only memory
after the memory map operation.

This issue has been produced by commit c9b534c.
This commit resolves the issue #64758.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
(cherry picked from commit c4ffadb0b6)
2023-11-13 11:47:43 +02:00
Daniel DeGrasse
6b12e12312 drivers: flash: mcux_flexspi_nor: Remove flash reads while programming
Care must be taken to avoid any flash access while programming the flash
attached to the FlexSPI either via executing XIP code or reading RO data.

Remove locations where a constant device pointer might be dereferenced
within the mcux_flexspi_nor driver, to help avoid RWW hazards.

Fixes #64702

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-11-11 19:05:13 +02:00
Yong Cong Sin
5a11de06b6 kernel: mmu: fix compilation warnings when memory address and size are 0
When both the memory base address & its size are zero, the
assertions test will be comparing an unsigned int against zero
which result in compilation warning, and will be raised to
error in Twister

Fix them with more conditional compilations.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
(cherry picked from commit 3ed8c4d64b)
2023-11-10 19:33:50 +02:00
Vinayak Kariappa Chettimada
086b5b96db Bluetooth: Controller: Fix missing ext adv terminate event
Fix missing Extended Advertising terminate event and
advertising scheduling not being stopped.

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

The fix now generates the done extra event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f64d123a3d)
2023-11-10 19:31:36 +02:00
Vinayak Kariappa Chettimada
abd9ecdd23 Bluetooth: Controller: Fix periodic advertising sync window
Fix periodic advertising sync window calculation to include
the scheduling resolution margin, i.e. be double as with
the event jitter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 05c85ddbcf)
2023-11-10 19:31:36 +02:00
Fabio Baltieri
a14c841af4 docs: migration-guide-3.5: add a note about optional modules
Add a note about modules moved to optional and how to enable them again.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
(cherry picked from commit 125e0e8741)
2023-11-06 11:11:18 +00:00
Jukka Rissanen
b872bca7c1 tests: net: tcp: Add test case for connect timeout
This checks that if connect() timeouts, we check TCP pointer
properly in select() and poll() in order to catch the situation.

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

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 5bf18e39ad)
2023-11-06 10:30:26 +02:00
Jukka Rissanen
91bf1b4ed4 net: tcp: Set errno properly if connecting to non listening port
If we try to connect to a port which no socket is listening to,
we will get a packet with "ACK | RST" flags set. In this case
the errno should be ECONNREFUSED instead of ETIMEDOUT like we
used to return earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit ec4973dd15)
2023-11-06 10:30:26 +02:00
Jukka Rissanen
954bd84d36 net: sockets: Add SO_ERROR socket option to SOL_SOCKET level
Return the last socket error to user.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit b864880000)
2023-11-06 10:30:26 +02:00
Jukka Rissanen
f9f78b4415 net: tcp: Increment ref count in initial SYN
Increase reference count already when initial SYN is sent.
This way the tcp pointer in net_context is fully valid for
the duration of the connection.

Fixes #63952

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit fd1c226cd8)
2023-11-06 10:30:26 +02:00
Johan Hedberg
94ab004c84 acpi: Fix ACPI PCI bus handle
The PRT bus name for most (especially older) platforms is _SB.PCI0. Only
newer platforms use something else (like _SB.PC00).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit ff0b803334)
2023-11-02 11:04:38 +02:00
Johan Hedberg
a000c24e64 acpi: Fix using correct buffer length for irq rt_table
We should use the given rt_size variable to indicate the size of
rt_table.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit b95931859e)
2023-11-02 11:04:38 +02:00
Johan Hedberg
da3858eaaf acpi: Fix ACPICA initialization routine order
The upstream ACPICA example initialization order does AcpiLoadTables()
before calling AcpiEnableSubsystem(), so use this order in Zephyr too.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit ab46cef69f)
2023-11-02 11:04:38 +02:00
Johan Hedberg
98f09e3442 acpi: Fix trying to register a system memory handler
ACPICA itself already registers its own handler (which works perfectly
fine for our purposes). Furthermore, ACPICA will always fail trying to
register another handler, unless the previous one is explicitly cleared
(which is something the Zephyr code didn't do).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit a0203d1b20)
2023-11-02 11:04:38 +02:00
Johan Hedberg
c65b84d2aa boards: x86: Increase minimum system heap size for ACPI
ACPICA initialization takes considerably more than 32k. E.g. on
up_squared the utilization is 400-500k, qemu_x86_64 about 120k and on
EHL about 1.5M. Increase the default on these platforms to be big enough
if ACPI is enabled.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit 542f95b811)
2023-11-02 11:04:38 +02:00
Johan Hedberg
6c80bf4811 manifest: Update to latest ACPICA Zephyr fixes
There are a couple of important fixes without which ACPICA doesn't work
on all supported platforms.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
(cherry picked from commit c92c7ab873)
2023-11-02 11:04:38 +02:00
Tomasz Bursztyka
6f207d4d06 arch/x86: Remove useless legacy ACPI code
ACPI is now being handled through ACPICA.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
(cherry picked from commit f5ce4ddc79)
2023-11-01 20:01:58 +02:00
Tomasz Bursztyka
79a538dad0 lib/acpi: Fix the behavior to fit with how it used to be
z_acpi_get_cpu() used to retrieve the local apic on enabled CPU, where
n was about the n'th enabled CPU, not just the n'th local apic.
The system indeed keeps local apic info also about non-enabled CPU,
and we don't care about these as there is nothing to do about it.

This issue exists on up_squared board for instance, but it's a common
one anyway.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
(cherry picked from commit c294b7d270)
2023-11-01 20:01:58 +02:00
Pedro Sousa
3b52bc7b85 kernel: timer: Fix race condition in k_timer_start
The documentation suggests that k_timer_start can be invoked from ISR
and preemptive contexts, however, an assertion failure occurs if one
k_timer_start call preempts another for the same timer instance. This
commit mitigates the issue by implementing a spinlock throughout the
k_timer_start function, ensuring thread-safety.

Fixes: #62908

Signed-off-by: Pedro Sousa <sousapedro596@gmail.com>
(cherry picked from commit 4207f4add8)
2023-11-01 10:59:39 +00:00
Jay Vasanth
a2bb849472 microchip: ps2: fix compilation error
fix compilation error when CONFIG_PM_DEVICE is not enabled

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
(cherry picked from commit 7c43370997)
2023-10-31 15:18:35 +02:00
Jamie McCrae
45c19a9917 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 14:10:50 +02:00
Robert Lubos
7ff91648cd tests: lib: thrift: Fix timing issues with TCP
The test delegates putting the server socket into listening (i. e.
calling listen() on the socket) to a separate thread, which did have a
chance to run before client attempted to establish TCP connection.

This was not visible before, as we did not reply with RST to a
connection attempt on a closed port, so the connection was eventually
establish after SYN retransmission. But as we do reject such a
connection now with RST, the connection attempt failed. Therefore, a
small delay was added after spawning the server thread, to give it a
chance to configure the server socket.

Additionally, lower the CONFIG_NET_TCP_TIME_WAIT_DELAY value so that TCP
contexts are released earlier, and add a respective delay in the test
teardown function. Not doing so also triggered unneeded SYN
retransmissions, as there were no enough TCP context to accept the
incoming connection, before freeing the resources allocated for the
previous one.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 822a82d619)
2023-10-31 14:10:11 +02:00
Robert Lubos
2560cea906 net: tcp: Add Kconfig option to enable TCP RST on unbound ports
Add Kconfig option to control TCP RST behavior on connection attempts on
unbound ports. If enabled, TCP stack will reply with RST packet (enabled
by default).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 4ea3d247d0)
2023-10-31 14:10:11 +02:00
Robert Lubos
76b340d210 tests: net: tcp: Add tests to cover improved RST handling
Add tests which verify that Zephyr's TCP stack replies with RST packet
as expected.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 2b601b34ff)
2023-10-31 14:10:11 +02:00
Robert Lubos
b110f80cc8 net: tcp: Send RST reply for unexpected TCP packets
Send RST as a reply for unexpected TCP packets in the following
scenarios:
1) Unexpected ACK value received during handshake (connection still open
   on the peer side),
2) Unexpected data packet on a listening port (accepted connection
   closed),
3) SYN received on a closed port.

This allows the other end to detect that the connection is no longer
valid (for example due to reboot) and release the resources.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 95d9543e2e)
2023-10-31 14:10:11 +02:00
Robert Lubos
796b8c7f96 net: tcp: Add helper function to send RST packet w/o active connection
Add a helper function which allows to send a RST packet in response to
an unexpected TCP packet, w/o associated connection or net context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit a28215d028)
2023-10-31 14:10:11 +02:00
Flavio Ceolin
2d4916cf78 ztest: Do not abort k_current_get from ISR
Do not abort k_current_get() from ISR.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit c166685fcf)
2023-10-31 14:09:27 +02:00
Flavio Ceolin
9eee5b3681 treewide: Add CODE_UNREACHABLE after k_thread_abort(current)
Compiler can't tell that k_thread_abort() won't return and issues a
warning unless we tell it that control never gets this far.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 564adad952)
2023-10-31 14:09:27 +02:00
Sophie 'Tyalie' Friedrich
a802b34af6 boards: esp23: m5stack_core2: Fix i2c1 pin definitions
For GPIO pins above 31, one needs to use the `&gpio1` (or similar)
definition, as zephyr seperates GPIOs into chunks of 32.

Signed-off-by: Sophie 'Tyalie' Friedrich <dev@flowerpot.me>
(cherry picked from commit 7857996e90)
2023-10-31 14:08:41 +02:00
Sophie 'Tyalie' Friedrich
933e579728 boards: xiao_esp32s3: Fix connector definition
Previously the seed connector was defined incorrectly and as such D6 and D7
weren't usable as i.e. inputs. Zephyr distinguishes GPIO pins in blocks of
32, a distinction the ESP32 reference manual doesn't do. As such one needs
to write `&gpio1 11` in order to access `GPIO43`.

Signed-off-by: Sophie 'Tyalie' Friedrich <dev@flowerpot.me>
(cherry picked from commit 70cb934959)
2023-10-31 14:08:41 +02:00
Dave Desrochers
480c64d3a7 arch: Fixes potential mangled isr table when SHARED_INTERRUPTS is enabled
The linker was optimizing away z_shared_isr() the zephyr_pre0.elf image
since the function is not used. However, zephyr.elf does use this
function via isr_tables.c file, generated after zephyr_pre0.elf.

This difference caused a shift in all symbol addresses by the size of the
z_shared_isr() function. isr_tables.c had pointers for zephyr_pre0.elf.
The build system assumes the ISR addresses are the same between both .elf
files, when in fact, before this fix, they were not.

When run on a device, interrupts were calling non-interrupt functions.

Signed-off-by: Dave Desrochers <dave@intercreate.io>
(cherry picked from commit 68b9cea690)
2023-10-31 14:07:58 +02:00
Rodrigo Peixoto
ebe1ef02d3 doc: zbus: fix VDED notification sequence figure
The figure and table related to the VDED notification sequence were wrong.
It fixes that by changing the image and adjusting the table content.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
(cherry picked from commit 32bdb24a92)
2023-10-31 14:06:47 +02:00
Alberto Escolar Piedras
63a769afad tests bsim cis: Fix sim_id collision
This test was reusing the sim_id from an l2cap test,
which was colliding with the corresponding l2cap test
when they were run in parallel.
Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
(cherry picked from commit e934e49aa9)
2023-10-31 11:19:51 +00:00
Flavio Ceolin
ced26e2340 doc: release: 3.5: Add info about CVE-2023-5753
Update 3.5 release notes with published CVE

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 27dedec4cc)
2023-10-31 10:55:23 +01:00
Flavio Ceolin
46cf4486fa doc: vuln: Add information about CVE-2023-5753
Information about CVE-2023-5753

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 31a92fc5e3)
2023-10-31 10:55:23 +01:00
Henrik Brix Andersen
3a67f3d906 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-27 11:36:03 +01:00
150 changed files with 3062 additions and 1319 deletions

View File

@@ -28,12 +28,11 @@ concurrency:
jobs:
bsim-test:
if: github.repository_owner == 'zephyrproject-rtos'
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/zephyrproject:/github/cache/zephyrproject
env:
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3
@@ -52,10 +51,16 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Clone cached Zephyr repository
continue-on-error: true
run: |
git clone --shared /github/cache/zephyrproject/zephyr .
git clone --shared /repo-cache/zephyrproject/zephyr .
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
- name: Checkout
@@ -75,7 +80,7 @@ jobs:
west init -l . || true
west config manifest.group-filter -- +ci
west config --global update.narrow true
west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/zephyrproject)
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
west forall -c 'git reset --hard HEAD'
- name: Check common triggering files

View File

@@ -9,18 +9,20 @@ concurrency:
jobs:
clang-build:
if: github.repository_owner == 'zephyrproject-rtos'
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/zephyrproject:/github/cache/zephyrproject
strategy:
fail-fast: false
matrix:
platform: ["native_posix"]
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3
CCACHE_DIR: /node-cache/ccache-zephyr
CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3"
CCACHE_REMOTE_ONLY: "true"
LLVM_TOOLCHAIN_PATH: /usr/lib/llvm-16
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
BASE_REF: ${{ github.base_ref }}
@@ -35,10 +37,16 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Clone cached Zephyr repository
continue-on-error: true
run: |
git clone --shared /github/cache/zephyrproject/zephyr .
git clone --shared /repo-cache/zephyrproject/zephyr .
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
- name: Checkout
@@ -64,7 +72,7 @@ jobs:
# So first retry to update, if that does not work, remove all modules
# and start over. (Workaround until we implement more robust module
# west caching).
west update --path-cache /github/cache/zephyrproject 2>&1 1> west.log || west update --path-cache /github/cache/zephyrproject 2>&1 1> west2.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/zephyrproject)
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west2.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
- name: Check Environment
run: |
@@ -73,31 +81,12 @@ jobs:
gcc --version
ls -la
- name: Prepare ccache timestamp/data
id: ccache_cache_timestamp
shell: cmake -P {0}
- name: Set up ccache
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
string(REPLACE "/" "_" repo ${{github.repository}})
string(REPLACE "-" "_" repo2 ${repo})
file(APPEND $ENV{GITHUB_OUTPUT} "repo=${repo2}\n")
- name: use cache
id: cache-ccache
uses: zephyrproject-rtos/action-s3-cache@v1.2.0
with:
key: ${{ steps.ccache_cache_timestamp.outputs.repo }}-${{ github.ref_name }}-clang-${{ matrix.platform }}-ccache
path: /github/home/.cache/ccache
aws-s3-bucket: ccache.zephyrproject.org
aws-access-key-id: ${{ vars.AWS_CCACHE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CCACHE_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: ccache stats initial
run: |
mkdir -p /github/home/.cache
test -d github/home/.cache/ccache && rm -rf /github/home/.cache/ccache && mv github/home/.cache/ccache /github/home/.cache/ccache
ccache -M 10G -s
mkdir -p ${CCACHE_DIR}
ccache -M 10G
ccache -p
ccache -z -s -vv
- name: Run Tests with Twister
id: twister
@@ -118,10 +107,10 @@ jobs:
echo "report_needed=0" >> $GITHUB_OUTPUT
fi
- name: ccache stats post
- name: Print ccache stats
if: always()
run: |
ccache -s
ccache -p
ccache -s -vv
- name: Upload Unit Test Results
if: always() && steps.twister.outputs.report_needed != 0

View File

@@ -10,19 +10,23 @@ concurrency:
jobs:
codecov:
if: github.repository == 'zephyrproject-rtos/zephyr'
runs-on: zephyr-runner-linux-x64-4xlarge
if: github.repository_owner == 'zephyrproject-rtos'
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/zephyrproject:/github/cache/zephyrproject
strategy:
fail-fast: false
matrix:
platform: ["native_posix", "qemu_x86", "unit_testing"]
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3
CCACHE_DIR: /node-cache/ccache-zephyr
CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3"
CCACHE_REMOTE_ONLY: "true"
# `--specs` is ignored because ccache is unable to resovle the toolchain specs file path.
CCACHE_IGNOREOPTIONS: '--specs=*'
steps:
- name: Apply container owner mismatch workaround
run: |
@@ -32,6 +36,12 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
@@ -39,7 +49,7 @@ jobs:
- name: Clone cached Zephyr repository
continue-on-error: true
run: |
git clone --shared /github/cache/zephyrproject/zephyr .
git clone --shared /repo-cache/zephyrproject/zephyr .
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
- name: checkout
@@ -57,30 +67,13 @@ jobs:
cmake --version
gcc --version
ls -la
- name: Prepare ccache keys
id: ccache_cache_prop
shell: cmake -P {0}
run: |
string(REPLACE "/" "_" repo ${{github.repository}})
string(REPLACE "-" "_" repo2 ${repo})
file(APPEND $ENV{GITHUB_OUTPUT} "repo=${repo2}\n")
- name: use cache
id: cache-ccache
uses: zephyrproject-rtos/action-s3-cache@v1.2.0
with:
key: ${{ steps.ccache_cache_prop.outputs.repo }}-${{github.event_name}}-${{matrix.platform}}-codecov-ccache
path: /github/home/.cache/ccache
aws-s3-bucket: ccache.zephyrproject.org
aws-access-key-id: ${{ vars.AWS_CCACHE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CCACHE_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: ccache stats initial
- name: Set up ccache
run: |
mkdir -p /github/home/.cache
test -d github/home/.cache/ccache && mv github/home/.cache/ccache /github/home/.cache/ccache
ccache -M 10G -s
mkdir -p ${CCACHE_DIR}
ccache -M 10G
ccache -p
ccache -z -s -vv
- name: Run Tests with Twister (Push)
continue-on-error: true
@@ -88,7 +81,8 @@ jobs:
export ZEPHYR_BASE=${PWD}
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
mkdir -p coverage/reports
./scripts/twister --force-color -N -v --filter runnable -p ${{ matrix.platform }} --coverage -T tests
./scripts/twister --force-color -N -v --filter runnable -p ${{ matrix.platform }} \
--coverage -T tests --timeout-multiplier 2
- name: Generate Coverage Report
run: |
@@ -98,10 +92,10 @@ jobs:
--remove lcov.pre.info *generated* \
-o coverage/reports/${{ matrix.platform }}.info --rc lcov_branch_coverage=1
- name: ccache stats post
- name: Print ccache stats
if: always()
run: |
ccache -s
ccache -p
ccache -s -vv
- name: Upload Coverage Results
if: always()

View File

@@ -35,13 +35,29 @@ env:
jobs:
doc-build-html:
name: "Documentation Build (HTML)"
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
timeout-minutes: 45
concurrency:
group: doc-build-html-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: install-pkgs
run: |
sudo apt-get update
sudo apt-get install -y wget python3-pip git ninja-build graphviz
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: checkout
uses: actions/checkout@v3
with:
@@ -59,13 +75,22 @@ jobs:
git rebase origin/${BASE_REF}
git log --graph --oneline HEAD...${PR_HEAD}
- name: install-pkgs
- name: checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Rebase
continue-on-error: true
env:
BASE_REF: ${{ github.base_ref }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
run: |
sudo apt-get update
sudo apt-get install -y ninja-build graphviz
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
echo "${PWD}/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
git config --global user.email "actions@zephyrproject.org"
git config --global user.name "Github Actions"
git rebase origin/${BASE_REF}
git log --graph --oneline HEAD...${PR_HEAD}
- name: cache-pip
uses: actions/cache@v3
@@ -131,7 +156,8 @@ jobs:
doc-build-pdf:
name: "Documentation Build (PDF)"
if: github.event_name != 'pull_request'
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container: texlive/texlive:latest
timeout-minutes: 60
concurrency:
@@ -139,6 +165,12 @@ jobs:
cancel-in-progress: true
steps:
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: checkout
uses: actions/checkout@v3

View File

@@ -22,10 +22,11 @@ concurrency:
jobs:
footprint-tracking:
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
if: github.repository_owner == 'zephyrproject-rtos'
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false
@@ -41,6 +42,12 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

View File

@@ -8,10 +8,11 @@ concurrency:
jobs:
footprint-delta:
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
if: github.repository == 'zephyrproject-rtos/zephyr'
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false
@@ -27,6 +28,12 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

View File

@@ -22,19 +22,18 @@ concurrency:
jobs:
twister-build-prep:
if: github.repository_owner == 'zephyrproject-rtos'
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/zephyrproject:/github/cache/zephyrproject
outputs:
subset: ${{ steps.output-services.outputs.subset }}
size: ${{ steps.output-services.outputs.size }}
fullrun: ${{ steps.output-services.outputs.fullrun }}
env:
MATRIX_SIZE: 10
PUSH_MATRIX_SIZE: 15
PUSH_MATRIX_SIZE: 20
DAILY_MATRIX_SIZE: 80
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3
BSIM_OUT_PATH: /opt/bsim/
@@ -51,11 +50,17 @@ jobs:
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Clone cached Zephyr repository
if: github.event_name == 'pull_request_target'
continue-on-error: true
run: |
git clone --shared /github/cache/zephyrproject/zephyr .
git clone --shared /repo-cache/zephyrproject/zephyr .
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
- name: Checkout
@@ -77,7 +82,7 @@ jobs:
west init -l . || true
west config manifest.group-filter -- +ci,+optional
west config --global update.narrow true
west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/zephyrproject)
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
west forall -c 'git reset --hard HEAD'
- name: Generate Test Plan with Twister
@@ -118,29 +123,40 @@ jobs:
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
twister-build:
runs-on: zephyr-runner-linux-x64-4xlarge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
needs: twister-build-prep
if: needs.twister-build-prep.outputs.size != 0
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.5
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.5.20231213
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/zephyrproject:/github/cache/zephyrproject
strategy:
fail-fast: false
matrix:
subset: ${{fromJSON(needs.twister-build-prep.outputs.subset)}}
timeout-minutes: 1440
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.16.3
CCACHE_DIR: /node-cache/ccache-zephyr
CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3"
CCACHE_REMOTE_ONLY: "true"
# `--specs` is ignored because ccache is unable to resolve the toolchain specs file path.
CCACHE_IGNOREOPTIONS: '--specs=*'
BSIM_OUT_PATH: /opt/bsim/
BSIM_COMPONENTS_PATH: /opt/bsim/components
TWISTER_COMMON: ' --force-color --inline-logs -v -N -M --retry-failed 3 '
TWISTER_COMMON: ' --force-color --inline-logs -v -N -M --retry-failed 3 --timeout-multiplier 2 '
DAILY_OPTIONS: ' -M --build-only --all --show-footprint'
PR_OPTIONS: ' --clobber-output --integration'
PUSH_OPTIONS: ' --clobber-output -M --show-footprint'
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
BASE_REF: ${{ github.base_ref }}
steps:
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: Apply container owner mismatch workaround
run: |
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
@@ -152,7 +168,7 @@ jobs:
- name: Clone cached Zephyr repository
continue-on-error: true
run: |
git clone --shared /github/cache/zephyrproject/zephyr .
git clone --shared /repo-cache/zephyrproject/zephyr .
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
- name: Checkout
@@ -176,7 +192,7 @@ jobs:
west init -l . || true
west config manifest.group-filter -- +ci,+optional
west config --global update.narrow true
west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/zephyrproject)
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
west forall -c 'git reset --hard HEAD'
- name: Check Environment
@@ -188,32 +204,12 @@ jobs:
echo "github.base_ref: ${{ github.base_ref }}"
echo "github.ref_name: ${{ github.ref_name }}"
- name: Prepare ccache timestamp/data
id: ccache_cache_timestamp
shell: cmake -P {0}
- name: Set up ccache
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
string(REPLACE "/" "_" repo ${{github.repository}})
string(REPLACE "-" "_" repo2 ${repo})
file(APPEND $ENV{GITHUB_OUTPUT} "repo=${repo2}\n")
- name: use cache
id: cache-ccache
uses: zephyrproject-rtos/action-s3-cache@v1.2.0
continue-on-error: true
with:
key: ${{ steps.ccache_cache_timestamp.outputs.repo }}-${{ github.ref_name }}-${{github.event_name}}-${{ matrix.subset }}-ccache
path: /github/home/.cache/ccache
aws-s3-bucket: ccache.zephyrproject.org
aws-access-key-id: ${{ vars.AWS_CCACHE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CCACHE_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: ccache stats initial
run: |
mkdir -p /github/home/.cache
test -d github/home/.cache/ccache && rm -rf /github/home/.cache/ccache && mv github/home/.cache/ccache /github/home/.cache/ccache
ccache -M 10G -s
mkdir -p ${CCACHE_DIR}
ccache -M 10G
ccache -p
ccache -z -s -vv
- if: github.event_name == 'push'
name: Run Tests with Twister (Push)
@@ -256,10 +252,10 @@ jobs:
fi
fi
- name: ccache stats post
- name: Print ccache stats
if: always()
run: |
ccache -p
ccache -s
ccache -s -vv
- name: Upload Unit Test Results
if: always()

View File

@@ -731,6 +731,14 @@ static inline void add_arm_mmu_region(struct arm_mmu_ptables *ptables,
static inline void inv_dcache_after_map_helper(void *virt, size_t size, uint32_t attrs)
{
/*
* DC IVAC instruction requires write access permission to the VA,
* otherwise it can generate a permission fault
*/
if ((attrs & MT_RW) != MT_RW) {
return;
}
if (MT_TYPE(attrs) == MT_NORMAL || MT_TYPE(attrs) == MT_NORMAL_WT) {
sys_cache_data_invd_range(virt, size);
}
@@ -987,6 +995,7 @@ void arch_mem_map(void *virt, uintptr_t phys, size_t size, uint32_t flags)
case K_MEM_CACHE_WB:
case K_MEM_CACHE_WT:
mem_flags = (mem_flags == K_MEM_CACHE_WB) ? MT_NORMAL : MT_NORMAL_WT;
mem_flags |= (flags & K_MEM_PERM_RW) ? MT_RW : 0;
inv_dcache_after_map_helper(virt, size, mem_flags);
default:
break;

View File

@@ -1,448 +0,0 @@
/*
* Copyright (c) 2020 Intel Corporation
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/arch/x86/acpi.h>
#include <zephyr/arch/x86/efi.h>
static struct acpi_rsdp *rsdp;
static bool is_rsdp_searched;
static struct acpi_dmar *dmar;
static bool is_dmar_searched;
static bool check_sum(struct acpi_sdt *t)
{
uint8_t sum = 0U, *p = (uint8_t *)t;
for (int i = 0; i < t->length; i++) {
sum += p[i];
}
return sum == 0U;
}
static void find_rsdp(void)
{
uint8_t *bda_seg, *zero_page_base;
uint64_t *search;
uintptr_t search_phys, rsdp_phys;
size_t search_length = 0U, rsdp_length;
if (is_rsdp_searched) {
/* Looking up for RSDP has already been done */
return;
}
/* Let's first get it from EFI, if enabled */
if (IS_ENABLED(CONFIG_X86_EFI)) {
rsdp_phys = (uintptr_t)efi_get_acpi_rsdp();
if (rsdp_phys != 0UL) {
/* See at found label why this is required */
search_length = sizeof(struct acpi_rsdp);
z_phys_map((uint8_t **)&search, rsdp_phys, search_length, 0);
rsdp = (struct acpi_rsdp *)search;
goto found;
}
}
/* We never identity map the NULL page, so need to map it before
* it can be accessed.
*/
z_phys_map(&zero_page_base, 0, 4096, 0);
/* Physical (real mode!) address 0000:040e stores a (real
* mode!!) segment descriptor pointing to the 1kb Extended
* BIOS Data Area.
*
* We had to memory map this segment descriptor since it is in
* the NULL page. The remaining structures (EBDA etc) are identity
* mapped somewhere within the minefield of reserved regions in the
* first megabyte and are directly accessible.
*/
bda_seg = 0x040e + zero_page_base;
search_phys = (long)(((int)*(uint16_t *)bda_seg) << 4);
/* Unmap after use */
z_phys_unmap(zero_page_base, 4096);
/* Might be nothing there, check before we inspect.
* Note that EBDA usually is in 0x80000 to 0x100000.
*/
if ((POINTER_TO_UINT(search_phys) >= 0x80000UL) &&
(POINTER_TO_UINT(search_phys) < 0x100000UL)) {
search_length = 1024;
z_phys_map((uint8_t **)&search, search_phys, search_length, 0);
for (int i = 0; i < 1024/8; i++) {
if (search[i] == ACPI_RSDP_SIGNATURE) {
rsdp_phys = search_phys + i * 8;
rsdp = (void *)&search[i];
goto found;
}
}
z_phys_unmap((uint8_t *)search, search_length);
}
/* If it's not there, then look for it in the last 128kb of
* real mode memory.
*/
search_phys = 0xe0000;
search_length = 128 * 1024;
z_phys_map((uint8_t **)&search, search_phys, search_length, 0);
for (int i = 0; i < 128*1024/8; i++) {
if (search[i] == ACPI_RSDP_SIGNATURE) {
rsdp_phys = search_phys + i * 8;
rsdp = (void *)&search[i];
goto found;
}
}
z_phys_unmap((uint8_t *)search, search_length);
rsdp = NULL;
is_rsdp_searched = true;
return;
found:
/* Determine length of RSDP table.
* ACPI v2 and above uses the length field.
* Otherwise, just the size of struct itself.
*/
if (rsdp->revision < 2) {
rsdp_length = sizeof(*rsdp);
} else {
rsdp_length = rsdp->length;
}
/* Need to unmap search since it is still mapped */
if (search_length != 0U) {
z_phys_unmap((uint8_t *)search, search_length);
}
/* Now map the RSDP */
z_phys_map((uint8_t **)&rsdp, rsdp_phys, rsdp_length, 0);
is_rsdp_searched = true;
}
void *z_acpi_find_table(uint32_t signature)
{
uint8_t *mapped_tbl;
uint32_t length;
struct acpi_rsdt *rsdt;
struct acpi_xsdt *xsdt;
struct acpi_sdt *t;
uintptr_t t_phys;
bool tbl_found;
find_rsdp();
if (!rsdp) {
return NULL;
}
if (rsdp->rsdt_ptr != 0U) {
z_phys_map((uint8_t **)&rsdt, rsdp->rsdt_ptr, sizeof(*rsdt), 0);
tbl_found = false;
if (check_sum(&rsdt->sdt)) {
/* Remap the memory to the indicated length of RSDT */
length = rsdt->sdt.length;
z_phys_unmap((uint8_t *)rsdt, sizeof(*rsdt));
z_phys_map((uint8_t **)&rsdt, rsdp->rsdt_ptr, length, 0);
uint32_t *end = (uint32_t *)((char *)rsdt + rsdt->sdt.length);
/* Extra indirection required to avoid
* -Waddress-of-packed-member
*/
void *table_ptrs = &rsdt->table_ptrs[0];
for (uint32_t *tp = table_ptrs; tp < end; tp++) {
t_phys = (long)*tp;
z_phys_map(&mapped_tbl, t_phys, sizeof(*t), 0);
t = (void *)mapped_tbl;
if (t->signature == signature && check_sum(t)) {
tbl_found = true;
break;
}
z_phys_unmap(mapped_tbl, sizeof(*t));
}
}
z_phys_unmap((uint8_t *)rsdt, sizeof(*rsdt));
if (tbl_found) {
goto found;
}
}
if (rsdp->revision < 2) {
return NULL;
}
if (rsdp->xsdt_ptr != 0ULL) {
z_phys_map((uint8_t **)&xsdt, rsdp->xsdt_ptr, sizeof(*xsdt), 0);
tbl_found = false;
if (check_sum(&xsdt->sdt)) {
/* Remap the memory to the indicated length of RSDT */
length = xsdt->sdt.length;
z_phys_unmap((uint8_t *)xsdt, sizeof(*xsdt));
z_phys_map((uint8_t **)&xsdt, rsdp->xsdt_ptr, length, 0);
uint64_t *end = (uint64_t *)((char *)xsdt + xsdt->sdt.length);
/* Extra indirection required to avoid
* -Waddress-of-packed-member
*/
void *table_ptrs = &xsdt->table_ptrs[0];
for (uint64_t *tp = table_ptrs; tp < end; tp++) {
t_phys = (long)*tp;
z_phys_map(&mapped_tbl, t_phys, sizeof(*t), 0);
t = (void *)mapped_tbl;
if (t->signature == signature && check_sum(t)) {
tbl_found = true;
break;
}
z_phys_unmap(mapped_tbl, sizeof(*t));
}
}
z_phys_unmap((uint8_t *)xsdt, sizeof(*xsdt));
if (tbl_found) {
goto found;
}
}
return NULL;
found:
/* Remap to indicated length of the table */
length = t->length;
z_phys_unmap(mapped_tbl, sizeof(*t));
z_phys_map(&mapped_tbl, t_phys, length, 0);
t = (void *)mapped_tbl;
return t;
}
/*
* Return the 'n'th CPU entry from the ACPI MADT, or NULL if not available.
*/
struct acpi_cpu *z_acpi_get_cpu(int n)
{
struct acpi_madt *madt = z_acpi_find_table(ACPI_MADT_SIGNATURE);
uintptr_t base = POINTER_TO_UINT(madt);
uintptr_t offset;
if (!madt) {
return NULL;
}
offset = POINTER_TO_UINT(madt->entries) - base;
while (offset < madt->sdt.length) {
struct acpi_madt_entry *entry;
entry = (struct acpi_madt_entry *)(offset + base);
if (entry->type == ACPI_MADT_ENTRY_CPU) {
struct acpi_cpu *cpu = (struct acpi_cpu *)entry;
if ((cpu->flags & ACPI_CPU_FLAGS_ENABLED) != 0) {
if (n == 0) {
return cpu;
}
--n;
}
}
offset += entry->length;
}
return NULL;
}
static void find_dmar(void)
{
if (is_dmar_searched) {
return;
}
dmar = z_acpi_find_table(ACPI_DMAR_SIGNATURE);
is_dmar_searched = true;
}
struct acpi_dmar *z_acpi_find_dmar(void)
{
find_dmar();
return dmar;
}
struct acpi_drhd *z_acpi_find_drhds(int *n)
{
struct acpi_drhd *drhds = NULL;
uintptr_t offset;
uintptr_t base;
find_dmar();
if (dmar == NULL) {
return NULL;
}
*n = 0;
base = POINTER_TO_UINT(dmar);
offset = POINTER_TO_UINT(dmar->remap_entries) - base;
while (offset < dmar->sdt.length) {
struct acpi_dmar_entry *entry;
entry = (struct acpi_dmar_entry *)(offset + base);
if (entry->type == ACPI_DMAR_TYPE_DRHD) {
if (*n == 0) {
drhds = (struct acpi_drhd *)entry;
}
(*n)++;
} else {
/* DMAR entries are found packed by type so
* if type is not DRHD, we will not encounter one,
* anymore.
*/
break;
}
offset += entry->length;
}
return drhds;
}
struct acpi_dmar_dev_scope *z_acpi_get_drhd_dev_scopes(struct acpi_drhd *drhd,
int *n)
{
uintptr_t offset;
uintptr_t base;
if (drhd->entry.length <= ACPI_DRHD_MIN_SIZE) {
return NULL;
}
*n = 0;
base = POINTER_TO_UINT(drhd);
offset = POINTER_TO_UINT(drhd->device_scope) - base;
while (offset < drhd->entry.length) {
struct acpi_dmar_dev_scope *dev_scope;
dev_scope = (struct acpi_dmar_dev_scope *)(offset + base);
(*n)++;
offset += dev_scope->length;
}
return (*n == 0) ? NULL : drhd->device_scope;
}
struct acpi_dmar_dev_path *
z_acpi_get_dev_scope_paths(struct acpi_dmar_dev_scope *dev_scope, int *n)
{
switch (dev_scope->type) {
case ACPI_DRHD_DEV_SCOPE_PCI_EPD:
/* Fall through */
case ACPI_DRHD_DEV_SCOPE_PCI_SUB_H:
/* Fall through */
case ACPI_DRHD_DEV_SCOPE_IOAPIC:
if (dev_scope->length < (ACPI_DMAR_DEV_SCOPE_MIN_SIZE +
ACPI_DMAR_DEV_PATH_SIZE)) {
return NULL;
}
break;
case ACPI_DRHD_DEV_SCOPE_MSI_CAP_HPET:
/* Fall through */
case ACPI_DRHD_DEV_SCOPE_NAMESPACE_DEV:
if (dev_scope->length != (ACPI_DMAR_DEV_SCOPE_MIN_SIZE +
ACPI_DMAR_DEV_PATH_SIZE)) {
return NULL;
}
break;
default:
return NULL;
}
*n = (dev_scope->length - ACPI_DMAR_DEV_SCOPE_MIN_SIZE) /
ACPI_DMAR_DEV_PATH_SIZE;
return dev_scope->path;
}
uint16_t z_acpi_get_dev_id_from_dmar(uint8_t dev_scope_type)
{
struct acpi_drhd *drhd;
int n_drhd;
find_dmar();
if (dmar == NULL) {
return USHRT_MAX;
}
drhd = z_acpi_find_drhds(&n_drhd);
for (; n_drhd > 0; n_drhd--) {
struct acpi_dmar_dev_scope *dev_scope;
int n_ds;
dev_scope = z_acpi_get_drhd_dev_scopes(drhd, &n_ds);
for (; n_ds > 0; n_ds--) {
if (dev_scope->type == dev_scope_type) {
struct acpi_dmar_dev_path *path;
int n_path;
path = z_acpi_get_dev_scope_paths(dev_scope,
&n_path);
if (n_path > 0) {
union acpi_dmar_id id;
/* Let's over simplify for now:
* we don't look for secondary bus
* and extra paths. We just stop here.
*/
id.bits.bus = dev_scope->start_bus_num;
id.bits.device = path->device;
id.bits.function = path->function;
return id.raw;
}
}
dev_scope = (struct acpi_dmar_dev_scope *)(
POINTER_TO_UINT(dev_scope) + dev_scope->length);
}
drhd = (struct acpi_drhd *)(POINTER_TO_UINT(drhd) +
drhd->entry.length);
}
return USHRT_MAX;
}

View File

@@ -13,7 +13,6 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_PINCTRL=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_ARM_MPU=y
CONFIG_RUNTIME_NMI=y

View File

@@ -13,7 +13,6 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_PINCTRL=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_ARM_MPU=y
CONFIG_RUNTIME_NMI=y

View File

@@ -13,7 +13,6 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_PINCTRL=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y

View File

@@ -13,7 +13,6 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_PINCTRL=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_ARM_MPU=y
CONFIG_RUNTIME_NMI=y

View File

@@ -12,7 +12,6 @@ CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_PINCTRL=y

View File

@@ -8,7 +8,6 @@ CONFIG_SOC_SERIES_LPC55XXX=y
CONFIG_SOC_LPC55S69_CPU1=y
CONFIG_BOARD_LPCXPRESSO55S69_CPU1=y
CONFIG_GPIO=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_PINCTRL=y
CONFIG_RUNTIME_NMI=y

View File

@@ -12,7 +12,6 @@ CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000
CONFIG_PINCTRL=y
# TFM sets up MPU_NS, can't correctly change this configuration yet

View File

@@ -38,6 +38,10 @@
};
};
&clk_lsi {
status = "okay";
};
&clk_hse {
clock-frequency = <DT_FREQ_M(16)>;
status = "okay";
@@ -99,3 +103,9 @@ zephyr_udc0: &usbotg_fs {
&cryp {
status = "okay";
};
&rtc {
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>,
<&rcc STM32_SRC_LSI RTC_SEL(2)>;
status = "okay";
};

View File

@@ -36,6 +36,8 @@ config HEAP_MEM_POOL_SIZE
default 64000000
config MAIN_STACK_SIZE
default 320000
config ACPI_PRT_BUS_NAME
default "_SB.PC00"
if SHELL
config SHELL_STACK_SIZE

View File

@@ -19,8 +19,12 @@ config SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
default n
endif
config ACPI_PRT_BUS_NAME
depends on ACPI
default "_SB.PC00"
config HEAP_MEM_POOL_SIZE
default 32768 if ACPI
default 2097152 if ACPI
depends on KERNEL_MEM_POOL
# TSC on this board is 1.9 GHz, HPET and APIC are 19.2 MHz

View File

@@ -29,6 +29,10 @@ endif
config ACPI
default y
config ACPI_PRT_BUS_NAME
depends on ACPI
default "_SB.PC00"
if DMA
config DMA_64BIT
default y

View File

@@ -25,7 +25,7 @@ config KERNEL_VM_SIZE
default 0x10000000 if ACPI
config HEAP_MEM_POOL_SIZE
default 32768 if ACPI
default 1048576 if ACPI
depends on KERNEL_MEM_POOL
config MULTIBOOT
@@ -54,7 +54,7 @@ config KERNEL_VM_SIZE
default 0x10000000 if ACPI
config HEAP_MEM_POOL_SIZE
default 32768 if ACPI
default 1048576 if ACPI
depends on KERNEL_MEM_POOL
endif # BOARD_QEMU_X86_64

View File

@@ -9,7 +9,7 @@ config MP_MAX_NUM_CPUS
default 2 if BOARD_UP_SQUARED
config HEAP_MEM_POOL_SIZE
default 32768 if ACPI
default 1048576 if ACPI
depends on KERNEL_MEM_POOL
config BUILD_OUTPUT_STRIPPED

View File

@@ -167,8 +167,8 @@
&i2c1 {
status = "disabled";
clock-frequency = <I2C_BITRATE_STANDARD>;
sda-gpios = <&gpio0 32 GPIO_OPEN_DRAIN>;
scl-gpios = <&gpio0 33 GPIO_OPEN_DRAIN>;
sda-gpios = <&gpio1 0 GPIO_OPEN_DRAIN>;
scl-gpios = <&gpio1 1 GPIO_OPEN_DRAIN>;
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
};

View File

@@ -16,8 +16,8 @@
<3 0 &gpio0 4 0>, /* D3 */
<4 0 &gpio0 5 0>, /* D4 */
<5 0 &gpio0 6 0>, /* D5 */
<6 0 &gpio0 43 0>, /* D6 */
<7 0 &gpio0 44 0>, /* D7 */
<6 0 &gpio1 11 0>, /* D6 */
<7 0 &gpio1 12 0>, /* D7 */
<8 0 &gpio0 7 0>, /* D8 */
<9 0 &gpio0 8 0>, /* D9 */
<10 0 &gpio0 9 0>; /* D10 */

View File

@@ -79,6 +79,10 @@
status = "okay";
};
&gpio1 {
status = "okay";
};
&wdt0 {
status = "okay";
};

View File

@@ -26,7 +26,11 @@ find_program(CMAKE_OBJCOPY NAMES
llvm-objcopy-${CLANGVER}
objcopy
${find_program_binutils_args})
find_program(CMAKE_READELF readelf ${find_program_binutils_args})
find_program(CMAKE_READELF NAMES
llvm-readelf
llvm-readelf-${CLANGVER}
readelf
${find_program_binutils_args})
# Use the gnu binutil abstraction
include(${ZEPHYR_BASE}/cmake/bintools/llvm/target_bintools.cmake)

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

@@ -2095,16 +2095,12 @@ function(toolchain_parse_make_rule input_file include_files)
# the element separator, so let's get the pure `;` back.
string(REPLACE "\;" ";" input_as_list ${input})
# Pop the first line and treat it specially
list(POP_FRONT input_as_list first_input_line)
string(FIND ${first_input_line} ": " index)
math(EXPR j "${index} + 2")
string(SUBSTRING ${first_input_line} ${j} -1 first_include_file)
# The file might also contain multiple files on one line if one or both of
# the file paths are short, split these up into multiple elements using regex
string(REGEX REPLACE "([^ ])[ ]([^ ])" "\\1;\\2" input_as_list "${input_as_list}")
# Remove whitespace before and after filename and convert to CMake path.
string(STRIP "${first_include_file}" first_include_file)
file(TO_CMAKE_PATH "${first_include_file}" first_include_file)
set(result "${first_include_file}")
# Pop the first item containing "empty_file.o:"
list(POP_FRONT input_as_list first_input_line)
# Remove whitespace before and after filename and convert to CMake path.
foreach(file ${input_as_list})

View File

@@ -71,7 +71,7 @@ REDIRECTS = [
('guides/pm/power_domain', 'services/pm/power_domain'),
('guides/pm/system', 'services/pm/system'),
('guides/portability/index', 'services/portability/index'),
('guides/portability/posix', 'services/portability/posix'),
('guides/portability/posix', 'services/portability/posix/index'),
('guides/porting/arch', 'hardware/porting/arch'),
('guides/porting/board_porting', 'hardware/porting/board_porting'),
('guides/porting/index', 'hardware/porting/index'),

View File

@@ -80,6 +80,8 @@ Zephyr offers a large and ever growing number of features including:
* Red/black tree ready queue
* Traditional multi-queue ready queue
.. _zephyr_intro_configurability:
**Highly configurable / Modular for flexibility**
Allows an application to incorporate *only* the capabilities it needs as it
needs them, and to specify their quantity and size.

View File

@@ -79,6 +79,25 @@ C Library
to a smaller, but inexact conversion algorithm. This requires building
Picolibc as a module.
Optional Modules
================
The following modules have been made optional and are not downloaded with `west update` by default anymore:
* ``chre``
* ``lz4``
* ``nanopb``
* ``psa-arch-tests``
* ``sof``
* ``tf-m-tests``
* ``tflite-micro``
* ``thrift``
* ``zscilib``
To enable them again use the ``west config manifest.project-filter -- +<module
name>`` command, or ``west config manifest.group-filter -- +optional`` to
enable all optional modules, and then run ``west update`` again.
Device Drivers and Device Tree
==============================

View File

@@ -68,6 +68,9 @@ https://docs.zephyrproject.org/latest/security/vulnerabilities.html
* CVE-2023-5563 `Zephyr project bug tracker GHSA-98mc-rj7w-7rpv
<https://github.com/zephyrproject-rtos/zephyr/security/advisories/GHSA-98mc-rj7w-7rpv>`_
* CVE-2023-5753 `Zephyr project bug tracker GHSA-hmpr-px56-rvww
<https://github.com/zephyrproject-rtos/zephyr/security/advisories/GHSA-hmpr-px56-rvww>`_
Kernel
******

View File

@@ -1547,3 +1547,17 @@ This has been fixed in main for v3.5.0
- `PR 63717 fix for 3.3
<https://github.com/zephyrproject-rtos/zephyr/pull/63717>`_
CVE-2023-5753
-------------
Potential buffer overflow vulnerabilities in the Zephyr Bluetooth
subsystem source code when asserts are disabled.
- `Zephyr project bug tracker GHSA-hmpr-px56-rvww
<https://github.com/zephyrproject-rtos/zephyr/security/advisories/GHSA-hmpr-px56-rvww>`_
This has been fixed in main for v3.5.0
- `PR 63605 fix for main
<https://github.com/zephyrproject-rtos/zephyr/pull/63605>`_

View File

@@ -14,6 +14,6 @@ supported by the Zephyr RTOS.
.. toctree::
:maxdepth: 1
posix.rst
posix/index.rst
cmsis_rtos_v1.rst
cmsis_rtos_v2.rst

View File

@@ -0,0 +1,191 @@
.. _posix_aep:
POSIX Application Environment Profiles (AEP)
############################################
Although inactive, `IEEE 1003.13-2003`_ defined a number of AEP that inspired the modern
subprofiling options of `IEEE 1003.1-2017`_. The single-purpose realtime system profiles
are listed below, for reference, in terms that agree with the current POSIX-1 standard. PSE54
is not considered at this time.
.. _posix_aep_pse51:
Minimal Realtime System Profile (PSE51)
=======================================
.. Conforming implementations shall define _POSIX_AEP_REALTIME_MINIMAL to the value 200312L
.. csv-table:: PSE51 System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_AEP_REALTIME_MINIMAL, -1,
.. csv-table:: PSE51 Option Groups
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
POSIX_C_LANG_JUMP,,
POSIX_C_LANG_SUPPORT, yes, :ref:`†<posix_undefined_behaviour>`
POSIX_DEVICE_IO,, :ref:`†<posix_undefined_behaviour>`
POSIX_FILE_LOCKING,,
POSIX_SIGNALS,, :ref:`†<posix_undefined_behaviour>`
POSIX_SINGLE_PROCESS,, :ref:`†<posix_undefined_behaviour>`
POSIX_THREADS_BASE, yes, :ref:`†<posix_undefined_behaviour>`
XSI_THREADS_EXT, yes, :ref:`†<posix_undefined_behaviour>`
.. csv-table:: PSE51 Option Requirements
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_CLOCK_SELECTION, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_FSYNC, -1,
_POSIX_MEMLOCK, -1,
_POSIX_MEMLOCK_RANGE, -1,
_POSIX_MONOTONIC_CLOCK, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_REALTIME_SIGNALS, -1,
_POSIX_SEMAPHORES, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_SHARED_MEMORY_OBJECTS, -1,
_POSIX_SYNCHRONIZED_IO, -1,
_POSIX_THREAD_ATTR_STACKADDR, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_ATTR_STACKSIZE, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_CPUTIME, -1,
_POSIX_THREAD_PRIO_INHERIT, 200809L, :kconfig:option:`CONFIG_PTHREAD_MUTEX`
_POSIX_THREAD_PRIO_PROTECT, -1,
_POSIX_THREAD_PRIORITY_SCHEDULING, -1,
_POSIX_THREAD_SPORADIC_SERVER, -1,
_POSIX_TIMEOUTS, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_TIMERS, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
.. note::
For PSE51 support, 44 of 75 symbols are currently implemented.
.. _posix_aep_pse52:
Realtime Controller System Profile (PSE52)
==========================================
.. Conforming implementations shall define _POSIX_AEP_REALTIME_CONTROLLER to the value 200312L
.. csv-table:: PSE52 System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_AEP_REALTIME_CONTROLLER, -1,
.. csv-table:: PSE52 Option Groups
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
POSIX_C_LANG_JUMP,,
POSIX_C_LANG_MATH, yes,
POSIX_C_LANG_SUPPORT, yes, :ref:`†<posix_undefined_behaviour>`
POSIX_DEVICE_IO,, :ref:`†<posix_undefined_behaviour>`
POSIX_FD_MGMT,,
POSIX_FILE_LOCKING,,
POSIX_FILE_SYSTEM,,
POSIX_SIGNALS,, :ref:`†<posix_undefined_behaviour>`
POSIX_SINGLE_PROCESS,, :ref:`†<posix_undefined_behaviour>`
POSIX_THREADS_BASE, yes, :ref:`†<posix_undefined_behaviour>`
XSI_THREADS_EXT, yes, :ref:`†<posix_undefined_behaviour>`
.. csv-table:: PSE52 Option Requirements
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_CLOCK_SELECTION, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_FSYNC, -1,
_POSIX_MAPPED_FILES, -1,
_POSIX_MEMLOCK, -1,
_POSIX_MEMLOCK_RANGE, -1,
_POSIX_MESSAGE_PASSING, 200809L, :kconfig:option:`CONFIG_POSIX_MQUEUE`
_POSIX_MONOTONIC_CLOCK, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_REALTIME_SIGNALS, -1,
_POSIX_SEMAPHORES, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_SHARED_MEMORY_OBJECTS, -1,
_POSIX_SYNCHRONIZED_IO, -1,
_POSIX_THREAD_ATTR_STACKADDR, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_ATTR_STACKSIZE, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_CPUTIME, -1,
_POSIX_THREAD_PRIO_INHERIT, 200809L, :kconfig:option:`CONFIG_PTHREAD_MUTEX`
_POSIX_THREAD_PRIO_PROTECT, -1,
_POSIX_THREAD_PRIORITY_SCHEDULING, -1,
_POSIX_THREAD_SPORADIC_SERVER, -1,
_POSIX_TIMEOUTS, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_TIMERS, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_TRACE, -1,
_POSIX_TRACE_EVENT_FILTER, -1,
_POSIX_TRACE_LOG, -1,
.. _posix_aep_pse53:
Dedicated Realtime System Profile (PSE53)
=========================================
.. Conforming implementations shall define _POSIX_AEP_REALTIME_MINIMAL to the value 200312L
.. csv-table:: PSE53 System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_AEP_REALTIME_CONTROLLER, -1,
.. csv-table:: PSE53 Option Groups
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
POSIX_C_LANG_JUMP,,
POSIX_C_LANG_MATH, yes,
POSIX_C_LANG_SUPPORT, yes, :ref:`†<posix_undefined_behaviour>`
POSIX_DEVICE_IO,, :ref:`†<posix_undefined_behaviour>`
POSIX_FD_MGMT,,
POSIX_FILE_LOCKING,,
POSIX_FILE_SYSTEM,,
POSIX_MULTI_PROCESS,, :ref:`†<posix_undefined_behaviour>`
POSIX_NETWORKING, yes, :ref:`†<posix_undefined_behaviour>`
POSIX_PIPE,, :ref:`†<posix_undefined_behaviour>`
POSIX_SIGNALS,, :ref:`†<posix_undefined_behaviour>`
POSIX_SIGNAL_JUMP,, :ref:`†<posix_undefined_behaviour>`
POSIX_SINGLE_PROCESS,, :ref:`†<posix_undefined_behaviour>`
POSIX_THREADS_BASE, yes, :ref:`†<posix_undefined_behaviour>`
XSI_THREADS_EXT, yes, :ref:`†<posix_undefined_behaviour>`
.. csv-table:: PSE53 Option Requirements
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_ASYNCHRONOUS_IO, -1,
_POSIX_CLOCK_SELECTION, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_CPUTIME, -1,
_POSIX_FSYNC, -1,
_POSIX_MAPPED_FILES, -1,
_POSIX_MEMLOCK, -1,
_POSIX_MEMLOCK_RANGE, -1,
_POSIX_MEMORY_PROTECTION, -1,
_POSIX_MESSAGE_PASSING, 200809L, :kconfig:option:`CONFIG_POSIX_MQUEUE`
_POSIX_MONOTONIC_CLOCK, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_PRIORITIZED_IO, -1,
_POSIX_PRIORITY_SCHEDULING, -1,
_POSIX_RAW_SOCKETS, 200809L, :kconfig:option:`CONFIG_NET_SOCKETS`
_POSIX_REALTIME_SIGNALS, -1,
_POSIX_SEMAPHORES, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_SHARED_MEMORY_OBJECTS, -1,
_POSIX_SPAWN, -1,
_POSIX_SPORADIC_SERVER, -1,
_POSIX_SYNCHRONIZED_IO, -1,
_POSIX_THREAD_ATTR_STACKADDR, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_ATTR_STACKSIZE, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_CPUTIME, -1,
_POSIX_THREAD_PRIO_INHERIT, 200809L, :kconfig:option:`CONFIG_PTHREAD_MUTEX`
_POSIX_THREAD_PRIO_PROTECT, -1,
_POSIX_THREAD_PRIORITY_SCHEDULING, -1,
_POSIX_THREAD_PROCESS_SHARED, -1,
_POSIX_THREAD_SPORADIC_SERVER, -1,
_POSIX_TIMEOUTS, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_TIMERS, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_TRACE, -1,
_POSIX_TRACE_EVENT_FILTER, -1,
_POSIX_TRACE_LOG, -1,
.. _IEEE 1003.1-2017: https://standards.ieee.org/ieee/1003.1/7101/
.. _IEEE 1003.13-2003: https://standards.ieee.org/ieee/1003.13/3322/

View File

@@ -0,0 +1,145 @@
.. _posix_conformance:
POSIX Conformance
#################
As per `IEEE 1003.1-2017`, this section details Zephyr's POSIX conformance.
.. _posix_undefined_behaviour:
.. note::
As per POSIX 1003.13, single process mode is supported directly by both PSE51 and PSE52
profiles. While Zephyr includes support for many features found in PSE53, PSE53 itself requires
supporting multiple processes. Since supporting multiple processes is beyond the scope of
Zephyr's current design, some features requiring multi-process capabilities may exhibit
undefined behaviour, which we denote with the † (obelus) symbol.
.. _posix_system_interfaces:
POSIX System Interfaces
=======================
.. The following have values greater than -1 in Zephyr, conformant with the POSIX specification.
.. csv-table:: POSIX System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_CHOWN_RESTRICTED, 0,
_POSIX_NO_TRUNC, 0,
_POSIX_VDISABLE, 0,
.. The following should be valued greater than zero in Zephyr, in order to be strictly conformant
with the POSIX specification.
.. csv-table:: POSIX System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_JOB_CONTROL, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX_REGEXP, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX_SAVED_IDS, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX_SHELL, -1, :ref:`†<posix_undefined_behaviour>`
.. TODO: POSIX_ASYNCHRONOUS_IO, and other interfaces below, are mandatory. That means that a
strictly conforming application need not be modified in order to compile against Zephyr.
However, we may add implementations that simply fail with ENOSYS as long as the functional
modification is clearly documented. The implementation is not required for PSE51 or PSE52
and beyond that POSIX async I/O functions are rarely used in practice.
.. csv-table:: POSIX System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_VERSION, 200809L,
_POSIX_ASYNCHRONOUS_IO, -1, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_BARRIERS<posix_option_group_barriers>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_BARRIER`
:ref:`_POSIX_CLOCK_SELECTION<posix_option_group_clock_selection>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_MAPPED_FILES, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX_MEMORY_PROTECTION, -1, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_READER_WRITER_LOCKS<posix_option_reader_writer_locks>`, -1, :kconfig:option:`CONFIG_PTHREAD_IPC`
_POSIX_REALTIME_SIGNALS, -1, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_SEMAPHORES<posix_option_group_semaphores>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
:ref:`_POSIX_SPIN_LOCKS<posix_option_group_spin_locks>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_SPINLOCK`
_POSIX_THREAD_SAFE_FUNCTIONS, 200809L,
:ref:`_POSIX_THREADS<posix_option_group_threads_base>`, -1, :kconfig:option:`CONFIG_PTHREAD_IPC`
:ref:`_POSIX_TIMEOUTS<posix_option_timeouts>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
:ref:`_POSIX_TIMERS<posix_option_group_timers>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX2_C_BIND, 200809L,
.. csv-table:: POSIX System Interfaces (Optional)
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_ADVISORY_INFO, -1,
_POSIX_CPUTIME, -1,
_POSIX_FSYNC, -1,
_POSIX_IPV6, 200809L, :kconfig:option:`CONFIG_NET_IPV6`
_POSIX_MEMLOCK, -1,
_POSIX_MEMLOCK_RANGE, -1,
:ref:`_POSIX_MESSAGE_PASSING<posix_option_message_passing>`, 200809L, :kconfig:option:`CONFIG_POSIX_MQUEUE`
_POSIX_MONOTONIC_CLOCK, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_PRIORITIZED_IO, -1,
:ref:`_POSIX_PRIORITY_SCHEDULING<posix_option_priority_scheduling>`, -1, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_RAW_SOCKETS, 200809L, :kconfig:option:`CONFIG_NET_SOCKETS`
_POSIX_SHARED_MEMORY_OBJECTS, -1,
_POSIX_SPAWN, -1,
_POSIX_SPORADIC_SERVER, -1,
_POSIX_SYNCHRONIZED_IO, -1,
:ref:`_POSIX_THREAD_ATTR_STACKADDR<posix_option_thread_attr_stackaddr>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_CPUTIME, -1,
:ref:`_POSIX_THREAD_ATTR_STACKSIZE<posix_option_thread_attr_stacksize>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_PRIO_INHERIT, 200809L, :kconfig:option:`CONFIG_PTHREAD_MUTEX`
_POSIX_THREAD_PRIO_PROTECT, -1,
:ref:`_POSIX_THREAD_PRIORITY_SCHEDULING<posix_option_thread_priority_scheduling>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_PROCESS_SHARED, -1,
_POSIX_THREAD_SPORADIC_SERVER, -1,
_POSIX_TRACE, -1,
_POSIX_TRACE_EVENT_FILTER, -1,
_POSIX_TRACE_INHERIT, -1,
_POSIX_TRACE_LOG, -1,
_POSIX_TYPED_MEMORY_OBJECTS, -1,
_XOPEN_CRYPT, -1,
_XOPEN_REALTIME, -1,
_XOPEN_REALTIME_THREADS, -1,
:ref:`_XOPEN_STREAMS<posix_option_xopen_streams>`, -1, :kconfig:option:`CONFIG_NET_SOCKETS`
_XOPEN_UNIX, -1,
POSIX Shell and Utilities
=========================
Zephyr does not support a POSIX shell or utilities at this time.
.. csv-table:: POSIX Shell and Utilities
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX2_C_DEV, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_CHAR_TERM, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_FORT_DEV, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_FORT_RUN, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_LOCALEDEF, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_PBS, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_PBS_ACCOUNTING, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_PBS_LOCATE, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_PBS_MESSAGE, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_PBS_TRACK, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_SW_DEV, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_UPE, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_UNIX, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX2_UUCP, -1, :ref:`†<posix_undefined_behaviour>`
XSI Conformance
###############
XSI System Interfaces
=====================
.. csv-table:: XSI System Interfaces
:header: Symbol, Support, Remarks
:widths: 50, 10, 50
_POSIX_FSYNC, -1, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_THREAD_ATTR_STACKADDR<posix_option_thread_attr_stackaddr>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
:ref:`_POSIX_THREAD_ATTR_STACKSIZE<posix_option_thread_attr_stacksize>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
_POSIX_THREAD_PROCESS_SHARED, -1,

View File

@@ -0,0 +1,77 @@
.. _posix_details:
Implementation Details
######################
In many ways, Zephyr provides support like any POSIX OS; API bindings are provided in the C
programming language, POSIX headers are available in the standard include path, when configured.
Unlike other multi-purpose POSIX operating systems
- Zephyr is not "a POSIX OS". The Zephyr kernel was not designed around the POSIX standard, and
POSIX support is an opt-in feature
- Zephyr apps are not linked separately, nor do they execute as subprocesses
- Zephyr, libraries, and application code are compiled and linked together, running similarly to
a single-process application, in a single (possibly virtual) address space
- Zephyr does not provide a POSIX shell, compiler, utilities, and is not self-hosting.
.. note::
Unlike the Linux kernel or FreeBSD, Zephyr does not maintain a static table of system call
numbers for each supported architecture, but instead generates system calls dynamically at
build time. See `System Calls <syscalls>`_ for more information.
Design
======
As a library, Zephyr's POSIX API implementation makes an effort to be a thin abstraction layer
between the application, middleware, and the Zephyr kernel.
Some general design considerations:
- The POSIX interface and implementations should be part of Zephyr's POSIX library, and not
elsewhere, unless required both by the POSIX API implementation and some other feature. An
example where the implementation should remain part of the POSIX implementation is
``getopt()``. Examples where the implementation should be part of separate libraries are
multithreading and networking.
- When the POSIX API and another Zephyr subsystem both rely on a feature, the implementation of
that feature should be as a separate Zephyr library that can be used by both the POSIX API and
the other library or subsystem. This reduces the likelihood of dependency cycles in code. When
practical, that rule should expand to include macros. In the example below, ``libposix``
depends on ``libzfoo`` for the implementation of some functionality "foo" in Zephyr. If
``libzfoo`` also depends on ``libposix``, then there is a dependency cycle. The cycle can be
removed via mutual dependency, ``libcommon``.
.. graphviz::
:caption: Dependency cycle between POSIX and another Zephyr library
digraph {
node [shape=rect, style=rounded];
rankdir=LR;
libposix [fillcolor="#d5e8d4"];
libzfoo [fillcolor="#dae8fc"];
libposix -> libzfoo;
libzfoo -> libposix;
}
.. graphviz::
:caption: Mutual dependencies between POSIX and other Zephyr libraries
digraph {
node [shape=rect, style=rounded];
rankdir=LR;
libposix [fillcolor="#d5e8d4"];
libzfoo [fillcolor="#dae8fc"];
libcommon [fillcolor="#f8cecc"];
libposix -> libzfoo;
libposix -> libcommon;
libzfoo -> libcommon;
}
- POSIX API calls should be provided as regular callable C functions; if a Zephyr
`System Call <syscalls>`_ is needed as part of the implementation, the declaration and the
implementation of that system call should be hidden behind the POSIX API.

View File

@@ -0,0 +1,14 @@
.. _posix_support:
POSIX
#####
.. toctree::
:maxdepth: 2
overview/index.rst
conformance/index.rst
aep/index.rst
implementation/index.rst
option_groups/index.rst
kconfig/index.rst

View File

@@ -0,0 +1,52 @@
.. _posix_kconfig_options:
Configuration Options
*********************
This is a non-exhaustive list of specific :ref:`kconfig` options relating to Zephyr's
implementation of the POSIX API.
* :kconfig:option:`CONFIG_APP_LINK_WITH_POSIX_SUBSYS`
* :kconfig:option:`CONFIG_EVENTFD`
* :kconfig:option:`CONFIG_EVENTFD_MAX`
* :kconfig:option:`CONFIG_FDTABLE`
* :kconfig:option:`CONFIG_FNMATCH`
* :kconfig:option:`CONFIG_GETOPT`
* :kconfig:option:`CONFIG_GETOPT_LONG`
* :kconfig:option:`CONFIG_MAX_PTHREAD_BARRIER_COUNT`
* :kconfig:option:`CONFIG_MAX_PTHREAD_COUNT`
* :kconfig:option:`CONFIG_MAX_PTHREAD_KEY_COUNT`
* :kconfig:option:`CONFIG_MAX_PTHREAD_MUTEX_COUNT`
* :kconfig:option:`CONFIG_MAX_PTHREAD_SPINLOCK_COUNT`
* :kconfig:option:`CONFIG_MAX_TIMER_COUNT`
* :kconfig:option:`CONFIG_MQUEUE_NAMELEN_MAX`
* :kconfig:option:`CONFIG_MSG_COUNT_MAX`
* :kconfig:option:`CONFIG_MSG_SIZE_MAX`
* :kconfig:option:`CONFIG_NET_SOCKETPAIR`
* :kconfig:option:`CONFIG_NET_SOCKETS`
* :kconfig:option:`CONFIG_NET_SOCKETS_POLL_MAX`
* :kconfig:option:`CONFIG_NET_SOCKETS_POSIX_NAMES`
* :kconfig:option:`CONFIG_POSIX_API`
* :kconfig:option:`CONFIG_POSIX_CLOCK`
* :kconfig:option:`CONFIG_POSIX_FS`
* :kconfig:option:`CONFIG_POSIX_LIMITS_RTSIG_MAX`
* :kconfig:option:`CONFIG_POSIX_MAX_FDS`
* :kconfig:option:`CONFIG_POSIX_MAX_OPEN_FILES`
* :kconfig:option:`CONFIG_POSIX_MQUEUE`
* :kconfig:option:`CONFIG_POSIX_RTSIG_MAX`
* :kconfig:option:`CONFIG_POSIX_SIGNAL`
* :kconfig:option:`CONFIG_POSIX_SIGNAL_STRING_DESC`
* :kconfig:option:`CONFIG_POSIX_UNAME`
* :kconfig:option:`CONFIG_POSIX_UNAME_NODENAME_LEN`
* :kconfig:option:`CONFIG_POSIX_UNAME_VERSION_LEN`
* :kconfig:option:`CONFIG_PTHREAD`
* :kconfig:option:`CONFIG_PTHREAD_BARRIER`
* :kconfig:option:`CONFIG_PTHREAD_COND`
* :kconfig:option:`CONFIG_PTHREAD_CREATE_BARRIER`
* :kconfig:option:`CONFIG_PTHREAD_IPC`
* :kconfig:option:`CONFIG_PTHREAD_KEY`
* :kconfig:option:`CONFIG_PTHREAD_MUTEX`
* :kconfig:option:`CONFIG_PTHREAD_RECYCLER_DELAY_MS`
* :kconfig:option:`CONFIG_PTHREAD_SPINLOCK`
* :kconfig:option:`CONFIG_SEM_VALUE_MAX`
* :kconfig:option:`CONFIG_TIMER`

View File

@@ -1,131 +1,18 @@
.. _posix_support:
.. _posix_option_groups:
POSIX Support
#############
Subprofiling Option Groups
##########################
The Portable Operating System Interface (POSIX) is a family of standards
specified by the IEEE Computer Society for maintaining compatibility between
operating systems. Zephyr implements a subset of the embedded profiles PSE51
and PSE52, and BSD Sockets API.
With the POSIX support available in Zephyr, an existing POSIX compliant
application can be ported to run on the Zephyr kernel, and therefore leverage
Zephyr features and functionality. Additionally, a library designed for use with
POSIX threading compatible operating systems can be ported to Zephyr kernel
based applications with minimal or no changes.
.. figure:: posix.svg
:align: center
:alt: POSIX Support in Zephyr
POSIX support in Zephyr
The POSIX API subset is an increasingly popular OSAL (operating system
abstraction layer) for IoT and embedded applications, as can be seen in
Zephyr, AWS:FreeRTOS, TI-RTOS, and NuttX.
Benefits of POSIX support in Zephyr include:
- Offering a familiar API to non-embedded programmers, especially from Linux
- Enabling reuse (portability) of existing libraries based on POSIX APIs
- Providing an efficient API subset appropriate for small (MCU) embedded systems
System Overview
===============
Units of Functionality
++++++++++++++++++++++
The system profile is defined in terms of component profiles that specify Units
of Functionality that can be combined to realize the application platform. A Unit
of Functionality is a defined set of services which can be implemented. If
implemented, the standard prescribes that all services in the Unit must
be implemented.
A Minimal Realtime System Profile implementation must support the
following Units of Functionality as defined in IEEE Std. 1003.1 (also referred to
as POSIX.1-2017).
.. csv-table:: Units of Functionality
:header: Requirements, Supported, Remarks
:widths: 50,10,60
POSIX_C_LANG_JUMP,
POSIX_C_LANG_SUPPORT,yes
POSIX_DEVICE_IO,
POSIX_FILE_LOCKING,
POSIX_SIGNALS,
POSIX_SINGLE_PROCESS,
POSIX_SPIN_LOCKS,yes
POSIX_THREADS_BASE,yes
XSI_THREAD_MUTEX_EXT,yes
XSI_THREADS_EXT,yes
Option Requirements
++++++++++++++++++++
An implementation supporting the Minimal Realtime System
Profile must support the POSIX.1 Option Requirements which are defined in the
standard. Options Requirements are used for further sub-profiling within the
units of functionality: they further define the functional behavior of the
system service (normally adding extra functionality). Depending on the profile
to which the POSIX implementation complies,parameters and/or the precise
functionality of certain services may differ.
The following list shows the option requirements that are implemented in
Zephyr.
.. csv-table:: Option Requirements
:header: Requirements, Supported
:widths: 50,10
_POSIX_BARRIERS,yes
_POSIX_CLOCK_SELECTION,yes
_POSIX_FSYNC,
_POSIX_MEMLOCK,
_POSIX_MEMLOCK_RANGE,
_POSIX_MONOTONIC_CLOCK,yes
_POSIX_NO_TRUNC,
_POSIX_REALTIME_SIGNALS,
_POSIX_SEMAPHORES,yes
_POSIX_SHARED_MEMORY_OBJECTS,
_POSIX_SPIN_LOCKS,yes
_POSIX_SYNCHRONIZED_IO,
_POSIX_THREAD_ATTR_STACKADDR,yes
_POSIX_THREAD_ATTR_STACKSIZE,yes
_POSIX_THREAD_CPUTIME,
_POSIX_THREAD_PRIO_INHERIT,
_POSIX_THREAD_PRIO_PROTECT,
_POSIX_THREAD_PRIORITY_SCHEDULING,yes
_POSIX_THREAD_SPORADIC_SERVER,
_POSIX_TIMEOUTS,
_POSIX_TIMERS,yes
_POSIX2_C_DEV,
_POSIX2_SW_DEV,
Units of Functionality
======================
This section describes the Units of Functionality (fixed sets of interfaces)
which are implemented (partially or completely) in Zephyr. Please refer to the
standard for a full description of each listed interface.
.. _posix_option_group_threads_base:
POSIX_THREADS_BASE
+++++++++++++++++++
==================
The basic assumption in this profile is that the system
consists of a single (implicit) process with multiple threads. Therefore, the
standard requires all basic thread services, except those related to
multiple processes.
.. csv-table:: POSIX_THREADS_BASE
:header: API, Supported
:widths: 50,10
@@ -179,12 +66,12 @@ multiple processes.
pthread_sigmask(),
pthread_testcancel(),
.. _posix_option_group_xsi_thread_ext:
XSI_THREAD_EXT
++++++++++++++
==============
The XSI_THREADS_EXT Unit of Functionality is required because it provides
The XSI_THREADS_EXT option group is required because it provides
functions to control a thread's stack. This is considered useful for any
real-time application.
@@ -201,33 +88,14 @@ This table lists service support status in Zephyr:
pthread_getconcurrency(),
pthread_setconcurrency()
XSI_THREAD_MUTEX_EXT
++++++++++++++++++++
The XSI_THREAD_MUTEX_EXT Unit of Functionality is required because it has
options for controlling the behavior of mutexes under erroneous application use.
This table lists service support status in Zephyr:
.. csv-table:: XSI_THREAD_MUTEX_EXT
:header: API, Supported
:widths: 50,10
pthread_mutexattr_gettype(),yes
pthread_mutexattr_settype(),yes
.. _posix_option_group_c_lang_support:
POSIX_C_LANG_SUPPORT
++++++++++++++++++++
====================
The POSIX_C_LANG_SUPPORT Unit of Functionality contains the general ISO C
The POSIX_C_LANG_SUPPORT option group contains the general ISO C
Library.
This is implemented as part of the minimal C library available in Zephyr.
.. csv-table:: POSIX_C_LANG_SUPPORT
:header: API, Supported
:widths: 50,10
@@ -338,11 +206,12 @@ This is implemented as part of the minimal C library available in Zephyr.
vsprintf(),yes
vsscanf(),
.. _posix_option_group_single_process:
POSIX_SINGLE_PROCESS
+++++++++++++++++++++
====================
The POSIX_SINGLE_PROCESS Unit of Functionality contains services for single
The POSIX_SINGLE_PROCESS option group contains services for single
process applications.
.. csv-table:: POSIX_SINGLE_PROCESS
@@ -358,9 +227,10 @@ process applications.
uname(),yes
unsetenv()
.. _posix_option_group_signals:
POSIX_SIGNALS
+++++++++++++
=============
Signal services are a basic mechanism within POSIX-based systems and are
required for error and event handling.
@@ -369,7 +239,6 @@ required for error and event handling.
:header: API, Supported
:widths: 50,10
abort(),yes
alarm(),
kill(),
@@ -388,32 +257,20 @@ required for error and event handling.
sigwait(),
strsignal(),yes
.. csv-table:: POSIX_SPIN_LOCKS
:header: API, Supported
:widths: 50,10
pthread_spin_destroy(),yes
pthread_spin_init(),yes
pthread_spin_lock(),yes
pthread_spin_trylock(),yes
pthread_spin_unlock(),yes
.. _posix_option_group_device_io:
POSIX_DEVICE_IO
+++++++++++++++
===============
.. csv-table:: POSIX_DEVICE_IO
:header: API, Supported
:widths: 50,10
flockfile(),
ftrylockfile(),
funlockfile(),
getc_unlocked(),
getchar_unlocked(),yes
putc_unlocked(),
putchar_unlocked()
clearerr(),
FD_CLR(),yes
FD_ISSET(),yes
FD_SET(),yes
FD_ZERO(),yes
clearerr(),yes
close(),yes
fclose(),
fdopen(),
@@ -436,17 +293,22 @@ POSIX_DEVICE_IO
gets(),
open(),yes
perror(),yes
poll(),yes
printf(),yes
pread(),
pselect(),
putc(),yes
putchar(),yes
puts(),yes
pwrite(),
read(),yes
scanf(),
select(),yes
setbuf(),
setvbuf(),
stderr,yes
stdin,yes
stdout,yes
stderr,
stdin,
stdout,
ungetc(),
vfprintf(),yes
vfscanf(),
@@ -454,8 +316,72 @@ POSIX_DEVICE_IO
vscanf(),
write(),yes
.. _posix_option_group_barriers:
POSIX_BARRIERS
==============
.. csv-table:: POSIX_BARRIERS
:header: API, Supported
:widths: 50,10
pthread_barrier_destroy(),yes
pthread_barrier_init(),yes
pthread_barrier_wait(),yes
pthread_barrierattr_destroy(),yes
pthread_barrierattr_init(),yes
.. _posix_option_group_clock_selection:
POSIX_CLOCK_SELECTION
=====================
.. csv-table:: POSIX_CLOCK_SELECTION
:header: API, Supported
:widths: 50,10
pthread_condattr_getclock(),yes
pthread_condattr_setclock(),yes
clock_nanosleep(),yes
.. _posix_option_group_semaphores:
POSIX_SEMAPHORES
================
.. csv-table:: POSIX_SEMAPHORES
:header: API, Supported
:widths: 50,10
sem_close(),
sem_destroy(),yes
sem_getvalue(),yes
sem_init(),yes
sem_open(),
sem_post(),yes
sem_trywait(),yes
sem_unlink(),
sem_wait(),yes
.. _posix_option_group_spin_locks:
POSIX_SPIN_LOCKS
================
.. csv-table:: POSIX_SPIN_LOCKS
:header: API, Supported
:widths: 50,10
pthread_spin_destroy(),yes
pthread_spin_init(),yes
pthread_spin_lock(),yes
pthread_spin_trylock(),yes
pthread_spin_unlock(),yes
.. _posix_option_group_timers:
POSIX_TIMERS
++++++++++++
============
.. csv-table:: POSIX_TIMERS
:header: API, Supported
@@ -471,13 +397,143 @@ POSIX_TIMERS
timer_getoverrun(),yes
timer_settime(),yes
POSIX_CLOCK_SELECTION
+++++++++++++++++++++
.. csv-table:: POSIX_CLOCK_SELECTION
.. _posix_options:
Additional POSIX Options
========================
.. _posix_option_message_passing:
_POSIX_MESSAGE_PASSING
++++++++++++++++++++++
.. csv-table:: _POSIX_MESSAGE_PASSING
:header: API, Supported
:widths: 50,10
pthread_condattr_getclock(),yes
pthread_condattr_setclock(),yes
clock_nanosleep(),yes
mq_close(),yes
mq_getattr(),yes
mq_notify(),
mq_open(),yes
mq_receive(),yes
mq_send(),yes
mq_setattr(),yes
mq_unlink(),yes
_POSIX_PRIORITY_SCHEDULING
++++++++++++++++++++++++++
.. _posix_option_priority_scheduling:
.. csv-table:: _POSIX_PRIORITY_SCHEDULING
:header: API, Supported
:widths: 50,10
sched_get_priority_max(),yes
sched_get_priority_min(),yes
sched_getparam(),
sched_getscheduler(),
sched_rr_get_interval(),
sched_setparam(),
sched_setscheduler(),
sched_yield(),yes
.. _posix_option_reader_writer_locks:
_POSIX_READER_WRITER_LOCKS
++++++++++++++++++++++++++
.. csv-table:: _POSIX_READER_WRITER_LOCKS
:header: API, Supported
:widths: 50,10
pthread_rwlock_destroy(),yes
pthread_rwlock_init(),yes
pthread_rwlock_rdlock(),yes
pthread_rwlock_tryrdlock(),yes
pthread_rwlock_trywrlock(),yes
pthread_rwlock_unlock(),yes
pthread_rwlock_wrlock(),yes
pthread_rwlockattr_destroy(),yes
pthread_rwlockattr_getpshared(),
pthread_rwlockattr_init(),yes
pthread_rwlockattr_setpshared(),
.. _posix_option_thread_attr_stackaddr:
_POSIX_THREAD_ATTR_STACKADDR
++++++++++++++++++++++++++++
.. csv-table:: _POSIX_THREAD_ATTR_STACKADDR
:header: API, Supported
:widths: 50,10
pthread_attr_getstackaddr(),yes
pthread_attr_setstackaddr(),yes
.. _posix_option_thread_attr_stacksize:
_POSIX_THREAD_ATTR_STACKSIZE
++++++++++++++++++++++++++++
.. csv-table:: _POSIX_THREAD_ATTR_STACKSIZE
:header: API, Supported
:widths: 50,10
pthread_attr_getstacksize(),yes
pthread_attr_setstacksize(),yes
.. _posix_option_thread_priority_scheduling:
_POSIX_THREAD_PRIORITY_SCHEDULING
+++++++++++++++++++++++++++++++++
.. csv-table:: _POSIX_THREAD_PRIORITY_SCHEDULING
:header: API, Supported
:widths: 50,10
pthread_attr_getinheritsched(),
pthread_attr_getschedpolicy(),yes
pthread_attr_getscope(),
pthread_attr_setinheritsched(),
pthread_attr_setschedpolicy(),yes
pthread_attr_setscope(),
pthread_getschedparam(),yes
pthread_setschedparam(),yes
pthread_setschedprio(),yes
.. _posix_option_timeouts:
_POSIX_TIMEOUTS
+++++++++++++++
.. csv-table:: _POSIX_TIMEOUTS
:header: API, Supported
:widths: 50,10
mq_timedreceive(),
mq_timedsend(),
pthread_mutex_timedlock(),yes
pthread_rwlock_timedrdlock(),yes
pthread_rwlock_timedwrlock(),yes
sem_timedwait(),yes
posix_trace_timedgetnext_event(),
.. _posix_option_xopen_streams:
_XOPEN_STREAMS
++++++++++++++
.. csv-table:: _XOPEN_STREAMS
:header: API, Supported
:widths: 50,10
fattach(),
fdetach(),
getmsg(),
getpmsg(),
ioctl(),yes
isastream(),
putmsg(),
putpmsg(),

View File

@@ -0,0 +1,135 @@
.. _posix_overview:
Overview
########
The Portable Operating System Interface (POSIX) is a family of standards specified by the
`IEEE Computer Society`_ for maintaining compatibility between operating systems. Zephyr
implements a subset of the standard POSIX API specified by `IEEE 1003.1-2017`_ (also known as
POSIX-1.2017).
.. figure:: posix.svg
:align: center
:alt: POSIX Support in Zephyr
POSIX support in Zephyr
.. note::
This page does not document Zephyr's :ref:`POSIX architecture<Posix arch>`, which is used to
run Zephyr as a native application under the host operating system for prototyping,
test, and diagnostic purposes.
With the POSIX support available in Zephyr, an existing POSIX conformant
application can be ported to run on the Zephyr kernel, and therefore leverage
Zephyr features and functionality. Additionally, a library designed to be
POSIX conformant can be ported to Zephyr kernel based applications with no changes.
The POSIX API is an increasingly popular OSAL (operating system abstraction layer) for IoT and
embedded applications, as can be seen in Zephyr, AWS:FreeRTOS, TI-RTOS, and NuttX.
Benefits of POSIX support in Zephyr include:
- Offering a familiar API to non-embedded programmers, especially from Linux
- Enabling reuse (portability) of existing libraries based on POSIX APIs
- Providing an efficient API subset appropriate for small (MCU) embedded systems
.. _posix_subprofiles:
POSIX Subprofiles
=================
While Zephyr supports running multiple `threads <threads_v2>`_ (possibly in an `SMP <smp_arch>`_
configuration), as well as `Virtual Memory and MMUs <memory_management_api>`_, Zephyr code and data
normally share a common address space. The Zephyr kernel executable code and the application
executable code are typically compiled into the same binary artifact. From that perspective, Zephyr
apps can be seen as running in the context of a single process.
While multi-purpose operating systems (OS) offer full POSIX conformance, Real-Time Operating
Systems (RTOS) such as Zephyr typically serve a fixed-purpose, have limited hardware resources,
and experience limited user interaction. In such systems, full POSIX conformance can be
impractical and unnecessary.
For that reason, POSIX defined the following :ref:`Application Environment Profiles (AEP)<posix_aep>`
as part of `IEEE 1003.13-2003`_ (also known as POSIX.13-2003).
* Minimal Realtime System Profile (:ref:`PSE51 <posix_aep_pse51>`)
* Realtime Controller System Profile (:ref:`PSE52 <posix_aep_pse52>`)
* Dedicated Realtime System Profile (:ref:`PSE53 <posix_aep_pse53>`)
* Multi-Purpose Realtime System (PSE54)
POSIX.13-2003 AEP were formalized in 2003 via "Units of Functionality" but the specification is now
inactive (for reference only). Nevertheless, the intent is still captured as part of POSIX-1.2017
via :ref:`Options<posix_options>` and :ref:`Option Groups<posix_option_groups>`, in Appendix E.
.. _posix_apps:
POSIX Applications in Zephyr
============================
A POSIX app in Zephyr is :ref:`built like any other app<application>` and therefore requires the
usual :file:`prj.conf`, :file:`CMakeLists.txt`, and source code. For example, the app below
leverages the ``nanosleep()`` and ``perror()`` POSIX functions.
.. code-block:: cfg
:caption: `prj.conf` for a simple POSIX app in Zephyr
CONFIG_POSIX_API=y
.. code-block:: c
:caption: A simple app that uses Zephyr's POSIX API
#include <stddef.h>
#include <stdio.h>
#include <time.h>
void megasleep(size_t megaseconds)
{
struct timespec ts = {
.tv_sec = megaseconds * 1000000,
.tv_nsec = 0,
};
printf("See you in a while!\n");
if (nanosleep(&ts, NULL) == -1) {
perror("nanosleep");
}
}
int main()
{
megasleep(42);
return 0;
}
..
TODO: insert a link to a list of all samples tagged with 'posix'
.. _posix_config:
Configuration
=============
Like most features in Zephyr, POSIX features are
:ref:`highly configurable<zephyr_intro_configurability>` but disabled by default. Users must
explicitly choose to enable POSIX options via :ref:`Kconfig<kconfig>` selection. Indeed, there are
:ref:`many Kconfig options in Zephyr<posix_kconfig_options>` for the POSIX API to allow for
feature selection at various levels of granularity.
Alternatively, users may enable one of the Kconfig options below as a shortcut to enable multiple
:ref:`Option Groups<posix_option_groups>`.
* :kconfig:option:`CONFIG_POSIX_API`
* :kconfig:option:`CONFIG_PTHREAD_IPC`
.. note::
Since the POSIX environment in Zephyr is fully configurable via :ref:`Kconfig<kconfig>`,
configurations that require modifying features should not be made if strict compliance is
required (POSIX-1.2017, section 2.1.3.1).
..
TODO: create Kconfig shortcuts for PSE51, PSE52, and PSE53
.. _IEEE: https://www.ieee.org/
.. _IEEE Computer Society: https://www.computer.org/
.. _IEEE 1003.1-2017: https://standards.ieee.org/ieee/1003.1/7101/
.. _IEEE 1003.13-2003: https://standards.ieee.org/ieee/1003.13/3322/

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -235,17 +235,22 @@ priority.
it cannot access the channel since it is still locked.
* - i
- VDED finishes the publishing by unlocking channel A.
- VDED finishes the publishing by unlocking channel A. The MS1 leaves the pending state and
starts executing.
* - j, k, l
* - j
- MS1 finishes execution. The MS2 leaves the pending state and starts executing.
* - k
- MS2 finishes execution. The S1 leaves the pending state and starts executing.
* - l, m, n
- The S1 leaves the pending state since channel A is not locked. It gets in the CPU again and
starts executing. As it did receive a notification from channel A, it performs a channel read
(as simple as lock, memory copy, unlock), continues its execution, and goes out the CPU.
* - m
- S1 goes out of the MCU.
starts executing. As it did receive a notification from channel A, it performed a channel read
(as simple as lock, memory copy, unlock), continues its execution and goes out of the CPU.
* - n, o
- MS2 and MS1 execute and finish their workload.
* - o
- S1 finishes its workload.
The figure below illustrates the actions performed during the VDED execution when T1 publishes to

View File

@@ -639,7 +639,7 @@ static int lmp90xxx_adc_read_channel(const struct device *dev,
if (buf[3] != crc) {
LOG_ERR("CRC mismatch (0x%02x vs. 0x%02x)", buf[3],
crc);
return err;
return -EIO;
}
}

View File

@@ -1007,8 +1007,6 @@ static void adc_context_on_complete(struct adc_context *ctx, int status)
ARG_UNUSED(status);
adc_stm32_disable(adc);
/* Reset acquisition time used for the sequence */
data->acq_time_index = -1;
@@ -1019,6 +1017,8 @@ static void adc_context_on_complete(struct adc_context *ctx, int status)
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32U5X)
/* Reset channel preselection register */
LL_ADC_SetChannelPreselection(adc, 0);
#else
ARG_UNUSED(adc);
#endif /* CONFIG_SOC_SERIES_STM32H7X || CONFIG_SOC_SERIES_STM32U5X */
}

View File

@@ -1,4 +1,4 @@
# Bosch m_can configuration options
# Bosch M_CAN configuration options
# Copyright (c) 2020 Alexander Wachter
# SPDX-License-Identifier: Apache-2.0
@@ -6,17 +6,4 @@
config CAN_MCAN
bool
help
Enable Bosch m_can driver.
This driver supports the Bosch m_can IP. This IP is built into the
STM32G4, STM32G0, STM32H7, and the Microchip SAM controllers with
CAN-FD.
if CAN_MCAN
config CAN_DELAY_COMP
bool "Transceiver delay compensation"
default y
help
Enable the automatic transceiver delay compensation.
endif #CAN_MCAN
Enable the Bosch M_CAN CAN IP module driver backend.

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

@@ -225,8 +225,10 @@ unlock:
#ifdef CONFIG_CAN_FD_MODE
int can_mcan_set_timing_data(const struct device *dev, const struct can_timing *timing_data)
{
const uint8_t tdco_max = FIELD_GET(CAN_MCAN_TDCR_TDCO, CAN_MCAN_TDCR_TDCO);
struct can_mcan_data *data = dev->data;
uint32_t dbtp = 0U;
uint8_t tdco;
int err;
if (data->started) {
@@ -240,6 +242,23 @@ int can_mcan_set_timing_data(const struct device *dev, const struct can_timing *
FIELD_PREP(CAN_MCAN_DBTP_DTSEG2, timing_data->phase_seg2 - 1UL) |
FIELD_PREP(CAN_MCAN_DBTP_DBRP, timing_data->prescaler - 1UL);
if (timing_data->prescaler == 1U || timing_data->prescaler == 2U) {
/* TDC can only be enabled if DBRP = { 0, 1 } */
dbtp |= CAN_MCAN_DBTP_TDC;
/* Set TDC offset for correct location of the Secondary Sample Point (SSP) */
tdco = CAN_CALC_TDCO(timing_data, 0U, tdco_max);
LOG_DBG("TDC enabled, using TDCO %u", tdco);
err = can_mcan_write_reg(dev, CAN_MCAN_TDCR, FIELD_PREP(CAN_MCAN_TDCR_TDCO, tdco));
if (err != 0) {
goto unlock;
}
} else {
LOG_DBG("TDC cannot be enabled, prescaler value %u too high",
timing_data->prescaler);
}
err = can_mcan_write_reg(dev, CAN_MCAN_DBTP, dbtp);
if (err != 0) {
goto unlock;
@@ -426,16 +445,59 @@ unlock:
static void can_mcan_state_change_handler(const struct device *dev)
{
const struct can_mcan_config *config = dev->config;
struct can_mcan_data *data = dev->data;
const can_state_change_callback_t cb = data->state_change_cb;
void *cb_data = data->state_change_cb_data;
const can_state_change_callback_t state_cb = data->state_change_cb;
void *state_cb_data = data->state_change_cb_data;
const struct can_mcan_callbacks *cbs = config->callbacks;
can_tx_callback_t tx_cb;
uint32_t tx_idx;
struct can_bus_err_cnt err_cnt;
enum can_state state;
uint32_t cccr;
int err;
(void)can_mcan_get_state(dev, &state, &err_cnt);
if (cb != NULL) {
cb(dev, state, err_cnt, cb_data);
if (state_cb != NULL) {
state_cb(dev, state, err_cnt, state_cb_data);
}
if (state == CAN_STATE_BUS_OFF) {
/* Request all TX buffers to be cancelled */
err = can_mcan_write_reg(dev, CAN_MCAN_TXBCR, CAN_MCAN_TXBCR_CR);
if (err != 0) {
return;
}
/* Call all TX queue callbacks with -ENETUNREACH */
for (tx_idx = 0U; tx_idx < cbs->num_tx; tx_idx++) {
tx_cb = cbs->tx[tx_idx].function;
if (tx_cb != NULL) {
cbs->tx[tx_idx].function = NULL;
tx_cb(dev, -ENETUNREACH, cbs->tx[tx_idx].user_data);
k_sem_give(&data->tx_sem);
}
}
if (IS_ENABLED(CONFIG_CAN_AUTO_BUS_OFF_RECOVERY)) {
/*
* Request leaving init mode, but do not take the lock (as we are in ISR
* context), nor wait for the result.
*/
err = can_mcan_read_reg(dev, CAN_MCAN_CCCR, &cccr);
if (err != 0) {
return;
}
cccr &= ~CAN_MCAN_CCCR_INIT;
err = can_mcan_write_reg(dev, CAN_MCAN_CCCR, cccr);
if (err != 0) {
return;
}
}
}
}
@@ -1149,12 +1211,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;
}
@@ -1407,32 +1474,6 @@ int can_mcan_init(const struct device *dev)
return err;
}
#if defined(CONFIG_CAN_DELAY_COMP) && defined(CONFIG_CAN_FD_MODE)
err = can_mcan_read_reg(dev, CAN_MCAN_DBTP, &reg);
if (err != 0) {
return err;
}
reg |= CAN_MCAN_DBTP_TDC;
err = can_mcan_write_reg(dev, CAN_MCAN_DBTP, reg);
if (err != 0) {
return err;
}
err = can_mcan_read_reg(dev, CAN_MCAN_TDCR, &reg);
if (err != 0) {
return err;
}
reg |= FIELD_PREP(CAN_MCAN_TDCR_TDCO, config->tx_delay_comp_offset);
err = can_mcan_write_reg(dev, CAN_MCAN_TDCR, reg);
if (err != 0) {
return err;
}
#endif /* defined(CONFIG_CAN_DELAY_COMP) && defined(CONFIG_CAN_FD_MODE) */
err = can_mcan_read_reg(dev, CAN_MCAN_GFC, &reg);
if (err != 0) {
return err;
@@ -1527,7 +1568,7 @@ int can_mcan_init(const struct device *dev)
return err;
}
/* Interrupt on every TX fifo element*/
/* Interrupt on every TX buffer transmission event */
reg = CAN_MCAN_TXBTIE_TIE;
err = can_mcan_write_reg(dev, CAN_MCAN_TXBTIE, reg);
if (err != 0) {

View File

@@ -661,6 +661,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

@@ -922,9 +922,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;
}

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

@@ -975,7 +975,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

@@ -560,7 +560,7 @@ static int cmd_can_send(const struct shell *sh, size_t argc, char **argv)
const struct device *dev = device_get_binding(argv[1]);
static unsigned int frame_counter;
unsigned int frame_no;
struct can_frame frame;
struct can_frame frame = { 0 };
uint32_t max_id;
int argidx = 2;
uint32_t val;
@@ -665,7 +665,7 @@ static int cmd_can_send(const struct shell *sh, size_t argc, char **argv)
(frame.flags & CAN_FRAME_RTR) != 0 ? 1 : 0,
(frame.flags & CAN_FRAME_FDF) != 0 ? 1 : 0,
(frame.flags & CAN_FRAME_BRS) != 0 ? 1 : 0,
can_dlc_to_bytes(frame.dlc));
frame.dlc);
err = can_send(dev, &frame, K_NO_WAIT, can_shell_tx_callback, UINT_TO_POINTER(frame_no));
if (err != 0) {

View File

@@ -1035,7 +1035,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);

View File

@@ -297,14 +297,15 @@ int eth_ivshmem_initialize(const struct device *dev)
}
dev_data->peer_id = (id == 0) ? 1 : 0;
bool tx_buffer_first = id == 0;
uintptr_t output_section_addr;
uintptr_t output_sections[2];
size_t output_section_size = ivshmem_get_output_mem_section(
cfg_data->ivshmem, 0, &output_section_addr);
cfg_data->ivshmem, 0, &output_sections[0]);
ivshmem_get_output_mem_section(
cfg_data->ivshmem, 1, &output_sections[1]);
res = eth_ivshmem_queue_init(
&dev_data->ivshmem_queue, output_section_addr,
output_section_size, tx_buffer_first);
&dev_data->ivshmem_queue, output_sections[id],
output_sections[dev_data->peer_id], output_section_size);
if (res != 0) {
LOG_ERR("Failed to init ivshmem queue");
return res;

View File

@@ -40,8 +40,8 @@ struct eth_ivshmem_queue {
};
int eth_ivshmem_queue_init(
struct eth_ivshmem_queue *q, uintptr_t shmem,
size_t shmem_section_size, bool tx_buffer_first);
struct eth_ivshmem_queue *q, uintptr_t tx_shmem,
uintptr_t rx_shmem, size_t shmem_section_size);
void eth_ivshmem_queue_reset(struct eth_ivshmem_queue *q);
int eth_ivshmem_queue_tx_get_buff(struct eth_ivshmem_queue *q, void **data, size_t len);
int eth_ivshmem_queue_tx_commit_buff(struct eth_ivshmem_queue *q);

View File

@@ -28,8 +28,8 @@ static int tx_clean_used(struct eth_ivshmem_queue *q);
static int get_rx_avail_desc_idx(struct eth_ivshmem_queue *q, uint16_t *avail_desc_idx);
int eth_ivshmem_queue_init(
struct eth_ivshmem_queue *q, uintptr_t shmem,
size_t shmem_section_size, bool tx_buffer_first)
struct eth_ivshmem_queue *q, uintptr_t tx_shmem,
uintptr_t rx_shmem, size_t shmem_section_size)
{
memset(q, 0, sizeof(*q));
@@ -44,14 +44,8 @@ int eth_ivshmem_queue_init(
q->desc_max_len = vring_desc_len;
q->vring_data_max_len = shmem_section_size - vring_header_size;
q->vring_header_size = vring_header_size;
if (tx_buffer_first) {
q->tx.shmem = (void *)shmem;
q->rx.shmem = (void *)(shmem + shmem_section_size);
} else {
q->rx.shmem = (void *)shmem;
q->tx.shmem = (void *)(shmem + shmem_section_size);
}
q->tx.shmem = (void *)tx_shmem;
q->rx.shmem = (void *)rx_shmem;
/* Init vrings */
vring_init(&q->tx.vring, vring_desc_len, q->tx.shmem, ETH_IVSHMEM_VRING_ALIGNMENT);

View File

@@ -58,9 +58,17 @@ enum {
ERASE_CHIP,
};
struct flash_flexspi_nor_config {
/* Note: don't use this controller reference in code. It is
* only used during init to copy the device structure from ROM
* into a RAM structure
*/
const struct device *controller;
};
/* Device variables used in critical sections should be in this structure */
struct flash_flexspi_nor_data {
const struct device *controller;
struct device controller;
flexspi_device_config_t config;
flexspi_port_t port;
struct flash_pages_layout layout;
@@ -154,10 +162,9 @@ static const uint32_t flash_flexspi_nor_lut[][4] = {
},
};
static int flash_flexspi_nor_get_vendor_id(const struct device *dev,
static int flash_flexspi_nor_get_vendor_id(struct flash_flexspi_nor_data *data,
uint8_t *vendor_id)
{
struct flash_flexspi_nor_data *data = dev->data;
uint32_t buffer = 0;
int ret;
@@ -173,17 +180,15 @@ static int flash_flexspi_nor_get_vendor_id(const struct device *dev,
LOG_DBG("Reading id");
ret = memc_flexspi_transfer(data->controller, &transfer);
ret = memc_flexspi_transfer(&data->controller, &transfer);
*vendor_id = buffer;
return ret;
}
static int flash_flexspi_nor_read_status(const struct device *dev,
static int flash_flexspi_nor_read_status(struct flash_flexspi_nor_data *data,
uint32_t *status)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = 0,
.port = data->port,
@@ -196,14 +201,12 @@ static int flash_flexspi_nor_read_status(const struct device *dev,
LOG_DBG("Reading status register");
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_write_status(const struct device *dev,
static int flash_flexspi_nor_write_status(struct flash_flexspi_nor_data *data,
uint32_t *status)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = 0,
.port = data->port,
@@ -216,13 +219,11 @@ static int flash_flexspi_nor_write_status(const struct device *dev,
LOG_DBG("Writing status register");
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_write_enable(const struct device *dev)
static int flash_flexspi_nor_write_enable(struct flash_flexspi_nor_data *data)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = 0,
.port = data->port,
@@ -235,14 +236,12 @@ static int flash_flexspi_nor_write_enable(const struct device *dev)
LOG_DBG("Enabling write");
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_erase_sector(const struct device *dev,
static int flash_flexspi_nor_erase_sector(struct flash_flexspi_nor_data *data,
off_t offset)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = offset,
.port = data->port,
@@ -255,14 +254,12 @@ static int flash_flexspi_nor_erase_sector(const struct device *dev,
LOG_DBG("Erasing sector at 0x%08zx", (ssize_t) offset);
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_erase_block(const struct device *dev,
static int flash_flexspi_nor_erase_block(struct flash_flexspi_nor_data *data,
off_t offset)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = offset,
.port = data->port,
@@ -275,13 +272,11 @@ static int flash_flexspi_nor_erase_block(const struct device *dev,
LOG_DBG("Erasing block at 0x%08zx", (ssize_t) offset);
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_erase_chip(const struct device *dev)
static int flash_flexspi_nor_erase_chip(struct flash_flexspi_nor_data *data)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = 0,
.port = data->port,
@@ -294,14 +289,12 @@ static int flash_flexspi_nor_erase_chip(const struct device *dev)
LOG_DBG("Erasing chip");
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_page_program(const struct device *dev,
static int flash_flexspi_nor_page_program(struct flash_flexspi_nor_data *data,
off_t offset, const void *buffer, size_t len)
{
struct flash_flexspi_nor_data *data = dev->data;
flexspi_transfer_t transfer = {
.deviceAddress = offset,
.port = data->port,
@@ -314,16 +307,16 @@ static int flash_flexspi_nor_page_program(const struct device *dev,
LOG_DBG("Page programming %d bytes to 0x%08zx", len, (ssize_t) offset);
return memc_flexspi_transfer(data->controller, &transfer);
return memc_flexspi_transfer(&data->controller, &transfer);
}
static int flash_flexspi_nor_wait_bus_busy(const struct device *dev)
static int flash_flexspi_nor_wait_bus_busy(struct flash_flexspi_nor_data *data)
{
uint32_t status = 0;
int ret;
do {
ret = flash_flexspi_nor_read_status(dev, &status);
ret = flash_flexspi_nor_read_status(data, &status);
LOG_DBG("status: 0x%x", status);
if (ret) {
LOG_ERR("Could not read status");
@@ -334,14 +327,13 @@ static int flash_flexspi_nor_wait_bus_busy(const struct device *dev)
return 0;
}
static int flash_flexspi_nor_enable_quad_mode(const struct device *dev)
static int flash_flexspi_nor_enable_quad_mode(struct flash_flexspi_nor_data *data)
{
struct flash_flexspi_nor_data *data = dev->data;
uint32_t status = 0x40;
flash_flexspi_nor_write_status(dev, &status);
flash_flexspi_nor_wait_bus_busy(dev);
memc_flexspi_reset(data->controller);
flash_flexspi_nor_write_status(data, &status);
flash_flexspi_nor_wait_bus_busy(data);
memc_flexspi_reset(&data->controller);
return 0;
}
@@ -350,7 +342,7 @@ static int flash_flexspi_nor_read(const struct device *dev, off_t offset,
void *buffer, size_t len)
{
struct flash_flexspi_nor_data *data = dev->data;
uint8_t *src = memc_flexspi_get_ahb_address(data->controller,
uint8_t *src = memc_flexspi_get_ahb_address(&data->controller,
data->port,
offset);
@@ -368,11 +360,11 @@ static int flash_flexspi_nor_write(const struct device *dev, off_t offset,
int i;
unsigned int key = 0;
uint8_t *dst = memc_flexspi_get_ahb_address(data->controller,
uint8_t *dst = memc_flexspi_get_ahb_address(&data->controller,
data->port,
offset);
if (memc_flexspi_is_running_xip(data->controller)) {
if (memc_flexspi_is_running_xip(&data->controller)) {
/*
* ==== ENTER CRITICAL SECTION ====
* No flash access should be performed in critical section. All
@@ -390,20 +382,20 @@ static int flash_flexspi_nor_write(const struct device *dev, off_t offset,
#ifdef CONFIG_FLASH_MCUX_FLEXSPI_NOR_WRITE_BUFFER
memcpy(nor_write_buf, src, i);
#endif
flash_flexspi_nor_write_enable(dev);
flash_flexspi_nor_write_enable(data);
#ifdef CONFIG_FLASH_MCUX_FLEXSPI_NOR_WRITE_BUFFER
flash_flexspi_nor_page_program(dev, offset, nor_write_buf, i);
flash_flexspi_nor_page_program(data, offset, nor_write_buf, i);
#else
flash_flexspi_nor_page_program(dev, offset, src, i);
flash_flexspi_nor_page_program(data, offset, src, i);
#endif
flash_flexspi_nor_wait_bus_busy(dev);
memc_flexspi_reset(data->controller);
flash_flexspi_nor_wait_bus_busy(data);
memc_flexspi_reset(&data->controller);
src += i;
offset += i;
len -= i;
}
if (memc_flexspi_is_running_xip(data->controller)) {
if (memc_flexspi_is_running_xip(&data->controller)) {
/* ==== EXIT CRITICAL SECTION ==== */
irq_unlock(key);
}
@@ -425,7 +417,7 @@ static int flash_flexspi_nor_erase(const struct device *dev, off_t offset,
int i;
unsigned int key = 0;
uint8_t *dst = memc_flexspi_get_ahb_address(data->controller,
uint8_t *dst = memc_flexspi_get_ahb_address(&data->controller,
data->port,
offset);
@@ -439,7 +431,7 @@ static int flash_flexspi_nor_erase(const struct device *dev, off_t offset,
return -EINVAL;
}
if (memc_flexspi_is_running_xip(data->controller)) {
if (memc_flexspi_is_running_xip(&data->controller)) {
/*
* ==== ENTER CRITICAL SECTION ====
* No flash access should be performed in critical section. All
@@ -449,29 +441,29 @@ static int flash_flexspi_nor_erase(const struct device *dev, off_t offset,
}
if ((offset == 0) && (size == data->config.flashSize * KB(1))) {
flash_flexspi_nor_write_enable(dev);
flash_flexspi_nor_erase_chip(dev);
flash_flexspi_nor_wait_bus_busy(dev);
memc_flexspi_reset(data->controller);
flash_flexspi_nor_write_enable(data);
flash_flexspi_nor_erase_chip(data);
flash_flexspi_nor_wait_bus_busy(data);
memc_flexspi_reset(&data->controller);
} else if ((0 == (offset % SPI_NOR_BLOCK_SIZE)) && (0 == (size % SPI_NOR_BLOCK_SIZE))) {
for (i = 0; i < num_blocks; i++) {
flash_flexspi_nor_write_enable(dev);
flash_flexspi_nor_erase_block(dev, offset);
flash_flexspi_nor_wait_bus_busy(dev);
memc_flexspi_reset(data->controller);
flash_flexspi_nor_write_enable(data);
flash_flexspi_nor_erase_block(data, offset);
flash_flexspi_nor_wait_bus_busy(data);
memc_flexspi_reset(&data->controller);
offset += SPI_NOR_BLOCK_SIZE;
}
} else {
for (i = 0; i < num_sectors; i++) {
flash_flexspi_nor_write_enable(dev);
flash_flexspi_nor_erase_sector(dev, offset);
flash_flexspi_nor_wait_bus_busy(dev);
memc_flexspi_reset(data->controller);
flash_flexspi_nor_write_enable(data);
flash_flexspi_nor_erase_sector(data, offset);
flash_flexspi_nor_wait_bus_busy(data);
memc_flexspi_reset(&data->controller);
offset += SPI_NOR_SECTOR_SIZE;
}
}
if (memc_flexspi_is_running_xip(data->controller)) {
if (memc_flexspi_is_running_xip(&data->controller)) {
/* ==== EXIT CRITICAL SECTION ==== */
irq_unlock(key);
}
@@ -504,17 +496,24 @@ static void flash_flexspi_nor_pages_layout(const struct device *dev,
static int flash_flexspi_nor_init(const struct device *dev)
{
const struct flash_flexspi_nor_config *config = dev->config;
struct flash_flexspi_nor_data *data = dev->data;
uint8_t vendor_id;
uint32_t temp_lut[sizeof(flash_flexspi_nor_lut) / sizeof(uint32_t)];
if (!device_is_ready(data->controller)) {
/* First step- use ROM pointer to controller device to create
* a copy of the device structure in RAM we can use while in
* critical sections of code.
*/
memcpy(&data->controller, config->controller, sizeof(struct device));
if (!device_is_ready(&data->controller)) {
LOG_ERR("Controller device is not ready");
return -ENODEV;
}
if (!memc_flexspi_is_running_xip(data->controller) &&
memc_flexspi_set_device_config(data->controller, &data->config,
if (!memc_flexspi_is_running_xip(&data->controller) &&
memc_flexspi_set_device_config(&data->controller, &data->config,
data->port)) {
LOG_ERR("Could not set device configuration");
return -EINVAL;
@@ -530,22 +529,22 @@ static int flash_flexspi_nor_init(const struct device *dev)
memcpy(temp_lut, flash_flexspi_nor_lut,
sizeof(flash_flexspi_nor_lut));
if (memc_flexspi_update_lut(data->controller, 0,
if (memc_flexspi_update_lut(&data->controller, 0,
(const uint32_t *) temp_lut,
sizeof(temp_lut) / sizeof(uint32_t))) {
LOG_ERR("Could not update lut");
return -EINVAL;
}
memc_flexspi_reset(data->controller);
memc_flexspi_reset(&data->controller);
if (flash_flexspi_nor_get_vendor_id(dev, &vendor_id)) {
if (flash_flexspi_nor_get_vendor_id(data, &vendor_id)) {
LOG_ERR("Could not read vendor id");
return -EIO;
}
LOG_DBG("Vendor id: 0x%0x", vendor_id);
if (flash_flexspi_nor_enable_quad_mode(dev)) {
if (flash_flexspi_nor_enable_quad_mode(data)) {
LOG_ERR("Could not enable quad mode");
return -EIO;
}
@@ -596,9 +595,12 @@ static const struct flash_driver_api flash_flexspi_nor_api = {
} \
#define FLASH_FLEXSPI_NOR(n) \
static const struct flash_flexspi_nor_config \
flash_flexspi_nor_config_##n = { \
.controller = DEVICE_DT_GET(DT_INST_BUS(n)), \
}; \
static struct flash_flexspi_nor_data \
flash_flexspi_nor_data_##n = { \
.controller = DEVICE_DT_GET(DT_INST_BUS(n)), \
.config = FLASH_FLEXSPI_DEVICE_CONFIG(n), \
.port = DT_INST_REG_ADDR(n), \
.layout = { \
@@ -616,7 +618,7 @@ static const struct flash_driver_api flash_flexspi_nor_api = {
flash_flexspi_nor_init, \
NULL, \
&flash_flexspi_nor_data_##n, \
NULL, \
&flash_flexspi_nor_config_##n, \
POST_KERNEL, \
CONFIG_FLASH_INIT_PRIORITY, \
&flash_flexspi_nor_api);

View File

@@ -70,7 +70,7 @@ static int riscv_plic_is_edge_irq(uint32_t irq)
volatile uint32_t *trig = (volatile uint32_t *)PLIC_EDGE_TRIG_TYPE;
trig += (irq >> PLIC_EDGE_TRIG_SHIFT);
return *trig & BIT(irq);
return *trig & BIT(irq & BIT_MASK(PLIC_EDGE_TRIG_SHIFT));
}
/**

View File

@@ -16,10 +16,8 @@
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
#endif
#include <zephyr/drivers/pinctrl.h>
#ifdef CONFIG_PM_DEVICE
#include <zephyr/pm/device.h>
#include <zephyr/pm/policy.h>
#endif
#include <zephyr/drivers/ps2.h>
#include <soc.h>
#include <zephyr/logging/log.h>

View File

@@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(ams_as5600, CONFIG_SENSOR_LOG_LEVEL);
#define AS5600_ANGLE_REGISTER_H 0x0E
#define AS5600_FULL_ANGLE 360
#define AS5600_PULSES_PER_REV 4096
#define AS5600_MILLION_UNIT 1000000
struct as5600_dev_cfg {
struct i2c_dt_spec i2c_port;
@@ -60,8 +61,8 @@ static int as5600_get(const struct device *dev, enum sensor_channel chan,
val->val1 = ((int32_t)dev_data->position * AS5600_FULL_ANGLE) /
AS5600_PULSES_PER_REV;
val->val2 = ((int32_t)dev_data->position * AS5600_FULL_ANGLE) -
(val->val1 * AS5600_PULSES_PER_REV);
val->val2 = (((int32_t)dev_data->position * AS5600_FULL_ANGLE) %
AS5600_PULSES_PER_REV) * (AS5600_MILLION_UNIT / AS5600_PULSES_PER_REV);
} else {
return -ENOTSUP;
}

View File

@@ -7,7 +7,8 @@ config TEMP_KINETIS
bool "NXP Kinetis Temperature Sensor"
default y
depends on DT_HAS_NXP_KINETIS_TEMPERATURE_ENABLED
depends on (ADC && SOC_FAMILY_KINETIS)
depends on SOC_FAMILY_KINETIS
select ADC
help
Enable driver for NXP Kinetis temperature sensor.

View File

@@ -159,7 +159,7 @@ static int temp_kinetis_init(const struct device *dev)
},
};
memset(&data->buffer, 0, ARRAY_SIZE(data->buffer));
memset(&data->buffer, 0, sizeof(data->buffer));
if (!device_is_ready(config->adc)) {
LOG_ERR("ADC device is not ready");

View File

@@ -225,13 +225,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

@@ -66,4 +66,10 @@ config IVSHMEM_V2
Enable ivshmem-v2 support.
ivshmem-v2 is primarily used for IPC in the Jailhouse hypervisor.
config IVSHMEM_V2_MAX_PEERS
int "Maximum number of ivshmem-v2 peers"
depends on IVSHMEM_V2
default 2
range 2 65536
endif # VIRTUALIZATION

View File

@@ -198,7 +198,7 @@ static bool ivshmem_configure(const struct device *dev)
(volatile struct ivshmem_v2_reg *)DEVICE_MMIO_GET(dev);
data->max_peers = regs->max_peers;
if (!IN_RANGE(data->max_peers, 2, 0x10000)) {
if (!IN_RANGE(data->max_peers, 2, CONFIG_IVSHMEM_V2_MAX_PEERS)) {
LOG_ERR("Invalid max peers %u", data->max_peers);
return false;
}
@@ -211,26 +211,49 @@ static bool ivshmem_configure(const struct device *dev)
shmem_phys_addr = pcie_conf_read_u64(data->pcie->bdf, cap_pos);
}
/* State table R/O */
cap_pos = vendor_cap + IVSHMEM_CFG_STATE_TAB_SZ / 4;
size_t state_table_size = pcie_conf_read(data->pcie->bdf, cap_pos);
LOG_INF("State table size 0x%zX", state_table_size);
if (state_table_size < sizeof(uint32_t) * data->max_peers) {
LOG_ERR("Invalid state table size %zu", state_table_size);
return false;
}
z_phys_map((uint8_t **)&data->state_table_shmem,
shmem_phys_addr, state_table_size,
K_MEM_CACHE_WB | K_MEM_PERM_USER);
/* R/W section (optional) */
cap_pos = vendor_cap + IVSHMEM_CFG_RW_SECTION_SZ / 4;
data->rw_section_size = pcie_conf_read_u64(data->pcie->bdf, cap_pos);
data->rw_section_offset = state_table_size;
size_t rw_section_offset = state_table_size;
LOG_INF("RW section size 0x%zX", data->rw_section_size);
if (data->rw_section_size > 0) {
z_phys_map((uint8_t **)&data->rw_section_shmem,
shmem_phys_addr + rw_section_offset, data->rw_section_size,
K_MEM_CACHE_WB | K_MEM_PERM_RW | K_MEM_PERM_USER);
}
/* Output sections */
cap_pos = vendor_cap + IVSHMEM_CFG_OUTPUT_SECTION_SZ / 4;
data->output_section_size = pcie_conf_read_u64(data->pcie->bdf, cap_pos);
data->output_section_offset = data->rw_section_offset + data->rw_section_size;
size_t output_section_offset = rw_section_offset + data->rw_section_size;
LOG_INF("Output section size 0x%zX", data->output_section_size);
for (uint32_t i = 0; i < data->max_peers; i++) {
uintptr_t phys_addr = shmem_phys_addr +
output_section_offset +
(data->output_section_size * i);
uint32_t flags = K_MEM_CACHE_WB | K_MEM_PERM_USER;
data->size = data->output_section_offset +
/* Only your own output section is R/W */
if (i == regs->id) {
flags |= K_MEM_PERM_RW;
}
z_phys_map((uint8_t **)&data->output_section_shmem[i],
phys_addr, data->output_section_size, flags);
}
data->size = output_section_offset +
data->output_section_size * data->max_peers;
/* Ensure one-shot ISR mode is disabled */
@@ -249,11 +272,11 @@ static bool ivshmem_configure(const struct device *dev)
}
data->size = mbar_shmem.size;
}
z_phys_map((uint8_t **)&data->shmem,
shmem_phys_addr, data->size,
K_MEM_CACHE_WB | K_MEM_PERM_RW | K_MEM_PERM_USER);
z_phys_map((uint8_t **)&data->shmem,
shmem_phys_addr, data->size,
K_MEM_CACHE_WB | K_MEM_PERM_RW | K_MEM_PERM_USER);
}
if (msi_x_bar_present) {
if (!ivshmem_configure_msi_x_interrupts(dev)) {
@@ -284,6 +307,13 @@ static size_t ivshmem_api_get_mem(const struct device *dev,
{
struct ivshmem *data = dev->data;
#ifdef CONFIG_IVSHMEM_V2
if (data->ivshmem_v2) {
*memmap = 0;
return 0;
}
#endif
*memmap = data->shmem;
return data->size;
@@ -389,11 +419,11 @@ static size_t ivshmem_api_get_rw_mem_section(const struct device *dev,
struct ivshmem *data = dev->data;
if (!data->ivshmem_v2) {
memmap = NULL;
*memmap = 0;
return 0;
}
*memmap = data->shmem + data->rw_section_offset;
*memmap = data->rw_section_shmem;
return data->rw_section_size;
}
@@ -405,12 +435,11 @@ static size_t ivshmem_api_get_output_mem_section(const struct device *dev,
struct ivshmem *data = dev->data;
if (!data->ivshmem_v2 || peer_id >= data->max_peers) {
memmap = NULL;
*memmap = 0;
return 0;
}
*memmap = data->shmem + data->output_section_offset +
data->output_section_size * peer_id;
*memmap = data->output_section_shmem[peer_id];
return data->output_section_size;
}
@@ -425,7 +454,7 @@ static uint32_t ivshmem_api_get_state(const struct device *dev,
}
const volatile uint32_t *state_table =
(const volatile uint32_t *)data->shmem;
(const volatile uint32_t *)data->state_table_shmem;
return state_table[peer_id];
}

View File

@@ -57,9 +57,10 @@ struct ivshmem {
bool ivshmem_v2;
uint32_t max_peers;
size_t rw_section_size;
size_t rw_section_offset;
size_t output_section_size;
size_t output_section_offset;
uintptr_t state_table_shmem;
uintptr_t rw_section_shmem;
uintptr_t output_section_shmem[CONFIG_IVSHMEM_V2_MAX_PEERS];
#endif
};

View File

@@ -61,8 +61,8 @@
reg = <0x5000d000 0x400>;
num-lines = <16>;
interrupts = <6 0>, <7 0>, <8 0>, <9 0>,
<10 0>, <23 0>, <40 0>, <42 0>,
<64 0>, <65 0>, <66 0>, <67 0>,
<10 0>, <23 0>, <64 0>, <65 0>,
<66 0>, <67 0>, <40 0>, <42 0>,
<76 0>, <77 0>, <121 0>, <127 0>;
interrupt-names = "line0", "line1", "line2", "line3",
"line4", "line5", "line6", "line7",

View File

@@ -47,6 +47,3 @@ properties:
description: |
Initial time quanta of phase buffer 2 segment for the data phase (ISO11898-1:2015). Deprecated
in favor of setting advanced timing parameters from the application.
tx-delay-comp-offset:
type: int
default: 0

View File

@@ -175,10 +175,10 @@ int acpi_drhd_get(enum AcpiDmarScopeType scope, struct acpi_dmar_device_scope *d
union acpi_dmar_id *dmar_id, int *num_inst, int max_inst);
/**
* @brief Retrieve lapic info for a specific cpu.
* @brief Retrieve the 'n'th enabled local apic info.
*
* @param cpu_num the cpu number
* @return lapic info on success or NULL
* @return local apic info on success or NULL otherwise
*/
struct acpi_madt_local_apic *acpi_local_apic_get(uint32_t cpu_num);
struct acpi_madt_local_apic *acpi_local_apic_get(int cpu_num);
#endif

View File

@@ -318,6 +318,23 @@ typedef void (*can_state_change_callback_t)(const struct device *dev,
* For internal driver use only, skip these in public documentation.
*/
/**
* @brief Calculate Transmitter Delay Compensation Offset from data phase timing parameters.
*
* Calculates the TDC Offset in minimum time quanta (mtq) using the sample point and CAN core clock
* prescaler specified by a set of data phase timing parameters.
*
* The result is clamped to the minimum/maximum supported TDC Offset values provided.
*
* @param _timing_data Pointer to data phase timing parameters.
* @param _tdco_min Minimum supported TDC Offset value in mtq.
* @param _tdco_max Maximum supported TDC Offset value in mtq.
* @return Calculated TDC Offset value in mtq.
*/
#define CAN_CALC_TDCO(_timing_data, _tdco_min, _tdco_max) \
CLAMP((1U + _timing_data->prop_seg + _timing_data->phase_seg1) * _timing_data->prescaler, \
_tdco_min, _tdco_max)
/**
* @brief Callback API upon setting CAN bus timing
* See @a can_set_timing() for argument description

View File

@@ -640,7 +640,7 @@ enum can_mcan_psr_lec {
*/
#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
@@ -1253,7 +1253,6 @@ struct can_mcan_config {
uint8_t sjw_data;
uint8_t prop_ts1_data;
uint8_t ts2_data;
uint8_t tx_delay_comp_offset;
#endif
const struct device *phy;
uint32_t max_bitrate;
@@ -1327,7 +1326,6 @@ struct can_mcan_config {
.prop_ts1_data = DT_PROP_OR(node_id, prop_seg_data, 0) + \
DT_PROP_OR(node_id, phase_seg1_data, 0), \
.ts2_data = DT_PROP_OR(node_id, phase_seg2_data, 0), \
.tx_delay_comp_offset = DT_PROP(node_id, tx_delay_comp_offset), \
.phy = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, phys)), \
.max_bitrate = DT_CAN_TRANSCEIVER_MAX_BITRATE(node_id, 8000000), \
.custom = _custom, \

View File

@@ -84,6 +84,12 @@ __subsystem struct ivshmem_driver_api {
/**
* @brief Get the inter-VM shared memory
*
* Note: This API is not supported for ivshmem-v2, as
* the R/W and R/O areas may not be mapped contiguously.
* For ivshmem-v2, use the ivshmem_get_rw_mem_section,
* ivshmem_get_output_mem_section and ivshmem_get_state
* APIs to access the shared memory.
*
* @param dev Pointer to the device structure for the driver instance
* @param memmap A pointer to fill in with the memory address
*

View File

@@ -40,6 +40,11 @@
/* TODO: does this section require alignment? */
KEEP(*(_SHARED_SW_ISR_TABLE_SECTION_SYMS))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(.text.z_shared_isr,,)
{
KEEP(*(.text.z_shared_isr))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif
#endif

View File

@@ -49,8 +49,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

@@ -153,8 +153,12 @@ static inline uintptr_t z_mem_phys_addr(void *virt)
#if CONFIG_KERNEL_VM_BASE != 0
(addr >= CONFIG_KERNEL_VM_BASE) &&
#endif
#if (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_SIZE) != 0
(addr < (CONFIG_KERNEL_VM_BASE +
(CONFIG_KERNEL_VM_SIZE))),
#else
false,
#endif
"address %p not in permanent mappings", virt);
#else
/* Should be identity-mapped */
@@ -162,8 +166,12 @@ static inline uintptr_t z_mem_phys_addr(void *virt)
#if CONFIG_SRAM_BASE_ADDRESS != 0
(addr >= CONFIG_SRAM_BASE_ADDRESS) &&
#endif
#if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
(addr < (CONFIG_SRAM_BASE_ADDRESS +
(CONFIG_SRAM_SIZE * 1024UL))),
#else
false,
#endif
"physical address 0x%lx not in RAM",
(unsigned long)addr);
#endif /* CONFIG_MMU */
@@ -182,8 +190,12 @@ static inline void *z_mem_virt_addr(uintptr_t phys)
#if CONFIG_SRAM_BASE_ADDRESS != 0
(phys >= CONFIG_SRAM_BASE_ADDRESS) &&
#endif
#if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
(phys < (CONFIG_SRAM_BASE_ADDRESS +
(CONFIG_SRAM_SIZE * 1024UL))),
#else
false,
#endif
"physical address 0x%lx not in RAM", (unsigned long)phys);
/* TODO add assertion that this page frame is pinned to boot mapping,

View File

@@ -141,7 +141,15 @@ void z_impl_k_timer_start(struct k_timer *timer, k_timeout_t duration,
{
SYS_PORT_TRACING_OBJ_FUNC(k_timer, start, timer, duration, period);
/* Acquire spinlock to ensure safety during concurrent calls to
* k_timer_start for scheduling or rescheduling. This is necessary
* since k_timer_start can be preempted, especially for the same
* timer instance.
*/
k_spinlock_key_t key = k_spin_lock(&lock);
if (K_TIMEOUT_EQ(duration, K_FOREVER)) {
k_spin_unlock(&lock, key);
return;
}
@@ -168,6 +176,8 @@ void z_impl_k_timer_start(struct k_timer *timer, k_timeout_t duration,
z_add_timeout(&timer->timeout, z_timer_expiration_handler,
duration);
k_spin_unlock(&lock, key);
}
#ifdef CONFIG_USERSPACE

View File

@@ -14,6 +14,12 @@ module = ACPI
module-str = acpi
source "subsys/logging/Kconfig.template.log_config"
config ACPI_PRT_BUS_NAME
string "ACPI name of PCI bus"
default "_SB.PCI0"
help
ACPI name of PCI bus.
config ACPI_MAX_PRT_ENTRY
int "Size of PRT buffer"
default 4096

View File

@@ -52,24 +52,6 @@ static void notify_handler(ACPI_HANDLE device, UINT32 value, void *ctx)
ACPI_INFO(("Received a notify 0x%X", value));
}
static ACPI_STATUS region_handler(UINT32 Function, ACPI_PHYSICAL_ADDRESS address, UINT32 bit_width,
UINT64 *value, void *handler_ctx, void *region_ctx)
{
return AE_OK;
}
static ACPI_STATUS region_init(ACPI_HANDLE RegionHandle, UINT32 Function, void *handler_ctx,
void **region_ctx)
{
if (Function == ACPI_REGION_DEACTIVATE) {
*region_ctx = NULL;
} else {
*region_ctx = RegionHandle;
}
return AE_OK;
}
static ACPI_STATUS install_handlers(void)
{
ACPI_STATUS status;
@@ -82,13 +64,7 @@ static ACPI_STATUS install_handlers(void)
goto exit;
}
status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY,
region_handler, region_init, NULL);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "While installing an OpRegion handler"));
}
exit:
return status;
}
@@ -115,10 +91,10 @@ static ACPI_STATUS initialize_acpica(void)
goto exit;
}
/* Initialize the ACPI hardware */
status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
/* Create the ACPI namespace from ACPI tables */
status = AcpiLoadTables();
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "While enabling ACPI"));
ACPI_EXCEPTION((AE_INFO, status, "While loading ACPI tables"));
goto exit;
}
@@ -129,10 +105,10 @@ static ACPI_STATUS initialize_acpica(void)
goto exit;
}
/* Create the ACPI namespace from ACPI tables */
status = AcpiLoadTables();
/* Initialize the ACPI hardware */
status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "While loading ACPI tables"));
ACPI_EXCEPTION((AE_INFO, status, "While enabling ACPI"));
goto exit;
}
@@ -239,7 +215,7 @@ static int acpi_get_irq_table(struct acpi *bus, char *bus_name,
}
rt_buffer.Pointer = rt_table;
rt_buffer.Length = ACPI_DEBUG_BUFFER_SIZE;
rt_buffer.Length = rt_size;
status = AcpiGetIrqRoutingTable(node, &rt_buffer);
if (ACPI_FAILURE(status)) {
@@ -263,7 +239,8 @@ static int acpi_get_irq_table(struct acpi *bus, char *bus_name,
static int acpi_retrieve_legacy_irq(struct acpi *bus)
{
/* TODO: assume platform have only one PCH with single PCI bus (bus 0). */
return acpi_get_irq_table(bus, "_SB.PC00", bus->pci_prt_table, sizeof(bus->pci_prt_table));
return acpi_get_irq_table(bus, CONFIG_ACPI_PRT_BUS_NAME,
bus->pci_prt_table, sizeof(bus->pci_prt_table));
}
static ACPI_STATUS dev_resource_enum_callback(ACPI_HANDLE obj_handle, UINT32 level, void *ctx,
@@ -791,10 +768,13 @@ int acpi_drhd_get(enum AcpiDmarScopeType scope, struct acpi_dmar_device_scope *d
return 0;
}
struct acpi_madt_local_apic *acpi_local_apic_get(uint32_t cpu_num)
#define ACPI_CPU_FLAGS_ENABLED 0x01u
struct acpi_madt_local_apic *acpi_local_apic_get(int cpu_num)
{
struct acpi_madt_local_apic *lapic;
int cpu_cnt;
int idx;
if (acpi_madt_entry_get(ACPI_MADT_TYPE_LOCAL_APIC, (ACPI_SUBTABLE_HEADER **)&lapic,
&cpu_cnt)) {
@@ -802,10 +782,15 @@ struct acpi_madt_local_apic *acpi_local_apic_get(uint32_t cpu_num)
return NULL;
}
if ((cpu_num >= cpu_cnt) || !(lapic[cpu_num].LapicFlags & 1u)) {
/* Proccessor not enabled. */
return NULL;
for (idx = 0; cpu_num >= 0 && idx < cpu_cnt; idx++) {
if (lapic[idx].LapicFlags & ACPI_CPU_FLAGS_ENABLED) {
if (cpu_num == 0) {
return &lapic[idx];
}
cpu_num--;
}
}
return &lapic[cpu_num];
return NULL;
}

View File

@@ -10,6 +10,7 @@
#include <zephyr/posix/pthread.h>
#include <zephyr/posix/pthread_key.h>
#include <zephyr/sys/bitarray.h>
#include <zephyr/sys/__assert.h>
struct pthread_key_data {
sys_snode_t node;
@@ -120,6 +121,8 @@ int pthread_key_create(pthread_key_t *key,
*/
int pthread_key_delete(pthread_key_t key)
{
size_t bit;
__unused int ret;
pthread_key_obj *key_obj;
struct pthread_key_data *key_data;
sys_snode_t *node_l, *next_node_l;
@@ -145,7 +148,9 @@ int pthread_key_delete(pthread_key_t key)
k_free((void *)key_data);
}
(void)sys_bitarray_free(&posix_key_bitarray, 1, 0);
bit = posix_key_to_offset(key_obj);
ret = sys_bitarray_free(&posix_key_bitarray, 1, bit);
__ASSERT_NO_MSG(ret == 0);
k_spin_unlock(&pthread_key_lock, key_key);

View File

@@ -628,6 +628,8 @@ void pthread_exit(void *retval)
/* not a valid posix_thread */
LOG_DBG("Aborting non-pthread %p", k_current_get());
k_thread_abort(k_current_get());
CODE_UNREACHABLE;
}
/* Make a thread as cancelable before exiting */

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

@@ -149,6 +149,8 @@ void inferenceProcessTask(void *_name, void *heap, void *_params)
}
k_thread_abort(k_current_get());
CODE_UNREACHABLE;
}
/* inferenceSenderTask - Creates NUM_INFERENCE_JOBS jobs, queues them, and then

View File

@@ -23,9 +23,7 @@ ISR_FLAG_DIRECT = 1 << 0
# into 1 line which then goes into the 1st level)
# 0x00FF0000 - represents the 3rd level (i.e. the interrupts funnel
# into 1 line which then goes into the 2nd level)
FIRST_LVL_INTERRUPTS = 0x000000FF
SECND_LVL_INTERRUPTS = 0x0000FF00
THIRD_LVL_INTERRUPTS = 0x00FF0000
INTERRUPT_LVL_BITMASK = [0x000000FF, 0x0000FF00, 0x00FF0000]
INTERRUPT_BITS = [8, 8, 8]
@@ -269,16 +267,18 @@ def bit_mask(bits):
return mask
def update_masks():
global FIRST_LVL_INTERRUPTS
global SECND_LVL_INTERRUPTS
global THIRD_LVL_INTERRUPTS
if sum(INTERRUPT_BITS) > 32:
raise ValueError("Too many interrupt bits")
FIRST_LVL_INTERRUPTS = bit_mask(INTERRUPT_BITS[0])
SECND_LVL_INTERRUPTS = bit_mask(INTERRUPT_BITS[1]) << INTERRUPT_BITS[0]
THIRD_LVL_INTERRUPTS = bit_mask(INTERRUPT_BITS[2]) << INTERRUPT_BITS[0] + INTERRUPT_BITS[2]
INTERRUPT_LVL_BITMASK[0] = bit_mask(INTERRUPT_BITS[0])
INTERRUPT_LVL_BITMASK[1] = bit_mask(INTERRUPT_BITS[1]) << INTERRUPT_BITS[0]
INTERRUPT_LVL_BITMASK[2] = bit_mask(INTERRUPT_BITS[2]) << INTERRUPT_BITS[0] + INTERRUPT_BITS[1]
debug("Level Bits Bitmask")
debug("----------------------------")
for i in range(3):
bitmask_str = "0x" + format(INTERRUPT_LVL_BITMASK[i], '08X')
debug(f"{i + 1:>5} {INTERRUPT_BITS[i]:>7} {bitmask_str:>14}")
def main():
parse_args()
@@ -368,9 +368,9 @@ def main():
else:
# Figure out third level interrupt position
debug('IRQ = ' + hex(irq))
irq3 = (irq & THIRD_LVL_INTERRUPTS) >> INTERRUPT_BITS[0] + INTERRUPT_BITS[1]
irq2 = (irq & SECND_LVL_INTERRUPTS) >> INTERRUPT_BITS[0]
irq1 = irq & FIRST_LVL_INTERRUPTS
irq3 = (irq & INTERRUPT_LVL_BITMASK[2]) >> INTERRUPT_BITS[0] + INTERRUPT_BITS[1]
irq2 = (irq & INTERRUPT_LVL_BITMASK[1]) >> INTERRUPT_BITS[0]
irq1 = irq & INTERRUPT_LVL_BITMASK[0]
if irq3:
irq_parent = irq2

View File

@@ -19,7 +19,7 @@ lpc_checksum
Pillow>=10.0
# can be used to sign a Zephyr application binary for consumption by a bootloader
imgtool>=1.9
imgtool>=2.0.0
# used by nanopb module to generate sources from .proto files
grpcio-tools>=1.47.0

View File

@@ -56,7 +56,7 @@ class Snippet:
path = pathobj.parent / value
if not path.is_file():
_err(f'snippet file {pathobj}: {variable}: file not found: {path}')
return f'"{path}"'
return f'"{path.as_posix()}"'
if variable in ('DTS_EXTRA_CPPFLAGS'):
return f'"{value}"'
_err(f'unknown append variable: {variable}')

View File

@@ -67,6 +67,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

@@ -130,6 +130,10 @@ config INIT_PLL1
Note that flash programming operations are limited to 100MHz, and
this PLL should not be used as the core clock in those cases.
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 144000000 if INIT_PLL1
default 96000000
config SECOND_CORE_MCUX
bool "LPC55xxx's second core"
depends on HAS_MCUX

View File

@@ -8505,7 +8505,7 @@ static void le_ltk_request(struct pdu_data *pdu_data, uint16_t handle,
}
static void encrypt_change(uint8_t err, uint16_t handle,
struct net_buf *buf)
struct net_buf *buf, bool encryption_on)
{
struct bt_hci_evt_encrypt_change *ep;
@@ -8516,9 +8516,9 @@ static void encrypt_change(uint8_t err, uint16_t handle,
hci_evt_create(buf, BT_HCI_EVT_ENCRYPT_CHANGE, sizeof(*ep));
ep = net_buf_add(buf, sizeof(*ep));
ep->status = err;
ep->status = err ? err : (encryption_on ? err : BT_HCI_ERR_UNSPECIFIED);
ep->handle = sys_cpu_to_le16(handle);
ep->encrypt = !err ? 1 : 0;
ep->encrypt = encryption_on ? 1 : 0;
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
@@ -8660,7 +8660,7 @@ static void encode_data_ctrl(struct node_rx_pdu *node_rx,
break;
case PDU_DATA_LLCTRL_TYPE_START_ENC_RSP:
encrypt_change(0x00, handle, buf);
encrypt_change(0x00, handle, buf, true);
break;
#endif /* CONFIG_BT_CTLR_LE_ENC */
@@ -8677,7 +8677,7 @@ static void encode_data_ctrl(struct node_rx_pdu *node_rx,
#if defined(CONFIG_BT_CTLR_LE_ENC)
case PDU_DATA_LLCTRL_TYPE_REJECT_IND:
encrypt_change(pdu_data->llctrl.reject_ind.error_code, handle,
buf);
buf, false);
break;
#endif /* CONFIG_BT_CTLR_LE_ENC */

View File

@@ -49,6 +49,9 @@
static int init_reset(void);
static int prepare_cb(struct lll_prepare_param *p);
#if !defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)
static void isr_early_abort(void *param);
#endif /* !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */
static void isr_done(void *param);
#if defined(CONFIG_BT_CTLR_ADV_AUX_PDU_BACK2BACK)
static void isr_tx_chain(void *param);
@@ -188,7 +191,7 @@ static int prepare_cb(struct lll_prepare_param *p)
/* Abort if no aux_ptr filled */
if (unlikely(!pri_hdr->aux_ptr || !PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr))) {
radio_isr_set(lll_isr_early_abort, lll);
radio_isr_set(isr_early_abort, lll);
radio_disable();
return 0;
@@ -325,7 +328,7 @@ static int prepare_cb(struct lll_prepare_param *p)
if (overhead) {
LL_ASSERT_OVERHEAD(overhead);
radio_isr_set(lll_isr_abort, lll);
radio_isr_set(isr_done, lll);
radio_disable();
return -ECANCELED;
@@ -347,6 +350,33 @@ static int prepare_cb(struct lll_prepare_param *p)
return 0;
}
#if !defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)
static void isr_race(void *param)
{
radio_status_reset();
}
static void isr_early_abort(void *param)
{
struct event_done_extra *extra;
int err;
/* Generate auxiliary radio event done */
extra = ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_ADV_AUX);
LL_ASSERT(extra);
radio_isr_set(isr_race, param);
if (!radio_is_idle()) {
radio_disable();
}
err = lll_hfclock_off();
LL_ASSERT(err >= 0);
lll_done(NULL);
}
#endif /* !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */
static void isr_done(void *param)
{
struct event_done_extra *extra;

View File

@@ -1951,12 +1951,15 @@ int ull_disable(void *lll)
if (!ull_ref_get(hdr)) {
return -EALREADY;
}
cpu_dmb(); /* Ensure synchronized data access */
k_sem_init(&sem, 0, 1);
hdr->disabled_param = &sem;
hdr->disabled_cb = disabled_cb;
cpu_dmb(); /* Ensure synchronized data access */
/* ULL_HIGH can run after we have call `ull_ref_get` and it can
* decrement the ref count. Hence, handle this race condition by
* ensuring that `disabled_cb` has been set while the ref count is still

View File

@@ -284,11 +284,26 @@ void llcp_rx_node_retain(struct proc_ctx *ctx)
{
LL_ASSERT(ctx->node_ref.rx);
/* Mark RX node to NOT release */
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RETAIN;
/* Only retain if not already retained */
if (ctx->node_ref.rx->hdr.type != NODE_RX_TYPE_RETAIN) {
/* Mark RX node to NOT release */
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RETAIN;
/* store link element reference to use once this node is moved up */
ctx->node_ref.rx->hdr.link = ctx->node_ref.link;
/* store link element reference to use once this node is moved up */
ctx->node_ref.rx->hdr.link = ctx->node_ref.link;
}
}
void llcp_rx_node_release(struct proc_ctx *ctx)
{
LL_ASSERT(ctx->node_ref.rx);
/* Only release if retained */
if (ctx->node_ref.rx->hdr.type == NODE_RX_TYPE_RETAIN) {
/* Mark RX node to release and release */
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RELEASE;
ll_rx_put_sched(ctx->node_ref.rx->hdr.link, ctx->node_ref.rx);
}
}
void llcp_nodes_release(struct ll_conn *conn, struct proc_ctx *ctx)
@@ -296,12 +311,14 @@ void llcp_nodes_release(struct ll_conn *conn, struct proc_ctx *ctx)
if (ctx->node_ref.rx && ctx->node_ref.rx->hdr.type == NODE_RX_TYPE_RETAIN) {
/* RX node retained, so release */
ctx->node_ref.rx->hdr.link->mem = conn->llcp.rx_node_release;
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RELEASE;
conn->llcp.rx_node_release = ctx->node_ref.rx;
}
#if defined(CONFIG_BT_CTLR_PHY) && defined(CONFIG_BT_CTLR_DATA_LENGTH)
if (ctx->proc == PROC_PHY_UPDATE && ctx->data.pu.ntf_dle_node) {
/* RX node retained, so release */
ctx->data.pu.ntf_dle_node->hdr.link->mem = conn->llcp.rx_node_release;
ctx->data.pu.ntf_dle_node->hdr.type = NODE_RX_TYPE_RELEASE;
conn->llcp.rx_node_release = ctx->data.pu.ntf_dle_node;
}
#endif
@@ -706,9 +723,6 @@ void ull_cp_release_nodes(struct ll_conn *conn)
hdr = &rx->hdr;
rx = hdr->link->mem;
/* Mark for buffer for release */
hdr->type = NODE_RX_TYPE_RELEASE;
/* enqueue rx node towards Thread */
ll_rx_put(hdr->link, hdr);
}

View File

@@ -1135,6 +1135,7 @@ static void rp_comm_ntf(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t gene
/* Allocate ntf node */
ntf = ctx->node_ref.rx;
ctx->node_ref.rx = NULL;
LL_ASSERT(ntf);
/* This should be an 'old' RX node, so put/sched when done */

View File

@@ -196,6 +196,22 @@ static bool cu_check_conn_parameters(struct ll_conn *conn, struct proc_ctx *ctx)
}
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
static bool cu_check_conn_ind_parameters(struct ll_conn *conn, struct proc_ctx *ctx)
{
const uint16_t interval_max = ctx->data.cu.interval_max; /* unit 1.25ms */
const uint16_t timeout = ctx->data.cu.timeout; /* unit 10ms */
const uint16_t latency = ctx->data.cu.latency;
/* Valid conn_update_ind parameters */
return (interval_max >= CONN_INTERVAL_MIN(conn)) &&
(interval_max <= CONN_UPDATE_CONN_INTV_4SEC) &&
(latency <= CONN_UPDATE_LATENCY_MAX) &&
(timeout >= CONN_UPDATE_TIMEOUT_100MS) &&
(timeout <= CONN_UPDATE_TIMEOUT_32SEC) &&
((timeout * 4U) > /* *4U re. conn events is equivalent to *2U re. ms */
((latency + 1U) * interval_max));
}
static void cu_prepare_update_ind(struct ll_conn *conn, struct proc_ctx *ctx)
{
ctx->data.cu.win_size = 1U;
@@ -585,8 +601,20 @@ static void lp_cu_st_wait_rx_conn_update_ind(struct ll_conn *conn, struct proc_c
switch (evt) {
case LP_CU_EVT_CONN_UPDATE_IND:
llcp_pdu_decode_conn_update_ind(ctx, param);
/* Invalid PDU, mark the connection for termination */
if (!cu_check_conn_ind_parameters(conn, ctx)) {
llcp_rr_set_incompat(conn, INCOMPAT_NO_COLLISION);
conn->llcp_terminate.reason_final = BT_HCI_ERR_INVALID_LL_PARAM;
lp_cu_complete(conn, ctx);
break;
}
llcp_rr_set_incompat(conn, INCOMPAT_RESERVED);
/* Keep RX node to use for NTF */
llcp_rx_node_retain(ctx);
ctx->state = LP_CU_STATE_WAIT_INSTANT;
break;
case LP_CU_EVT_UNKNOWN:
@@ -633,8 +661,7 @@ static void lp_cu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint
lp_cu_ntf_complete(conn, ctx, evt, param);
} else {
/* Release RX node kept for NTF */
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RELEASE;
ll_rx_put_sched(ctx->node_ref.rx->hdr.link, ctx->node_ref.rx);
llcp_rx_node_release(ctx);
ctx->node_ref.rx = NULL;
lp_cu_complete(conn, ctx);
@@ -973,11 +1000,18 @@ static void rp_cu_st_wait_conn_param_req_available(struct ll_conn *conn, struct
case RP_CU_EVT_RUN:
if (cpr_active_is_set(conn)) {
ctx->state = RP_CU_STATE_WAIT_CONN_PARAM_REQ_AVAILABLE;
if (!llcp_rr_ispaused(conn) && llcp_tx_alloc_peek(conn, ctx)) {
/* We're good to reject immediately */
ctx->data.cu.rejected_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ;
ctx->data.cu.error = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL;
rp_cu_send_reject_ext_ind(conn, ctx, evt, param);
/* Possibly retained rx node to be released as we won't need it */
llcp_rx_node_release(ctx);
ctx->node_ref.rx = NULL;
break;
}
/* In case we have to defer NTF */
llcp_rx_node_retain(ctx);
@@ -992,6 +1026,9 @@ static void rp_cu_st_wait_conn_param_req_available(struct ll_conn *conn, struct
rp_cu_conn_param_req_ntf(conn, ctx);
ctx->state = RP_CU_STATE_WAIT_CONN_PARAM_REQ_REPLY;
} else {
/* Possibly retained rx node to be released as we won't need it */
llcp_rx_node_release(ctx);
ctx->node_ref.rx = NULL;
#if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
/* Handle APM as a vendor specific user extension */
if (conn->lll.role == BT_HCI_ROLE_PERIPHERAL &&
@@ -1177,8 +1214,7 @@ static void rp_cu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint
cu_ntf(conn, ctx);
} else {
/* Release RX node kept for NTF */
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RELEASE;
ll_rx_put_sched(ctx->node_ref.rx->hdr.link, ctx->node_ref.rx);
llcp_rx_node_release(ctx);
ctx->node_ref.rx = NULL;
}
rp_cu_complete(conn, ctx);
@@ -1198,19 +1234,27 @@ static void rp_cu_st_wait_rx_conn_update_ind(struct ll_conn *conn, struct proc_c
case BT_HCI_ROLE_PERIPHERAL:
llcp_pdu_decode_conn_update_ind(ctx, param);
if (is_instant_not_passed(ctx->data.cu.instant,
ull_conn_event_counter(conn))) {
/* Valid PDU */
if (cu_check_conn_ind_parameters(conn, ctx)) {
if (is_instant_not_passed(ctx->data.cu.instant,
ull_conn_event_counter(conn))) {
/* Keep RX node to use for NTF */
llcp_rx_node_retain(ctx);
llcp_rx_node_retain(ctx);
ctx->state = RP_CU_STATE_WAIT_INSTANT;
/* In case we only just received it in time */
rp_cu_check_instant(conn, ctx, evt, param);
break;
}
ctx->state = RP_CU_STATE_WAIT_INSTANT;
/* In case we only just received it in time */
rp_cu_check_instant(conn, ctx, evt, param);
} else {
conn->llcp_terminate.reason_final = BT_HCI_ERR_INSTANT_PASSED;
llcp_rr_complete(conn);
ctx->state = RP_CU_STATE_IDLE;
} else {
conn->llcp_terminate.reason_final = BT_HCI_ERR_INVALID_LL_PARAM;
}
llcp_rr_complete(conn);
ctx->state = RP_CU_STATE_IDLE;
break;
default:
/* Unknown role */

View File

@@ -225,6 +225,7 @@ static void lp_enc_ntf(struct ll_conn *conn, struct proc_ctx *ctx)
/* Piggy-back on RX node */
ntf = ctx->node_ref.rx;
ctx->node_ref.rx = NULL;
LL_ASSERT(ntf);
ntf->hdr.type = NODE_RX_TYPE_DC_PDU;
@@ -381,19 +382,29 @@ static void lp_enc_store_s(struct ll_conn *conn, struct proc_ctx *ctx, struct pd
static inline uint8_t reject_error_code(struct pdu_data *pdu)
{
uint8_t error;
if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_IND) {
return pdu->llctrl.reject_ind.error_code;
error = pdu->llctrl.reject_ind.error_code;
#if defined(CONFIG_BT_CTLR_EXT_REJ_IND)
} else if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND) {
return pdu->llctrl.reject_ext_ind.error_code;
error = pdu->llctrl.reject_ext_ind.error_code;
#endif /* CONFIG_BT_CTLR_EXT_REJ_IND */
} else {
/* Called with an invalid PDU */
LL_ASSERT(0);
/* Keep compiler happy */
return BT_HCI_ERR_UNSPECIFIED;
error = BT_HCI_ERR_UNSPECIFIED;
}
/* Check expected error code from the peer */
if (error != BT_HCI_ERR_PIN_OR_KEY_MISSING &&
error != BT_HCI_ERR_UNSUPP_REMOTE_FEATURE) {
error = BT_HCI_ERR_UNSPECIFIED;
}
return error;
}
static void lp_enc_st_wait_rx_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,

View File

@@ -413,6 +413,7 @@ void llcp_ntf_set_pending(struct ll_conn *conn);
void llcp_ntf_clear_pending(struct ll_conn *conn);
bool llcp_ntf_pending(struct ll_conn *conn);
void llcp_rx_node_retain(struct proc_ctx *ctx);
void llcp_rx_node_release(struct proc_ctx *ctx);
/*
* ULL -> LLL Interface

View File

@@ -81,6 +81,12 @@ void llcp_lr_check_done(struct ll_conn *conn, struct proc_ctx *ctx)
ctx_header = llcp_lr_peek(conn);
LL_ASSERT(ctx_header == ctx);
/* If we have a node rx it must not be marked RETAIN as
* the memory referenced would leak
*/
LL_ASSERT(ctx->node_ref.rx == NULL ||
ctx->node_ref.rx->hdr.type != NODE_RX_TYPE_RETAIN);
lr_dequeue(conn);
llcp_proc_ctx_release(ctx);
@@ -312,6 +318,11 @@ void llcp_lr_rx(struct ll_conn *conn, struct proc_ctx *ctx, memq_link_t *link,
break;
}
/* If rx node was not retained clear reference */
if (ctx->node_ref.rx && ctx->node_ref.rx->hdr.type != NODE_RX_TYPE_RETAIN) {
ctx->node_ref.rx = NULL;
}
llcp_lr_check_done(conn, ctx);
}

View File

@@ -433,6 +433,7 @@ static void pu_ntf(struct ll_conn *conn, struct proc_ctx *ctx)
/* Piggy-back on stored RX node */
ntf = ctx->node_ref.rx;
ctx->node_ref.rx = NULL;
LL_ASSERT(ntf);
if (ctx->data.pu.ntf_pu) {
@@ -449,15 +450,9 @@ static void pu_ntf(struct ll_conn *conn, struct proc_ctx *ctx)
}
/* Enqueue notification towards LL */
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
/* only 'put' as the 'sched' is handled when handling DLE ntf */
ll_rx_put(ntf->hdr.link, ntf);
#else
ll_rx_put_sched(ntf->hdr.link, ntf);
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
ctx->data.pu.ntf_pu = 0;
ctx->node_ref.rx = NULL;
}
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)

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