Cannot Upload a Sketch: Getting "Can't export GPIO 18, already exported/busy?"

Hi

When I am uploading the new sketch to Arduino yun. I get this following error

Can't export GPIO 18, already exported/busy?: Device or resource busy
avrdude done. Thank you.

Upload fails. Only option for me is to reboot the arduino

How to fix this error without rebooting

Thanks for any information on this

Regards

BRE

echo 18 > /sys/class/gpio/unexport

Hi NoblePepper,
Super - This worked.

I also needed to do the same thing for PIN 11, 27, and 8

echo 18 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport
echo 27 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport

Thank you very much

karma++

Looks like avrdude failed and did not unexport GPIOs. Is that true? If so: any chance to know how it failed? (error message, sketch being uploaded, anything that could help to reproduce the error)

I now have the same problem!

Can't export GPIO 18, already exported/busy?: Device or resource busyavrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch

OK... spoke (paniced) too soon...

The

echo 18 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport
echo 27 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport

Did resolve it.
(No spaces before/after ">" above.)

Can you explain the solution more please

Where are you meant to enter these commands (if they are in fact commands)

echo 18 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport
echo 27 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport

thankyou

Upload the YunSerialTerminal sketch so you can access to the Linux console through the Arduino Serial Monitor. Then write these commands line by line in the serial monitor and press enter.

Angelo9999:
Upload the YunSerialTerminal sketch so you can access to the Linux console through the Arduino Serial Monitor. Then write these commands line by line in the serial monitor and press enter.

While this will generally work, there's a catch-22 if you want to issue these commands because you can't upload a sketch (which is the topic of this thread.)

You can also use SSH to connect to the Yun over the network (wired or wireless) then log in and enter these command there.

Well, ... no

This issue involves uploading a sketch over WiFi.

To use the YunSerialTerminal sketch you need to be connected with USB, you upload the sketch over the USB.

Oops, thanks for the clarification. :-*

But you should still be able to connect via SSH and issue the commands that way. I don't see that it's strictly necessary to upload the serial terminal sketch in this case, although it is very helpful in cases where there is no network connectivity.

Maybe it's just because I've had some dropped character issues with the serial terminal sketch, and because I detest the Arduino IDE's serial monitor. (Even using PuTTY to talk to the serial terminal sketch I get dropped characters, which makes using something like nano very difficult - I don't have such issues using SSH.) I see the YunSerialTerminal sketch as a last resort sort of utility.

Today I tried to use avrdude:

sudo avrdude -p atmega328p -C ~/avrdude_gpio.conf -c orangepi_pc -v

avrdude: Version 6.1, compiled on Jul 23 2016 at 15:41:42
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
        Copyright (c) 2007-2014 Joerg Wunsch

        System wide configuration file is "/home/kont/avrdude_gpio.conf"
        User configuration file is "/home/kont/.avrduderc"
        User configuration file does not exist or is not a regular file, skipping

        Using Port                    : unknown
        Using Programmer              : orangepi_pc
Can't export GPIO 12, already exported/busy?: Device or resource busy
avrdude done.  Thank you.

I tried to unexport the required GPIOs and did it successfully but still get the same response

avrdude 6.3 returns the same result

Sorry I just realized the topic is about Arduino Yun.
I'm working directly with Atmega328p and OrangePi GPIO.
I managed to flash Arduino Uno with arduino programmer in avrdude and got the issue above when I tried linux_gpio programmer.
If my question is not relevant feel free to remove it.

I came here looking for the solution to the same problem, perhaps different cause. I had manually installed the "Linux Arm (experimental)" version, which as of 2016, is the 1.6.12 version of the Arduino IDE on a Raspberry Pi.

I was trying to program the RasPiO Duino RasP.iO | duino (it uses SPI GPIO bit-banging ports)

The big hint for me was when I came across this: AVR Downloader/UploaDEr - Bugs: bug #40748, linuxgpio doesn't work on... [Savannah]

Sure enough, the version of avrdude (Version 6.3, compiled on Sep 12 2016 at 15:28:39) that is used by the latest stable release of the Linux Arm (experimental) Arduino IDE had problems with the GPIO settings.

The short answer is that I used a symlink to force the Arduino IDE to use a different version of avrdude (specifically Version 6.1, compiled on Jul 7 2015 at 13:18:47).

See ./hardware/tools/avr/bin/avrdude (I used /usr/bin/avrdude instead)

I've documented all of the steps here:

Hopefully someone will find this useful.... :slight_smile: