Go Down

Topic: Unable to upload a code after having successfully uploaded before (Read 669 times) previous topic - next topic

momin01

Hello,

I am unsure if this is the correct place to ask this so apologies in advance if it isn't the right place.

I am working with the following robot:
https://www.robotshop.com/uk/4wd-arduino-compatible-mecanum-robot.html

It came with an Arduino and an I/O shield pre-installed on it.
The pics of the two boards are uploaded on the following link as they were too big to upload with the post:
https://imgur.com/a/Ax7DWHG?

As you can see, it does not look like a typical Arduino board. And I am unsure as to what this board is exactly. If anyone knows the name of the board, that would be really helpful.

I managed to upload a code to the board yesterday by choosing Arduino/Genuino Uno on the IDE.

I tried uploading a different code today but the IDE gets stuck in the uploading state for a while and then gives an error. I tried to reset it by uploading an empty code (with just setup() and void() methods) but that also gave the following error.

"Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.


Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
""
I tried uninstalling and re-installing the IDE, I have gone to Device Manager and disconnected the Arduino to ensure that it is definitely Port 3 that it is connected to as well.

I am lost as to what to do now. Any suggestions would be really helpful.

Thanks in advance.

DrAzzy

Access denied indicates that you have the serial port open in another program (serial monitor? something else?). Close that program. If the port was closed uncleanly, you may need to reboot the computer to make it work again.

ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

unknownme

I restarted my computer and tried to upload the empty file again. It did not work.

I tried using the local IDE as well as the online IDE to upload the code. I also tried to use a Raspberry Pi instead of my computer to try and upload the code to the Arduino.

I get the following error when I try to upload the code via Windows IDE:
"Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"

I get the following when I used online IDE:
"
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0
avrdude done. Thank you.

"

And the same error is found on the Pi as well.

I have restarted the computer and made sure to only run the IDE when trying to upload the code to ensure that there wasn't anything else using the same resources.
I have changed the USB port that the Arduino was connected to as well but still encountered the same error.
One thing I noticed is that when I tried to upload the code, only the Tx light is blinking but the Rx remains off. Not sure if that is how it is meant to act this way.

Any help would be greatly appreciated. Thanks

FB2016X

Have you tried another USB port ?
Do you use an USB hub ?
Have you tried the reset button on the board ?
Are there other USB devices that use a lot of power ?
Is it on 8 Mhz ?
Do you need  external power or USB power only ?
You use board :
"Arduino/Genuino Uno" while it's a ATMEGA168


unknownme

Hello,

1- I have used multiple USB ports and get the same error.

2- I do not use a USB hub.

3- I tried resetting the Arduino (pressing the RST button on the board for a few seconds and then letting go) but still unable to communicate.

4- No other USB devices are attached to my computer.

5- I'm not sure how to check for whether it is on 8MHz. Would appreciate if you could expand on this a bit.

6- There are motors on attached to the Arduino but they are power via an external battery. The Arduino is being driven just by my USB.

7- Could you tell me how I can set it to ATMEGA168 on the IDE? There is no board called that on the IDE. There is a board on the IDE called "Arduino/Genuino Mega or Mega 2560". I'm not sure if this is the one I should use.

I appreciate the help so far. :)

unknownme

So I tried the code again by setting the board to Arduino Mega with processor set to ATmega 1280. I got the following error while running it in the windows IDE:
"Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega1280"

Build options changed, rebuilding all
Sketch uses 658 bytes (0%) of program storage space. Maximum is 126976 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"

I also set the processor to ATmega2560 and got the following error:
"Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
Sketch uses 656 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"


FB2016X

Try this:

Find your boards.txt
Like: C:\....\arduino-1.8.9\hardware\arduino\avr\boards.txt
make a safety copy of it, like org_boards.txt
use the boards.txt to add: code below:

(then restart Arduino IDE) after that and choose the ATMEGA168 board

#
# ATmega168/168p
#

atmega168.name=ATmega168/168p

atmega168.bootloader.tool=arduino:avrdude
atmega168.bootloader.unlock_bits=0x3f
atmega168.bootloader.lock_bits=0x0f

atmega168.upload.tool=arduino:avrdude
atmega168.upload.maximum_size=16384
atmega168.upload.maximum_data_size=1024
atmega168.upload.speed=19200
atmega168.build.variant=arduino:standard
atmega168.build.core=arduino:arduino
atmega168.build.board=atmega168

