Native POSIX execution (native_posix)
Overview
Warning
native_posix
is deprecated in favour of native_sim, and will be removed
in the 4.2 release.
Note
For native_posix users, if needed, native_sim includes a compatibility mode
CONFIG_NATIVE_SIM_NATIVE_POSIX_COMPAT
,
which will set its configuration to mimic a native_posix-like configuration.
native_posix
is the predecessor of native_sim.
Just like with native_sim you can build your Zephyr application
with the Zephyr kernel, creating a normal Linux executable with your host tooling,
and can debug and instrument it like any other Linux program.
But unlike with native_sim you are limited to only using the host C library.
native_sim supports all native_posix
use cases.
This board does not intend to simulate any particular HW, but it provides a few peripherals such as an Ethernet driver, display, UART, etc., to enable developing and testing application code which would require them. This board supports the same peripherals and backends as native_sim.
Host system dependencies
Please check the Posix Arch Dependencies
Important limitations
This board inherits the limitations of its architecture
Moreover, being limited to build only with the host C library, it is not possible to build applications with the Zephyr POSIX OS abstraction, as there would be symbol collisions between the host OS and this abstraction layer.
How to use it
To build, simply specify the native_posix
board as target:
west build -b native_posix samples/hello_world
Now you have a Linux executable, ./build/zephyr/zephyr.exe
, you can use just like any
other Linux program.
You can run, debug, build it with sanitizers or with coverage just like with native_sim. Please check native_sim’s how to for more info.
32 and 64bit versions
Just like native_sim, native_posix
comes with two targets:
A 32 bit and 64 bit version.
The 32 bit version, native_posix
, is the default target, which will compile
your code for the ILP32 ABI (i386 in a x86 or x86_64 system) where pointers
and longs are 32 bits.
This mimics the ABI of most embedded systems Zephyr targets,
and is therefore normally best to test and debug your code, as some bugs are
dependent on the size of pointers and longs.
This target requires either a 64 bit system with multilib support installed or
one with a 32bit userspace.
The 64 bit version, native_posix/native/64
, compiles your code targeting the
LP64 ABI (x86-64 in x86 systems), where pointers and longs are 64 bits.
You can use this target if you cannot compile or run 32 bit binaries.