首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"avr-gcc:命令未找到“在Ubuntu上

"avr-gcc:命令未找到“在Ubuntu上
EN

Stack Overflow用户
提问于 2015-12-09 16:47:34
回答 2查看 10.3K关注 0票数 2

我想在家里做一个Arduino项目。但是,当我试图运行示例代码时,会得到以下错误:

avr-gcc:找不到指挥部

这个程序在大学计算机上运行得很好。然而,在我的Ubuntu虚拟机上根本没有工作。我对此完全陌生。所以,我真的不知道怎么回事。

EN

回答 2

Stack Overflow用户

发布于 2018-10-01 19:04:11

我试过的是:

代码语言:javascript
复制
yum install *avr*gcc*

给我找了一些更长的包裹,上面有通配符。我发布这个答案是因为这适用于更多的案例和其他dists。

票数 1
EN

Stack Overflow用户

发布于 2020-11-30 20:49:30

您可能需要flex、byacc、bison、gcc和libusb-dev:

代码语言:javascript
复制
sudo apt-get install flex byacc bison gcc libusb-dev

以及libusb点信息中的libusb,然后在终端中使用这些命令从其根目录安装它:

代码语言:javascript
复制
./configure
make
sudo make install

代码语言:javascript
复制
sudo apt-get install libusb-1.0-0

然后下载binutils:http://ftp.gnu.org/gnu/binutils/配置它:

代码语言:javascript
复制
./configure --target=avr --program-prefix="avr-"

那就制造和安装它。然后,从:http://gcc.gnu.org/mirrors.html下载GCC的最新版本。在我试图安装它之后,它出现了错误,我说我需要gmp、mpfr和mpc,所以我从以下网站下载了它们:

https://gmplib.org/

https://www.mpfr.org/mpfr-current/

https://ftp.gnu.org/gnu/mpc/

并使用

代码语言:javascript
复制
./configure
make
sudo make install

在Ubuntu终点站。

幸运的是,在此之后,gcc成功地安装了。然后您需要从:http://download.savannah.gnu.org/releases/avr-libc/安装avr-libc。

以及访问物理板的avrdude:http://download.savannah.gnu.org/releases/avrdude/

使用

代码语言:javascript
复制
./configure --enable-linuxgpio 

在avrdude上启用通用输入/输出(并在avrdude.conf中设置引脚复位、sck、mosi和miso )。阿夫都德检查(最后)是否有libelf,libftdi1,libftdi和libhid

https://web.archive.org/web/20160430090619/http://www.mr511.de/software/libelf-0.8.3.tar.gz

代码语言:javascript
复制
sudo apt-get update -y
sudo apt-get install -y libelf-dev

ftdi是可选的(对于ftdi芯片和usb到串行的ft芯片),您可以从intra2net获得它,或者使用以下命令:

代码语言:javascript
复制
sudo apt-get update -y
sudo apt-get install -y libftdi1-dev
sudo apt-get install -y libftdi-dev

最后,libhid (人类接口设备):

代码语言:javascript
复制
sudo apt-get install libhidapi-dev

但由于某种奇怪的原因它甚至没有发现。

你可能不需要做所有这些步骤。您可以尝试只为最低要求安装avr,但为了安全起见,建议通过其他步骤。

在编译AVR程序时(如果您使用IDE的代码,则将Arduino IDE库编译成一个库),您需要使用g++,而不是gcc。下面是一些使用Arduino编译简单程序的代码和说明:

代码语言:javascript
复制
//After calling it ardcpp.cpp, I compiled this and got it working for Arduino Uno (atmega328p) in Linux Terminal with the following 3 commands:
//avr-g++ ardcpp.cpp -O1 -Os -Wall -DF_CPU=16000000L -mmcu=atmega328p -I/snap/arduino/41/hardware/arduino/avr/cores/arduino -I/snap/arduino/41/hardware/tools/avr/avr/include/ -I/snap/arduino/41/hardware/arduino/avr/variants/circuitplay32u4 -I/usr/include/ -o ardcpp.bin
//avr-objcopy -j .text -j .data -O ihex ardcpp.bin ardcpp.hex
//avrdude -c arduino -P /dev/ttyUSB0 -p m328p -U flash:w:ardcpp.hex

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

int main (void) {
    DDRB |= _BV(DDB4);//data direction register sets 4th bit as output (pin 12)
    //0 thru 7 bits equal pins 8 thru 13, GND, and AREF on Arduino (SDA, and SCL for input from devices such as a gyroscope or a pressure/temperature/humidity sensor are not in PORTB, so use I2C/TWI for them)
    while(1) {
      //4=12,5=13
      PORTB |= (1<<4);//Set pin 12 to HIGH/ON
      _delay_ms(50);//wait 50 ms
      PORTB &= ~(1<<4);//Set pin 12 to LOW/OFF
      _delay_ms(50);//wait 50 ms
    }
}

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

https://stackoverflow.com/questions/34184335

复制
相关文章

相似问题

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