Add a version check to allow building with older GCC versions that did
not support this option.
Fixes#16607
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The _k_mutex linker section is used to gather instances of
struct k_mutex into a list so that init_mutex_module() could iterate
that list to perform runtime initialization tasks. In this case, we're
not defining a struct k_mutex but rather a struct pthread_mutex which is
a completely different structure. Not only those struct pthread_mutex
would be corrupted with unexpected data, but since they're not the
same size as struct k_mutex, the actual struct k_mutex instances that
follow in the list would be misaligned and get corrupted too.
There is nothing that requires runtime initialization in the static
definition of a struct pthread_mutex so let's remove the section
attribute.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit fixes the zassert_mem_equal macro to properly print
the formatting string is given as a parameter by the user.
There is an error that is an effect of directly copying the
previous implementation that was using the inline function.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
The compiler and linker was generating errors after
disabling `CONFIG_EXTI_STM32` due to inconsistency
in `interrupt_controller/CMakeLists.txt`
and not considering this option in gpio implementation.
Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
These events aren't errors at all, but rather part of normal operation.
They shouldn't trigger error messages, especially given that the console
gets absolutely flooded with them if power management is activated.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
When mcumgr smp data was received over shell uart transport
it was not waking up shell thread and thus request was not
processed. Shell thread must be waken up on any incoming
data, even data which is only dedicated for mcumgr smp.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This documents the context in which callbacks are run, that is now
the System Workqueue.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Disable flow control with POSIX_ARCH since these boards tend to run
faster than normal defering the TX callback to system wq may not be
able to run before another packet is received.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the transmission complete callbacks to run on system wq
context so they are not executed in TX thread which usually has a much
smaller, and non-configurable, stack size.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reworks bt_gatt_notify_cb to allow passing an UUID, in addition to
that it can now accept multiple notification at once as there could be
multiple instance of the same UUID the user can set multiple set of
parameters.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type in gatt show-db to match
attributes by UUID.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type to match the CCC UUID which
previously was not possible with bt_gatt_foreach_attr.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_foreach_attr_type which can match attribute by UUID
and/or attribute user_data, in addition of that the user can also limit
the number of matches.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With code that looks like this:
for (int i = ARRAY_SIZfoo) - 1; i >= 0; i--) ...
If foo is empty, ARRAY_SIZfoo) will return 0. But since it is
implemented using an unsigned long, the answer to 0UL - 1 is
18446744073709551615 on a 64-bit system, and that doesn't fit into
an int. The compiler complains with:
warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘18446744073709551615’ to ‘-1’ [-Woverflow]
Let's fix that and get the expected behavior simply by turning the
unsigned long into a signed long.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The fifo/lifo API is implemented on top of the queue API with macros
that blindly force a cast to struct k_queue. Providing a reference to
the _queue member from the k_fifo structure is much cleaner as it let
the compiler perform pointer type checking. Generated code is identical.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
All architectures declare those variables the same way, no need to
define them per arch, instead put them in common. If someone deviates,
they can create their own header.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
We had architectures doing this differently, some had a dedicated
sys_io.h file, some not. Unify how it is done by splitting the arch
specific sys_io implementation into a sys_io file and include it
instead.
Move bits_portable.h to arch/common and split the file so more
architecture can reuse some of the definitions here instead of
duplicating code.
Where applicable use the common sys_io/ffs definitions.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
With gcc 9.1.x on fedora 30 we are getting new warnings that turn into
errors when running sanitycheck. Disable those while the issues are
being addressed.
Relates to #16587
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Documentation updated, added reference to the latest
LPClink2 firmware, default provided firmware may not
work on latest boards (e.g. LPC55xx).
Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Board LPCXpresso55S69 added to supported zephyr boards, initial simple
configuration to boot board and use UART.
Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Importing MCUX drivers will copy fsl_power and fsl_reset to devices,
not drivers as before. Script will exclude 'freertos' drivers from SDK.
Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Since LPC devices use different power hardware, a separation is
required between device specific drivers and common drivers.
Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
ip register holds the stack_info.size (it is passed as argument
into z_arch_user_mode_enter(.)). We trust that the value of
stack_info.size contains the accurate size of the writable
stack buffer, above stack_info.start (as specified in kernel.h).
Therefore, we do not need to subtract any bytes for the MPU
stack guard. This allows us to clean-up one more occurrence of
CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT in userspace.S.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
The internal "reschedule" API has always understood the idea that it
might run in a ISR context where it can't swap. But it has always
been happy to swap away when in thread mode, even when the environment
contains an outer lock that would NOT be expecting to swap! As it
happened, the way irq locks are implemented (they store flag state
that can be restored without context) this would "work" even though it
was completely breaking the synchronization promise made by the outer
lock.
But now, with spinlocks, the error gets detected (albeit in a clumsy
way) in debug builds. The unexpected swap triggers SPIN_VALIDATE
failures in later threads (this gets reported as a "recursive" lock,
but what actually happened is that another thread got to run before
the lock was released and tried to grab the same lock).
Fix this so that swap can only be called in a situation where the irq
lock key it was passed would have the effect of unmasking interrupts.
Note that this is a real behavioral change that affects when swaps
occur: it's not impossible that there is code out there that actually
relies on this "lock breaking reschedule" for correct behavior. But
our previous implementation was irredeemably broken and I don't know
how to address that.
Fixes#16273
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Architectures that lack implementations of synchronous traps (via
Z_ARCH_EXCEPT()) end up using a z_except_reason() implementation that
doesn't actually trap at all. It just invokes
z_NanoFatalErrorHandler() in the current thread context.
That has two problems:
First, it was just blindly assuming that the error handling invoked
would abort the current thread, swap away, and never return. But that
can be application code in z_SysFatalErrorHandler that we can't
control.
Second, it was too broad with this assumption and stuff a
CODE_UNREACHABLE hint in for the compiler. But in fact
z_except_reason() may be invoked in interrupt context (for example the
stackprot check) where it may NOT swap away and WILL return
synchronously from the call. This doesn't seem to have caused a
miscompilation in production code, but it made a total voodoo hash out
of my debugging around this macro for an hour or so until I figured
out why my logging was being optimized out.
Do the abort unconditionally instead of relying on the app, and remove
the incorrect compiler hint.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Contrary to the comment in code, this test is NOT, in fact, compiled
with a traditional ticked kernel. Spinning won't work reliably
because interrupts won't necessarily be delivered when you expect.
This test case would fail spuriously as I moved things around when
debugging.
Doing it right (using a k_timer in this case) is actually less code
anyway.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The z_reschedule() call (as of the accompanying fix) will not swap
away from a thread if called with a nested irq lock held.
But for the specific case of aborting the current thread, we
absolutely need to swap regardless of how many locks the thread that
just aborted might have held. So call z_swap() explicitly here.
This preserves the existing z_reschedule() call in other circumstances
for compatibility with existing test cases, but adds a note explaining
why it's there when the only obvious reason for it is already covered.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
It's useful to be able to inspect the key returned from
z_arch_irq_unlock() to see if interrupts were enabled at the point
where z_arch_irq_lock() was called. Architectures tend to represent
this is a simple way that doesn't require platform assembly to
inspect.
Adds a simple test to kernel/common that validates this predicate with
a nested lock.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
We do have a multi-architecture latency benchmark now, this one was x86
only, was never used or compiled in and is out-dated.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
1. Add flash partitions.
2. Add macro DT_START_UP_ENTRY_OFFSET. The entry of the RV32M1 is
not the start of the vector table. Add the macro to inform the
entry offset.
3. Update linker file to support MCUboot
a. For normal cases (CONFIG_BOOTLOADER_MCUBOOT is cleared), the
vector table is located last 256bytes of the flash.
b. If CONFIG_BOOTLOADER_MCUBOOT is set, the vector table is located
after the image header of MCUboot.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Configure the LPSPI PCSx pins as GPIO if not dedicated to SPI CS. This
allows using them for SPI GPIO CS.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit changes zassert_mem_equal as a macro instead
of a function implementation.
In the previous implementation when an assertion fails
the location inside ztest_assert.h file was displayed.
This modification displays the location where zassert_mem_equal
was used.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
stm32wb55rg is a dual core SoC (M4/M0) with a radio/protocol stack
running on M0 core. M0 FW starts at flash address 0x80CB000.
So flash size available to zephyr is 812K instead of 1M.
Configure package size to reflect this (flash size is now 812K)
and update MPU setting to exclude M0 FW. From MPU point of view,
we set flash size to 512K since we should chose a size being a power
of 2.
If we consider there will be 2 images partitions in a FOTA scheme,
512 K is beyond image-0 and hence is sufficient to cover application
image.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
sram2a and sram2b where defined in the prospect of defining
HCI shared memory sections from device tree.
Remove them, since this is not the case anymore.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>