atmega168.menu.clock.internal1=Internal 1 MHz
atmega168.menu.clock.internal1.bootloader.low_fuses=0x62
atmega168.menu.clock.internal1.bootloader.high_fuses=0xdd
atmega168.menu.clock.internal1.bootloader.extended_fuses=0xf9
atmega168.menu.clock.internal1.build.f_cpu=1000000L

atmega168.menu.clock.internal8=Internal 8 MHz
atmega168.menu.clock.internal8.bootloader.low_fuses=0xe2
atmega168.menu.clock.internal8.bootloader.high_fuses=0xdd
atmega168.menu.clock.internal8.bootloader.extended_fuses=0xf9
atmega168.menu.clock.internal8.build.f_cpu=8000000L

atmega168.menu.clock.external8=External 8 MHz
atmega168.menu.clock.external8.bootloader.low_fuses=0xff
atmega168.menu.clock.external8.bootloader.high_fuses=0xdd
atmega168.menu.clock.external8.bootloader.extended_fuses=0xf9
atmega168.menu.clock.external8.build.f_cpu=8000000L

atmega168.menu.clock.external12=External 12 MHz
atmega168.menu.clock.external12.bootloader.low_fuses=0xff
atmega168.menu.clock.external12.bootloader.high_fuses=0xdd
atmega168.menu.clock.external12.bootloader.extended_fuses=0xf9
atmega168.menu.clock.external12.build.f_cpu=12000000L

atmega168.menu.clock.external16=External 16 MHz
atmega168.menu.clock.external16.bootloader.low_fuses=0xff
atmega168.menu.clock.external16.bootloader.high_fuses=0xdd
atmega168.menu.clock.external16.bootloader.extended_fuses=0xf9
atmega168.menu.clock.external16.build.f_cpu=16000000L

atmega168.menu.clock.external20=External 20 MHz
atmega168.menu.clock.external20.bootloader.low_fuses=0xff
atmega168.menu.clock.external20.bootloader.high_fuses=0xdd
atmega168.menu.clock.external20.bootloader.extended_fuses=0xf9
atmega168.menu.clock.external20.build.f_cpu=20000000L

# Signature: ATmega168
# Specs: http://www.atmel.com/devices/ATMEGA168.aspx
atmega168.menu.cpu.atmega168=ATmega168
atmega168.menu.cpu.atmega168.build.board=atmega168
atmega168.menu.cpu.atmega168.build.mcu=atmega168

# Signature: ATmega168p
# Specs: http://www.atmel.com/devices/ATMEGA168P.aspx
atmega168.menu.cpu.atmega168p=ATmega168p
atmega168.menu.cpu.atmega168p.build.board=atmega168p
atmega168.menu.cpu.atmega168p.build.mcu=atmega168p

unknownme

Just followed what you said. I can now see a new board called ATmega168/168p. I selected it and tried to upload the empty file again but the file does not compile now. I get the following error:

"Arduino: 1.8.9 (Windows 10), Board: "ATmega168/168p, ATmega168"

Error reading file (C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt:0): Invalid line format, should be 'key=value'

Error compiling for board ATmega168/168p.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"

FB2016X

Edit the boards.txt again and leave out this:

#
# ATmega168/168p
#

unknownme

Just did that. Still get the following error:

"Arduino: 1.8.9 (Windows 10), Board: "ATmega168/168p, ATmega168"

Error reading file (C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt:0): Invalid line format, should be 'key=value'

Error compiling for board ATmega168/168p.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"

FB2016X


unknownme

If I copy paste the contents of the boards.txt file, it exceeds the 9000 characters limit. I've attached the file to this post tho. The modification is the third one down.

FB2016X

I will look into it.

FB2016X

It's working fine here.
Try something different, I don't use the Arduino IDE
but Visual Micro https://www.visualmicro.com/

In your IDE menu there is an item:
Tools / boards manager
have a look at that, that's the place where you can add a new board.

But first, use your saved org_board.txt file again to go back to the original state.




FB2016X

In your previous comment you had a problem:

Error reading file (C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt:0): Invalid line format, should be 'key=value'

This link shows how to  resolve this:

https://forum.arduino.cc/index.php?topic=590941.0


Go Up