【引言】
移植的必要性
通过移植Contiki到IAR环境,可以很清晰的查看contiki操作系统的细节,同时IAR开发环境支持CC2530在线仿真,这对于WSN网络是十分有用的,有效地。这也是为什么喜欢2530的原因。
概述
通过移植Contiki到IAR环境,可以很清晰的查看contiki操作系统的细节,同时IAR开发环境支持CC2530在线仿真,这对于WSN网络是十分有用的,有效地。这也是为什么喜欢2530的原因。
你将学到
- 如何移植contiki到IAR环境。
- 关于移植的细节
【IAR文件路径】
- $TOOLKIT_DIR$\INC\DLIB\C\
- $PROJ_DIR$\contiki-2.7\
- $PROJ_DIR$\contiki-2.7\core\
- $PROJ_DIR$\contiki-2.7\core\cfs\
- $PROJ_DIR$\contiki-2.7\core\ctk\
- $PROJ_DIR$\contiki-2.7\core\dev\
- $PROJ_DIR$\contiki-2.7\core\lib\
- $PROJ_DIR$\contiki-2.7\core\loader\
- $PROJ_DIR$\contiki-2.7\core\net\
- $PROJ_DIR$\contiki-2.7\core\net\mac\
- $PROJ_DIR$\contiki-2.7\core\net\rime\
- $PROJ_DIR$\contiki-2.7\core\net\routing\
- $PROJ_DIR$\contiki-2.7\core\sys\
- $PROJ_DIR$\contiki-2.7\cpu\
- $PROJ_DIR$\contiki-2.7\cpu\cc253x\
- $PROJ_DIR$\contiki-2.7\cpu\cc253x\dev\
- $PROJ_DIR$\contiki-2.7\platform\
- $PROJ_DIR$\contiki-2.7\platform\cc2530dk\
- $PROJ_DIR$\contiki-2.7\platform\cc2530dk\dev\
- $PROJ_DIR$\contiki-2.7\examples\
- $PROJ_DIR$\contiki-2.7\examples\hello-world\
- UIP_CONF_IPV6=1
- VP_CONFIG_H="contiki-conf.h
(1) __asm__未定义
GCC下关键字__asm__,等同于IAR的asm。不过,从文档《IAR C/C++ Compiler Reference Guide.pdf》来看,推荐使用关键字__asm(英文原文:the asm keyword is not available when the option --strict is used. The __asm keyword is always available)。在相应文件增加如下代码,即可解决:
- #ifdef __IAR_SYSTEMS_ICC__
- #define __asm__ __asm
- #endif
- __xdata __at(0x0000) static unsigned long timer_value = 0;
- static volatile unsigned long timer_value = 0;
//static CC_AT_DATA struct timer debouncetimer;
变成
- #ifdef SDCC
- static__data structtimer debouncetimer;
- #else
- staticstruct timer debouncetimer;
- #endif
- void 2 port_0_isr(void) __interrupt(P0INT_VECTOR)
- #ifdef SDCC
- void
- port_0_isr(void) __interrupt(P0INT_VECTOR)
- #else
- #pragma vector=P0INT_VECTOR
- __near_func __interrupt void port_0_isr(void)
- #endif
为了找到cc2530的IEEE Addres,在cc253x.h(改编自iocc2530.h)中
添加了#define X_IEEE_ADDR PXREG(0x780C ) /* Start of unique IEEE Address */
2,中断服务函数 linux 下是SDCC 要改成IAR格式
- void rtimer_isr(void) __interrupt(T1_VECTOR);
- #ifdef SDCC
- void port_0_isr(void) __interrupt(P0INT_VECTOR)
- #else
- #pragma vector=P0INT_VECTOR
- __near_func __interrupt void port_0_isr(void)
- #endif
//__xdata __at(0x0000) static unsigned long timer_value = 0;
static volatile unsigned long timer_value = 0;
修改了button-sensor.h 使之符合IAR格式
修改了button-sensor.c 清除了cc2531的情况
--这样做,不合算,仅是为了更快的修改而已,以后也要加上cc2531这种情况
- Error[e46]: Undefined external"BUTTON_IRQ_CHECK::?relay"referredinbutton-sensor ( F:\Contiki OS\2530contiki2.7\Debug\Obj\
- Error[e46]: Undefined external"BUTTON_IRQ_FLAG_OFF::?relay"referredinbutton-sensor ( F:\Contiki OS\2530contiki2.7\Debug\Obj\
- Error[e27]: Entry"rime_sniffer_add::?relay"inmodule rime ( F:\Contiki OS\2530contiki2.7\Debug\Obj\rime.r51 ) redefinedinmodule
Error[e46]: Undefined external "autostart_processes" referred in contiki-main ( F:\Contiki OS\2530contiki2.7\Debug\Obj\contiki-main.r51 )
相应的文件没有添加上
Error[e46]: Undefined external "rtimer_arch_init::?relay" referred in rtimer ( F:\Contiki OS\2530contiki2.7\Debug\Obj\rtimer.r51 )
相应的文件没有添加上
Error[e46]: Undefined external "?DPL1" referred in cc2530-rf ( F:\Contiki OS\2530contiki2.7\Debug\Obj\cc2530-rf.r51 )
在8051def.h 屏蔽了部分宏(没用明确定义)
- //#if !defined(__SDCC_mcs51) && !defined(SDCC_mcs51)
- //#define __data
- //#define __xdata
- //#define __code
- //#define __bit bool
- //#define __sfr volatile unsigned char
- //#define __sbit volatile bool
- //#define __critical
- //#define __at(x)
- //#define __using(x)
- //#define __interrupt(x)
- //#define __naked
- //#endif
- /* ------------------------------------------------------------------------------------------------
- * Flash
- * ------------------------------------------------------------------------------------------------
- */
- #define X_INFOPAGE PXREG( 0x7800 ) /* Pointer to Start of Flash Information Page */
- #define X_XBANK PXREG( 0x8000 ) /* Pointer to Start of Selectable Flash Bank (XBANK) */
- //#define X_IEEE_ADDR PXREG(0x780C ) /* Start of unique IEEE Address */
- #define X_IEEE_ADDR (*(uint8_t*)(X_INFOPAGE + 0x0C)) /* Start of unique IEEE Address */
- #define OVFIM T1OVFIM
主要是第8行,根据这个地址,程序可以读取芯片的MAC地址,由此作为网络IP或者节点IP等。
系统莫名其名重启---溢出问题和看门狗设置
1,修改看门狗启动--- WDCTL|=0x08
2,溢出--适当减少XDATA;
编译器的bug---更改一次烧写 linker 换成128_banked.xcl就好了,耗了我一天啊。