Compare commits

...

62 Commits

Author SHA1 Message Date
Anas Nashif
1a814fc0fd VERSION: bump version to 2.6.1-rc2
Update version to 2.6.1-rc2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 12:02:16 -04:00
Anas Nashif
69f162f6c9 requirements: pin west to 0.11.1
Some backward compatibility issues with latest west and building
documentation for this branch. Pin the version to fix doc builds.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 12:02:16 -04:00
Gerard Marull-Paretas
86cd2c84c3 ci: manifest: do not persist git credentials
With this setting enabled, Git credentials are not kept after checkout.
Credentials are not necessary after the checkout step, since we do not
do any further manual push/pull operations.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-25 07:10:24 -05:00
Gerard Marull-Paretas
b590a4f64a ci: bsim: split workflow
Split workflow into 2 chunks:

- One that runs tests
- A second one that publishes results

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-25 07:10:24 -05:00
Gerard Marull-Paretas
05d334baa0 ci: clang: do not persist git credentials
With this setting enabled, Git credentials are not kept after checkout.
Credentials are not necessary after the checkout step, since we do not
do any further manual push/pull operations.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-25 07:10:24 -05:00
Lucas Dietrich
c388f1a17e net: mqtt: Add support for TLS option TLS_CERT_NOCOPY
Add an option in MQTT client context to take advantage of the
"TLS_CERT_NOCOPY" option when using  TLS socket transport.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2021-12-14 15:20:44 +01:00
Lucas Dietrich
42cd204d3a net: sockets: tls: Support for DER cert chain and NOCOPY optimisation
Add TLS socket option "TLS_CERT_NOCOPY" to prevent the copy of
certificates to mbedTLS heap if possible.

Add support to provide a chain of DER certificates by registering
them with multiple tags.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2021-12-14 15:20:44 +01:00
Vinayak Kariappa Chettimada
707162ce93 Bluetooth: Controller: Fix node rx memory corruption regression
Fix the node rx memory pool corruption regression introduced
due to same peer connection being rejected.

Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-11-08 11:15:40 -05:00
Thomas Wendtland
42d7e71206 drivers: display: fix faulty PM symbol in st7789v driver
the driver for the st7789v display uses an old define and therefore
does not compile. fix for the 2.6 branch, the 2.7 driver is already
correct.

Signed-off-by: Thomas Wendtland <twendtland@gmail.com>
2021-10-18 15:43:04 +02:00
Daniel Leung
2d6322d74a demand_paging: eviction/nru: fix incorrect dirty bit return val
In k_mem_paging_eviction_select(), the returned dirty bit value
may not be actually associated with the page selected, but
rather the last page examined. So fix this.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-09-22 07:28:33 -04:00
Alexandre Bourdiol
25771e6928 drivers: clock_control: stm32: enable PWR clock unconditionally
Enable PWR clock unconditionally for L4, L5 and U5
like it is done on other stm32 series

Fixes #37781

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-09-18 09:15:32 -04:00
Scott Worley
92e36185e8 [Backport v2.6-branch] Microchip: XEC GPIO driver interrupt enable part 2
Fixes issue #34879
This PR updates previous PR's 37138 and 37139.
Refer to issue 34879 for information from MCHP HW
designers. A delay after enabling interrupts is a
more appropriate work-around than depending upon
behavior of ARM DMB instruction.

Comparing to the original PR #37479 left changes only related to the
drivers/gpio/gpio_mchp_xec.c file
Tested  mec15xxevb_assy6853 board, no bugs GPIO detected.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2021-09-14 20:11:02 -04:00
Dylan Hung
68d33e3834 libc/minimal: locate the memory pool for malloc() to .bss
When CONFIG_USERSPACE is turned off, the POOL_SECTION will be located in
.data section.  This will increase the target binary size.  Since the
memory pool is for malloc() use and it doesn't need for initial values,
locate it in the .bss section to reduce binary size.

Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com>
Change-Id: Iee52ac06a48414c083518c79775fe31334eab674
2021-09-10 15:43:23 -04:00
Nicolas Marty
7f3abab9bf net: tcp: accept [FIN, PSH, ACK] in TCP_FIN_WAIT_2 state
TCP state machine gets stuck in TCP_FIN_WAIT_2 state
when server responds with [ FIN, PSH, ACK ]

Fixes #37842

Signed-off-by: Nicolas Marty <nicolas.marty@zuehlke.com>
2021-09-08 10:29:58 -04:00
Nicolas Pitre
533dcaf374 lib/os/cbprintf_nano.c: avoid sign extension on unsigned formats
There might be a sign extension when a long is promoted to
int_value_type and the former type is smaller than the later.
This produces the wrong output if the specified format is unsigned.

Let's avoid this problem by handling signed and unsigned cases
explicitly. When the type already matches int_value_type then the
compiler is smart enough to recognize the redundancy and removes
unneeded duplications automatically, meaning that the code will stay
small when code size matters.

A similar issue also existed in the restricted %llu case.
The fix is the same as above.

Those fixes exposed wrong results in the printk.c test with %llx
so fix that as well.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-09-03 08:17:19 -04:00
Daniel Leung
ea55ebfa74 tests: schedule_api: use stack array extern macro
The stack array tstacks was declared in the header file using
the same macro which defines the same stack array but with
an added "extern" in front. This macro adds alignment and section
attribute which are actually not the same as the actual stack array
defined in main.c. The section name used in the section attribute
contains the file name where the stack array is defined or extern
declared. So the same symbol, in this case z_interrupt_stacks, has
different attributes in two places, and GCC 11 starts to complain
about this. So use the newly introduced macro to extern declare
the stack array without adding/replacing any symbol attributes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
95bb8841b8 tests: mem_protect: fix warning on uninitialized variable
In test_kobject_release_null(), dummy is not initialized
before being fed to k_object_release(). So set it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
1f8c53dfaf tests: kernel/common: avoid using compiler builtin popcount
Not all arch has native support for __builtin_popcount() on
hardware and GCC falls back in using software only implementation.
However, with GCC 11, this is no longer included automatically
and requires linking explicitly with libgcc.a. This is not
trivial as it requires changes some linker magic and a sizable
change to most linker scripts. So opt for an easy solution
by implementing our own popcount in the test.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
7bb7454a00 kernel: use proper macro to declare extern interrupt stacks
The z_interrupt_stacks was declared extern in the kernel internal
header file using the same macro which defines the same stack
array but with an added "extern" in front. This macro adds
alignment and section attribute which are actually not the same
as the actual stack array defined in kernel/init.c. The section
name used in the section attribute contains the file name where
the stack array is defined or extern declared. So the same
symbol, in this case z_interrupt_stacks, has different
attributes in two places, and GCC 11 starts to complain about
this. So use the newly introduced macro to extern declare
the stack array without adding/replacing any symbol attributes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
25fd176014 kernel: add macros to allow declaring extern stack arrays
A stack can already be declared extern via K_KERNEL_STACK_EXTERN().
This adds similar macros for stack arrays.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
e1cde092ac kernel: move Z_KERNEL_STACK_LEN higher in thread_stack.h
Moves Z_KERNEL_STACK_LEN() higher in the header file so it is
near the other stack size calculation macros. Also, it was
actually declared after it is first used in the header.
So this seems a logical move.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
244049bd71 x86: type cast to uint8_t* for bit ops
This changes the type casting of the incoming addresses to
the bit ops from uint32_t* to uint8_t*. This avoids compilers
and static analyzers complaining about the incoming out of
bound access if incoming argument is an array smaller than
4 bytes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:47 -04:00
Daniel Leung
5dae0c1bf0 kernel: ignore array bound warnings for generated syscall funcs
Compilers and static code analyzers do not understand Zephyr's
syscall mechanism so they always complain about out of bound
array access inside the generated syscall header functions.
So add a flag for GCC to ignore this type of warning for these
functions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:26 -04:00
Daniel Leung
5666e4d525 cmake: force GCC to emit DWARF version 4
GCC 11 defaults to output DWARF version 5 which pyelftools cannot
currently parse. So keep output at version 4 for the time being.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-30 09:17:26 -04:00
Vinayak Kariappa Chettimada
91a78866ca Bluetooth: Controller: Fix advertising after connections from same peer
Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.

