Having trouble programming MegaPi directly from Arduino IDE


#1

Hello,
I’m a teacher testing out the 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 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.)

#2

Here is my Arduino error log:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 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
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
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: 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: ser_send(): write error: Device not configured
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_send(): write error: Device not configured

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 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.


#3

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

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 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


Upload error on MegaPi
#4

Hmm, not sure right off although the serial port I get is /dev/cu.wchusbserial1410. Is there anything else plugged in via USB? Also, may I assume that you have the MegaPi powered up?


#5

No other USB devices are connected. The MegaPi power is switched on (switch pushed away from power connector).


#6

Hi jnapior,

The example program “EncoderMotorTestRunSpeed” is base on Me Orion not MegaPi. If you want to upload this program to MegaPi, you may need modify it.

For the upload error while uploading MegaPi firmware, please check if you have connected the serial port of MegaPi to mBlock software. You may close all the Arduino software and mBlock software, then only open the Arduino software have a check.

Besides, you may unplug the Bluetooth module from the MegaPi have a try too.


#7

Ok, I removed the BT module, and that earned me one successful download of the 7-segment LED example code. But now I can’t upload anything else.

You say that “EncoderMotorTestRunSpeed” is based on Orion. Aside from changing the “MeOrion.h” to “MeMegaPi.h”, what else needs to be changed? Are the function calls different? Can you recommend a sample code that is specifically for MegaPi?


#8

Normally, changing the “MeOrion.h” to “MeMegaPi.h”, the program can be compiled and uploaded without issue. At least it says upload done when do the test here. Is there any compile issue on your side?
Besides, does it still say " can’t open device “/dev/cu.wchusbserial1420”: Resource busy" when you upload other program?

Normally, the MegaPi firmware is the program special for MegaPi board.
The encoder motor sample code that is specifically for MegaPi, please see picture below:

Before you uploading the example programs to the MegaPi, please compile the programs first and see if it can compiled successfully.


#9

One other thing to note is that when you get a Resource busy message it is typically because some other program has opened that serial port and is not sharing it. Make sure that you have shut down mBlock or any other application that uses that serial port.


#10

I restarted my computer, made sure no other USB devices were plugged in, restarted Chrome (in case there was any remnants of mBlock trying to control the MegaPi), and compiled the example code successfully. I then tried running the program Firmware_for_MegaPi, and got this error.

Arduino: 1.8.3 (Mac OS X), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega2560 -cwiring -P/dev/cu.wchusbserial1420 -b115200 -D -Uflash:w:/var/folders/n4/l4yn_3_d4nl_5brj194t6x_r0000gr/T/arduino_build_925615/Firmware_for_MegaPi.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 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: stk500v2_getsync(): timeout communicating with programmer

avrdude done. Thank you.

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


#11

Then I tried all the above again, but this time executed the sample program Me_MegaPi_encoder_pid_pos, and got this error:

/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/JN/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega2560 -cwiring -P/dev/cu.wchusbserial1420 -b115200 -D -Uflash:w:/var/folders/n4/l4yn_3_d4nl_5brj194t6x_r0000gr/T/arduino_build_129304/Me_Megapi_encoder_pid_pos.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 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 | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "/var/folders/n4/l4yn_3_d4nl_5brj194t6x_r0000gr/T/arduino_build_129304/Me_Megapi_encoder_pid_pos.ino.hex"
avrdude: writing flash (12018 bytes):

Writing | ###############################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


#12

Hi jnapior,

Was the Bluetooth module always removed from MegaPi while you uploading?
Do you have the issue when program the MegaPi with mBlock software?

Is the /dev/cu.wchusbserial1420 correct serial port for the MegaPi, do you select the same serial port when program MegaPi with mBlock?

If the mBlock program works with MegaPi, please check if you can upload the arduino program with the mBlock integrated Arduino software?


#13

The Bluetooth module was removed for these latest test. Truthfully, when I first started playing around with this, the BT was still connected. But as of now, it is removed.

I don’t have these issues when I upload the program using mBlock software.

Yes, /dev/cu.wchusbserial1420 is the correct serial port, and its the one I use when programming with mBlock software.

Can you explain your last recommendation in more detail? It sounds like you want me to somehow paste my Arduino code into mBlock, and then upload it from there. Can you say more about that?


#14

You can launch the Arduino IDE that is included with mBlock (it’s how compilation happens under the covers for the code generated by the code generator). Be aware that if you have mBlock launched and connected to the MegaPi that you will need to disconnect from within the mBlock IDE before you can connect with the Arduino IDE.

So @tec_support is asking you to:

  1. Open mBlock
  2. Go to Arduino mode
  3. Click the Edit with Arduino button to launch the Arduino IDE
  4. Paste your code into the sketch that pops up in the Arduino IDE
  5. Disconnect mBlock from the MegaPi
  6. Connect the Arduino IDE to the MegaPi
  7. Compile and upload your code

All of this to see if it makes a difference. :slight_smile:


#15

I have the same problem with timeout. Problem is with Arduino mode with cable. There is no way to transfer program to mBot with Arduino IDE - why? Of course with mBlock works fine but with Arduino Mode doesn’t. Every steps are make correctly.


#16

Hi test-mBot,

Do you mean, you can upload program to mBot successfully with mBlock software?
You may take a clear video to show your steps while uploading the program to mBot with Arduino IDE software.
Btw, what is the operating system of your computer and what is the version of your Arduino software?


#17

Hmm, I’m doing that all of the time from the Arduino IDE. Make sure that nothing else is using that serial port (i.e., if you have Makeblock open, then close it).


#18