首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将.c编译到.hex - cc1.exe: error: avr25:没有这样的文件或目录

将.c编译到.hex - cc1.exe: error: avr25:没有这样的文件或目录
EN

Stack Overflow用户
提问于 2013-02-18 12:21:56
回答 2查看 1.6K关注 0票数 1

今天,我终于通过Arduino Uno编程了attiny2313a。那是个测试眨眼程序。上传后,我看到LED闪烁了8秒,而不是1秒,所以我决定改变Makefile和main.c中的时钟设置,然后再烧芯片。因此,我在Makefile和main.c中只将8000000更改为1000000,并在cmd (windows )中运行make flash。以下是产出:

代码语言:javascript
运行
复制
avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny2313 -F -c main.c -o main.o
cc1.exe: error: avr25: No such file or directory
make: *** [main.o] Error 1

,为什么我会收到这个错误?为什么我只能编译和刻录程序一次?我没有删除,也没有添加任何新的东西。事实上,除了那些时钟设置,我什么也没碰。但是,即使我返回到原来的设置(8000000),我仍然得到同样的错误。

我的制作文件

代码语言:javascript
运行
复制
DEVICE     = attiny2313 -F
CLOCK      = 1000000
PROGRAMMER = -c arduino -P COM5 -b 19200 
OBJECTS    = main.o
FUSES      = -U lfuse:w:0x5e:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m


######################################################################
######################################################################

# Tune the lines below only if you know what you are doing:

AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)

# symbolic targets:
all:    main.hex

.c.o:
    $(COMPILE) -c $< -o $@

.S.o:
    $(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.

.c.s:
    $(COMPILE) -S $< -o $@

flash:  all
    $(AVRDUDE) -U flash:w:main.hex:i

fuse:
    $(AVRDUDE) $(FUSES)

install: flash fuse

# if you use a bootloader, change the command below appropriately:
load: all
    bootloadHID main.hex

clean:
    rm -f main.hex main.elf $(OBJECTS)

# file targets:
main.elf: $(OBJECTS)
    $(COMPILE) -o main.elf $(OBJECTS)

main.hex: main.elf
    rm -f main.hex
    avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.

# Targets for code debugging and analysis:
disasm: main.elf
    avr-objdump -d main.elf

cpp:
    $(COMPILE) -E main.c

我的主营

代码语言:javascript
运行
复制
#define F_CPU 1000000  // CPU frequency for proper time calculation in delay function

#include <avr/io.h>
#include <util/delay.h>

int main (void){
    DDRD |= (1 << PD6);  // make PD6 an output

    for(;;){
        PORTD ^= (1 << PD6);  // toggle PD6
        _delay_ms(1000);  // delay for a second
    }

    return 0;  // the program executed successfully
}
EN

回答 2

Stack Overflow用户

发布于 2013-02-19 09:30:09

原来原因是在Makefile中添加了"-F“键,以使avrdude认为attiny2313a实际上是一个attiny2313 (覆盖签名检查)。这是奇怪的,但"-F“键必须删除后,第一次编程的芯片。我想,这也适用于其他更新的修改AVR芯片,是相同的基础(ar父?)修改,但在其名称中添加了各种后缀(如“attiny2313a”或“atmega168p”)

所以。当第一次对微控制器进行编程,而avrdude不识别该芯片时,应该在芯片的名称之后添加-F键:

代码语言:javascript
运行
复制
DEVICE = attiny2313 -F

但是,芯片第一次编程后,-F 密钥必须删除,否则就不可能再对芯片进行编程了。

票数 1
EN

Stack Overflow用户

发布于 2013-02-19 13:13:37

为了芯片的利益,请不要在avrdude上使用-F。

您的tinyAVR编程出现问题的原因是您给avrdude输入了错误的部件号。对ATtiny2313进行编程的正确参数是-pt2313或只使用part t2313。使用-F可以继续砖块你的芯片,特别是因为你是给它保险丝,在某些情况下,可能会恢复使用高压程序员,取决于什么保险丝设置抛向它。

如需有关avrdude的更多信息,请阅读其手册页。

代码语言:javascript
运行
复制
       -p partno
               This is the only option that is mandatory for every invocation of avrdude.  It specifies the type of the MCU connected to the program‐
               mer.  These are read from the config file.  If avrdude does not know about a part that you have, simply add it to the config file (be
               sure and submit a patch back to the author so that it can be incorporated for the next version).  See the sample config file for the
               format.  Currently, the following MCU types are understood:

               Option tag   Official part name
               ...snip...
               t2313        ATtiny2313
               ...snip...

ATtiny2313和ATtiny2313A的设备签名是相同的,但是avrdude声称不和2313A通话。如果您不需要fuse编程,就禁用fuse编程,然后在没有-F选项的情况下测试它们。干杯。

PS。gcc对你的指责是因为

代码语言:javascript
运行
复制
   -Fdir
       Add the framework directory dir to the head of the list of directories to be searched for header files.  These directories are interleaved with
       those specified by -I options and are scanned in a left-to-right order.

你给它传递了一个论点,它不知道该如何处理它。若要修复这些内容,请在生成文件上添加

代码语言:javascript
运行
复制
PROGDEV=t2313

并将avrdude调用更改为使用PROGDEV而不是DEVICE

同样,正如在先前的答复中所述

代码语言:javascript
运行
复制
PORTD ^= (1 << PD6);

可代之以

代码语言:javascript
运行
复制
PIND = (1 << PD6);

后者仅编译为一条指令,而您拥有的只有两条指令。这样可以节省芯片上的代码空间,并使代码运行得更快。有关详细信息,请参阅Atmel的数据表。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14936205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档