AVRDude/USBTiny failing to initialize with ATMega2560 using AVR Pocket Programmer - arduino

I have a brand new Atmega2560 sitting on a board that I made. I'm trying to use a Sparkfun AVR Pocket Programmer to program the board with USBTiny/AVRdude but when I input avrdude -c usbtiny -p atmega2560 -v -v -v into the CMD for avrdude, I'm getting an error as seen below
avrdude: programmer operation not supported
avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
I checked connections and the board is fine. I was able to program it with a friends AVR Pocket Programmer without issue. For some reason, this one isn't working. I programmed another board I have without issue so I don't think it's the pocket programmer. I would use his again, but he's in another state.
Any ideas?

So I ended up triple checking my connections and MOSI wasn't fully connected to the board. Strange.
Suggestions for those who run into this issue in the future:
Check connections. Double check connections. Triple check connections. Make sure the pad from the MCU is touching the pad of the board
Try slowing the speed of the read. ex: avrdude -c usbtiny -p atmega2560 -B 250
Make sure your avrdude is upto date - I'm currently using avrdude version 6.0.1
Make sure your drivers are up to date
From what I've read, with other peoples experiences, is that it is usually number 1 - the connections not being correct.
For others, if you changed your fuses and it stopped responding. You may have 'bricked' your MCU and need the programmer/debugger from AVR to unbrick it.

Related

Problem Flashing nrf52 chip using Openocd

I have a custom nrf52 chip on a pcb with swd pins exposed. I have cloned and installed the latest openocd from https://github.com/ntfreak/openocd. The latest version includes all the latest pathes for the nrf52 chip, so no need for any additional changes as suggested in many older guides online. I am able to connect to the chip using ST-LinkV2. when connected I can read and write memory locations using mdw and mdb. I can also run some basic openocd commands like dump_image e.t.c, which confirms that the setup is good. But halt and program commannds always lead to errors like:
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
target halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 00000000 msp: 00000000
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Previous state query failed, trying to reconnect
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
if I try to use flash image_write I get the error,
JTAG failure
Error setting register
error starting target flash write algorithm
Failed to enable read-only operation
Failed to write to nrf52 flash
error writing to flash at address 0x00000000 at offset 0x00000000
in procedure 'dap'
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
I have read different guides online, and one of the possible solutions involves the APPPROTECT register which has to be disabled to enable any writes to flash.
APP_PROTECT, But the dap commmand which is supposed to help us access this bit,
dap apreg 1 0x04 0x01
returns an error:
invalid subcommand apreg 1 0x04 0x01
Please, I will like to know if anyone has had success programming a new empty nrf52 chip with the stlink-v2 and the steps which are necessary, or if any one has encountered similar problems. Thanks.
Here is my config file:
#nRF52832 Target
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/nrf52.cfg]
#reset_config srst_nogate connect_assert_srst
I solved the "protected nRF52" chip problem this way, on Windows, using a Particle.io Debugger https://store.particle.io/products/particle-debugger setup to program nRF52 chips from Arduino as described in https://www.forward.com.au/pfod/BLE/LowPower/index.html
Note: The recovery process described here does NOT need Arduino to be installed
Download OpenOCD-20181130.7z pre-compiled openocd for windows from
http://gnutoolchains.com/arm-eabi/openocd/
The latest version of openocd src on https://github.com/ntfreak/openocd should also work as it includes the apreg cmd in target\arm_adi_v5.c
unzip, open cmd prompt to unzip dir, enter cmd
bin\openocd.exe -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg
response
Info : auto-selecting first available session transport "swd". To override use '
transport select <transport>'.
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Error: Could not find MEM-AP to control the core
Info : Listening on port 3333 for gdb connections
Open telnet program eg teraTerm and connect to localhost on port 4444, i.e. 127.0.0.1 telnet port 4444
cmd window shows
Info : accepting 'telnet' connection on tcp/4444
in telnet (i.e. teraTerm) type
nrf52.dap apreg 1 0x04
returns 0 <<< chip protected
then
nrf52.dap apreg 1 0x04 0x01
then
nrf52.dap apreg 1 0x04
returns 1 << chip un-protected
then power cycle board
Can now use arduino ide to flash softdevice and code low power BLE
Even though the dap command is listed by openOCD help, it isn't implemented for transport hla_swd that you have to use with ST-Link.
If the ST-Link is a generic type from China, it can be upgraded to CMSIS-DAP which uses the swd transport and supports the nrf52.dap apreg 1 0x04 0x01 command to disable the readback protection and erase the flash. You'll need another ST-Link to do that, or you can instead install CMSIS-DAP on a generic STM32F103C8T6 board.
After that you can either use ST-Link to program the nRF52 or continue using CMSIS-DAP, which can also be used to program STM32 MCU.
Nucleo board embedded ST-Links can also be upgraded to J-Link, which allow the use of the "recover" option in nRFgo Studio to erase the flash, it should also work with "nrfjtool --recover" or OpenOCD.
If anyone encounters this problem, I solved the problem by getting an original Jlink-Edu. I also had to pull the reset pin of the microcontroller high to get the jlink working.
There are lots of JTAG messages.
I think you might be missing the
transport select hla_swd
line in your (board) cfg file. The NRF5x chips only work properly with SWD, and ST-Link uses the hla_swd variant.