Relates to commit 010c5c2f20 ("Bluetooth: controller:
Ignore connections from same peer").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-30 09:16:58 -04:00
Dong Wang
0afddb2341 x86/cache: fix issues in arch dcache flush function
Correct the wrong operand of clflush instruction. The old operand
points to a location inside stack and doesn't work. The new one
works well by taking linux kernel code as reference.

End address instead of size should get round up

Add Kconfig option to disable the usage of mfence intruction for
SoC that has clfulsh but no mfence supported.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2021-08-30 09:16:39 -04:00
Michael Zimmermann
9bcf9b6a53 json: fix parsing first array-array element
Previously, the first element inside the array-array didn't contain the
decoded data.

Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
2021-08-30 09:15:58 -04:00
Chen Peng1
2595cce714 cmake: oneApi: add oneApi support on windows.
add .S file extension suffix into CMAKE_ASM_SOURCE_FILE_EXTENSIONS,
because clang from OneApi can't recongnize them as asm files on
windows, then they won't be added into build system.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-03 22:58:32 -04:00
Chen Peng1
18d314e750 cmake: oneApi: add oneApi support on windows
The icx compiler of oneApi will invoke clang-cl on windows,
this is not supported in zephyr now, so change to use
clang directly.
And the clang from oneApi can't recognize those cross
compiling target variables of cmake, such as
CMAKE_C_COMPILER_TARGET, so used other cmake functions
to pass them to clang.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-03 22:58:32 -04:00
Chen Peng1
c8755e0b46 tests/benchmarks: add dynamic memory allocation measurement
add a test into latency_measure test case to measure
the average time for dynamic memory allocation and release.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-03 16:17:15 -04:00
Anas Nashif
a4d35f0a3e doc: 2.6.1 release notes
Start release note section for 2.6.1.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-08-03 15:31:51 -04:00
Anas Nashif
7094aaee55 release: Bump release to 2.6.1-rc1
Bump version to 2.6.1-rc1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-08-03 15:31:51 -04:00
Erwan Gouriou
585c03a0b6 drivers/clock_control: stm32: Fix macro to get HCLK freq
__LL_RCC_CALC_HCLK1_FREQ is only available for WL and WB series,
for other series __LL_RCC_CALC_HCLK_FREQ should be used.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-07-24 18:18:16 -05:00
Patrick Rathje
cacb0a4e59 Bluetooth: L2CAP: Fix missing net_buf_unref()
In case of non-recoverable errors (e.g. the connection breaks while
transmitting), the l2cap_chan_tx_process deques the net_buf but does
not unreference it. As this is inside a work queue thread, the sending
thread gets no information on this error, relying on the tx_process to
ultimately free the buffer.

Signed-off-by: Patrick Rathje <git@patrickrathje.de>
2021-07-22 07:26:40 -05:00
Daniel Leung
78ab750540 timer: hpet: convert register access to functions
This converts register access from macro to functions.
This allows SoCs to override these functions if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:26:17 -05:00
Daniel Leung
d9df404d47 timer: hpet: don't force TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
This allows the HPET timer to use kconfig to specify clock
frequency instead of relying on calculation at runtime.
When the frequency is known at build, this allow the toolchain
to optimize some calculations.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:26:17 -05:00
Daniel Leung
8e80955511 timer: hpet: allow overriding MIN_DELAY
This renames MIN_DELAY to HPET_CMP_MIN_DELAY, and also allows it
to be overridden. The default delay is for HPET with relative
high frequency, and may not suitable for all HPET
implementations.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:26:17 -05:00
Daniel Leung
99dc33faaf timer: hpet: extract Counter Clock Period into a macro
This extracts the hard-coded value into a macro which can be
overridden. This is in preparation for SoCs where the period
is not in femptoseconds.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:26:17 -05:00
Marcin Niestroj
02fbe652a5 logging: fs: fix leak of opened directories in check_log_file_exist()
Opened directory descriptor is leaked when returning 1. Fix that by
utilizing goto in function return path.

Fixes: 6b18e6992d ("subsys/loggin/log_backend_fs: added recovery after
  file lost")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-21 05:50:18 -04:00
Daniel Leung
80b406d784 x86: acpi: limit search on where EBDA can be
This limits the search for Extended BIOS Data Area (EBDA) to
0x80000 to 0x100000 as this is usually the area for it.
If 0000:040e has an address not pointing to this area, it is
probably an invalid address, and should not be de-referenced
to avoid segfault.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-20 20:02:52 -04:00
Evgeniy Paltsev
837ab4a915 ARC: save/restore accumulator registers on all ARCv2 HS CPUs by default
Accumulator registers (ACCL, ACCH) are used on HS CPUs not only
in case of FPU usage but also in case of MPY usage. We enable MPY
for all ARCv2 HS in commit
18a24c3f6 ARC: gcc-m-cpu: use -mcpu=archs as a default for ARCv2 HS
but we didn't enable accumulator registers management.

Let's enable accumulator registers save/restore on all ARCv2 HS CPUs
by default.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-07-06 21:29:22 -04:00
Kumar Gala
0943608550 riscv: openisa_rv32m1: Fix booting of rv32m1_vega
rv32m1_vega don't boot due to device init ordering and changes with the
device model.  The soc code is looking for a device pointer for the
intmux.  Change to using DEVICE_DT_GET here as that will ensure we get
a valid pointer and by the time we need to utilize the pointer the
intmux driver will have been initialized and thus the device pointer
will be ready.

Also set BUILD_OUTPUT_HEX since we utilize openocd to flash and west
flash is looking for a hex file for openocd targets.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-07-02 06:36:28 -05:00
Stephanos Ioannidis
3c56e0df0b cmake: ld: Disable manual linking of libgcc components for host
When the host toolchain is used, `-nostdlib` option is not specified
and therefore all default libraries, including the libgcc and its
components, are automatically linked -- so it is not necessary to
manually link them here.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-07-01 07:24:48 -05:00
Stephanos Ioannidis
b0cb7412b9 cmake: host-gcc: Remove libgcc library path resolution
The host toolchain makes use of the host toolchain libraries (i.e.
`-nostdlib` is not specified), so it is not necessary to detect the
toolchain libgcc path and specify one manually.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-07-01 07:24:48 -05:00
Stephanos Ioannidis
80e1b785dc cmake: host-gcc: Detect libgcc for all archs
This commit updates the build system to always detect the libgcc path
for the host platforms regardless of the target architecture.

The native_posix_64 target previously used the x32 ABI (`-mx32`) and
the multilib for this ABI was not commonly available in the x86-64 host
toolchains.

That is no longer the case because native_posix_64 had been updated to
use the x86-64 ABI (`-m64`).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-07-01 07:24:48 -05:00
Stephanos Ioannidis
e72a327107 cmake: gcc: Remove no_libgcc exclusion for libgcc detection
This commit removes the `NOT no_libgcc` condition for the automatic
libgcc path detection.

The `no_libgcc` variable was previously set in this file to exclude
libgcc detection for the x86-64 targets because the x86-64 arch used
x32 ABI (`-mx32`) and the multilib for this ABI was not commonly
available. This is no longer the case (x86-64 targets now use `-m64`)
and libgcc must always be available.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-07-01 07:24:48 -05:00
Vinayak Kariappa Chettimada
1cf1d75d3f Bluetooth: Controller: Fix Data Length Update node Rx reservations
Reserve a minimum node rx of 2 that can happen when local
central initiated PHY Update reserves 2 node rx, one for PHY
Update complete and another for Data Length Update complete
notification. Otherwise, a peripheral only needs 1
additional node rx to generate Data Length Update complete
when PHY Update completes.

Relates to #36381.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-30 08:24:55 -05:00
Vinayak Kariappa Chettimada
e43afd10f7 Bluetooth: Controller: Fix free rx buffer MFIFO enqueue
Replace the post decrement in loop's conditional into
explicit decrement inside the loop so as to avoid
decrementing the maximum count without enqueueing free rx
buffers into the free rx buffer MFIFO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-30 08:24:55 -05:00
Vinayak Kariappa Chettimada
6d9b318dca Bluetooth: Controller: Minor change to use IS_ENABLED
Minor changes to use IS_ENABLED and updates to comments in
code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-30 08:24:55 -05:00
Martí Bolívar
d4d362d081 doc: api: fix devicetree modification version
This was modified in 2.6.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-29 13:25:42 -04:00
Andy Ross
d0dca15734 arch/x86/zefi: Fix entry-nop hack for EFI entry
commit 5e9c583c24 ("arch/x86_64: Terrible, awful hackery to
bootstrap entry") introduced a terrible trick which begins execution
at the bottom of .locore with a jump, which then gets replaced with
NOP instructions for the benefit of 16 bit real mode startup of the
other CPUs later on.

But I forgot that EFI enters in 64 bit code natively, and so never
hits that path.  And moving it to the 64 bit setup code doesn't work,
because at that point when we are NOT loaded from EFI, we already have
the Zephyr page tables in place that disallow writes to .locore.

So do it in the EFI loader, which while sort of a weird place, has the
benefit of being in C instead of assembly.

Really all this code needs to go away.  A proper x86 entry
architecture would enter somewhere in the main blob, and .locore
should be a tiny stub we copy in at runtime.

Fixes #36107

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-06-28 20:05:27 -04:00
Francois Ramu
218e438f3e drivers: bluetooth: hci driver for stm32wb includes clock control
The definition of the STM32_LSE_CLOCK is given by the
drivers/clock_control/stm32_clock_control.h
to the hci/ipm_stm32wb driver

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-06-18 12:33:17 -05:00
Torbjörn Leksell
f66d0cea06 Tracing: TraceRecorder CMake update
- Fixed some incorrect streamport references that pointed to the
base streamport files instead of those dedicated for Zephyr.
- Updated the source file compilation to match the updated
TraceRecorder module.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-18 12:32:53 -05:00
Martí Bolívar
d5a1a22b1a python-devicetree: tox: fix mypy
Recent versions of mypy have learned that the yaml module has type
stubs and the tool is now erroring out when it discovers we import
yaml since the stubs are not involved.

This is breaking CI on unrelated patches; fix it following the
instructions here:

https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-10 07:52:49 -05:00
Erwan Gouriou
c77f8fae83 doc/guides/dts: bindings: Fix code snippet for 'signal-gpios'
Code snippet to demonstrate use of 'zephyr,user' binding
for gpio pin was missing a #define to easily get the code
compiling.
Fix this.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-08 18:15:23 -05:00
Bhavesh Bhojwani
3ec1caa504 dts/arm: st: g0: closes parenthesis for soc
This commit adds a closing parenthesis for soc model of stm32g050.
Resolves issue #36014

Signed-off-by: Bhavesh Bhojwani <bhaavesh.bhojwaani@gmail.com>
2021-06-08 14:36:27 -05:00
Fabio Baltieri
a221f358eb drivers: flash_stm32_v1: fix a potential unaligned access
The flash write function casts a void * to flash_prg_t, which can be 2,
4 or 8 bytes long depending on the SoC. This can trigger a hard fault
exception if data is not aligned, such as when passing a constant string
from settings_save_one().

Copying the chunk of data to a temporary variable on the stack to avoid
the problem.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-06-08 14:36:18 -05:00
Stephanos Ioannidis
f5a6110b4a tests: cpp: libcxx: Test with full and nano variants of newlib
In order to increase test coverage, this commit updates the libcxx test
to run with both full and nano variants of the newlib.

Note that C++ exception handling feature is only enabled for the newlib
full variant because the nano variant does not support C++ exception
handling.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 14:36:01 -05:00
Stephanos Ioannidis
1d6106fd5e tests: cpp: libcxx: Use full version of newlib for testing
Use the full version of newlib (i.e. not nano) for libcxx testing since
some features (e.g. C++ exception handling) require the full version of
newlib.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 14:36:01 -05:00
Stephanos Ioannidis
4b87e90167 cpp: Fix C++ exception handling newlib dependency
This commit makes C++ exception handling feature depend on the full
version of newlib (i.e. `CONFIG_NEWLIB_LIBC_NANO=n`).

The `nano.specs`, which selects the nano variant of newlib, libstdc++,
and libsupc++, does not support C++ exception handling because its
lib*c++ is compiled with `-fno-exceptions`.

For more details, refer to the issue #35972.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 14:36:01 -05:00
Stephanos Ioannidis
1d4d16b748 linker: cpp: Fix C++ exception handling info section linking
The `.eh_frame_hdr` and `.eh_frame` ROM sections, which contain read-
only C++ exception handling information, are currently specified in
`cplusplus-ram.ld`, and this can cause the linker output location
counter to take a ROM region address while in the RAM region.

This commit relocates these sections to `cplusplus-rom.ld` in order to
prevent the linker output location counter from getting corrupted.

For more details, refer to the issue #35972.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 14:36:01 -05:00
Anas Nashif
4a564cdef0 version: add EXTRAVERSION to VERSION file
Readd EXTRAVERSION.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-05 11:41:09 -05:00
71 changed files with 963 additions and 306 deletions

29
.github/workflows/bsim-publish.yaml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Publish Bluetooth Tests Results
on:
workflow_run:
workflows: ["Bluetooth Tests"]
types:
- completed
jobs:
bluetooth-test-results:
name: "Publish Bluetooth Test Results"
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: bluetooth-tests.yaml
run_id: ${{ github.event.workflow_run.id }}
- name: Publish Bluetooth Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: Bluetooth Test Results
comment_mode: off
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "bluetooth-test-results/**/bsim_results.xml"

View File

@@ -1,7 +1,7 @@
name: Bluetooth Tests
on:
pull_request_target:
pull_request:
paths:
- "west.yml"
- "subsys/bluetooth/**"
@@ -39,9 +39,6 @@ jobs:
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: west setup
run: |
@@ -60,26 +57,13 @@ jobs:
if: always()
uses: actions/upload-artifact@v2
with:
name: Bluetooth Test Results
name: bluetooth-test-results
path: ./bsim_bt_out/bsim_results.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: bsim-build
runs-on: ubuntu-20.04
# the build-and-test job might be skipped, we don't need to run this job then
if: success() || failure()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Upload Event Details
if: always()
uses: actions/upload-artifact@v2
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.12
with:
check_name: Bluetooth Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "**/bsim_results.xml"
comment_on_pr: false
name: event
path: |
${{ github.event_path }}

View File

@@ -38,6 +38,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- name: west setup
run: |

View File

@@ -15,6 +15,7 @@ jobs:
path: zephyrproject/zephyr
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- name: Manifest
uses: zephyrproject-rtos/action-manifest@v1.1.0

View File

@@ -1,4 +1,5 @@
VERSION_MAJOR = 2
VERSION_MINOR = 6
PATCHLEVEL = 0
PATCHLEVEL = 1
VERSION_TWEAK = 0
EXTRAVERSION = rc2

View File

@@ -252,6 +252,7 @@ config CODE_DENSITY
config ARC_HAS_ACCL_REGS
bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
default y if CPU_HS3X
default y if FPU
help
Depending on the configuration, CPU can contain accumulator reg-pair

View File

@@ -170,4 +170,12 @@ config X86_USE_THREAD_LOCAL_STORAGE
help
Internal config to enable thread local storage.
config X86_MFENCE_INSTRUCTION_SUPPORTED
bool "X86 MFENCE instruction supported"
default y
depends on CACHE_MANAGEMENT
help
Set n to disable the use of MFENCE instruction in arch_dcache_flush()
for X86 CPUs have CLFLUSH instruction but no MFENCE
endif # !X86_64

View File

@@ -50,8 +50,11 @@ static void find_rsdp(void)
bda_seg = 0x040e + zero_page_base;
uint64_t *search = (void *)(long)(((int)*(uint16_t *)bda_seg) << 4);
/* Might be nothing there, check before we inspect */
if (search != NULL) {
/* Might be nothing there, check before we inspect.
* Note that EBDA usually is in 0x80000 to 0x100000.
*/
if ((POINTER_TO_UINT(search) >= 0x80000UL) &&
(POINTER_TO_UINT(search) < 0x100000UL)) {
for (int i = 0; i < 1024/8; i++) {
if (search[i] == ACPI_RSDP_SIGNATURE) {
rsdp = (void *)&search[i];

View File

@@ -33,20 +33,24 @@ static void arch_dcache_flush(void *start_addr, size_t size)
{
size_t line_size = sys_cache_data_line_size_get();
uintptr_t start = (uintptr_t)start_addr;
uintptr_t end;
uintptr_t end = start + size;
if (line_size == 0U) {
return;
}
size = ROUND_UP(size, line_size);
end = start + size;
end = ROUND_UP(end, line_size);
for (; start < end; start += line_size) {
__asm__ volatile("clflush %0;\n\t" : : "m"(start));
__asm__ volatile("clflush %0;\n\t" :
"+m"(*(volatile char *)start));
}
__asm__ volatile("mfence;\n\t");
#if defined(CONFIG_X86_MFENCE_INSTRUCTION_SUPPORTED)
__asm__ volatile("mfence;\n\t":::"memory");
#else
__asm__ volatile("lock; addl $0,-4(%%esp);\n\t":::"memory", "cc");
#endif
}
int arch_dcache_range(void *addr, size_t size, int op)

View File

@@ -1,7 +1,8 @@
# Copyright (c) 2019 Intel Corp.
# SPDX-License-Identifier: Apache-2.0
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
if (CMAKE_C_COMPILER_ID STREQUAL "Clang"
OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
# We rely on GAS for assembling, so don't use the integrated assembler
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-no-integrated-as>)
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")

View File

@@ -12,7 +12,8 @@ endif()
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang"
OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
zephyr_compile_options(-Qunused-arguments)
zephyr_cc_option(

View File

@@ -92,6 +92,20 @@ uintptr_t __abi efi_entry(void *img_handle, struct efi_system_table *sys_tab)
for (int j = 0; j < bytes; j++) {
dst[j] = src[j];
}
/* Page-aligned blocks below 1M are the .locore
* section, which has a jump in its first bytes for
* the benefit of 32 bit entry. Those have to be
* written over with NOP instructions. (See comment
* about OUTRAGEOUS HACK in locore.S) before Zephyr
* starts, because the very first thing it does is
* install its own page table that disallows writes.
*/
if (((long)dst & 0xfff) == 0 && dst < (uint8_t *)0x100000L) {
for (int i = 0; i < 8; i++) {
dst[i] = 0x90; /* 0x90 == 1-byte NOP */
}
}
}
unsigned char *code = (void *)zefi_entry;

View File

@@ -602,6 +602,11 @@ endif()
include(${ZEPHYR_BASE}/cmake/target_toolchain.cmake)
project(Zephyr-Kernel VERSION ${PROJECT_VERSION})
# Add .S file extension suffix into CMAKE_ASM_SOURCE_FILE_EXTENSIONS,
# because clang from OneApi can't recongnize them as asm files on
# windows now.
list(APPEND CMAKE_ASM_SOURCE_FILE_EXTENSIONS "S")
enable_language(C CXX ASM)
# The setup / configuration of the toolchain itself and the configuration of
# supported compilation flags are now split, as this allows to use the toolchain

View File

@@ -7,7 +7,10 @@ endif()
find_program(CMAKE_AR llvm-ar ${find_program_clang_args} )
find_program(CMAKE_NM llvm-nm ${find_program_clang_args} )
find_program(CMAKE_OBJDUMP llvm-objdump ${find_program_clang_args} )
# In OneApi installation directory on Windows, there is no llvm-objdump
# binary, so would better use objdump from system environment both
# on Linux and Windows.
find_program(CMAKE_OBJDUMP objdump ${find_program_binutils_args})
find_program(CMAKE_RANLIB llvm-ranlib ${find_program_clang_args} )
find_program(CMAKE_OBJCOPY llvm-objcopy ${find_program_binutils_args})
find_program(CMAKE_READELF readelf ${find_program_binutils_args})

View File

@@ -69,7 +69,7 @@ if(NOT "${ARCH}" STREQUAL "posix")
list(APPEND TOOLCHAIN_LIBS gcc)
endif()
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
list(APPEND CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
endif()

View File

@@ -167,6 +167,10 @@ set_compiler_property(PROPERTY freestanding -ffreestanding)
# Flag to enable debugging
set_compiler_property(PROPERTY debug -g)
# GCC 11 by default emits DWARF version 5 which cannot be parsed by
# pyelftools. Can be removed once pyelftools supports v5.
check_set_compiler_property(APPEND PROPERTY debug -gdwarf-4)
set_compiler_property(PROPERTY no_common -fno-common)
# GCC compiler flags for imacros. The specific header must be appended by user.

View File

@@ -61,23 +61,21 @@ elseif("${ARCH}" STREQUAL "sparc")
include(${CMAKE_CURRENT_LIST_DIR}/target_sparc.cmake)
endif()
if(NOT no_libgcc)
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
assert_exists(LIBGCC_FILE_NAME)
assert_exists(LIBGCC_FILE_NAME)
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
assert_exists(LIBGCC_DIR)
assert_exists(LIBGCC_DIR)
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
LIST(APPEND TOOLCHAIN_LIBS gcc)
endif()
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
LIST(APPEND TOOLCHAIN_LIBS gcc)
if(SYSROOT_DIR)
# The toolchain has specified a sysroot dir that we can use to set

View File

@@ -18,21 +18,6 @@ else()
endif()
find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} CACHE INTERNAL " " FORCE)
# The x32 version of libgcc is usually not available (can't trust gcc
# -mx32 --print-libgcc-file-name) so don't fail to build for something
# that is currently not needed. See comments in compiler/gcc/target.cmake
if (CONFIG_X86)
# Convert to list as cmake Modules/*.cmake do it
STRING(REGEX REPLACE " +" ";" PRINT_LIBGCC_ARGS "${CMAKE_C_FLAGS}")
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} "${PRINT_LIBGCC_ARGS}" --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
assert_exists(LIBGCC_FILE_NAME)
endif()
set(NOSTDINC "")
# Note that NOSYSDEF_CFLAG may be an empty string, and

View File

@@ -13,14 +13,16 @@ endif()
set_ifndef(LINKERFLAGPREFIX -Wl)
if(CONFIG_EXCEPTIONS)
# When building with C++ Exceptions, it is important that crtbegin and crtend
# are linked at specific locations.
# The location is so important that we cannot let this be controlled by normal
# link libraries, instead we must control the link command specifically as
# part of toolchain.
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "host")
if(CONFIG_EXCEPTIONS)
# When building with C++ Exceptions, it is important that crtbegin and crtend
# are linked at specific locations.
# The location is so important that we cannot let this be controlled by normal
# link libraries, instead we must control the link command specifically as
# part of toolchain.
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
endif()
endif()
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_script_gen}

View File

@@ -6,14 +6,15 @@ else()
set_ifndef(ONEAPI_TOOLCHAIN_PATH "$ENV{ONEAPI_TOOLCHAIN_PATH}")
endif()
# the default oneApi installation path is related to os
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} system)
if(ONEAPI_TOOLCHAIN_PATH)
set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/linux/bin/)
set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/${system}/bin/)
set(ONEAPI_PYTHON_PATH ${ONEAPI_TOOLCHAIN_PATH}/intelpython/latest/bin)
endif()
set(ONEAPI_TOOLCHAIN_PATH ${ONEAPI_TOOLCHAIN_PATH} CACHE PATH "oneApi install directory")
set(COMPILER icx)
set(LINKER lld)
set(BINTOOLS oneApi)
@@ -23,8 +24,23 @@ else()
set(triple i686-pc-none-elf)
endif()
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
if(system STREQUAL "linux")
set(COMPILER icx)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
# icx compiler of oneApi will invoke clang-cl on windows,
# this is not supported in zephyr now, so change to use
# clang directly.
# and the clang from oneApi can't recognize those cross
# compiling target variables of cmake, so used other
# cmake functions to pass them to clang.
elseif(system STREQUAL "windows")
set(COMPILER clang)
list(APPEND CMAKE_REQUIRED_FLAGS --target=${triple})
add_compile_options(--target=${triple})
add_link_options(--target=${triple})
endif()
message(STATUS "Found toolchain: host (clang/ld)")

