CPU specific hacks never should go to `core`. This simplifies the hack
and moves it to `cpu/native` by providing a custom `sched.h` that adds
the workarounds for glibc and adds an `#include_next "sched.h"`.
It's a bit of a pity that RIOT's sched.h has a name conflict with
POSIX's sched.h - otherwise those hacks wouldn't really be needed.
The `setcontext()` implementation of glibc does restore the signal
mask to the target thread during the switch, libucontext [does not][1]
[1]: https://man.archlinux.org/man/libucontext.3.en#CAVEATS
Instead, we just manually enable signals again just before the call
to `setcontext()`.
With this, tests like `tests/core/mutex_canel` or `tests/core/irq` now
pass on `native64` when using libucontext.
Co-authored-by: crasbe <crasbe@gmail.com>
This allows I2C emulation on native architecture in the same way than
periph_gpio_mock.
All I2C functions from this driver are set as weak to be easily
overridden in each application.
Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
Fix duplicate GPIO mode values on native platform when using Linux
kernel 5.5 or later. The kernel renamed GPIOHANDLE_REQUEST_PULL_* flags
to GPIOHANDLE_REQUEST_BIAS_PULL_* in version 5.5.
Without this fix, both GPIO_IN_PU and GPIO_OD_PU would have the same
fallback value (0xFF), causing compilation errors in switch statements.
Error: "duplicate case value"
Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
XTIMER_BACKOFF and XTIMER_ISR_BACKOFF were defined in periph_conf.h
since 2016 for the legacy xtimer module, which required high backoff
values (200) on native to prevent timer underflow issues.
However, since the migration to ztimer, all code now uses
MODULE_ZTIMER_XTIMER_COMPAT which includes ztimer/xtimer_compat.h
before periph_conf.h. This means xtimer_compat.h always defines
XTIMER_BACKOFF=1 first, and the periph_conf.h definitions are never
used.
Remove these unused definitions as they serve no purpose with the
current ztimer-based implementation.
Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
`pid_t` is provided e.g. by `<sys/types.h>`. It seems that on glibc,
`<stdlib.h>` will also provide `pid_t`. But this way it should work on
both musl and glibc.
This changes a bunch of things that allows building with the musl C lib,
provided that `libucontext-dev` and `pkg-config` are installed.
Note that installing libucontext makes absolutely zero sense on C libs
that do natively provide this deprecated System V API, such as glibc.
Hence, it no sane glibc setup is expected to ever have libucontext
installed.
A main pain point was that argv and argc are expected to be passed to
init_fini handlers, but that is actually a glibc extension. This just
parses `/proc/self/cmdline` by hand to populate argv and argc during
startup, unless running on glibc.
This commit introduces a more robust GPIO mocking mechanism by utilizing
a 2-dimensional array. Each element of the array holds a gpio_mock_t
structure describing a pin's attributes such as value, mode, flank,
interruption callback, and callback argument.
This enhancement allows for the arbitrary simulation of GPIOs across
various microcontroller architectures using the current API, while
maintaining consistency through the use of the GPIO_PIN macro.
Additionally, it should be noted that only the maximum number of ports
and maximum number of pins can be altered according to the context.
The implemented API in gpio_mock.c remains rudimentary, providing no
validation but fulfilling the required functions. However, it remains
customizable as all its functions are marked as weak.
Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
Adds a separate board for native64 instead of the `NATIVE_64BIT` workaround.
The files in `boards/native64` are more or less dummy files and just include
the `boards/native` logic (similar to `openlabs-kw41z-mini-256kib`).
The main logic for native is in `makefiles/arch/native.inc.mk`, `cpu/native`
and `boards/native`.
The remaining changes concern the build system, and change native board checks
to native CPU checks to cover both boards.
Initial version to test 64 bit compatibility.
Instead of a separate board, the inital version for Linux/x86_64 is enabled
by setting the environment variable `NATIVE_64BIT=y` and compiling as usual.
Not currently implemented:
* Architectures other than x86_64 or operating systems other than Linux
* No FreeBSD support
* No Aarch support
* Rust support for x86_64
Add support for querying the frequency supported by
`periph_timer`. This allows applications which require
this feature to run on the `native` board.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
19368: debug: add DEBUG_BREAKPOINT() macro, set breakpoint on failed assertion r=benpicco a=benpicco
19529: cpu/stm32/periph/dac: optimize setting DAC r=benpicco a=Enoch247
### Contribution description
The current implmentation right shifted the 16 bit value passed into `dac_set()` down to the 12 bits that the DAC is actually capable of. This patch drops the shift and instead writes the 16 bit value to the DAC's left aligned 12 bit wide data holding register.
### Testing procedure
do something like:
``` c
#include "perip/dac.h"
int main(void)
{
dac_set(DAC_LINE(0), 0xffff/2);
return 0;
}
```
- observe DAC's output is half of vref
### Issues/PRs references
- none known
19531: tests/unittests: allow passing `UNIT_TESTS` via env r=benpicco a=kaspar030
Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: Joshua DeWeese <jdeweese@primecontrols.com>
Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>