在空中编程代码中运行时丢失符号

时间:2014-05-28 05:11:14

标签: c shell air symbols contiki

我目前正致力于开发天空节目的无线节目支持。附上我到目前为止的文件。我基本上尝试使用sky-shell-exec示例将我修改过的test-deluge.ce文件加载到mote上。然后我尝试使用shell'exec'命令运行test-deluge文件,如在sky-shell-exec示例中所做的那样。
最终目标是将test-deluge.ce和hello-world.ce编译的文件加载到mote上,然后能够'exec'我的test-deluge.ce文件,然后找到存储的hello-world.ce文件并对其进行deluge_disseminate。

我正在运行的命令的进展如下:

1) sudo make TARGET=sky clean CLEAN=symbols.?
2) sudo make sky-shell-exec.sky TARGET=sky
3) sudo make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky
4) sudo make sky-shell-exec.upload CORE=sky-shell-exec.sky
5) sudo make compile-test-deluge-executable
6) sudo make upload-test-deluge-executable
7) sudo make login 
8) ls (to see that the file made it)
9) exec test-deluge.ce

此时我收到'未找到符号:deluge_disseminate'错误

我认为错误出现在make的'CORE = ...'部分(在上面的步骤2中)。我已经检查了上面步骤2中填写的symbols.c文件,并且确实没有符号用于deluge_disseminate或者我记得的任何泛滥命令。

对于实验,我尝试了以下方法:

sudo make test-deluge.sky TARGET=sky
sudo make test-deluge.sky CORE=test-deluge.sky TARGET=sky

我发现了大脑的符号,但我无法正确制作sky-shell-exec文件,因为这样做会删除符号表并写一个新符号。

我觉得必须有一个简单的解决方法,因为我可以按照上面的步骤(1-9)从sky-shell-exec示例目录运行hello-world。

有没有人知道如何解决这个问题?

注意:我的test-deluge.c中可能存在一个错误,我试图打开'hello-world.sky'而不是'hello-world.ce'...我真的不确定哪一个。由于上面解释了缺失的符号问题,我还没有能够测试这个,但如果有人愿意阐明这个问题,我会非常感激。

由于

MAKEFILE

CONTIKI = ../..
ifndef TARGET
TARGET=sky
endif

APPS = deluge serial-shell
all: blink sky-collect #rt-leds test-button test-cfs tcprudolph0
#all: $(CONTIKI_PROJECT)

%.tgz: %.ihex
    mkdir $(basename $<) ; \
    mv $< $(basename $<) ; \
    echo $(basename $<)/$(basename $<).ihex 600 > $(basename $<)/runfile ; \
    tar czf $@ $(basename $<)

%.class: %.java
    javac $(basename $<).java

viewrssi: ViewRSSI.class
    make login | java ViewRSSI

include $(CONTIKI)/Makefile.include

%.shell-upload: %.ce
    (echo; sleep 4; echo "~K"; sleep 4; \
     echo "dec64 | write $*.ce | null"; sleep 4; \
     ../../tools/base64-encode < $<; sleep 4; \
     echo ""; echo "~K"; echo "read $*.ce | size"; sleep 4) | make login

.PHONY: compile-test-deluge-executable upload-test-deluge-executable compile-hello-world-executable upload-test-deluge-executable 

compile-hello-world-executable: hello-world.ce
    echo Compiled Contiki executable: $<

upload-hello-world-executable: hello-world.shell-upload
    echo Uploaded Contiki executable: $<

compile-test-deluge-executable: test-deluge.ce
    echo Compiled Contiki executable: $<

upload-test-deluge-executable: test-deluge.shell-upload
    echo Uploaded Contiki executable: $<

天空壳exec.c

#include "contiki.h"
#include "shell.h"
#include "serial-shell.h"
#include "deluge.h"

#include "dev/watchdog.h"

#include "net/rime.h"
#include "dev/cc2420.h"
#include "dev/leds.h"
#include "dev/light.h"
#include "dev/sht11.h"
#include "dev/battery-sensor.h"

#include "lib/checkpoint.h"

#include "net/rime/timesynch.h"

#include <stdio.h>
#include <string.h>