Code is not uploading in new aurdino mega

I am new(new purched board and me also) in arduino programming. when I am uploading my code in ardino mega board (using Aurdino 1.8.2) i am getting following error
Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Sketch uses 1482 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.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM3 -b115200 -D -Uflash:w:C:\Users\Admin\AppData\Local\Temp\arduino_build_393128/Blink.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM3
Using Programmer : wiring
Overriding Baud Rate : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
An error occurred while uploading the sketch
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude done. Thank you.
How i solve this problem.
My setting are as follows
.
rest of them are as default. also my driver are up to date in device manager.
First, try a loopback test. If that fails, you have a problem with the hardware most likely. If it passes, try replacing the avr directory with another version. Additionally, if pins 1 or 0 are connected to anything, this error could be caused. That is because these pins are used for Tx/Rx. Additionally, the bootloader for the mega will break if you use !!! in your code. If all of that fails to help, try reinstalling the FTDI drivers.

I have changed signature in avrdude but not able to load bootloader in atmega328-PU with UNO

avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.
If the bootloader has been compiled for ATmega328P it may not work as expected on 328PB (I personally experience issues on application code).
Also the 328PB is a quite recent chip and may not be completely supported by avrdude ref

El capitan pololu isp dongle pgm03a not working anymore

I have a Pololu PGM03A isp dongle to programm microcontrollers via avrdude. It worked great under Yosemite, but under El Capitan, it seems to disconnect and reconnect randomly every 1 - 5 sec. I can see this by the green status LED and in the terminal:
Macintosh:~ xxxxx$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.usbmodem00070153
/dev/cu.serial1 /dev/cu.usbmodem2169
/dev/cu.usbmodem00070151
Macintosh:~ xxxxx$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.usbmodem00070153
/dev/cu.serial1
Macintosh:~ xxxxx$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.usbmodem00070153
/dev/cu.serial1 /dev/cu.usbmodem2177
/dev/cu.usbmodem00070151
As you can see, the usbmodem00070151 is there, then not, and then again available. The usbmodem00070153 belongs to the ISP Dongle too, but it provides an different feature than programming the microcontroller (it's an USART Port or something I think).
Edit: The latter modem now also disconnects.
When I try to flash the microcontroller, it sometimes manages it to write some bytes, but the time between 2 disconnects is to short to finish the job:
Writing | ######################## | 47% 0.08s
avrdude: ser_recv(): read error: Device not configured
make: *** [all] Error 1
Does anyone know how to fix this?

Arduino nano 3 - avrdude: stk500_getsync(): not in sync: resp=0x00

I have got an arduino nano v 3.0.
When I tried to install drivers using arduino installation folder, it not shows any driver for nano board. I installed the driver from FTDI website.
When i upload the program to board, it's uploaded correctly, but the program is not working. IDE shows the error
avrdude: stk500_getsync(): not in sync: resp=0x00
at console after uploading the program to board.
My OS is Win 8.1 64 bit
Solution for my problem with Nano clone (based on CH340 not FTDI) was to change baud rate to 57600.
Following command line works for me:
avrdude.exe -v -P COM3 -c arduino -p atmega328p -b57600 ...
I was able to fix this by selecting the right board that I was using from the Tools Menu. Tools>Boards>Arduino Model
I had the same problem with a nano chinese clone with the 340. The solution for me was to reset the baud rate in device manager to 57600. At first it did not work until I pressed the reset on the nano. Bottom line baud rate to 57600 press reset before uploading.
i have removed all drivers available in computer currentely for arduino connecitn while it is connected to computer.
installed this file
http://www.ftdichip.com/Drivers/CDM/CDM20824_Setup.exe
It worked perfect.

Resources