Compare commits

...

33 Commits

Author SHA1 Message Date
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
33 changed files with 519 additions and 155 deletions

View File

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

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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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