avr-gcc 重新编译的 ledramp 示例出现分段错误
我在 Ubuntu 上安装了 simavr。我安装了以下软件包: avrdude binutils-avr gcc-avr avr-libc gdb-avr libelf-dev libglut3-dev gtkwave 构建必备。
我尝试运行 ledramp 示例(simarv 文件夹中的一个示例),工作正常。但是,当我将 board_ledramp 文件夹复制到 board_ledramp2 文件夹时,并在 board_ledramp2文件夹,我重新编译并执行它,我得到了分段错误错误。
我的命令是:
make clean
make
./obj-i686-linux-gnu/ledramp.elf
make 命令后的控制台日志是:
AVR-CC atmega48_ledramp.c
1869 32 11 1912 778 atmega48_ledramp.axf
CC ../parts/button.c
CC ledramp.c
LD obj-i686-linux-gnu/ledramp.elf
ledramp done
错误消息是:
Loaded 1850 .text
Loaded 32 .data
firmware atmega48_ledramp.axf f=8000000 mmcu=atmega48
Starting atmega48 - flashend 0fff ramend 02ff e2end 00ff
atmega48 init
Segmentation fault
我尝试使用“file”命令来比较原始的 elf 文件和 我的 elf 文件,输出是相同的:
./obj-i686-linux-gnu/ledramp.elf: ELF 32-bit LSB executable, Intel
80386, version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.15, not stripped
任何人都可以解释出了什么问题吗?
谢谢!
I have simavr installed on Ubuntu. I have the following packages installed:
avrdude binutils-avr gcc-avr avr-libc gdb-avr libelf-dev libglut3-dev gtkwave build-essential.
I tried to run the ledramp example (one example in the simarv folder), works fine. However, when I copy the board_ledramp folder to board_ledramp2 folder, and in the
board_ledramp2 folder, I recompile it and execute it, I got the segmentation fault error.
My commands was:
make clean
make
./obj-i686-linux-gnu/ledramp.elf
The console log after make command is:
AVR-CC atmega48_ledramp.c
1869 32 11 1912 778 atmega48_ledramp.axf
CC ../parts/button.c
CC ledramp.c
LD obj-i686-linux-gnu/ledramp.elf
ledramp done
The error message was:
Loaded 1850 .text
Loaded 32 .data
firmware atmega48_ledramp.axf f=8000000 mmcu=atmega48
Starting atmega48 - flashend 0fff ramend 02ff e2end 00ff
atmega48 init
Segmentation fault
I try to use "file" command to compare the original elf file and
my elf file, the output is the same:
./obj-i686-linux-gnu/ledramp.elf: ELF 32-bit LSB executable, Intel
80386, version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.15, not stripped
Anyone can explain what went wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从这一行的外观来看:
./obj-i686-linux-gnu/ledramp.elf: ELF 32-bit LSBexecutable, Intel
看来您无意中编译了在主机 PC 上运行的程序,而不是在 AVR 上运行。
From the look of this line:
./obj-i686-linux-gnu/ledramp.elf: ELF 32-bit LSB executable, Intel
It looks like you have inadvertently compiled the program to run on the host PC, rather than an AVR.
@XTL 这里有一个很好的提示,使用 gdb 运行 ledram.elf 并查看它在哪里崩溃。尽管我尝试让示例为“剪切和粘贴”调整做好准备,但我还没有尝试一切。
另一种选择是执行“make V=1”,看看编译原始 ledramp 和新的 ledramp 时有何不同...原始 ledramp 是由“顶级 makefile”构建的,它可能略有不同(例如,也许使用gcc 与 clang?)。
一个有用的一点是获取 make V=1 时得到的输出,并告诉我们您正在使用的编译器版本......
@XTL has a good tip here, run the ledram.elf using gdb and see where it crashes. As much as I tried to have the examples ready for 'cut and paste' tweaking, I haven't tried everything.
Another option is to do 'make V=1' and see what's different when compiling the original ledramp and the new one... the original one is build by the 'top level makefile' and it might be subtly different (like, perhaps using gcc vs clang?).
One useful bit would be to get the output you get when doing make V=1 and tell us what compiler version you are using...