View File

@@ -1013,6 +1013,8 @@ gpio_dt_spec``, then use it like this:
#include <drivers/gpio.h>
#define ZEPHYR_USER_NODE DT_PATH(zephyr_user)
const struct gpio_dt_spec signal =
GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, signal_gpios);

View File

@@ -80,7 +80,7 @@ current :ref:`stability level <api_lifecycle>`.
* - :ref:`devicetree_api`
- Experimental
- 2.2
- 2.4
- 2.6
* - :ref:`disk_access_api`
- Stable

View File

@@ -2,6 +2,29 @@
.. _zephyr_2.6:
.. _zephyr_2.6.1:
Zephyr 2.6.1
#############
This is a maintenance release with the following fixes.
Security Vulnerability Related
******************************
The following security vulnerabilities (CVEs) were addressed in this
release:
More detailed information can be found in:
https://docs.zephyrproject.org/latest/security/vulnerabilities.html
Issues Fixed
************
.. _zephyr_2.6.0:
Zephyr 2.6.0
############

View File

@@ -12,6 +12,7 @@
#include <bluetooth/hci.h>
#include <drivers/bluetooth/hci_driver.h>
#include "bluetooth/addr.h"
#include <drivers/clock_control/stm32_clock_control.h>
#include "app_conf.h"
#include "stm32_wpan_common.h"

View File

@@ -55,7 +55,7 @@
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK3_FREQ
#define GET_CURRENT_FLASH_PRESCALER LL_RCC_GetAHB3Prescaler
#else
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK1_FREQ
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK_FREQ
#define GET_CURRENT_FLASH_PRESCALER LL_RCC_GetAHBPrescaler
#endif

View File

