1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native
Cenk Gündoğan 044fac8d17 native: add break to satisfy compiler gcc-7.1.1
Building any application with gcc 7.1.1 fails with the following error:

```
~/RIOT % make -C examples/hello-world
make: Entering directory 'RIOT/examples/hello-world'
Building application "hello-world" for "native" with MCU "native".

"make" -C RIOT/boards/native
"make" -C RIOT/boards/native/drivers
"make" -C RIOT/core
"make" -C RIOT/cpu/native
RIOT/cpu/native/startup.c: In function ‘startup’:
RIOT/cpu/native/startup.c:292:17: error: this statement may fall through [-Werror=implicit-fallthrough=]
       usage_exit(EXIT_SUCCESS);
       ^~~~~~~~~~~~~~~~~~~~~~~~
RIOT/cpu/native/startup.c:293:13: note: here
   case 'i':
   ^~~~
cc1: all warnings being treated as errors
make[2]: *** [RIOT/Makefile.base:81: RIOT/examples/hello-world/bin/native/cpu/startup.o] Error 1
make[1]: *** [RIOT/Makefile.base:20: ALL--RIOT/cpu/native] Error 2
make: *** [RIOT/examples/hello-world/../../Makefile.include:297: all] Error 2
make: Leaving directory 'RIOT/examples/hello-world'
```

```
% gcc --version
gcc (GCC) 7.1.1 20170528
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

fixed by adding a `break` statement after `usage_exit()`
2017-05-30 13:56:17 +02:00
..
include cleanup: apply headerguard script output 2017-05-24 17:54:02 +02:00
mtd doc: fix grouping of mtd_native 2017-03-31 13:38:01 +02:00
netdev_tap net/gnrc/eth: enable filtering of L2 addresses 2017-05-18 15:24:25 +02:00
osx-libc-extra cleanup: apply headerguard script output 2017-05-24 17:54:02 +02:00
periph periph/hwrng: use void* buf for hwrng_read() 2017-02-07 13:20:39 +01:00
vfs cpu: native: add vfs wrappers 2017-03-07 17:59:59 +01:00
async_read.c cpu: native: make syscalls vfs ready (introduce real_fcntl) 2017-03-22 20:18:57 +01:00
irq_cpu.c native: support add periph/pm support 2017-01-12 11:24:15 +01:00
Makefile Merge pull request #5624 from OTAkeys/pr/mtdi_flash 2017-03-17 17:18:13 +01:00
Makefile.features native: support add periph/pm support 2017-01-12 11:24:15 +01:00
Makefile.include cbor: fix redefined macro error on macOS 2016-11-10 16:16:06 +01:00
native_cpu.c netdev2: rename to netdev and remove gnrc_netdev 2017-03-15 09:31:20 +01:00
panic.c documentation: update my name (Ortmann -> Knüpfer) 2015-09-27 18:58:30 +02:00
README.md netdev2: rename to netdev and remove gnrc_netdev 2017-03-15 09:31:20 +01:00
startup.c native: add break to satisfy compiler gcc-7.1.1 2017-05-30 13:56:17 +02:00
syscalls.c cpu: native: make syscalls vfs ready (introduce real_fcntl) 2017-03-22 20:18:57 +01:00
tramp.S native: add syscall-leave trampoline 2016-10-15 07:50:44 +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 use the targets debug-valgrind-server and debug-valgrind. Therefore, you need to open two terminals and run:

make debug-valgrind-server

in the first one and run:

make debug-valgrind

in the seconde one. This starts per default gdb attached to valgrinds gdb server (vgdb).

Network Support

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

make term PORT=tap0

Please note: in case you're using RIOT's default network stack, the GNRC stack, you may also use gnrc_netdev_default module and also add auto_init_gnrc_netif in order to automatically initialize the interface.

Setting Up A Virtual Network

There is a shellscript in RIOT/dist/tools/tapsetup called tapsetup 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:

../../dist/tools/tapsetup/tapsetup [-c [<count>]]

On OSX you need to start the RIOT instance at some point during the script's execution. The script will instruct you when to do that.

To delete the bridge and all tap interfaces:

../../dist/tools/tapsetup/tapsetup -d

For OSX you have to run this after killing your RIOT instance and rerun ../../dist/tools/tapsetup [-c [<count>]] before restarting.

Please note: If you want to communicate between RIOT and your host operating system, you must not use the tapsetup script, but create and activate the tap interface manually. On Linux you can do so, by calling

sudo ip tuntap add tap0 mode tap user ${USER}
sudo ip link set tap0 up

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

Compile Time Options

Compile with

CFLAGS=-DNATIVE_AUTO_EXIT make

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