【问题标题】:C executable to hexC 可执行到十六进制
【发布时间】:2016-03-06 10:48:08
【问题描述】:

我使用 CLion 作为 IDE。构建后的输出是一个可执行文件example。我想要实现的是从中制作.hex 文件并通过avrdude 将其上传到我的AVR。我阅读并尝试了一些possible solutions here

xxd -p example | tr -d '\n' > example.hex

avrdude -u -c usbasp-clone -p atmega8 -P /dev/bus/usb/001/006 -U flash:w:example.hex

avrdude 输出

avrdude: input file example.hex auto detected as invalid format
avrdude: invalid input file format: -1
avrdude: read from file 'example.hex' failed

这里有什么想法吗?

【问题讨论】:

    标签: cmake hex avr clion avrdude


    【解决方案1】:

    从可执行文件中提取节并将其转换为另一种格式的工具是objcopy

    avr-objcopy -j .text -j .data -O ihex example example.hex
    

    或者,如果您的 avrdude 是使用 ELF 支持构建的,那么您可以直接使用可执行文件。

    avrdude -c usbasp-clone -p atmega8 -U flash:w:example
    

    【讨论】:

    • 太棒了!最后一个例子就是那个。
    猜你喜欢
    • 2011-12-09
    • 2011-06-01
    • 2014-04-18
    • 2014-11-30
    • 1970-01-01
    • 2018-07-26
    • 2014-08-24
    • 2011-02-04
    • 2015-11-10
    相关资源
    最近更新 更多