Native POSIX execution (native_posix)¶
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.
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.
Please check the Posix Arch Dependencies
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.
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.
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_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.