This step is to use Blink application invoking Timer, which is the first real step to debug timer, after it is developed.

At Blink directory in cygwin, input make toni.

1. First compiling error:

In component `PlatformLedsC’:
../../tos/platforms/toni/PlatformLedsC.nc:38: component HplNios2GeneralIOC not found

It reminds me that I forgot to include timer and pins in .platform. So .platform should be like the followings:

push( @includes, qw(

  %T/platforms/toni
  %T/chips/nios2
  %T/lib/timer
  %T/lib/serial
  %T/chips/nios2/pins
  %T/chips/nios2/timer

) );

Now more errors come;)

2. Second compiling error:

In component `HplNios2GeneralIOP’:
/opt/tinyos-2.x/tos/chips/nios2/pins/HplNios2GeneralIOC.nc:69: constant out of range for argument type

The error reason is

in HplNios2GeneralIOC: new HplNios2GeneralIOP(LED_RED_BASE, 0) as LR0,  LED_RED_BASE is 32 bit;

but in HplNios2GeneralIOP

generic module HplNios2GeneralIOP(
                uint8_t base,
                uint8_t pin
                )

change it to

generic module HplNios2GeneralIOP(
                uint32_t base,
                uint32_t pin
                )

Solved!

3. Third compiling error:

In component `PlatformLedsC’:
../../tos/platforms/toni/PlatformLedsC.nc:45: cannot find `LedsInit’

For PlatformP hasn’t defined LedsInit, so PlatformLedsC.nc cannot find ‘LedsInit’, define it as follows:

module PlatformP {
  provides interface Init;
  uses interface Init as LedsInit;
}

implementation {
  command error_t Init.init() {
      call LedsInit.init();
    return SUCCESS;
  }
  default command error_t LedsInit.init() { return SUCCESS; }
}

4. Fourth compiling error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:32,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In component `Nios2AlarmAsyncP’:
/opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncP.nc: In function `Init.init’:
/opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncP.nc:58: implicit declaration of function `alt_ticks_per_second’

Search path input wrongly,be careful!

PFLAGS += -I/cgydrive/C/Altera/72/nios2eds/components/altera_hal/HAL/inc  —->>

PFLAGS += -I/cygdrive/C/Altera/72/nios2eds/components/altera_hal/HAL/inc

5. Fifth compiling error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:43,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In interface `McuPowerOverride’:
/opt/tinyos-2.x/tos/interfaces/McuPowerOverride.nc:54: only commands and events can be defined in interfaces

/opt/tinyos-2.x/tos/interfaces/McuPowerOverride.nc:54: warning: return-type defaults to `int’
/opt/tinyos-2.x/tos/interfaces/McuPowerOverride.nc:54: syntax error before `lowestState’

McuPowerOverride.nc:54 is async command mcu_power_t lowestState();

mcu_power_t hasn’t been defined, it seems each new platform should define it in platformhardware.h

We define it like this:

typedef uint8_t mcu_power_t @combine("mcombine");

mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) {
  return (m1 < m2) ? m1: m2;
}

Solved!

6. Sixth Compiling Error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:44,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In interface `HplNios2TimerAsync’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2TimerAsync.nc:21: only commands and events can be defined in interfaces
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2TimerAsync.nc:21: warning: return-type defaults to `int’
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2TimerAsync.nc:21: syntax error before `getAssr’

This HplNios2TimerAsync was introduced from another platform, but it is no need for Toni platform, so delete all code related with this file.

Solved!

7. Seventh Compiling Error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In component `HplNios2Timer0AsyncP’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc: In function `Timer.get’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:55: implicit declaration of function `gettimeofday’

Add #include "sys/time.h" into Nios2timer.h,

solved!

8. Eighth Compiling Error:

In file included from /usr/include/time.h:130,
                 from /usr/include/sys/select.h:24,
                 from /usr/include/sys/time.h:27,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2Timer.h:40,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:20,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
/usr/include/signal.h:21: syntax error before `signal’

After searching about 1 hour, the error is the conflict of path to include header files.

Add PFLAGS += -I/cygdrive/C/Altera/72/nios2eds/bin/nios2-gnutools/src/newlib/newlib/libc/include/sys into toni.target.

Solved!

9. Nineth Compiling Error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In component `HplNios2Timer0AsyncP’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:83: conflicting types for `Timer.getScale’

Hmm, this is the work of tomorrow, today free la~

Continue…

Change return type from uint32_t into uint8_t, solved!

Note: This getScale should be redefined again, considering its real function.

10. Tenth Compiling Error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In component `HplNios2Timer0AsyncP’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc: In function `Compare.get’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:143: `i_ticks’ undeclared (first use in this function)
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:143: (Each undeclared identifier is reported only once
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:143: for each function it appears in.)

Define i_ticks, Solved!

11. Eleventh Compiling Error:

In file included from /opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:54,
                 from /opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:33,
                 from ../../tos/platforms/toni/AlarmCounterMilliP.nc:32,
                 from ../../tos/platforms/toni/HilTimerMilliC.nc:43,
                 from /opt/tinyos-2.x/tos/system/TimerMilliP.nc:41,
                 from /opt/tinyos-2.x/tos/system/TimerMilliC.nc:40,
                 from BlinkAppC.nc:46:
In component `HplNios2Timer0AsyncP’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc: In function `FIRED_HANDLER’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncP.nc:171: syntax error before `)’

Format error, correct it, solved!

12. Twelfth Compiling Error:

In component `HplNios2Timer0AsyncC’:
/opt/tinyos-2.x/tos/chips/nios2/timer/HplNios2Timer0AsyncC.nc:57: cannot find `McuPowerOverride’

In McuSleep component, define McuPowerOverride, cauz for now we haven’t explored power management of NiosII, so just define it with dummy one. Anyway, Solved!

13. Thirteenth Compiling Error:

In component `Nios2AlarmAsyncC’:
/opt/tinyos-2.x/tos/chips/nios2/timer/Nios2AlarmAsyncC.nc:39: no match

In Nios2AlarmAsyncP, I defined interface HplNios2Timer<uint8_t> as Timer;

but in HplNios2Timer0AsyncC, interface HplNios2Timer<uint32_t>   as Timer;

So type mismatch, change it, solved!

 

All solved! Compiling it in NiosII command shell with nesC Compiling Env. Though at link stage it has errors, the reason is that nesC could not figure NiosII HAL API out, cauz it is now genrating for PC, ignore them, drag app.c into NiosII IDE, compile it successfully, run Quartus II Programmer, run generated image!

Good thing is it really run, bad thing is only red lights are lighted up, without blin:'(…

Next Step, Debugging the application…

Advertisements