@@ -48,6 +48,11 @@ void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
*/
void config_enable_default_clocks(void)
{
#ifdef LL_APB1_GRP1_PERIPH_PWR
/* Enable the power interface clock */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
#endif
#if STM32_LSE_CLOCK
/* LSE belongs to the back-up domain, enable access.*/
@@ -57,11 +62,6 @@ void config_enable_default_clocks(void)
#endif
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
#ifdef LL_APB1_GRP1_PERIPH_PWR
/* Enable the power interface clock */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
#endif
/* Set the DBP bit in the Power control register 1 (PWR_CR1) */
LL_PWR_EnableBkUpAccess();
while (!LL_PWR_IsEnabledBkUpAccess()) {

View File

@@ -415,7 +415,7 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
struct st7789v_data *data = (struct st7789v_data *)dev->data;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
case PM_DEVICE_STATE_SET:
if (*state == PM_DEVICE_STATE_ACTIVE) {
st7789v_exit_sleep(data);
data->pm_state = PM_DEVICE_STATE_ACTIVE;

View File

@@ -210,11 +210,13 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
const void *data, unsigned int len)
{
int i, rc = 0;
const flash_prg_t *values = (const flash_prg_t *)data;
flash_prg_t value;
for (i = 0; i < len / sizeof(flash_prg_t); i++) {
rc = write_value(dev, offset + i * sizeof(flash_prg_t),
values[i]);
memcpy(&value,
(const uint8_t *)data + i * sizeof(flash_prg_t),
sizeof(flash_prg_t));
rc = write_value(dev, offset + i * sizeof(flash_prg_t), value);
if (rc < 0) {
return rc;
}

View File

@@ -9,10 +9,13 @@
#include <errno.h>
#include <device.h>
#include <drivers/gpio.h>
#include <sys/sys_io.h>
#include <soc.h>
#include "gpio_utils.h"
#define XEC_GPIO_EDGE_DLY_COUNT 4
#define GPIO_IN_BASE(config) \
((__IO uint32_t *)(GPIO_PARIN_BASE + (config->port_num << 2)))
@@ -211,6 +214,10 @@ static int gpio_xec_pin_interrupt_configure(const struct device *dev,
*/
current_pcr1 = config->pcr1_base + pin;
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
/* delay for HW to synchronize after it ungates its clock */
for (int i = 0; i < XEC_GPIO_EDGE_DLY_COUNT; i++) {
(void)*current_pcr1;
}
if (mode != GPIO_INT_MODE_DISABLED) {
/* We enable the interrupts in the EC aggregator so that the

View File

@@ -82,7 +82,7 @@ config HPET_TIMER
depends on X86
select IOAPIC if X86
select LOAPIC if X86
select TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
imply TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
select TICKLESS_CAPABLE
help
This option selects High Precision Event Timer (HPET) as a

View File

@@ -13,40 +13,233 @@
#include <dt-bindings/interrupt-controller/intel-ioapic.h>
#include <soc.h>
/**
* @file
* @brief HPET (High Precision Event Timers) driver
*
* HPET hardware contains a number of timers which can be used by
* the operating system, where the number of timers is implementation
* specific. The timers are implemented as a single up-counter with
* a set of comparators where the counter increases monotonically.
* Each timer has a match register and a comparator, and can generate
* an interrupt when the value in the match register equals the value of
* the free running counter. Some of these timers can be enabled to
* generate periodic interrupt.
*
* The HPET registers are usually mapped to memory space on x86
* hardware. If this is not the case, custom register access functions
* can be used by defining macro HPET_USE_CUSTOM_REG_ACCESS_FUNCS in
* soc.h, and implementing necessary initialization and access
* functions as described below.
*
* HPET_COUNTER_CLK_PERIOD can be overridden in soc.h if
* COUNTER_CLK_PERIOD is not in femtoseconds (1e-15 sec).
*
* HPET_CMP_MIN_DELAY can be overridden in soc.h to better match
* the frequency of the timers. Default is 1000 where the value
* written to the comparator must be 1000 larger than the current
* main counter value.
*/
/* General Configuration register */
#define GCONF_ENABLE BIT(0)
#define GCONF_LR BIT(1) /* legacy interrupt routing, */
/* disables PIT */
/* General Interrupt Status register */
#define TIMER0_INT_STS BIT(0)
/* Timer Configuration and Capabilities register */
#define TIMER_CONF_INT_LEVEL BIT(1)
#define TIMER_CONF_INT_ENABLE BIT(2)
#define TIMER_CONF_PERIODIC BIT(3)
#define TIMER_CONF_VAL_SET BIT(6)
#define TIMER_CONF_MODE32 BIT(8)
#define TIMER_CONF_FSB_EN BIT(14) /* FSB interrupt delivery */
/* enable */
/*
* The following MMIO initialization and register access functions
* should work on generic x86 hardware. If the targeted SoC requires
* special handling of HPET registers, these functions will need to be
* implemented in the SoC layer by first defining the macro
* HPET_USE_CUSTOM_REG_ACCESS_FUNCS in soc.h to signal such intent.
*
* This is a list of functions which must be implemented in the SoC
* layer:
* void hpet_mmio_init(void)
* uint32_t hpet_counter_get(void)
* uint32_t hpet_counter_clk_period_get(void)
* uint32_t hpet_gconf_get(void)
* void hpet_gconf_set(uint32_t val)
* void hpet_int_sts_set(uint32_t val)
* uint32_t hpet_timer_conf_get(void)
* void hpet_timer_conf_set(uint32_t val)
* void hpet_timer_comparator_set(uint32_t val)
*/
#ifndef HPET_USE_CUSTOM_REG_ACCESS_FUNCS
DEVICE_MMIO_TOPLEVEL_STATIC(hpet_regs, DT_DRV_INST(0));
#define HPET_REG32(off) (*(volatile uint32_t *)(long) \
(DEVICE_MMIO_TOPLEVEL_GET(hpet_regs) + (off)))
#define HPET_REG_ADDR(off) \
((mm_reg_t)(DEVICE_MMIO_TOPLEVEL_GET(hpet_regs) + (off)))
#define CLK_PERIOD_REG HPET_REG32(0x04) /* High dword of caps reg */
#define GENERAL_CONF_REG HPET_REG32(0x10)
#define INTR_STATUS_REG HPET_REG32(0x20)
#define MAIN_COUNTER_REG HPET_REG32(0xf0)
#define TIMER0_CONF_REG HPET_REG32(0x100)
#define TIMER0_COMPARATOR_REG HPET_REG32(0x108)
/* High dword of General Capabilities and ID register */
#define CLK_PERIOD_REG HPET_REG_ADDR(0x04)
/* GENERAL_CONF_REG bits */
#define GCONF_ENABLE BIT(0)
#define GCONF_LR BIT(1) /* legacy interrupt routing, disables PIT */
/* General Configuration register */
#define GCONF_REG HPET_REG_ADDR(0x10)
/* INTR_STATUS_REG bits */
#define TIMER0_INT_STS BIT(0)
/* General Interrupt Status register */
#define INTR_STATUS_REG HPET_REG_ADDR(0x20)
/* TIMERn_CONF_REG bits */
#define TCONF_INT_LEVEL BIT(1)
#define TCONF_INT_ENABLE BIT(2)
#define TCONF_PERIODIC BIT(3)
#define TCONF_VAL_SET BIT(6)
#define TCONF_MODE32 BIT(8)
#define TCONF_FSB_EN BIT(14) /* FSB interrupt delivery enable */
/* Main Counter Register */
#define MAIN_COUNTER_REG HPET_REG_ADDR(0xf0)
#define MIN_DELAY 1000
/* Timer 0 Configuration and Capabilities register */
#define TIMER0_CONF_REG HPET_REG_ADDR(0x100)
/* Timer 0 Comparator Register */
#define TIMER0_COMPARATOR_REG HPET_REG_ADDR(0x108)
/**
* @brief Setup memory mappings needed to access HPET registers.
*
* This is called in sys_clock_driver_init() to setup any memory
* mappings needed to access HPET registers.
*/
static inline void hpet_mmio_init(void)
{
DEVICE_MMIO_TOPLEVEL_MAP(hpet_regs, K_MEM_CACHE_NONE);
}
/**
* @brief Return the value of the main counter.
*
* @return Value of Main Counter
*/
static inline uint32_t hpet_counter_get(void)
{
return sys_read32(MAIN_COUNTER_REG);
}
/**
* @brief Get COUNTER_CLK_PERIOD
*
* Read and return the COUNTER_CLK_PERIOD, which is the high
* 32-bit of the General Capabilities and ID Register. This can
* be used to calculate the frequency of the main counter.
*
* Usually the period is in femtoseconds. If this is not
* the case, define HPET_COUNTER_CLK_PERIOD in soc.h so
* it can be used to calculate frequency.
*
* @return COUNTER_CLK_PERIOD
*/
static inline uint32_t hpet_counter_clk_period_get(void)
{
return sys_read32(CLK_PERIOD_REG);
}
/**
* @brief Return the value of the General Configuration Register
*
* @return Value of the General Configuration Register
*/
static inline uint32_t hpet_gconf_get(void)
{
return sys_read32(GCONF_REG);
}
/**
* @brief Write to General Configuration Register
*
* @param val Value to be written to the register
*/
static inline void hpet_gconf_set(uint32_t val)
{
sys_write32(val, GCONF_REG);
}
/**
* @brief Write to General Interrupt Status Register
*
* This is used to acknowledge and clear interrupt bits.
*
* @param val Value to be written to the register
*/
static inline void hpet_int_sts_set(uint32_t val)
{
sys_write32(val, INTR_STATUS_REG);
}
/**
* @brief Return the value of the Timer Configuration Register
*
* This reads and returns the value of the Timer Configuration
* Register of Timer #0.
*
* @return Value of the Timer Configuration Register
*/
static inline uint32_t hpet_timer_conf_get(void)
{
return sys_read32(TIMER0_CONF_REG);
}
/**
* @brief Write to the Timer Configuration Register
*
* This writes the specified value to the Timer Configuration
* Register of Timer #0.
*
* @param val Value to be written to the register
*/
static inline void hpet_timer_conf_set(uint32_t val)
{
sys_write32(val, TIMER0_CONF_REG);
}
/**
* @brief Write to the Timer Comparator Value Register
*
* This writes the specified value to the Timer Comparator
* Value Register of Timer #0.
*
* @param val Value to be written to the register
*/
static inline void hpet_timer_comparator_set(uint32_t val)
{
sys_write32(val, TIMER0_COMPARATOR_REG);
}
#endif /* HPET_USE_CUSTOM_REG_ACCESS_FUNCS */
#ifndef HPET_COUNTER_CLK_PERIOD
/* COUNTER_CLK_PERIOD (CLK_PERIOD_REG) is in femtoseconds (1e-15 sec) */
#define HPET_COUNTER_CLK_PERIOD (1000000000000000ULL)
#endif
#ifndef HPET_CMP_MIN_DELAY
/* Minimal delay for comparator before the next timer event */
#define HPET_CMP_MIN_DELAY (1000)
#endif
#define MAX_TICKS 0x7FFFFFFFUL
static __pinned_bss struct k_spinlock lock;
static __pinned_bss unsigned int max_ticks;
static __pinned_bss unsigned int cyc_per_tick;
static __pinned_bss unsigned int last_count;
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
static __pinned_bss unsigned int cyc_per_tick;
static __pinned_bss unsigned int max_ticks;
#else
#define cyc_per_tick \
(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC)
#define max_ticks \
((MAX_TICKS - cyc_per_tick) / cyc_per_tick)
#endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
__isr
static void hpet_isr(const void *arg)
{
@@ -54,7 +247,7 @@ static void hpet_isr(const void *arg)
k_spinlock_key_t key = k_spin_lock(&lock);
uint32_t now = MAIN_COUNTER_REG;
uint32_t now = hpet_counter_get();
#if ((DT_INST_IRQ(0, sense) & IRQ_TYPE_LEVEL) == IRQ_TYPE_LEVEL)
/*
@@ -62,7 +255,7 @@ static void hpet_isr(const void *arg)
* When edge trigger is selected, spec says only 0 can
* be written.
*/
INTR_STATUS_REG = TIMER0_INT_STS;
hpet_int_sts_set(TIMER0_INT_STS);
#endif
if (IS_ENABLED(CONFIG_SMP) &&
@@ -85,10 +278,10 @@ static void hpet_isr(const void *arg)
if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
uint32_t next = last_count + cyc_per_tick;
if ((int32_t)(next - now) < MIN_DELAY) {
if ((int32_t)(next - now) < HPET_CMP_MIN_DELAY) {
next += cyc_per_tick;
}
TIMER0_COMPARATOR_REG = next;
hpet_timer_comparator_set(next);
}
k_spin_unlock(&lock, key);
@@ -98,26 +291,30 @@ static void hpet_isr(const void *arg)
__pinned_func
static void set_timer0_irq(unsigned int irq)
{
uint32_t val = hpet_timer_conf_get();
/* 5-bit IRQ field starting at bit 9 */
uint32_t val = (TIMER0_CONF_REG & ~(0x1f << 9)) | ((irq & 0x1f) << 9);
val = (val & ~(0x1f << 9)) | ((irq & 0x1f) << 9);
#if ((DT_INST_IRQ(0, sense) & IRQ_TYPE_LEVEL) == IRQ_TYPE_LEVEL)
/* Level trigger */
val |= TCONF_INT_LEVEL;
val |= TIMER_CONF_INT_LEVEL;
#endif
TIMER0_CONF_REG = val;
hpet_timer_conf_set(val);
}
__boot_func
int sys_clock_driver_init(const struct device *dev)
{
extern int z_clock_hw_cycles_per_sec;
uint32_t hz;
uint32_t hz, reg;
ARG_UNUSED(dev);
ARG_UNUSED(hz);
ARG_UNUSED(z_clock_hw_cycles_per_sec);
DEVICE_MMIO_TOPLEVEL_MAP(hpet_regs, K_MEM_CACHE_NONE);
hpet_mmio_init();
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
@@ -125,27 +322,34 @@ int sys_clock_driver_init(const struct device *dev)
set_timer0_irq(DT_INST_IRQN(0));
irq_enable(DT_INST_IRQN(0));
/* CLK_PERIOD_REG is in femtoseconds (1e-15 sec) */
hz = (uint32_t)(1000000000000000ULL / CLK_PERIOD_REG);
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
hz = (uint32_t)(HPET_COUNTER_CLK_PERIOD / hpet_counter_clk_period_get());
z_clock_hw_cycles_per_sec = hz;
cyc_per_tick = hz / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
max_ticks = (MAX_TICKS - cyc_per_tick) / cyc_per_tick;
#endif
last_count = hpet_counter_get();
/* Note: we set the legacy routing bit, because otherwise
* nothing in Zephyr disables the PIT which then fires
* interrupts into the same IRQ. But that means we're then
* forced to use IRQ2 contra the way the kconfig IRQ selection
* is supposed to work. Should fix this.
*/
GENERAL_CONF_REG |= GCONF_LR | GCONF_ENABLE;
TIMER0_CONF_REG &= ~TCONF_PERIODIC;
TIMER0_CONF_REG &= ~TCONF_FSB_EN;
TIMER0_CONF_REG |= TCONF_MODE32;
reg = hpet_gconf_get();
reg |= GCONF_LR | GCONF_ENABLE;
hpet_gconf_set(reg);
max_ticks = (0x7fffffff - cyc_per_tick) / cyc_per_tick;
last_count = MAIN_COUNTER_REG;
reg = hpet_timer_conf_get();
reg &= ~TIMER_CONF_PERIODIC;
reg &= ~TIMER_CONF_FSB_EN;
reg |= TIMER_CONF_MODE32;
reg |= TIMER_CONF_INT_ENABLE;
hpet_timer_conf_set(reg);
TIMER0_CONF_REG |= TCONF_INT_ENABLE;
TIMER0_COMPARATOR_REG = MAIN_COUNTER_REG + cyc_per_tick;
hpet_timer_comparator_set(last_count + cyc_per_tick);
return 0;
}
@@ -165,8 +369,12 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
ARG_UNUSED(idle);
#if defined(CONFIG_TICKLESS_KERNEL)
uint32_t reg;
if (ticks == K_TICKS_FOREVER && idle) {
GENERAL_CONF_REG &= ~GCONF_ENABLE;
reg = hpet_gconf_get();
reg &= ~GCONF_ENABLE;
hpet_gconf_set(reg);
return;
}
@@ -174,7 +382,7 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
ticks = CLAMP(ticks - 1, 0, (int32_t)max_ticks);
k_spinlock_key_t key = k_spin_lock(&lock);
uint32_t now = MAIN_COUNTER_REG, cyc, adj;
uint32_t now = hpet_counter_get(), cyc, adj;
uint32_t max_cyc = max_ticks * cyc_per_tick;
/* Round up to next tick boundary. */
@@ -188,11 +396,11 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
cyc = (cyc / cyc_per_tick) * cyc_per_tick;
cyc += last_count;
if ((cyc - now) < MIN_DELAY) {
if ((cyc - now) < HPET_CMP_MIN_DELAY) {
cyc += cyc_per_tick;
}
TIMER0_COMPARATOR_REG = cyc;
hpet_timer_comparator_set(cyc);
k_spin_unlock(&lock, key);
#endif
}
@@ -205,7 +413,7 @@ uint32_t sys_clock_elapsed(void)
}
k_spinlock_key_t key = k_spin_lock(&lock);
uint32_t ret = (MAIN_COUNTER_REG - last_count) / cyc_per_tick;
uint32_t ret = (hpet_counter_get() - last_count) / cyc_per_tick;
k_spin_unlock(&lock, key);
return ret;
@@ -214,11 +422,15 @@ uint32_t sys_clock_elapsed(void)
__pinned_func
uint32_t sys_clock_cycle_get_32(void)
{
return MAIN_COUNTER_REG;
return hpet_counter_get();
}
__pinned_func
void sys_clock_idle_exit(void)
{
GENERAL_CONF_REG |= GCONF_ENABLE;
uint32_t reg;
reg = hpet_gconf_get();
reg |= GCONF_ENABLE;
hpet_gconf_set(reg);
}

View File

@@ -36,4 +36,5 @@
dmamux1: dmamux@40020800 {
dma-channels = <7>;
};
};
};

View File

@@ -154,7 +154,7 @@ static ALWAYS_INLINE uint32_t sys_read32(mm_reg_t addr)
static ALWAYS_INLINE void sys_set_bit(mem_addr_t addr, unsigned int bit)
{
__asm__ volatile("btsl %1, %0"
: "+m" (*(volatile uint32_t *) (addr))
: "+m" (*(volatile uint8_t *) (addr))
: "Ir" (bit)
: "memory");
}
@@ -162,7 +162,7 @@ static ALWAYS_INLINE void sys_set_bit(mem_addr_t addr, unsigned int bit)
static ALWAYS_INLINE void sys_clear_bit(mem_addr_t addr, unsigned int bit)
{
__asm__ volatile("btrl %1, %0"
: "+m" (*(volatile uint32_t *) (addr))
: "+m" (*(volatile uint8_t *) (addr))
: "Ir" (bit));
}
@@ -172,7 +172,7 @@ static ALWAYS_INLINE int sys_test_bit(mem_addr_t addr, unsigned int bit)
__asm__ volatile("btl %2, %1;"
"sbb %0, %0"
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
: "Ir" (bit));
return ret;
@@ -185,7 +185,7 @@ static ALWAYS_INLINE int sys_test_and_set_bit(mem_addr_t addr,
__asm__ volatile("btsl %2, %1;"
"sbb %0, %0"
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
: "Ir" (bit));
return ret;
@@ -198,7 +198,7 @@ static ALWAYS_INLINE int sys_test_and_clear_bit(mem_addr_t addr,
__asm__ volatile("btrl %2, %1;"
"sbb %0, %0"
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
: "Ir" (bit));
return ret;

View File

@@ -360,11 +360,14 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
.offset = offsetof(struct_, \
len_field_), \
{ \
.object = { \
.sub_descr = \
.array = { \
.element_descr = \
elem_descr_, \
.sub_descr_len = \
elem_descr_len_, \
.n_elements = \
1 + \
ZERO_OR_COMPILE_ERROR( \
elem_descr_len_ == 1 \
), \
}, \
}, \
} }, \

View File

@@ -104,6 +104,9 @@ static inline char *z_stack_ptr_align(char *ptr)
#define Z_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
#endif
#define Z_KERNEL_STACK_LEN(size) \
ROUND_UP(Z_KERNEL_STACK_SIZE_ADJUST(size), Z_KERNEL_STACK_OBJ_ALIGN)
/**
* @brief Obtain an extern reference to a stack
*
@@ -119,6 +122,36 @@ static inline char *z_stack_ptr_align(char *ptr)
* @{
*/
/**
* @def K_KERNEL_STACK_ARRAY_EXTERN
* @brief Obtain an extern reference to a stack array
*
* This macro properly brings the symbol of a stack array declared
* elsewhere into scope.
*
* @param sym Thread stack symbol name
* @param nmemb Number of stacks to declare
* @param size Size of the stack memory region
*/
#define K_KERNEL_STACK_ARRAY_EXTERN(sym, nmemb, size) \
extern struct z_thread_stack_element \
sym[nmemb][Z_KERNEL_STACK_LEN(size)]
/**
* @def K_KERNEL_PINNED_STACK_ARRAY_EXTERN
* @brief Obtain an extern reference to a pinned stack array
*
* This macro properly brings the symbol of a pinned stack array
* declared elsewhere into scope.
*
* @param sym Thread stack symbol name
* @param nmemb Number of stacks to declare
* @param size Size of the stack memory region
*/
#define K_KERNEL_PINNED_STACK_ARRAY_EXTERN(sym, nmemb, size) \
extern struct z_thread_stack_element \
sym[nmemb][Z_KERNEL_STACK_LEN(size)]
/**
* @def Z_KERNEL_STACK_DEFINE_IN
* @brief Define a toplevel kernel stack memory region in specified section
@@ -204,9 +237,6 @@ static inline char *z_stack_ptr_align(char *ptr)
Z_KERNEL_STACK_DEFINE_IN(sym, size, __kstackmem)
#endif
#define Z_KERNEL_STACK_LEN(size) \
ROUND_UP(Z_KERNEL_STACK_SIZE_ADJUST(size), Z_KERNEL_STACK_OBJ_ALIGN)
/**
* @def K_KERNEL_STACK_ARRAY_DEFINE
* @brief Define a toplevel array of kernel stack memory regions
@@ -272,6 +302,7 @@ static inline char *Z_KERNEL_STACK_BUFFER(k_thread_stack_t *sym)
#define K_THREAD_STACK_MEMBER K_KERNEL_STACK_MEMBER
#define Z_THREAD_STACK_BUFFER Z_KERNEL_STACK_BUFFER
#define K_THREAD_STACK_EXTERN K_KERNEL_STACK_EXTERN
#define K_THREAD_STACK_ARRAY_EXTERN K_KERNEL_STACK_ARRAY_EXTERN
#else
/**
* @def K_THREAD_STACK_RESERVED
@@ -371,6 +402,20 @@ static inline char *Z_KERNEL_STACK_BUFFER(k_thread_stack_t *sym)
*/
#define K_THREAD_STACK_EXTERN(sym) extern k_thread_stack_t sym[]
/**
* @brief Obtain an extern reference to a thread stack array
*
* This macro properly brings the symbol of a stack array declared
* elsewhere into scope.
*
* @param sym Thread stack symbol name
* @param nmemb Number of stacks to declare
* @param size Size of the stack memory region
*/
#define K_THREAD_STACK_ARRAY_EXTERN(sym, nmemb, size) \
extern struct z_thread_stack_element \
sym[nmemb][K_THREAD_STACK_LEN(size)]
/**
* @addtogroup thread_stack_api
* @{

View File

@@ -11,17 +11,6 @@
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#if defined (CONFIG_EXCEPTIONS)
SECTION_PROLOGUE(.eh_frame_hdr,,)
{
*(.eh_frame_hdr)
}
SECTION_PROLOGUE(.eh_frame,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
KEEP (*(SORT_NONE(.eh_frame)))
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(.tm_clone_table,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .tm_clone_table)))

View File

@@ -9,4 +9,18 @@
{
*(.gcc_except_table .gcc_except_table.*)
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif
#if defined (CONFIG_EXCEPTIONS)
SECTION_PROLOGUE(.eh_frame_hdr,,)
{
*(.eh_frame_hdr)
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(.eh_frame,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
KEEP (*(SORT_NONE(.eh_frame)))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif /* CONFIG_EXCEPTIONS */
#endif /* CONFIG_CPLUSPLUS */

View File

@@ -354,6 +354,9 @@ struct mqtt_sec_config {
* May be NULL to skip hostname verification.
*/
const char *hostname;
/** Indicates the preference for copying certificates to the heap. */
int cert_nocopy;
};
/** @brief MQTT transport type. */

View File

@@ -139,6 +139,12 @@ struct zsock_pollfd {
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MIN 8
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MAX 9
/** Socket option for preventing certificates from being copied to the mbedTLS
* heap if possible. The option is only effective for DER certificates and is
* ignored for PEM certificates.
*/
#define TLS_CERT_NOCOPY 10
/** @} */
/* Valid values for TLS_PEER_VERIFY option */
@@ -150,6 +156,10 @@ struct zsock_pollfd {
#define TLS_DTLS_ROLE_CLIENT 0 /**< Client role in a DTLS session. */
#define TLS_DTLS_ROLE_SERVER 1 /**< Server role in a DTLS session. */
/* Valid values for TLS_CERT_NOCOPY option */
#define TLS_CERT_NOCOPY_NONE 0 /**< Cert duplicated in heap */
#define TLS_CERT_NOCOPY_OPTIONAL 1 /**< Cert not copied in heap if DER */
struct zsock_addrinfo {
struct zsock_addrinfo *ai_next;
int ai_flags;

View File

@@ -152,7 +152,7 @@ extern struct k_thread z_main_thread;
#ifdef CONFIG_MULTITHREADING
extern struct k_thread z_idle_threads[CONFIG_MP_NUM_CPUS];
#endif
extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
K_KERNEL_PINNED_STACK_ARRAY_EXTERN(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
CONFIG_ISR_STACK_SIZE);
#ifdef CONFIG_GEN_PRIV_STACKS

View File

@@ -26,7 +26,7 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
K_APPMEM_PARTITION_DEFINE(z_malloc_partition);
#define POOL_SECTION K_APP_DMEM_SECTION(z_malloc_partition)
#else
#define POOL_SECTION .data
#define POOL_SECTION .bss
#endif /* CONFIG_USERSPACE */
#define HEAP_BYTES CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE

View File

@@ -174,20 +174,40 @@ start:
uint_value_type d;
if (length_mod == 'z') {
d = va_arg(ap, ssize_t);
} else if (length_mod == 'l') {
d = va_arg(ap, long);
} else if (length_mod == 'L') {
long long lld = va_arg(ap, long long);
if (sizeof(int_value_type) < 8U &&
lld != (int_value_type) lld) {
data = "ERR";
data_len = 3;
precision = 0;
break;
if (*fmt == 'u') {
d = va_arg(ap, size_t);
} else {
d = va_arg(ap, ssize_t);
}
} else if (length_mod == 'l') {
if (*fmt == 'u') {
d = va_arg(ap, unsigned long);
} else {
d = va_arg(ap, long);
}
} else if (length_mod == 'L') {
if (*fmt == 'u') {
unsigned long long llu =
va_arg(ap, unsigned long long);
if (llu != (uint_value_type) llu) {
data = "ERR";
data_len = 3;
precision = 0;
break;
}
d = (uint_value_type) llu;
} else {
long long lld = va_arg(ap, long long);
if (lld != (int_value_type) lld) {
data = "ERR";
data_len = 3;
precision = 0;
break;
}
d = (int_value_type) lld;
}
d = (uint_value_type) lld;
} else if (*fmt == 'u') {
d = va_arg(ap, unsigned int);
} else {
@@ -229,7 +249,16 @@ start:
} else if (length_mod == 'l') {
x = va_arg(ap, unsigned long);
} else if (length_mod == 'L') {
x = va_arg(ap, unsigned long long);
unsigned long long llx =
va_arg(ap, unsigned long long);
if (llx != (uint_value_type) llx) {
data = "ERR";
data_len = 3;
precision = 0;
break;
}
x = (uint_value_type) llx;
} else {
x = va_arg(ap, unsigned int);
}

View File

@@ -509,12 +509,18 @@ static int arr_parse(struct json_obj *obj,
{
ptrdiff_t elem_size = get_elem_size(elem_descr);
void *last_elem = (char *)field + elem_size * max_elements;
size_t *elements = (size_t *)((char *)val + elem_descr->offset);
size_t *elements = NULL;
struct token value;
if (val) {
elements = (size_t *)((char *)val + elem_descr->offset);
}
__ASSERT_NO_MSG(elem_size > 0);
*elements = 0;
if (elements) {
*elements = 0;
}
while (!arr_next(obj, &value)) {
if (value.type == JSON_TOK_LIST_END) {
@@ -525,11 +531,13 @@ static int arr_parse(struct json_obj *obj,
return -ENOSPC;
}
if (decode_value(obj, elem_descr, &value, field, val) < 0) {
if (decode_value(obj, elem_descr, &value, field, NULL) < 0) {
return -EINVAL;
}
(*elements)++;
if (elements) {
(*elements)++;
}
field = (char *)field + elem_size;
}

View File

@@ -10,17 +10,28 @@ if(CONFIG_PERCEPIO_TRACERECORDER)
zephyr_library_sources_ifdef(
CONFIG_PERCEPIO_TRACERECORDER
${TRACERECORDER_DIR}/kernelports/Zephyr/trcKernelPort.c
${TRACERECORDER_DIR}/trcInternalBuffer.c
${TRACERECORDER_DIR}/trcStreamingRecorder.c
${TRACERECORDER_DIR}/extras/SDK/trcSDK.c
)
if(CONFIG_PERCEPIO_RECORDER_TRC_RECORDER_STREAM_PORT_RTT)
zephyr_library_sources(
${TRACERECORDER_DIR}/streamports/Jlink_RTT/trcStreamingPort.c
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Jlink_RTT/trcStreamingPort.c
)
zephyr_include_directories(
${TRACERECORDER_DIR}/streamports/Jlink_RTT/include/
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Jlink_RTT/include/
)
endif()
if(CONFIG_PERCEPIO_RECORDER_TRC_RECORDER_STREAM_PORT_ITM)
zephyr_library_sources(
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/ARM_ITM/trcStreamingPort.c
)
zephyr_include_directories(
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/ARM_ITM/include/
)
endif()

View File

@@ -5,6 +5,7 @@ envlist=py3
deps =
setuptools-scm
pytest
types-PyYAML
mypy
setenv =
TOXTEMPDIR={envtmpdir}

View File

@@ -86,6 +86,7 @@ syscall_template = """
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
#ifdef __cplusplus

View File

@@ -27,7 +27,7 @@ anytree
intelhex
# it's west
west>=0.10.1
west==0.11.1
# used for windows based 'menuconfig'
# "win32" is used for 64-bit Windows as well

View File

@@ -17,6 +17,7 @@ config SOC_OPENISA_RV32M1_RISCV32
select CLOCK_CONTROL
select HAS_RV32M1_FTFX
select HAS_FLASH_LOAD_OFFSET
select BUILD_OUTPUT_HEX
help
Enable support for OpenISA RV32M1 RISC-V processors. Choose
this option to target the RI5CY or ZERO-RISCY core. This

View File

@@ -146,9 +146,7 @@ void soc_interrupt_init(void)
(void)(EVENT_UNIT->EVTPENDCLEAR); /* Ensures write has finished. */
if (IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS)) {
dev_intmux = device_get_binding(
DT_LABEL(DT_INST(0, openisa_rv32m1_intmux)));
__ASSERT(dev_intmux, "no INTMUX device found");
dev_intmux = DEVICE_DT_GET(DT_INST(0, openisa_rv32m1_intmux));
}
}

View File

@@ -312,11 +312,20 @@ static struct {
* Increasing this by times the max. simultaneous connection count will permit
* simultaneous parallel PHY update or Connection Update procedures amongst
* active connections.
* Minimum node rx of 2 that can be reserved happens when local central
* initiated PHY Update reserves 2 node rx, one for PHY update complete and
* another for Data Length Update complete notification. Otherwise, a
* peripheral only needs 1 additional node rx to generate Data Length Update
* complete when PHY Update completes; node rx for PHY update complete is
* reserved as the received PHY Update Ind PDU.
*/
#if defined(CONFIG_BT_CTLR_PHY) && defined(CONFIG_BT_CTLR_DATA_LENGTH)
#define LL_PDU_RX_CNT 3
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_CTLR_PHY) && \
defined(CONFIG_BT_CTLR_DATA_LENGTH)
#define LL_PDU_RX_CNT (2 * (CONFIG_BT_CTLR_LLCP_CONN))
#elif defined(CONFIG_BT_CONN)
#define LL_PDU_RX_CNT (CONFIG_BT_CTLR_LLCP_CONN)
#else
#define LL_PDU_RX_CNT 2
#define LL_PDU_RX_CNT 0
#endif
/* No. of node rx for LLL to ULL.
@@ -1997,7 +2006,7 @@ static inline void rx_alloc(uint8_t max)
max = mem_link_rx.quota_pdu;
}
while ((max--) && MFIFO_ENQUEUE_IDX_GET(pdu_rx_free, &idx)) {
while (max && MFIFO_ENQUEUE_IDX_GET(pdu_rx_free, &idx)) {
memq_link_t *link;
struct node_rx_hdr *rx;
@@ -2017,6 +2026,8 @@ static inline void rx_alloc(uint8_t max)
MFIFO_BY_IDX_ENQUEUE(pdu_rx_free, idx, rx);
ll_rx_link_inc_quota(-1);
max--;
}
#if defined(CONFIG_BT_CONN)

View File

@@ -4017,12 +4017,12 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
rx->hdr.link->mem = conn->llcp_rx;
conn->llcp_rx = rx;
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
/* reserve rx node for DLE event generation */
rx = ll_pdu_rx_alloc();
rx->hdr.link->mem = conn->llcp_rx;
conn->llcp_rx = rx;
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
if (IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH)) {
rx = ll_pdu_rx_alloc();
rx->hdr.link->mem = conn->llcp_rx;
conn->llcp_rx = rx;
}
}
/* place the phy update ind packet as next in
@@ -4047,6 +4047,21 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
struct node_rx_pdu *rx;
uint8_t old_tx, old_rx;
/* Acquire additional rx node for Data length notification as
* a peripheral.
*/
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH) &&
conn->lll.role) {
rx = ll_pdu_rx_alloc();
if (!rx) {
return;
}
rx->hdr.link->mem = conn->llcp_rx;
conn->llcp_rx = rx;
}
#if defined(CONFIG_BT_PERIPHERAL) && defined(CONFIG_BT_CTLR_LE_ENC)
if (conn->lll.role && (conn->slave.llcp_type != LLCP_NONE)) {
/* Local peripheral initiated PHY update completed while
@@ -4107,8 +4122,11 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
/* enqueue rx node towards Thread */
ll_rx_put(rx->hdr.link, rx);
/* Release rx node that was reserved for Data Length
* notification.
*/
if (IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH)) {
/* get the DLE rx node reserved for ULL->LL */
/* Get the DLE rx node reserved for ULL->LL */
rx = conn->llcp_rx;
LL_ASSERT(rx && rx->hdr.link);
conn->llcp_rx = rx->hdr.link->mem;
@@ -5454,23 +5472,27 @@ static inline uint8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link,
conn->llcp.phy_upd_ind.instant = instant;
conn->llcp.phy_upd_ind.initiate = 0U;
/* Reserve the Rx-ed PHY Update Indication PDU in the connection
* context, by appending to the LLCP node rx list. We do not mark it
* for release in ULL, i.e., by returning *rx as NULL.
* PHY Update notification to HCI layer will use node rx from this
* list when at the instant.
* If data length update is supported in the Controller, then, at the
* instant we attempt to acquire an additional free node rx for Data
* Length Update notification.
*/
link->mem = conn->llcp_rx;
(*rx)->hdr.link = link;
conn->llcp_rx = *rx;
*rx = NULL;
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
/* reserve rx node for DLE event generation */
struct node_rx_pdu *rx_dle = ll_pdu_rx_alloc();
LL_ASSERT(rx_dle);
rx_dle->hdr.link->mem = conn->llcp_rx;
conn->llcp_rx = rx_dle;
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
/* Transition to PHY Update Ind received state and wait for the
* instant.
*/
conn->llcp_type = LLCP_PHY_UPD;
conn->llcp_ack -= 2U;
/* Enforce packet timing restrictions until the instant */
if (conn->llcp.phy_upd_ind.tx) {
conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx;
}

View File

@@ -49,6 +49,8 @@
#include "common/log.h"
#include "hal/debug.h"
static void invalid_release(struct ull_hdr *hdr, struct lll_conn *lll,
memq_link_t *link, struct node_rx_hdr *rx);
static void ticker_op_stop_adv_cb(uint32_t status, void *param);
static void ticker_op_cb(uint32_t status, void *param);
static void ticker_update_latency_cancel_op_cb(uint32_t ticker_status,
@@ -112,10 +114,8 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
/* Do not connect twice to the same peer */
if (ull_conn_peer_connected(own_addr_type, own_addr,
peer_addr_type, peer_id_addr)) {
rx->type = NODE_RX_TYPE_RELEASE;
invalid_release(&adv->ull, lll, link, rx);
ll_rx_put(link, rx);
ll_rx_sched();
return;
}
@@ -136,34 +136,7 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
lll->interval = sys_le16_to_cpu(pdu_adv->connect_ind.interval);
if ((lll->data_chan_count < 2) || (lll->data_chan_hop < 5) ||
(lll->data_chan_hop > 16) || !lll->interval) {
lll->slave.initiated = 0U;
/* Mark for buffer for release */
rx->type = NODE_RX_TYPE_RELEASE;
/* Release CSA#2 related node rx too */
if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
struct node_rx_pdu *rx_csa;
/* pick the rx node instance stored within the
* connection rx node.
*/
rx_csa = (void *)ftr->extra;
/* Enqueue the connection event to be release */
ll_rx_put(link, rx);
/* Use the rx node for CSA event */
rx = (void *)rx_csa;
link = rx->link;
/* Mark for buffer for release */
rx->type = NODE_RX_TYPE_RELEASE;
}
/* Enqueue connection or CSA event to be release */
ll_rx_put(link, rx);
ll_rx_sched();
invalid_release(&adv->ull, lll, link, rx);
return;
}
@@ -578,6 +551,43 @@ uint8_t ll_start_enc_req_send(uint16_t handle, uint8_t error_code,
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
static void invalid_release(struct ull_hdr *hdr, struct lll_conn *lll,
memq_link_t *link, struct node_rx_hdr *rx)
{
/* Reset the advertising disabled callback */
hdr->disabled_cb = NULL;
/* Let the advertiser continue with connectable advertising */
lll->slave.initiated = 0U;
/* Mark for buffer for release */
rx->type = NODE_RX_TYPE_RELEASE;
/* Release CSA#2 related node rx too */
if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
struct node_rx_pdu *rx_csa;
/* pick the rx node instance stored within the
* connection rx node.
*/
rx_csa = rx->rx_ftr.extra;
/* Enqueue the connection event to be release */
ll_rx_put(link, rx);
/* Use the rx node for CSA event */
rx = (void *)rx_csa;
link = rx->link;
/* Mark for buffer for release */
rx->type = NODE_RX_TYPE_RELEASE;
}
/* Enqueue connection or CSA event to be release */
ll_rx_put(link, rx);
ll_rx_sched();
}
static void ticker_op_stop_adv_cb(uint32_t status, void *param)
{
LL_ASSERT(status != TICKER_STATUS_FAILURE ||

View File

@@ -872,6 +872,8 @@ static void l2cap_chan_tx_process(struct k_work *work)
if (sent < 0) {
if (sent == -EAGAIN) {
ch->tx_buf = buf;
} else {
net_buf_unref(buf);
}
break;
}

View File

@@ -54,6 +54,7 @@ if LIB_CPLUSPLUS
config EXCEPTIONS
bool "Enable C++ exceptions support"
depends on !NEWLIB_LIBC_NANO
help
This option enables support of C++ exceptions.

View File

@@ -45,6 +45,7 @@ struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
unsigned int last_prec = 4U;
struct z_page_frame *last_pf = NULL, *pf;
bool accessed;
bool last_dirty = false;
bool dirty = false;
uintptr_t flags, phys;
@@ -71,18 +72,20 @@ struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
if (prec == 0) {
/* If we find a not accessed, clean page we're done */
last_pf = pf;
last_dirty = dirty;
break;
}
if (prec < last_prec) {
last_prec = prec;
last_pf = pf;
last_dirty = dirty;
}
}
/* Shouldn't ever happen unless every page is pinned */
__ASSERT(last_pf != NULL, "no page to evict");
*dirty_ptr = dirty;
*dirty_ptr = last_dirty;
return last_pf;
}

View File

@@ -119,8 +119,8 @@ static int check_log_file_exist(int num)
while (true) {
rc = fs_readdir(&dir, &ent);
if (rc < 0) {
(void) fs_closedir(&dir);
return -EIO;
rc = -EIO;
goto close_dir;
}
if (ent.name[0] == 0) {
break;
@@ -129,13 +129,17 @@ static int check_log_file_exist(int num)
rc = get_log_file_id(&ent);
if (rc == num) {
return 1;
rc = 1;
goto close_dir;
}
}
rc = 0;
close_dir:
(void) fs_closedir(&dir);
return 0;
return rc;
}
int write_log_to_file(uint8_t *data, size_t length, void *ctx)

View File

@@ -1913,7 +1913,8 @@ next_state:
break;
case TCP_FIN_WAIT_2:
if (th && (FL(&fl, ==, FIN, th_seq(th) == conn->ack) ||
FL(&fl, ==, FIN | ACK, th_seq(th) == conn->ack))) {
FL(&fl, ==, FIN | ACK, th_seq(th) == conn->ack) ||
FL(&fl, ==, FIN | PSH | ACK, th_seq(th) == conn->ack))) {
/* Received FIN on FIN_WAIT_2, so cancel the timer */
k_work_cancel_delayable(&conn->fin_timer);

View File

@@ -78,6 +78,15 @@ int mqtt_client_tls_connect(struct mqtt_client *client)
}
}
if (tls_config->cert_nocopy != TLS_CERT_NOCOPY_NONE) {
ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS,
TLS_CERT_NOCOPY, &tls_config->cert_nocopy,
sizeof(tls_config->cert_nocopy));
if (ret < 0) {
goto error;
}
}
size_t peer_addr_size = sizeof(struct sockaddr_in6);
if (broker->sa_family == AF_INET) {

View File

@@ -113,6 +113,11 @@ __net_socket struct tls_context {
/** Peer verification level. */
int8_t verify_level;
/** Indicating on whether DER certificates should not be copied
* to the heap.
*/
int8_t cert_nocopy;
/** DTLS role, client by default. */
int8_t role;
@@ -679,12 +684,30 @@ static int tls_rx(void *ctx, unsigned char *buf, size_t len)
return received;
}
#if defined(MBEDTLS_X509_CRT_PARSE_C)
static bool crt_is_pem(const unsigned char *buf, size_t buflen)
{
return (buflen != 0 && buf[buflen - 1] == '\0' &&
strstr((const char *)buf, "-----BEGIN CERTIFICATE-----") != NULL);
}
#endif
static int tls_add_ca_certificate(struct tls_context *tls,
struct tls_credential *ca_cert)
{
#if defined(MBEDTLS_X509_CRT_PARSE_C)
int err = mbedtls_x509_crt_parse(&tls->ca_chain,
ca_cert->buf, ca_cert->len);
int err;
if (tls->options.cert_nocopy == TLS_CERT_NOCOPY_NONE ||
crt_is_pem(ca_cert->buf, ca_cert->len)) {
err = mbedtls_x509_crt_parse(&tls->ca_chain, ca_cert->buf,
ca_cert->len);
} else {
err = mbedtls_x509_crt_parse_der_nocopy(&tls->ca_chain,
ca_cert->buf,
ca_cert->len);
}
if (err != 0) {
return -EINVAL;
}
@@ -704,29 +727,59 @@ static void tls_set_ca_chain(struct tls_context *tls)
#endif /* MBEDTLS_X509_CRT_PARSE_C */
}
static int tls_set_own_cert(struct tls_context *tls,
struct tls_credential *own_cert,
struct tls_credential *priv_key)
static int tls_add_own_cert(struct tls_context *tls,
struct tls_credential *own_cert)
{
#if defined(MBEDTLS_X509_CRT_PARSE_C)
int err = mbedtls_x509_crt_parse(&tls->own_cert,
own_cert->buf, own_cert->len);
int err;
if (tls->options.cert_nocopy == TLS_CERT_NOCOPY_NONE ||
crt_is_pem(own_cert->buf, own_cert->len)) {
err = mbedtls_x509_crt_parse(&tls->own_cert,
own_cert->buf, own_cert->len);
} else {
err = mbedtls_x509_crt_parse_der_nocopy(&tls->own_cert,
own_cert->buf,
own_cert->len);
}
if (err != 0) {
return -EINVAL;
}
return 0;
#endif /* MBEDTLS_X509_CRT_PARSE_C */
return -ENOTSUP;
}
static int tls_set_own_cert(struct tls_context *tls)
{
#if defined(MBEDTLS_X509_CRT_PARSE_C)
int err = mbedtls_ssl_conf_own_cert(&tls->config, &tls->own_cert,
&tls->priv_key);
if (err != 0) {
err = -ENOMEM;
}
return err;
#endif /* MBEDTLS_X509_CRT_PARSE_C */
return -ENOTSUP;
}
static int tls_set_private_key(struct tls_context *tls,
struct tls_credential *priv_key)
{
#if defined(MBEDTLS_X509_CRT_PARSE_C)
int err;
err = mbedtls_pk_parse_key(&tls->priv_key, priv_key->buf,
priv_key->len, NULL, 0);
if (err != 0) {
return -EINVAL;
}
err = mbedtls_ssl_conf_own_cert(&tls->config, &tls->own_cert,
&tls->priv_key);
if (err != 0) {
err = -ENOMEM;
}
return 0;
#endif /* MBEDTLS_X509_CRT_PARSE_C */
@@ -760,21 +813,11 @@ static int tls_set_credential(struct tls_context *tls,
return tls_add_ca_certificate(tls, cred);
case TLS_CREDENTIAL_SERVER_CERTIFICATE:
{
struct tls_credential *priv_key =
credential_get(cred->tag, TLS_CREDENTIAL_PRIVATE_KEY);
if (!priv_key) {
return -ENOENT;
}
return tls_set_own_cert(tls, cred, priv_key);
}
return tls_add_own_cert(tls, cred);
case TLS_CREDENTIAL_PRIVATE_KEY:
/* Ignore private key - it will be used together
* with public certificate
*/
break;
return tls_set_private_key(tls, cred);
break;
case TLS_CREDENTIAL_PSK:
{
@@ -805,7 +848,7 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
struct tls_credential *cred;
sec_tag_t tag;
int i, err = 0;
bool tag_found, ca_cert_present = false;
bool tag_found, ca_cert_present = false, own_cert_present = false;
credentials_lock();
@@ -824,6 +867,8 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
if (cred->type == TLS_CREDENTIAL_CA_CERTIFICATE) {
ca_cert_present = true;
} else if (cred->type == TLS_CREDENTIAL_SERVER_CERTIFICATE) {
own_cert_present = true;
}
}
@@ -836,8 +881,13 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
exit:
credentials_unlock();
if (err == 0 && ca_cert_present) {
tls_set_ca_chain(tls);
if (err == 0) {
if (ca_cert_present) {
tls_set_ca_chain(tls);
}
if (own_cert_present) {
err = tls_set_own_cert(tls);
}
}
return err;
@@ -1312,6 +1362,31 @@ static int tls_opt_peer_verify_set(struct tls_context *context,
return 0;
}
static int tls_opt_cert_nocopy_set(struct tls_context *context,
const void *optval, socklen_t optlen)
{
int *cert_nocopy;
if (!optval) {
return -EINVAL;
}
if (optlen != sizeof(int)) {
return -EINVAL;
}
cert_nocopy = (int *)optval;
if (*cert_nocopy != TLS_CERT_NOCOPY_NONE &&
*cert_nocopy != TLS_CERT_NOCOPY_OPTIONAL) {
return -EINVAL;
}
context->options.cert_nocopy = *cert_nocopy;
return 0;
}
static int tls_opt_dtls_role_set(struct tls_context *context,
const void *optval, socklen_t optlen)
{
@@ -2340,6 +2415,10 @@ int ztls_setsockopt_ctx(struct tls_context *ctx, int level, int optname,
err = tls_opt_peer_verify_set(ctx, optval, optlen);
break;
case TLS_CERT_NOCOPY:
err = tls_opt_cert_nocopy_set(ctx, optval, optlen);
break;
case TLS_DTLS_ROLE:
err = tls_opt_dtls_role_set(ctx, optval, optlen);
break;

View File

@@ -15,27 +15,30 @@ This benchmark measures the latency of selected kernel capabilities, including:
* Time it takes to resume a suspended thread
* Time it takes to create a new thread (without starting it)
* Time it takes to start a newly created thread
* Measure average time to alloc memory from heap then free that memory
Sample output of the benchmark::
*** Booting Zephyr OS build zephyr-v2.3.0-2257-g0f420483db07 ***
*** Booting Zephyr OS build zephyr-v2.6.0-1119-g378a1e082ac5 ***
START - Time Measurement
Timing results: Clock frequency: 120 MHz
Average thread context switch using yield : 420 cycles , 3502 ns
Average context switch time between threads (coop) : 429 cycles , 3583 ns
Switch from ISR back to interrupted thread : 670 cycles , 5583 ns
Time from ISR to executing a different thread : 570 cycles , 4750 ns
Time to create a thread (without start) : 360 cycles , 3000 ns
Time to start a thread : 545 cycles , 4541 ns
Time to suspend a thread : 605 cycles , 5041 ns
Time to resume a thread : 660 cycles , 5500 ns
Time to abort a thread (not running) : 495 cycles , 4125 ns
Average semaphore signal time : 195 cycles , 1626 ns
Average semaphore test time : 62 cycles , 518 ns
Semaphore take time (context switch) : 695 cycles , 5791 ns
Semaphore give time (context switch) : 845 cycles , 7041 ns
Average time to lock a mutex : 79 cycles , 659 ns
Average time to unlock a mutex : 370 cycles , 3085 ns
Timing results: Clock frequency: 1000 MHz
Average thread context switch using yield : 9060 cycles , 9060 ns
Average context switch time between threads (coop) : 9503 cycles , 9503 ns
Switch from ISR back to interrupted thread : 14208 cycles , 14208 ns
Time from ISR to executing a different thread : 9664 cycles , 9664 ns
Time to create a thread (without start) : 3968 cycles , 3968 ns
Time to start a thread : 12064 cycles , 12064 ns
Time to suspend a thread : 12640 cycles , 12640 ns
Time to resume a thread : 12096 cycles , 12096 ns
Time to abort a thread (not running) : 2208 cycles , 2208 ns
Average semaphore signal time : 8928 cycles , 8928 ns
Average semaphore test time : 2048 cycles , 2048 ns
Semaphore take time (context switch) : 13472 cycles , 13472 ns
Semaphore give time (context switch) : 18400 cycles , 18400 ns
Average time to lock a mutex : 3072 cycles , 3072 ns
Average time to unlock a mutex : 9251 cycles , 9251 ns
Average time for heap malloc : 13056 cycles , 13056 ns
Average time for heap free : 7776 cycles , 7776 ns
===================================================================
PROJECT EXECUTION SUCCESSFUL

View File

@@ -22,3 +22,5 @@ CONFIG_PM=n
# Can only run under 1 CPU
CONFIG_MP_NUM_CPUS=1
CONFIG_TIMING_FUNCTIONS=y
CONFIG_HEAP_MEM_POOL_SIZE=2048

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <timing/timing.h>
#include "utils.h"
#define TEST_COUNT 100
#define TEST_SIZE 10
void heap_malloc_free(void)
{
timing_t heap_malloc_start_time = 0U;
timing_t heap_malloc_end_time = 0U;
timing_t heap_free_start_time = 0U;
timing_t heap_free_end_time = 0U;
uint32_t count = 0U;
uint32_t sum_malloc = 0U;
uint32_t sum_free = 0U;
timing_start();
while (count != TEST_COUNT) {
heap_malloc_start_time = timing_counter_get();
void *allocated_mem = k_malloc(TEST_SIZE);
heap_malloc_end_time = timing_counter_get();
if (allocated_mem == NULL) {
printk("Failed to alloc memory from heap "
"at count %d\n", count);
break;
}
heap_free_start_time = timing_counter_get();
k_free(allocated_mem);
heap_free_end_time = timing_counter_get();
sum_malloc += timing_cycles_get(&heap_malloc_start_time,
&heap_malloc_end_time);
sum_free += timing_cycles_get(&heap_free_start_time,
&heap_free_end_time);
count++;
}
PRINT_STATS_AVG("Average time for heap malloc", sum_malloc, count);
PRINT_STATS_AVG("Average time for heap free", sum_free, count);
timing_stop();
}

View File

@@ -27,6 +27,7 @@ extern int coop_ctx_switch(void);
extern int sema_test(void);
extern int sema_context_switch(void);
extern int suspend_resume(void);
extern void heap_malloc_free(void);
void test_thread(void *arg1, void *arg2, void *arg3)
{
@@ -57,6 +58,8 @@ void test_thread(void *arg1, void *arg2, void *arg3)
mutex_lock_unlock();
heap_malloc_free();
TC_END_REPORT(error_count);
}

View File

@@ -11,7 +11,6 @@
#include <tc_util.h>
#include <sys/bitarray.h>
#include <sys/util.h>
#include <toolchain.h>
#ifdef CONFIG_BIG_ENDIAN
#define BIT_INDEX(bit) ((3 - ((bit >> 3) & 0x3)) + 4*(bit >> 5))
@@ -338,13 +337,29 @@ void alloc_and_free_predefined(void)
"sys_bitarray_free() failed bits comparison");
}
static inline size_t count_bits(uint32_t val)
{
/* Implements Brian Kernighans Algorithm
* to count bits.
*/
size_t cnt = 0;
while (val != 0) {
val = val & (val - 1);
cnt++;
}
return cnt;
}
size_t get_bitarray_popcnt(sys_bitarray_t *ba)
{
size_t popcnt = 0;
unsigned int idx;
for (idx = 0; idx < ba->num_bundles; idx++) {
popcnt += popcount(ba->bundles[idx]);
popcnt += count_bits(ba->bundles[idx]);
}
return popcnt;

View File

@@ -51,7 +51,7 @@ char *expected = "22 113 10000 32768 40000 22\n"
"42 42 42 42\n"
"42 42 0042 00000042\n"
"255 42 abcdef 42\n"
"ERR -1 4294967295 ffffffff\n"
"ERR -1 ERR ERR\n"
"0xcafebabe 0xbeef 0x2a\n"
;
#endif

View File

@@ -362,7 +362,7 @@ void test_kobject_release_from_user(void)
*/
void test_kobject_release_null(void)
{
int dummy;
int dummy = 0;
k_object_release(&dummy);
}

View File

@@ -14,7 +14,7 @@
#define STACK_SIZE (640 + CONFIG_TEST_EXTRA_STACKSIZE)
K_THREAD_STACK_EXTERN(tstack);
extern K_THREAD_STACK_ARRAY_DEFINE(tstacks, MAX_NUM_THREAD, STACK_SIZE);
K_THREAD_STACK_ARRAY_EXTERN(tstacks, MAX_NUM_THREAD, STACK_SIZE);
extern struct k_thread user_thread;
extern struct k_sem user_sem;

View File

@@ -232,8 +232,20 @@ static void test_json_decoding_array_array(void)
&obj_array_array_ts);
zassert_equal(ret, 1, "Encoding array of object returned no errors");
zassert_equal(obj_array_array_ts.objects_array_len, 3, "Array has correct number of items");
zassert_true(!strcmp(obj_array_array_ts.objects_array[0].objects.name,
"Simón Bolívar"), "String decoded correctly");
zassert_equal(obj_array_array_ts.objects_array[0].objects.height, 168,
"Simón Bolívar height decoded correctly");
zassert_true(!strcmp(obj_array_array_ts.objects_array[1].objects.name,
"Pelé"), "String decoded correctly");
zassert_equal(obj_array_array_ts.objects_array[1].objects.height, 173,
"Pelé height decoded correctly");
zassert_true(!strcmp(obj_array_array_ts.objects_array[2].objects.name,
"Usain Bolt"), "String decoded correctly");
zassert_equal(obj_array_array_ts.objects_array[2].objects.height, 195,
"Usain Bolt height decoded correctly");
}

View File

@@ -3,14 +3,17 @@ common:
integration_platforms:
- mps2_an385
tests:
cpp.libcxx:
cpp.libcxx.newlib:
toolchain_exclude: xcc
min_flash: 54
tags: cpp
cpp.libcxx.exceptions:
extra_configs:
- CONFIG_NEWLIB_LIBC_NANO=n
- CONFIG_EXCEPTIONS=y
cpp.libcxx.newlib_nano:
toolchain_exclude: xcc
min_flash: 54
tags: cpp
timeout: 30
extra_configs:
- CONFIG_EXCEPTIONS=y
- CONFIG_NEWLIB_LIBC_NANO=y

View File

@@ -502,6 +502,7 @@ static void test_d_length(void)
int max = 1876543210;
long long svll = 123LL << 48;
long long svll2 = -2LL;
unsigned long long uvll = 4000000000LLU;
int rc;
TEST_PRF(&rc, "%d/%d", min, max);
@@ -518,22 +519,22 @@ static void test_d_length(void)
PRF_CHECK("46/-22", rc);
}
TEST_PRF(&rc, "%ld/%ld", (long)min, (long)max);
TEST_PRF(&rc, "%ld/%ld/%lu/", (long)min, (long)max, 4000000000UL);
if (IS_ENABLED(CONFIG_CBPRINTF_FULL_INTEGRAL)
|| (sizeof(long) <= 4)
|| IS_ENABLED(CONFIG_CBPRINTF_NANO)) {
PRF_CHECK("-1234567890/1876543210", rc);
PRF_CHECK("-1234567890/1876543210/4000000000/", rc);
} else {
PRF_CHECK("%ld/%ld", rc);
PRF_CHECK("%ld/%ld/%lu/", rc);
}
TEST_PRF(&rc, "/%lld/%lld/%lld/", svll, -svll, svll2);
TEST_PRF(&rc, "/%lld/%lld/%lld/%llu/", svll, -svll, svll2, uvll);
if (IS_ENABLED(CONFIG_CBPRINTF_FULL_INTEGRAL)) {
PRF_CHECK("/34621422135410688/-34621422135410688/-2/", rc);
PRF_CHECK("/34621422135410688/-34621422135410688/-2/4000000000/", rc);
} else if (IS_ENABLED(CONFIG_CBPRINTF_COMPLETE)) {
PRF_CHECK("/%lld/%lld/%lld/", rc);
PRF_CHECK("/%lld/%lld/%lld/%llu/", rc);
} else if (IS_ENABLED(CONFIG_CBPRINTF_NANO)) {
PRF_CHECK("/ERR/ERR/-2/", rc);
PRF_CHECK("/ERR/ERR/-2/4000000000/", rc);
} else {
zassert_true(false, "Missed case!");
}

View File

@@ -134,7 +134,7 @@ manifest:
revision: a47e326ca772ddd14cc3b9d4ca30a9ab44ecca16
- name: TraceRecorderSource
path: modules/debug/TraceRecorder
revision: d9889883abb4657d71e15ff055517a9b032f8212
revision: 5b5f8d7adbf0e93a09087e8f5708f0eebb8b25bf
- name: hal_xtensa
revision: 2f04b615cd5ad3a1b8abef33f9bdd10cc1990ed6
path: modules/hal/xtensa