我想在家里做一个Arduino项目。但是,当我试图运行示例代码时,会得到以下错误:
avr-gcc:找不到指挥部
这个程序在大学计算机上运行得很好。然而,在我的Ubuntu虚拟机上根本没有工作。我对此完全陌生。所以,我真的不知道怎么回事。
发布于 2018-10-01 19:04:11
我试过的是:
yum install *avr*gcc*给我找了一些更长的包裹,上面有通配符。我发布这个答案是因为这适用于更多的案例和其他dists。
发布于 2020-11-30 20:49:30
您可能需要flex、byacc、bison、gcc和libusb-dev:
sudo apt-get install flex byacc bison gcc libusb-dev以及libusb点信息中的libusb,然后在终端中使用这些命令从其根目录安装它:
./configure
make
sudo make install或
sudo apt-get install libusb-1.0-0然后下载binutils:http://ftp.gnu.org/gnu/binutils/配置它:
./configure --target=avr --program-prefix="avr-"那就制造和安装它。然后,从:http://gcc.gnu.org/mirrors.html下载GCC的最新版本。在我试图安装它之后,它出现了错误,我说我需要gmp、mpfr和mpc,所以我从以下网站下载了它们:
https://www.mpfr.org/mpfr-current/
并使用
./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/
使用
./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或
sudo apt-get update -y
sudo apt-get install -y libelf-devftdi是可选的(对于ftdi芯片和usb到串行的ft芯片),您可以从intra2net获得它,或者使用以下命令:
sudo apt-get update -y
sudo apt-get install -y libftdi1-dev
sudo apt-get install -y libftdi-dev最后,libhid (人类接口设备):
sudo apt-get install libhidapi-dev但由于某种奇怪的原因它甚至没有发现。
你可能不需要做所有这些步骤。您可以尝试只为最低要求安装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
}
}‘
https://stackoverflow.com/questions/34184335
复制相似问题