In file included from /cygdrive/C/Altera/72/ip/sopc_builder_ip/altera_avalon_pio/inc/altera_avalon_pio_regs.h:34, from ../../tos/platforms/toni/hardware.h:6, from /opt/tinyos-2.x/tos/system/SchedulerBasicP.nc:41:/cygdrive/C/Altera/72/nios2eds/components/altera_nios2/HAL/inc/io.h:45:2: #error SYSTEM_BUS_WIDTH undefined

After searching, I find that the SYSTEM_BUS_WIDTH is normally defined at generated_all.mk in corresponding system_lib directory, in which:

These variables are usually set inside a Makefile and are then appended to the command line when the compiler is invoked. If they are not specified in the Makefile, then they will be read from the environment, if present. Tools like autoconf‘s ./configure script will usually pick them up from the environment and write them into the generated Makefiles.

CFLAGS allows to add switches for the C compiler, while CXXFLAGS is meant to be used when invoking a C++ compiler. Similarly, a variable CPPFLAGS exists with switches to be passed to the C preprocessor.

These variables are most commonly used to specify optimization or debugging switches to a compiler, as for example -g, -O2 or (GCC-specific) -march=athlon.

Then I added CPPFLAGS += -DSYSTEM_BUS_WIDTH=32 to toni.target, still could not work, so I just add DSYSTEM_BUS_WIDTH definition to platform.h in platform/toni/ directory. Then solved!

3. 3rd compiling error:

In file included from /opt/tinyos-2.x/tos/system/SchedulerBasicP.nc:41, from /opt/tinyos-2.x/tos/system/TinySchedulerC.nc:40:../../tos/platforms/toni/hardware.h:21: syntax error before `1′

The line is TOSH_ASSIGN_PIN(LED_RED, 1);

Forgot to include .h file, which defines TOSH_ASSIGN_PIN.

After trace all Led related source code, it turns out that there’s no need to define TOSH_ASSIGN_PIN(LED_RED, 1); so I deleted them all. Solved!