chipKIT® Development Platform

Inspired by Arduino™

Possible bug in code for USB/Serial or failure with MAC OS?

Created Fri, 31 Jan 2014 07:58:09 +0000 by hughanderson


hughanderson

Fri, 31 Jan 2014 07:58:09 +0000

Hi,

I'm not sure if this is the correct forum for posting possible bugs, but I have found a peculiar behavior with recent releases of the mpide. In particular with the -test releases 20130817, 20131118 and 20140121. The behavior does not exhibit itself with versions 20130715 and earlier.

I am using mpide on two macs - one macos 10.6.8, and the other 10.9.1 Mavericks. The same behavior is exhibited on both. I am compiling code for Fubarino SD platforms. I get the same behavior with both the Seeed Fubarino SD and the Microchip one (The 512H model).

The behavior is this: If I compile and upload code that uses the USB Serial port, then on a mac I am unable to see the output of the Serial.print statements (using a terminal emulator or the mpide serial console). If I take this programmed fubarino and plug it into my linux or windows box, then the serial port appears to work fine. This behavior only happens if I compile using mpide more recent than 20130715. The serial data I send from the mac to the Fubarino appears to be arriving in either case, and I see /dev/*.usbmodem1421 on the mac.

Did something change in the code generation for USB/Serial between 20130715 and 20130817? I notice on Windows that the device manager reports two different kind of devices depending on if the program is running (where it is a stk500v2 serial device), or if the bootloader is running (where it is a bootloader device). Does the MAC have difficulty with the stk500v2 device? Or with changing from one device to another?

I note that another person on the forum reported a similar behavior without resolution recently. I believe this is repeatable, as I have tried on two different macs with the same results.

Can anyone help with a fix or workaround?

Cheers Hugh


pito

Fri, 31 Jan 2014 13:42:34 +0000

That is an issue I identified recently on XP and majenko did a patch (serial number "BURxxx" in the usb driver) for it afaik. http://uecide.org/forum/viewtopic.php?f=13&t=107#p353

I notice on Windows that the device manager reports two different kind of devices depending on if the program is running (where it is a stk500v2 serial device), or if the bootloader is running (where it is a bootloader device)

That was the bug on XP. It reported as two different com ports on XP.. So I had to switch the serial com depending on what I did..


majenko

Fri, 31 Jan 2014 14:06:28 +0000

I'm not sure if that is the problem, looking at the timing and version of MPIDE - it might be a version before the enhanced USB code was put in place...

Check the HardwareSerial_cdcacm.c file to see if there is a bit

#ifndef CDCACM_SER
#define CDCACM_SER "BURxxx"
#endif

in it, and if there is, empty out the "BURxxx" bit:

#ifndef CDCACM_SER
#define CDCACM_SER ""
#endif

hughanderson

Fri, 31 Jan 2014 14:12:41 +0000

Hi Pito,

Your issue may be related, but it seems quite different:

On the mac, I can connect to the port /dev/cu...... after 5 seconds or so, but then I cannot see any of the data sent to the serial console by the fubarino, although the fubarino sees the data sent from the console.

The same programmed fubarino works perfectly (both ways) on a Win7 machine, or on my Linux Fedora box.

And - as I said - if I revert to the previous stable mpide, there is no problem at all with any platform.

Majenko,

My system has the string like this: "" so I do not think it is that.

Cheers Hugh


pito

Fri, 31 Jan 2014 14:21:56 +0000

Check the com ports used you see on the MAC. Maybe you have there 2 defined for comm with usb fubarino..


hughanderson

Fri, 31 Jan 2014 14:32:13 +0000

Hi Pito,

On a mac, the "com" ports look like this:

crw-rw-rw- 1 root wheel 18, 89 Jan 31 22:24 cu.usbmodem1411 crw-rw-rw- 1 root wheel 18, 88 Jan 31 22:24 tty.usbmodem1411

When you re-boot the fubarino, the minor device number goes up, but the device name is unchanged:

crw-rw-rw- 1 root wheel 18, 91 Jan 31 22:36 /dev/cu.usbmodem1411 crw-rw-rw- 1 root wheel 18, 90 Jan 31 22:36 /dev/tty.usbmodem1411

And serial monitors/terminals connect to the cu or tty devices (which are two versions of the same port). The terminal emulator, and the mpide serial monitor, and avrdude all connect to /dev/cu.. Using minicom I have tried both /dev/tty and /dev/cu*, without any change in behaviour.

Everything works fine if I compiled the USB/Serial program with an older version of mpide, but if I use the recent versions, I get the behavior I described: Serial data sent to the Fubarino is received by the Fubarino. Serial data sent out by the Fubarino does not get to the mac.

Cheers Hugh


pito

Fri, 31 Jan 2014 14:37:55 +0000

So it seems the fubarino sends data via tty and receives data via cu.. :)


hughanderson

Fri, 31 Jan 2014 14:41:28 +0000

Hi Pito,

No - that is not how tty and cu work. And I have tried using minicom on both of them anyway. Do you have a mac?

Cheers Hugh


pito

Fri, 31 Jan 2014 14:43:03 +0000

Negative.. I cannot help you with Mac.. :( Last time I had Mac on my desk was in June '92..

When you re-boot the fubarino, the minor device number goes up, but the device name is unchanged

That is suspicious, though..


hughanderson

Fri, 31 Jan 2014 15:10:13 +0000

Possibly suspicious, but I just reverted to the older mpide, and reprogrammed my fubarinos, and notice that they exhibit the same behaviour (i.e. the number goes up each time the port is re-created).

I guess I'll see if the older version of mpide can do what I want to do...

Cheers Hugh


pito

Fri, 31 Jan 2014 16:22:53 +0000

Mind the MPIDE and the bootloader and your code are 3 different things. The bootloader is also the one messing with the usb stuff. So try to isolate the bootloader version, which shows the issue (needs to be flashed in with pickit2 or pickit3). https://github.com/chipKIT32/PIC32-avrdude-bootloader/tree/master/bootloaders


hughanderson

Sat, 01 Feb 2014 01:52:56 +0000

Hi - re bootloaders - I have two different types of Fubarino SDs, and both exhibit the same problem - one is the Microchip and the other the Seeed. They both have the bootloader they came with.

I used my PicKit3 to flash in the latest bootloader from Seeed: https://github.com/fubarino/fubarino.github.com/raw/master/sd/files/BL_1_1_6_FuncTest_1_0.hex

This caused no change to anything. The problem still exhibits. I tried one more mac here at home, with fresh installs of everything, and it also behaves in the same way. The older version of mpide with its compiler/libraries works fine on all platforms. The newer version has broken USB/Serial.

Can anyone else with a mac, and a fubarino SD, confirm (or otherwise) the behaviour?

Cheers Hugh


ricklon

Sat, 01 Feb 2014 23:43:52 +0000

It's definitely an issue on Mac OS X. I've confirmed it by attempting to read from my Mac OS X machine and unable to get the serial data to show. Then I ran VMware and ran linux and the serial data was available without problem.

I'm filing an issue on github, and reviewing the history of changes for the HardwareSerial_cdcacm.* files.

Here's the history of the HardwareSerial_cdcacm.h: https://github.com/chipKIT32/chipKIT32-MAX/commits/master/hardware/pic32/cores/pic32/HardwareSerial_cdcacm.h

This is the history for the HardwareSerial_cdcacm.c: https://github.com/chipKIT32/chipKIT32-MAX/commits/master/hardware/pic32/cores/pic32/HardwareSerial_cdcacm.c


ricklon

Sat, 01 Feb 2014 23:45:25 +0000

The issue is logged here: https://github.com/chipKIT32/chipKIT32-MAX/issues/402

Code changes, fixes, and bug discussion can be held there as needed. I'll make confirmation is updated here as well.

--Rick