&引用;avr gcc:找不到命令";在Ubuntu上

&引用;avr gcc:找不到命令";在Ubuntu上,ubuntu,gcc,Ubuntu,Gcc,我想在家里做一个Arduino项目。但是,当我尝试运行示例代码时,会出现以下错误: avr gcc:未找到命令 该程序在大学计算机上运行良好。但是,它在我的Ubuntu虚拟机上根本不起作用。我对这个完全陌生。所以,我真的不知道怎么了 avr gcc:未找到命令 这正是它所说的:找不到avr gcc命令 在avr gcc上搜索可快速显示: AVR Libc是一个自由软件项目,其目标是为Atmel AVR微控制器上的GCC提供高质量的C库 avr binutils、avr gcc和avr libc共

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

avr gcc:未找到命令

该程序在大学计算机上运行良好。但是,它在我的Ubuntu虚拟机上根本不起作用。我对这个完全陌生。所以,我真的不知道怎么了

avr gcc:未找到命令

这正是它所说的:找不到
avr gcc
命令

avr gcc
上搜索可快速显示:

AVR Libc是一个自由软件项目,其目标是为Atmel AVR微控制器上的GCC提供高质量的C库

avr binutils、avr gcc和avr libc共同构成了Atmel avr微控制器自由软件工具链的核心

这听起来很有希望

在搜索词中添加
ubuntu
。在虚拟机上运行
sudo-apt-get-install-gcc-avr
应该可以安装该软件包。

我尝试的是:

yum install *avr*gcc*

我在centos上找到了其他一些带有通配符的较长软件包。我发布这个答案是因为这适用于更多的情况和其他地区。

您可能需要flex、byacc、bison、gcc和libusb开发:

sudo apt-get install flex byacc bison gcc libusb-dev
然后在终端中使用以下命令从其根安装目录安装它:

./configure
make
sudo make install

然后下载binutils: 配置它:

./configure --target=avr --program-prefix="avr-"
然后制作并安装它。 之后,从以下站点下载最新版本的GCC: . 在我尝试安装它之后,它出现了错误,说我需要gmp、mpfr和mpc,所以我下载了它们 按以下顺序从这些网站:

并使用

./configure
make
sudo make install
在Ubuntu终端中

幸运的是,在此之后,gcc安装成功。 然后,您需要从以下位置安装avr libc:

和avrdude访问物理板:

使用

在avrdude上启用通用输入/输出(并在avrdude.conf中设置引脚reset、sck、mosi和miso)。Avrdude检查(在末尾)是否有libelf、libftdi1、libftdi和libhid

从下载libelf 或

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

sudo apt-get update -y
sudo apt-get install -y libftdi1-dev
sudo apt-get install -y libftdi-dev
最后是libhid(人机界面设备):

由于某种奇怪的原因,它甚至没有检测到

您可能不需要执行所有这些步骤。根据最低要求,您可以只安装avr,但为了安全起见,建议您执行其他步骤

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

//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
    }
}
//在调用它ardcpp.cpp之后,我编译了它,并使用以下3个命令在Linux终端上为Arduino Uno(atmega328p)工作:
//avr-g++ardcpp.cpp-O1-Os-Wall-DF_CPU=1600000l-mmcu=atmega328p-I/snap/arduino/41/hardware/arduino/avr/cores/arduino-I/snap/arduino/41/hardware/tools/avr/avr/include/-I/snap/arduino/avr/variants/circuitsplay32u4-I/usr/include/-o ardcpp.bin
//avr objcopy-j.text-j.data-O ihex ardcpp.bin ardcpp.hex
//avrdude-carduino-P/dev/ttyUSB0-pm328p-U闪存:w:ardcpp.hex
#包括
#包括
//#包括
内部主(空){
DDRB |=_BV(DDB4);//数据方向寄存器将第4位设置为输出(引脚12)
//Arduino上0到7位相等的引脚8到13、GND和AREF(用于陀螺仪或压力/温度/湿度传感器等设备输入的SDA和SCL不在端口B中,因此使用I2C/TWI)
而(1){
//4=12,5=13

PORTB |=(1这很有效!但是,对我来说,它仍然抱怨它找不到
avr/io.h
,但似乎没有适用于Ubuntu的开发版本。@Ghostkeeper,尝试安装
avr libc
。我使用一个名为的可选工具找到了这个包,特别是通过运行
apt file search avr/io.h
sudo apt-get update -y
sudo apt-get install -y libelf-dev
sudo apt-get update -y
sudo apt-get install -y libftdi1-dev
sudo apt-get install -y libftdi-dev
sudo apt-get install libhidapi-dev
//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
    }
}