int (*keep_1)(void) = deluge_disseminate;
int (*keep_2)(void) = node_id_burn;

/*---------------------------------------------------------------------------*/
PROCESS(sky_shell_process, "Sky Contiki shell");
AUTOSTART_PROCESSES(&sky_shell_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sky_shell_process, ev, data)
{
 PROCESS_BEGIN();

 serial_shell_init();
 /*shell_blink_init();*/
 shell_file_init();
 shell_coffee_init();
 /*shell_ps_init();*/
 /*shell_reboot_init();*/
 /*shell_rime_init();*/
 /*shell_rime_netcmd_init();*/
 /*shell_rime_ping_init();*/
 /*shell_rime_debug_init();*/
 /*shell_rime_sniff_init();*/
 /*shell_sky_init();*/
 shell_text_init();
 /*shell_time_init();*/
 /*  shell_checkpoint_init();*/
 shell_exec_init();
 shell_base64_init();

 PROCESS_END();
}
/*---------------------------------------------------------------------------*/

测试deluge.c

#include "contiki.h"
#include "cfs/cfs.h"
#include "deluge.h"
#include "sys/node-id.h"
#include "loader/elfloader.h"
#include <stdio.h>
#include <string.h>

#ifndef SINK_ID
#define SINK_ID 1
#endif

#ifndef FILE_SIZE
#define FILE_SIZE 1000
#endif

PROCESS(deluge_test_process, "Deluge test process");
AUTOSTART_PROCESSES(&deluge_test_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(deluge_test_process, ev, data)
{
 static struct etimer et;

 node_id_burn(2);
 PROCESS_BEGIN();

 if(node_id == SINK_ID) {
   printf("Sink node: trying to transmit file.\n");
 } else {
   printf("Non-sink node: trying to recieve file.\n");
 }

 cfs_remove("hello-world.sky");
 int fd = cfs_open("hello-world.sky", CFS_WRITE | CFS_READ);
 if(fd < 0) {
   process_exit(NULL);
 }

#if 0
 if(cfs_seek(fd, FILE_SIZE, CFS_SEEK_SET) != FILE_SIZE) {
   printf("failed to seek to the end\n");
 }
#endif

 deluge_disseminate("hello-world.sky", node_id == SINK_ID);
 cfs_close(fd);

 etimer_set(&et, CLOCK_SECOND * 5);
 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
 if(node_id != SINK_ID) {
   fd = cfs_open("hello-world.sky", CFS_READ);
   if(fd < 0) {
     printf("failed to open the test file\n");
   } else {
     printf("Start dynamic loading\n");
     int ret = elfloader_load(fd);
     printf("%d\n", ret); 

     cfs_close(fd);

     int i;
     switch(ret) {
case ELFLOADER_OK:
 for(i=0; elfloader_autostart_processes[i] != NULL; i++) {
   printf("exec: starting process %s. \n", 
  elfloader_autostart_processes[i]->name);
 }
 autostart_start(elfloader_autostart_processes);
         break;

default:
 printf("Unkown return code from ELF loader (internal bug)\n");
          break;
     } 
   }
 }
 etimer_reset(&et);

 PROCESS_END();
}
/*---------------------------------------------------------------------------*/

你好-world.c

#include "contiki.h"

#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
 PROCESS_BEGIN();

 printf("Hello, world\n");

 PROCESS_END();
}
/*---------------------------------------------------------------------------*/

1 个答案:

答案 0 :(得分:0)

所以在contiki社区的帮助下,我能够收集以下解决方案:

“嗨,

问题是Contiki的构建系统试图“行动聪明” 并且排除了显然不需要的符号。所以 在这种情况下,deluge_disseminate函数代码远离优化 sky-shell-exec可执行文件。显然,这与基本冲突 程序员在空中情况下的直觉 编程。

要解决此问题,请在中添加对deluge_disseminate的引用 sky-shell-exec代码。例如,添加此行(在全局范围内): int(* keep)(void)= deluge_disseminate;

您还可以尝试调整GCC链接器选项或使用自定义链接描述文件。“

同样使用node_id_burn的技巧,test-deluge.c运行 已对上述代码进行了更正。 希望这可以帮助那些可能在Contiki中与OTA代码挣扎的人。