Farmduino 2.0 bringup

Hi, I just wonder how do you start with new HW.
Do you use preprogrammed ATmega2560 or flash the bootloader via ISP?

My story… I assembled my own PCB. Now I am not successful with the ISP - avrdude says : part number is wrong (and random). Perhaps the virgin/unprogrammed STM32 loads the SPI_U1 bus? So I should start here?
But I was successful with the ATmega16 and I see TX data on my scope. Unfortunately the avrdude is unable connect the ATMega2560 ??? missing bootloader in the ATMega2560 could be the reason ???

Yes I enjoy this part, fortunately I have 10 pcs.
Thanks for hints.
Jan

Ok, the STM32 SPI1 pins are GPIO by default in input mode so this should have no influence on the ATmega2560.

Hi,

It’s been about 2 years since I built my Farmduino 2.0a board. Unfortunately, the project was then abandoned. It’s my turn now.
To give the ATmega2560 a bootloader, I used an Arduino Uno, which I turned into an ISP programmer. This is very easy to do with the Arduino IDE. Both creating the ISP programmer and burning the bootloader with this ISP programmer.
I flashed the ATmega16 with the Arduino-usbserial-atmega16u2-Uno-Rev3.hex.
And on the STM32 the encoder-tracker firmware has to be uploaded. It should be noted that encoder-tracker 1.0.1 must be used for Farmbot version 1.5 and encoder-tracker 1.0.2 for v1.6. Burning works with the SWD interface and an ST-Link programmer.
It looks like everything is working for me. The v1.6 in particular has the great advantage of being able to use the quiet mode. An absolute must.

Greetings Klaus

1 Like

Thank you Kalus, so you use the
ArduinoCore-avr/bootloaders/stk500v2/Mega2560-prod-firmware-2011-06-29.hex
as bootloader for the atmega2560 ?

The booloader blinks on GRE1 LED, but not periodically, looks like MCU resets during second period.
My fuses are probably wrong (H:0xD8, L:0xFF, E:0xFD), could you please share your fuses for the atmega2560 ?

Best Regards, Jan

1 Like

I don’t know. As I wrote Arduino IDE did the job.

The booloader blinks on GRE1 LED, but not periodically, looks like MCU resets during second period.
My fuses are probably wrong (H:0xD8, L:0xFF, E:0xFD), could you please share your fuses for the atmega2560 ?

Here the settings of my working board. I used Microchip Studio to read the values.

Greetings Klaus

1 Like

Thank you Klaus,
the issue I have caused by AVR chip’s default fuses - they run form internal calibrated RC oscillator at 1MHz by default.

I hope this could help to others… (or my selves in a future)

For atmega2560 - I was able to fix fuses for external 16MHz crystal resonator by providing clock on XTAL1 + Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer and flash correct fuses using ISP programmer (stk500v2).

For atmega16u2 I failed. I installed (maybe wrong) firmware
sudo dfu-programmer atmega16u2:1,17 flash /media/data/tmp/proj/farmduino/fw.ATmega16/Arduino-usbserial-atmega16u2-Uno-Rev3.hex

but definetly with default fuses. This caused the farmduino is visible on USB as
lsusb
Bus 001 Device 009: ID 2341:0042 Arduino SA Mega 2560 R3 (CDC ACM)

Unfortunately clock for serial port is slow (default fuses 1MHz instead of 16MHz external crystal). So it transmits data from the atmega2560 but by wrong speed. I did try all predefined speeds but I see only 0xFF data or some mess. I was even unable to recover fuses as for 2560 or attach ISP programmer. My HVSP failed for some reason also - it see always some random messy chip ID.

So order new chip, replace, attach USB with dfu-programmer, set fuses for 16MHz and fash the FW as you is probably the solution.

btw. external USB/RS232-5V convertor for arduino-pro-mini works well when attached to atmega2560.

I was also unable to connect arduino IDE to the farmbot, but I solved this by using arduino mega2560 as temporary target. Afterwards I download the binary using stk500 and flash on farmduino by stk500. I see no reason to spend more time for this issue now… maybe farmduino fw update will force me in future.

Best Regards, Jan

1 Like

OK, final notes. I fixed the problem (bringup procedure for atmega16u2) followin way :

  1. I replaced the QFN32 chip by factory clean one using hot air and capton tape.

  2. Then I set atmega16u2 fuses as E: 0xF0, H: 0xD9, L: 0xFF, LOCK: 0xEC

  3. finally I flashed: Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex formthis repository ArduinoCore-avr/firmwares/atmegaxxu2 at master · arduino/ArduinoCore-avr · GitHub

  4. now lsusb command outputs:
    Bus 001 Device 048: ID 2341:0042 Arduino SA Mega 2560 R3 (CDC ACM)

  5. system recognizes /dev/ttyACM0

  6. so I can connect terminal: sudo screen /dev/ttyACM0 115200

  7. the atmega2560 send to my terminal:
    R99 Serial connection sta4 V0 Q0
    R21 P5 V3 Q0
    R21 P11 V120 Q0
    R21 P12 V120 Q0
    R21 P13 V120 Q0
    R21 P15 V0 Q0
    R21 P16 V0 Q0
    R21 P17 V1 Q0
    R21 P18 V0 Q0
    R21 P19 V0 Q0
    R21 P20 V0 Q0
    R21 P21 V0 Q0
    3 V0 Q0 V0 Q0

    R21 P216 V60 Q0
    R21 P217 V1 Q0
    R21 P221 V0 Q0ment settings
    R99 Set motor enables off
    R99 Start pin guard
    R99 Start interrupt
    R99 Check homing on boot
    R99 ARDUINO STARTUP COMPLETE

  8. I removed D4 and R39 the 1M on atmega16u2 osc, this probably causing that my terminal skips some characters when I press the reset button

  9. really last note, I found the farmduino is possible to power by USB-A-A cable (5V for atmega2560) for programming purposes in the X8 (USB-power-out) .

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.