c - 无线编程代码运行时丢失符号

标签 c shell air symbols contiki

我目前正致力于为天空微尘开发无线编程支持。附件是我目前拥有的文件。我基本上是在尝试使用 sky-shell-exec 示例将修改后的 test-deluge.ce 文件加载到节点上。然后我尝试使用 shell 'exec' 命令运行 test-deluge 文件,就像在 sky-shell-exec 示例中所做的那样。
最终目标是将 test-deluge.ce 和 hello-world.ce 编译文件加载到节点上,然后能够“执行”我的 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 符号或我记得的与此相关的任何 deluge 命令。

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

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

我发现 deluge 的符号在那里,但我无法继续正确制作 sky-shell-exec 文件,因为这样做会删除符号表并写入一个新的。

我觉得必须有一个简单的修复方法,因为我可以在执行上述步骤 (1-9) 后从 sky-shell-exec 示例目录运行 hello-world。

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

注意:我的 test-deluge.c 中可能存在错误,我尝试打开“hello-world.sky”而不是“hello-world.ce”...我不确定是哪个。由于上面解释的缺少符号问题,我还无法对此进行测试,但如果有人愿意阐明这个问题,我将非常感激。

谢谢

生成文件

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: $<

sky-shell-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();
}
/*---------------------------------------------------------------------------*/

test-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();
}
/*---------------------------------------------------------------------------*/

hello-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();
}
/*---------------------------------------------------------------------------*/

最佳答案

因此,在 contiki 社区的大力帮助下,我能够收集到以下解决方案:

“你好,

问题在于 Contiki 的构建系统试图“聪明行事” 并排除应用程序显然不需要的符号。所以在 这种情况下 deluge_disseminate 函数代码被优化远离 sky-shell-exec 可执行文件。显然,这与基本原则相冲突 程序员在无线情况下的直觉 编程。

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

您还可以尝试调整 GCC 链接器选项或使用自定义链接器脚本。”

对 node_id_burn 也使用相同的技巧,test-deluge.c 运行。
已对上述代码进行更正。 希望这可以帮助那些可能在 Contiki 中与 OTA 代码作斗争的其他人。

关于c - 无线编程代码运行时丢失符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23903235/

相关文章:

c - OpenGL 中的无限循环绘图和断线问题

linux - 如何不使用正则表达式和 sed 检测结尾 '/'?

flash - 在 Windows 上将 AIR 应用程序(而非安装程序)打包为单个 EXE

c - if、else 和 else if 之间有什么区别?

C : assign value to uninitialzed struct and union

linux - 传输文件的shell脚本

android - 寻找Flash Android AS3教程

apache-flex - 弹性/空气 : Sending email with embedded image. 。如何?

c++ - SDL2 - 未检测到操纵杆?

bash - 如何列出所有导出的 bash 函数?