The NRF_TWI_Type struct doesn't have an homogeneous layout between
nRF51/52 series. This patch tries to select the right layout based on
selected SoC.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Avoids segfault in situations when we can't acquire an RX buffer, and VLAN
or PTP code is enabled which tries to inspect packets by adding a pkt
check.
Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
Fix compile error when debug pins are enabled for nRF53
Series SoCs.
Regression introduced in commit 743b0583fc ("Bluetooth:
controller: Enable debug pins with TF-M enabled").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use non-zero SID value so that regressions in use of
Periodic Advertiser List implementation is catch in
testing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing assignment of SID in the Periodic Advertiser
Accept List. This cause advertisers with SID 0 only to be
accepted when using list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Tx Power field in Extended and Periodic Advertising
for chain PDU reception. Tx Power shall be from the
current PDU containing the AD Data, Scan Response Data and
from first PDU of Periodic Advertising Data be used to
prepare the HCI report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The incorrect sequence will cause the thread cannot be aborted in the
ISR context. The following test case failed:
tests/kernel/fatal/exception/kernel.common.stack_sentinel.
The stack sentinel detects the stack overflow as normal during a timer
ISR exit. Note that, currently, the stack overflow detection is behind
the context switch checking, and then the detection will call svc to
raise a fatal error resulting in increasing the nested counter(+1). At
this point, it needs a context switch to finally abort the thread.
However, after the fatal error handling, the program cannot do a context
switch either during the svc exit[1], or during the timer ISR exit[2].
[1] is because the svc context is in an interrupt nested state (the
nested counter is 2).
[2] is because the current point (after svc context pop out) is right
behind the switch checking.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
The temp val should be uint64_t in read_sysreg64 instead of uint32_t.
The incorrect type uint32_t will cause an issue:
mrrc instruction needs 2 registers when reading from a 64-bit system
register. The type uint32_t tells GCC only to save/restore one register,
so after the mrrc is executed, the other would clash.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
This is painful. There is no way for u-mode code to know if we're
currently executing in u-mode without generating a fault, besides
stealing a general purpose register away from the standard ABI
that is. And a global variable doesn't work on SMP as this must be
per-CPU and we could be migrated to another CPU just at the right
moment to peek at the wrong CPU variable (and u-mode can't disable
preemption either).
So, given that we'll have to pay the price of an exception entry
anyway, let's at least make it free to privileged threads by using
the mscratch register as the non-user context indicator (it must
be zero in m-mode for exception entry to work properly). In the
case of u-mode we'll simulate a proper return value in the
exception trap code. Let's settle on the return value in t0
and omit the volatile to give the compiler a chance to cache
the result.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
To do so efficiently on systems without the mul instruction, we use
shifts and adds which is faster and sometimes smaller than a plain loop.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Stop using &_kernel as this is not SMP friendly. Let's use s0 (after
preserving its content) to hold ¤t_cpu instead so it won't have
to be reloaded each time it is needed. This will be even more relevant
when SMP support is added.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Rely on mstatus rather than thread->base.user_options since it is always
up to date (updated by z_riscv_switch) to simplify the code and be SMP
proof. Also carry over SF_INIT to the mstatus being restored in case
it was changed in the mean time.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The move to arch_switch() is a prerequisite for SMP support.
Make it optimal without the need for an ECALL roundtrip on every
context switch. Performance numbers from tests/benchmarks/sched:
Before:
unpend 107 ready 102 switch 188 pend 218 tot 615 (avg 615)
After:
unpend 107 ready 102 switch 170 pend 217 tot 596 (avg 595)
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This is a per-thread register that gets updated only when context
switching. No need to load and save it on every exception entry.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The minimum stack alignment is 16. Therefore, the stack space to store
a struct __esf object must be rounded up to the next 16-byte boundary.
It is not sufficient to do the rounding on the __z_arch_esf_t_SIZEOF
definition. When the stack is constructed in arch_new_thread() it is
also necessary to do the rounding there too.
Let's make the structure itself carry the alignment attribute instead to
make it work in all cases.
While at it, remove the unused _K_THREAD_NO_FLOAT_SIZEOF definition.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Get rid of all those global variables and IRQ locking.
Use the regular IRQ exit path to let tests validate preemption properly.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Complete revamp of the exception entry code, including syscall handling.
Proper syscall frame exception trigger. Many correctness fixes, hacks
removal, etc. etc.
I tried to make this into several commits, but this stuff is all
inter-related and a pain to split.
The diffstat summary:
14 files changed, 250 insertions(+), 802 deletions(-)
Binary size (before):
text data bss dec hex filename
1104 0 0 1104 450 isr.S.obj
64 0 0 64 40 userspace.S.obj
Binary size (after):
text data bss dec hex filename
600 0 0 600 258 isr.S.obj
36 0 0 36 24 userspace.S.obj
Run of samples/userspace/syscall_perf (before):
*** Booting Zephyr OS build zephyr-v3.0.0-325-g3748accae018 ***
Main Thread started; qemu_riscv32
Supervisor thread started
User thread started
Supervisor thread(0x80010048): 384 cycles 509 instructions
User thread(0x80010140): 77312 cycles 77437 instructions
Run of samples/userspace/syscall_perf (after):
*** Booting Zephyr OS build zephyr-v3.0.0-326-g4c877a2753b3 ***
Main Thread started; qemu_riscv32
Supervisor thread started
User thread started
Supervisor thread(0x80010048): 384 cycles 509 instructions
User thread(0x80010138): 7040 cycles 7165 instructions
Yes, that's more than a 10x speed-up!
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Same rationale as preceding commit. Let's create pseudo-instructions in
assembly scope to make the code more uniform and readable.
Furthermore the definition of COPY_ESF_FP() was wrong as the width of
floating point registers vary not according to CONFIG_64BIT but
CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION. It is therefore wrong to use
lr/sr (previously RV_OP_LOADREG/RV_OP_STOREREG) and a regular temporary
register to transfer such content.
Note: There are far more efficient ways to copy FP context around but
such optimisations will come separately.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Those are prominent enough that having RV_OP_LOADREG and RV_OP_STOREREG
shouting at you all over the place is rather unpleasant and bad taste.
Let's create pseudo-instructions of our own with assembler macros
rather than preprocessor defines and only in assembly scope.
This makes the asm code way more uniform and readable.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The thread->base.user_options field is an uint8_t. Access it using lb.
A "copy" of it is made into __esf.fp_state. Make that field an uint8_t
too and access it with lb/sb.
_callee_saved.fcsr is an uint32_t. Access it with lw/sw.
Ditto for is_user_mode.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This reverts commit 8686ab5472.
The purpose of this commit will be reintroduced later on top of
a cleaner codebase.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This reverts commit be28de692c.
The purpose of this commit will be reintroduced later on top of
a cleaner codebase.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This reverts commit b0458201cc.
The purpose of this commit will be reintroduced later on top of
a cleaner codebase.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The header file radio_df_vendor_hal.h was conditionally copiled in.
There were a dependency on a CONFIG_BT_CTRL_DR. The dependency is
removed because radio_df_vendor_hal.h and radio_df.h hasn't got any
DF related type dependencies. What more it allows to use IS_ENABLED
for code that uses types and functions defined in radio_df.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The EVENTS_CTEPRESENT is available when radio peripheral has
direction finding support. The event is set if received
PDU has CTEInfo and there were collected IQ samples during
CTE reception.
The event should be cleared always when other events are cleared.
That guarantees that the event is not set when use of radio for
following activities.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The radio_df_cte_ready function returns state of EVENTS_CTEPRESENT.
The function may not be used in create_iq_report function, because
it is called after lll_isr_rx_status_reset. The lll_isr_rx_status-
_reset clears EVENTS_CTEPRESENT value.
The result of this calls chain is lack of IQ sample report no matter
if the PDU has CTEInfo and radio has collected IQ samples.
To fix the problem, state of EVENTS_CTEPRESENT has to be get when
e.g. rssi_ready is get.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
As Extended Advertising primary PDUs do not use ticker
remainder value for fine scheduling of radio events, do not
use the remainder value for auxiliary PDUs. This fixes the
jitter in the aux_offset value that caused the auxiliary PDU
being observed to be late compared to the aux_offset value
filled in the primary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This was affecting following qualification test cases:
GAP/SEC/SEM/BV-56-C
GAP/SEC/SEM/BV-57-C
GAP/SEC/SEM/BV-58-C
GAP/SEC/SEM/BV-59-C
GAP/SEC/SEM/BV-60-C
GAP/SEC/SEM/BV-61-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Core Specification 5.3 clarified security requirements for GATT client
when handling incoming notifications and indications.
Vol 3: Part C: 10.3.2.2:
"...Since the configuration is persistent across a disconnection and
reconnection, the client shall check the security requirements against
the configuration upon a reconnection before processing any indications
or notifications from the server. Any notifications received before
the security requirements are met shall be ignored. Any indications
received before the security requirements are met shall be confirmed
and then discarded. ..."
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The commit fixes erase storage command so that it would return with
error code instead of bus faulting when no device is attached
to flash storage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
It is possible for flash partition to have no device attached
which may cause image commands to bus fault device.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This adds bare minimum implementation of Hearing Access Service.
The GATT HAS service contains one Hearing Aid Features mandatory
characteristic.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add a derogation to checkpatch's 'SPACING' rule, which randomly returns
the following type of issue when STM32Cube HAL *_TypeDef are used:
-:10: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#10: FILE: drivers/adc/adc_stm32.c:806:
+ ADC_TypeDef *adc = config->base;
This derogation applies to all _TypDef structures defined in STM32Cube
CMSIS descriptions:
FMC_Bank1E_6_TypeDef
DMA_Channel_TypeDef
ADC_TypeDef
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Currently when a node has a 'zephyr,memory-region' compatible and a
'zephyr,memory-region' string property, a new memory region is created
in the linker script.
Having a memory region without a section to place variables in could be
not that useful. With this patch we extend the memory-region mechanism
to also create sections.
The user can then place variables in the sections as usual by using for
example the GCC attributes.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Include a pointer to the CAN controller device for the CAN
transmit, receive, and state change callback functions.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Starting with LoRaWAN 1.0.4 the DevNonce sent with the OTAA join must be
monotonically increasing for each new join with the same EUI. The DevNonce
should be stored in non-volatile memory by the application.
This commit uses a simple extension of the lorawan_join_otaa struct to
allow specifying the DevNonce.
Signed-off-by: Martin Jäger <martin@libre.solar>
This updates hal_espressif so that a few changes and
features are available in main repository.
- Removed unused stubs
- Updated esptool version
- Fix macro redefinitions
- Changes to support Zephyr SDK toolchain
- pinctrl base files
- Fix BLE nested locking handling
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
odroid_go board was not up to date.
Fix compilation issues.
Add timers support and flash partitions.
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Add generic support for can_get_max_filters() to the Bosch M_CAN
base driver and use it in all driver frontends.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>