Having trouble programming MegaPi directly from Arduino IDE

Hello,
I'm a teacher testing out the MakeBlock Ultimate 2.0 robotics kit for use in my high school Advanced Robotics class next year. I really like the hardware, but I'm finding that the electronics and the programming leave something to be desired.

Truly what I want is a way to directly program the MegaPi (or hey some other microcontroller if it turns out MegaPi is a piece of garbage) using the Arduino IDE. I don't want to use mBlock. It's drag-and-drop, which is fine, but that's for Intro to Robotics, not Advanced. I want my kids writing code.

I have already uninstalled the old drivers, then installed the new CH340/341 drivers so my Macbook is no longer crashing when I connect to MegaPi via USB.

So I open the Arduino IDE, and select the following:

  • Boards > Arduino/Genuino Mega or Mega 2560
  • Processor > ATmega2560
  • Port > /dev/cu.wchusbserial1420

Then choose one of the MakeBlock sample code files, like:

  • Examples > MakeBlockDrive > Me_EncoderDriver_New > EncoderMotorTestRunSpeed

...and try to upload it, and I get an error (in comments below). Any help would be appreciated.

HW/SW config:

  • Ultimate 2.0 kit
  • MegaPi
  • Two 25mm Encoder Motors DC 9V, 185rpm
  • Two encoder modules connected to MegaPi ports 1 and 2
  • MegaPi and motors are powered using the six cell AA battery pack loaded with six fully charged Duracell NiMH rechargeables
  • Arduino IDE 1.8.3 with MakeBlock libraries and boards updated
  • Macbook Pro early 2015, running OSX Sierra 10.12.5
  • Connecting via USB (I know my USB cable is good because I can download the Blink code. Likewise, I had moderate success with mBlock, and managed to download a couple rudimentary programs.)

jnapior:
...and try to upload it, and I get an error (in comments below).

Did you forget to post the error?

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
User configuration file is "/Users/JN/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : wiring
Overriding Baud Rate : 115200
AVR Part : ATmega2560
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
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 : Wiring
Description : Wiring
Programmer Model: AVRISP
Hardware Version: 15
Firmware Version Master : 2.10
Vtarget : 0.0 V
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | 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_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
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_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
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_ReceiveMessage(): timeout

Then it repeats a lot of stuff...let me see if I can fit the rest in here:

avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x1b
avrdude: stk500isp_read_byte(): timeout/error communicating with programmer
avr_read(): error reading address 0x0000
read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATmega2560", rc=-2
avrdude: error reading signature data, rc=-1
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout

(snip)

avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Device not configured
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x11
avrdude: stk500v2_disable(): failed to leave programming mode
ioctl("TIOCMGET"): Device not configured
avrdude: ser_close(): can't reset attributes for device: Device not configured

avrdude done. Thank you.

I've also tried updating the firmware for MegaPi via the Arduino IDE. Here is the error it throws.

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
User configuration file is "/Users/JN/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : wiring
Overriding Baud Rate : 115200
avrdude: ser_open(): can't open device "/dev/cu.wchusbserial1420": Resource busy
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected