davidsainty / xbeeboot

XBeeBoot: XBee Series 2 API Bootloader for Arduino and Atmel AVR
10 stars 5 forks source link

ser_recv(): programmer is not responding #2

Closed watsonbkw closed 8 years ago

watsonbkw commented 8 years ago

Hi David,

Thanks for taking the time to create the xbeeboot bootloader. Unfortunately, I'm struggling to get it to work either OTA or directly connected to the serial port.

Hardware: Official Arduino Uno with ATMega328P (16 MHz external oscillator) AVR Programmer: 2nd Arduino Uno

I can successfully upload the 328 bootloader using the Arduino IDE and the 2nd Arudino as the AVR programmer:

.... avrdude: reading input file "/home/brian/arduino-1.6.9/hardware/arduino/avr/bootloaders/xbeeboot/xbeeboot_atmega328.hex" avrdude: writing flash (32768 bytes): Writing | ################################################## | 100% 0.00s avrdude: 32768 bytes of flash written avrdude: verifying flash memory against /home/brian/arduino-1.6.9/hardware/arduino/avr/bootloaders/xbeeboot/xbeeboot_atmega328.hex: avrdude: load data flash data from input file /home/brian/arduino-1.6.9/hardware/arduino/avr/bootloaders/xbeeboot/xbeeboot_atmega328.hex: avrdude: input file /home/brian/arduino-1.6.9/hardware/arduino/avr/bootloaders/xbeeboot/xbeeboot_atmega328.hex contains 32768 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 32768 bytes of flash verified avrdude: reading input file "0x2F" avrdude: writing lock (1 bytes): Writing | ################################################## | 100% 0.02s avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0x2F: avrdude: load data lock data from input file 0x2F: avrdude: input file 0x2F contains 1 bytes avrdude: reading on-chip lock data: Reading | ################################################## | 100% 0.01s avrdude: verifying ... avrdude: 1 bytes of lock verified

avrdude done. Thank you.

After that, when I try either OTA updates or directly connecting to the Serial port of the target Arduino I get the ser_recv(): programmer is not responding error message.

Specifying xbee as the programmer directly connected to serial

$ avrdude -vvvv -b 19200 -P @/dev/ttyACM0 -c xbee -p atmega328p -U flash:w:"./Blink.ino.hex":i

avrdude: Version 6.1, compiled on Jun 11 2016 at 13:01:57 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/home/brian/local/etc/avrdude.conf"
     User configuration file is "/home/brian/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : @/dev/ttyACM0
     Using Programmer              : xbee
     Overriding Baud Rate          : 19200

avrdude: XBee address: 0000000000000000 avrdude: Baud 19200 avrdude: ser_recv(): programmer is not responding avrdude: sendAPIRequest(): 1467761687.176157 1, 1, 23, 48 avrdude: Send: ~ [7e] . [00] } [7d] 1 [31] . [90] . [01] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [ff] . [fe] . [01] . [01] . [17] 0 [30] [20] . [08] avrdude: ser_recv(): programmer is not responding avrdude: sendAPIRequest(): 1467761688.177394 1, 1, 23, 48 avrdude: Send: ~ [7e] . [00] } [7d] 1 [31] . [90] . [02] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [ff] . [fe] . [01] . [01] . [17] 0 [30] [20] . [07] avrdude: ser_recv(): programmer is not responding avrdude: sendAPIRequest(): 1467761689.178544 1, 1, 23, 48 avrdude: Send: ~ [7e] . [00] } [7d] 1 [31] . [90] . [03] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [ff] . [fe] . [01] . [01] . [17] 0 [30] [20] . [06] avrdude: ser_recv(): programmer is not responding avrdude: sendAPIRequest(): 1467761690.179727 1, 1, 23, 48 avrdude: Send: ~ [7e] . [00] } [7d] 1 [31] . [90] . [04] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [ff] . [fe] . [01] . [01] . [17] 0 [30] [20] . [05] avrdude: ser_recv(): programmer is not responding

The same thing happens at a variety of baud rates including 9600, 14400, 115200, etc.

Specifying arduino as the programmer directly connected to the serial port

$ avrdude -vvvv -b 19200 -P /dev/ttyACM0 -c arduino -p atmega328p -U flash:w:"./Blink.ino.hex":i

avrdude: Version 6.1, compiled on Jun 11 2016 at 13:01:57 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/home/brian/local/etc/avrdude.conf"
     User configuration file is "/home/brian/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/ttyACM0
     Using Programmer              : arduino
     Overriding Baud Rate          : 19200

avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 avrdude: Send: 0 [30] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00 avrdude: Send: 0 [30] [20]

The same happens at different baud rates.

I would appreciate any suggestions or thoughts you would be willing to provide.

Thanks

davidsainty commented 8 years ago

Hi Brian,

You've tested all my immediate suggestions but one :)

The remaining suggestion is that the boot fuses might be wrong.

You need to program the bootloader with something like:

cd xbeeboot/xbeeboot/bootloaders/xbeeboot make atmega328_isp

... or, do it directly:

avrdude -c stk500v1 \ -p atmega328p -P /dev/ttyACM0 -b9600 \ -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xDC:m -U lfuse:w:0xFF:m \ -U flash:w:xbeeboot_atmega328.hex -U lock:w:0x2f:m

watsonbkw commented 8 years ago

Thanks for the prompt response! I updated the boot fuses manually using the command line you provided and tried the xbee protocol over direct serial at 9600 baud. Success!

When I burn the bootloader from the Arduino IDE, using the boards-1.6.txt file provided and choosing the following settings:

Board: XBeeboot on 28-pin CPUs Processor: ATmega328p CPU Speed: 16MHz

it outputs the following on the command line:

arduino-1.6.9/hardware/tools/avr/bin/avrdude -Carduino-1.6.9/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x0F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xF7:m

The high and low fuse bits are a bit different from the ones that worked. When I check those settings on Engbedded's site, it looks like the difference is that the boards1-6.txt file is specifying a full-swing crystal and a 256-word boot size. I swear I double-checked those fuse settings before submitting this issue, but tinkering with fuses and lock bits is definitely not my forte and I obviously didn't catch the issue with the boot section size.

It looks like the smaller 256-word boot section size comes from line 56 in boards-1.6.txt:

50 ## XBeeBoot for ATmega328p
51 ## ---------------------------------------------
52 xbeeboot28.menu.cpu.atmega328p=ATmega328p
53 xbeeboot28.menu.cpu.atmega328p.upload.maximum_size=32256
54 xbeeboot28.menu.cpu.atmega328p.upload.maximum_data_size=2048
55
56 xbeeboot28.menu.cpu.atmega328p.bootloader.high_fuses=0xDE

Shall I submit a pull request to change the high fuse to '0xDC' for the 512 word boot section size? I can also change the low fuse so that it doesn't use the full-swing crystal setting by default (google searches tell me that full swing shouldn't matter but it will consume more power).

Next up I'll try an OTA update. If my xbees are set to a different baud rate than 9600 can I simply pass that baud rate on the command line or do I need to tinker with the bootloader source and rebuild it in order to support higher baud rates OTA?

Also, do you have a beer or pizza fund I can donate to? Thanks for your kind support.

Brian

davidsainty commented 8 years ago

Yes, please, a pull request would be good for whatever you find works. I don't actually use the boards*.txt file, so it isn't that surprising I screwed it up :)

No, I don't have a beer fund :)

The local avrdude-side XBee can be on a different baud rate, and that's the baud rate you can pass to avrdude.

If the remote XBee is on a baud rate that doesn't match the bootloader it won't work. The bootloader has to be built for the right clock dividers to match the crystal and the XBee. What baud rate are you wanting?

watsonbkw commented 8 years ago

Hi David,

Sorry it took me so long to get back to you. I was distracted by work and family. I have submitted a pull request for the fuse bit changes in boards-1.6.txt.

I am now able to successfully do OTA updates! Thanks for you work on the xbeeboot project and for your excellent support!

Regards,

Brian