Upload error with AT90CAN128

Hi,
First time moving from Arduino IDE to PIO.
My project uses a SparkFun AST-CAN485 board, which is not in the PIO boards list. There is a AT90CAN128, which is what the Sparkfun board is based upon.
Looking at the AT90CAN128 boards JSON file, I see everything seems to make sense except the LED definition, so I changed it like so:

{
  "build": {
    "core": "MegaCore",
    "extra_flags": "-DARDUINO_AVR_AT90CAN128",
    "f_cpu": "16000000L",
    "mcu": "at90can128",
    "variant": "64-pin-avr"
  },
  "bootloader":{
    //"led_pin": "B5",
    "led_pin": "B1",
    "uart0_pins": "uart0_rxe0_txe1",
    "uart1_pins": "uart1_rxd2_txd3"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "AT90CAN128-mdr",
  "upload": {
    "maximum_ram_size": 4096,
    "maximum_size": 131072,
    "protocol": "urclock",
    "require_upload_port": true,
    "speed": 115200
  },
  "url": "https://www.microchip.com/wwwproducts/AT90CAN128",
  "vendor": "Microchip"
}

I saved the changes to a copy of the file and am using that in my project.
I’m using the sparkfun FTDI basic programmer. which is what I always use with the Arduino IDE.
I get the following error when trying to upload:

Processing AT90CAN128 (platform: atmelavr; board: AT90CAN128-MDR; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/AT90CAN128-MDR.html
PLATFORM: Atmel AVR (5.1.0) > AT90CAN128-mdr
HARDWARE: AT90CAN128 16MHz, 4KB RAM, 128KB Flash
PACKAGES:
 - framework-arduino-avr-megacore @ 3.0.2
 - tool-avrdude @ 1.70200.0 (7.2.0)
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...     
Dependency Graph
|-- ArduinoJson @ 7.3.1 
Building in release mode
Checking size .pio\build\AT90CAN128\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.5% (used 635 bytes from 4096 bytes)
Flash: [          ]   4.6% (used 6000 bytes from 130560 bytes)
Configuring upload protocol...
AVAILABLE: urclock
CURRENT: upload_protocol = urclock
Looking for upload port...
Using manually specified: COM3
Uploading .pio\build\AT90CAN128\firmware.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude error: unknown bootloader ... please specify -xbootsize=<num>

avrdude error: unable to read signature data for part AT90CAN128, rc=-1
avrdude error: unable to read signature data, rc=-1

avrdude done.  Thank you.

*** [upload] Error 1


Any ideas?

Thank you.

Can you please go into the Arduino IDE, go to File → Preferences → check “Verbose output during upload”. Then upload again. Paste last few lines of the log output (starting at the “avrdude” command) here, or to pastebin.com.

Here you go:

C:\Users\Foo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Foo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -pat90can128 -carduino -PCOM3 -b115200 -D "-Uflash:w:C:\Users\Foo\AppData\Local\arduino\sketches\673AF3783895F9624B26D82D65BEDBF8/Truck_Control_03.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Foo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"


         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : AT90CAN128
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail     

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     8    0 no       4096    8      0  9000  9000 0xff 0xff
           flash         65     6   256    0 yes    131072  256    512  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 6.2
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9781 (probably c128)
avrdude: reading input file "C:\Users\Foo\AppData\Local\arduino\sketches\673AF3783895F9624B26D82D65BEDBF8/Truck_Control_03.ino.hex"
avrdude: writing flash (5842 bytes):

Writing | ################################################## | 100% 1.47s

avrdude: 5842 bytes of flash written
avrdude: verifying flash memory against C:\Users\Foo\AppData\Local\arduino\sketches\673AF3783895F9624B26D82D65BEDBF8/Truck_Control_03.ino.hex:
avrdude: load data flash data from input file C:\Users\Foo\AppData\Local\arduino\sketches\673AF3783895F9624B26D82D65BEDBF8/Truck_Control_03.ino.hex:
avrdude: input file C:\Users\Foo\AppData\Local\arduino\sketches\673AF3783895F9624B26D82D65BEDBF8/Truck_Control_03.ino.hex contains 5842 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.22s

avrdude: verifying ...
avrdude: 5842 bytes of flash verified

avrdude done.  Thank you.



So that uses the “arduino” upload protocol at 115200 baud. Meaning,

Is wrong and should be just

    "protocol": "arduino",
    "require_upload_port": true,
    "speed": 115200

That did it!
Thanks!

1 Like