1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native
2014-10-30 16:37:10 +01:00
..
drivers native: relocate drivers/rtc implementation 2014-10-18 11:00:09 +02:00
include native: add and use callback type 2014-10-30 12:11:22 +01:00
net native: add and use callback type 2014-10-30 12:11:22 +01:00
periph native: relocate periph/cpuid implementation 2014-10-18 10:48:03 +02:00
atomic_cpu.c doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
crash.c doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
hwtimer_cpu.c doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
irq_cpu.c native: remove obsolete line 2014-10-30 16:37:10 +01:00
lpm_cpu.c doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
Makefile native: relocate drivers/rtc implementation 2014-10-18 11:00:09 +02:00
Makefile.include native: add drivers substructure 2014-10-18 10:58:51 +02:00
native_cpu.c core: introduce thread_yield_higher(), yield less 2014-10-24 00:09:56 +02:00
README.md native: update README 2014-05-13 11:25:34 +02:00
startup.c doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
syscalls.c native: add two more syscall declarations 2014-10-01 21:56:43 +02:00
tapsetup-freebsd.sh native/freebsd: fix tapsetup permission 2014-10-08 16:11:04 +02:00
tapsetup-osx.sh native cc1100x_ng network 2013-08-15 14:05:26 +02:00
tapsetup.sh allow for custom tap names 2013-11-08 13:59:26 +01:00
tramp.S native: add support for Linux on ARM 2014-09-04 16:39:33 +02:00

Valgrind Support

Rebuild your application using the all-valgrind target like this:

make -B clean all-valgrind

That way native will tell Valgrind about RIOT's stacks and prevent Valgrind from reporting lots of false positives. The debug information flag -g is not strictly necessary, but passing it allows Valgrind to tell you precisely which code triggered the error.

To run your application run:

make term-valgrind

All this does is run your application under Valgrind. Now Valgrind will print some information whenever it detects an invalid memory access.

In order to debug the program when this occurs you can pass the --db-attach parameter to Valgrind. E.g:

valgrind --db-attach=yes ./bin/native/default.elf tap0

Now, you will be asked whether you would like to attach the running process to gdb whenever a problem occurs.

In order for this to work under Linux 3.4 or newer, you might need to disable the ptrace access restrictions: As root call:

echo 0 > /proc/sys/kernel/yama/ptrace_scope

Network Support

If you compile RIOT for the native cpu and include the native_net module, you need to specify a network interface like this:

make term PORT=tap0

Setting Up A Tap Network

There is a shellscript in RIOT/cpu/native called tapsetup.sh which you can use to create a network of tap interfaces.

Usage: To create a bridge and two (or count at your option) tap interfaces:

./tapsetup.sh create [count]

To delete the bridge and all tap interfaces:

./tapsetup.sh delete

OSX Tap Networking

For tun/tap networking in OSX you will need: http://tuntaposx.sourceforge.net/

For OSX there is a separate script called tapsetup-osx.sh. Run it, (it instructs you to start the RIOT instances). In contrast to Linux you will need to run tapsetup-osx.sh delete after killing your instances and rerun tapsetup-osx.sh create before restarting.

FreeBSD Tap Networking

For FreeBSD there is a separate script called tapsetup-freebsd.sh.

Daemonization

You can daemonize a riot process. This is useful for larger networks. Valgrind will fork along with the riot process and dump its output in the terminal.

Usage:

./bin/native/default.elf -d

Use UART redirection if you want to use a shell or get stderr/stdout output with/from a daemonized process.

UART Redirection

You can redirect the processes' stdin/stdout/stderr by specifying one or more options from below.

UNIX socket

To redirect stdio to a UNIX socket run:

./bin/native/default.elf -u -d
RIOT pid: 18663

Attach this UNIX socket:

nc -U /tmp/riot.tty.18663

TCP socket

To redirect stdio to a TCP socket:

./bin/native/default.elf -t 4711 -d
RIOT pid: 18663

Attach this TCP socket:

nc localhost 4711

Stop the process:

kill 18663

File for stderr

To redirect stderr to a file:

./bin/native/default.elf -d -e
RIOT pid: 18663

Read from it:

tail -f /tmp/riot.stderr.18663

File for stdout

To redirect stdout to a file:

./bin/native/default.elf -d -o
RIOT pid: 18663

Read from it:

tail -f /tmp/riot.stdout.18663

Notes

The stdout redirection only writes to file while no socket connection is established.

Socket redirection is only available when the UART module has been compiled in.

Compile Time Options

Compile with

CFLAGS=-DNATIVE_AUTO_EXIT make

to exit the riot core after the last thread has exited.