programming under OSX

I finally got around to buying one of the new programming cables that was released last year. The good news is that it does implement the USB communications class correctly (unlike the cortex), the not so good news (which I suppose we already knew from the windows driver ini file) is that it still uses the microchip vendor id and the product id that was part of a micochip example program for their USB demo boards. The new cable works well under OSX without needing any drivers but I thought I would have another quick look to see if the cortex could also be made to simulate a serial port.

So what’s the difference between the two USB implementations?

Here is an extract from a microchip app not that describes how a communications device implementing the ACM (abstract control model) should be setup.

I highlighted one part which is key to understanding why the USB programming cable works under OSX and the cortex does not. Using an OSX developer utility called USBProber we can have a look at the USB device descriptors.

Here is the output when using the programming cable.


and the cortex


Notice that the programming cable implements the two interfaces required by the spec whereas the cortex does not.

Windows is less picky about this than OSX which is why everything works correctly there. OSX starts two separate drivers, one for the control interface and one for the data interface, this doesn’t work with the cortex as two drivers cannot open the same interface. I have written some application code in the past that does talk to the cortex over USB, the actual data exchange is still sort of CDC compliant, the same messages are sent so there is hope for a simple driver.

Other CDC devices also have this problem, one in particular is a USB to serial converter from Texas Instruments that is used on several eval boards they sell. There is a modified CDC driver for OSX that combines both control and data drivers into one for these boards, it may be possible to adapt this to work with the cortex and avoid writing the whole driver from scratch, the question is does anyone actually care? Do we need a driver for direct programming of the cortex with a USB A-A cable or is everyone happy using the programming cable via the joystick?

(of course the best solution would be new firmware for the cortex with a compliant CDC implementation, not going to happen I’m afraid)

1 Like

The Cortex is using an example device ID from some dev kit?

Why am I not surprised -_-’

Just… IFI just silently fix this one in an update. I don’t have the time or energy to start a debate on this but in short, for correctness sake my vote is to ask them nicely if they could bump it onto a short term to do list and get it fixed. This isn’t a big issue but it should be fixed, like I said for correctness sake alone is reason enough.

James I wouldn’t rewrite the driver just yet, OS X users aren’t dying on the street because of this one. I’m still fighting a one sided war with Apple over the ability to set my own mouse acceleration curve (and losing I might add).

Once again thanks for making us aware of another neat quark these are always a fun read. -Cody

The USB programming cable has product ID 0x000a, this was used by the microchip example code. Here it is

/* Device Descriptor */
    0x12,                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_DEVICE,  // DEVICE descriptor type
    0x0200,                 // USB Spec Release Number in BCD format
    CDC_DEVICE,             // Class Code
    0x00,                   // Subclass code
    0x00,                   // Protocol code
    USB_EP0_BUFF_SIZE,      // Max packet size for EP0, see usb_config.h
    0x04D8,                 // Vendor ID
    **0x000A,                                   // Product ID: CDC RS-232 Emulation Demo**
    0x0100,                 // Device release number in BCD format
    0x01,                   // Manufacturer string index
    0x02,                   // Product string index
    0x00,                   // Device serial number string index
    0x01                    // Number of possible configurations

The cortex uses product id 0x000b, the joystick uses 0x000c. (0x000b was some type of A-D converter according to the USB database I was looking at). I guess they just used sequential numbers for the cortex and joystick after developing the new cable.

I don’t know what exactly is in the programming cable as it is glued together (no screws) but it’s probably a PIC. The cortex may be able to be upgraded, it really depends on how the USB is implemented in the NXP processor it uses for this interface.

It does bug me a bit that IFI did not get their own vendor id, microchip used to allow the use of their vendor id for small production runs but you were still supposed to get a unique product id from them. In the quantities that IFI sells they would not have qualified from what I have read. Anyway, it too late to fix this at this point.

1 Like

So I found this poor Mac guy dying on the street and he said “please write a driver for OSX” so I did.

Version 0.9 is done, serial communication using the USB A-A cable direct to the cortex under Snow Leopard. It needs some more tweaking and testing under 10.7 and 10.8 but it seems to work. The driver only loads when it detects the cortex, the standard Apple CDC ACM driver is used for the programming cable, I need to make sure everything is playing nicely together so will not release for a few days.

Shows under /dev as another tty port, didn’t decide on the final naming yet.


1 Like

Any chance of finding a similar poor Linux guy?

1 Like

I don’t really do much with Linux. There was a link somewhere explaining why they disabled this VID/PID combo, otherwise it may work as it does with windows (although having hacked this driver together I don’t understand why it even works under windows, need to take a look at the setup file again). The thing is, I always use the programming cable to the joystick which is why I never did this before, there’s not much demand. I have not tried it with the PROS flash loader yet, I don’t know what they use to select which port to use.

1 Like

That was excellent :smiley:

1 Like

I’ve tested as much as I can today, works with Leopard (different installer) through Mountain Lion.

I changed the name of the serial device back to /dev/tty.usbmodemxxxx (where xxxx will be a unique number that depends on which USB port you plug into) so as to be compatible with the PROS flash utility. I preferred the /dev/tty.cortex name but PROS would not detect that as a suitable serial port so usbmodem (which is Mac default) it is. It also works with the stm32flash open source utility I released last year but the PROS utility seems more stable.

Install using the normal Mac package installer, it places a single kernel extension called VexCortexCDC.kext in the /System/Library/Extensions folder. The package is code signed so you should be able to install on 10.8 if the security setting is not set to App store only, the kext is not code signed so may not work on 10.9 when it is released, don’t know yet.

To uninstall just delete the extension as admin (don’t mistype this) and reboot.
sudo rm -r /System/Library/Extensions/VexCortexCDC.kext
in fact, change to the extensions directory and then remove, less chance to screw up.
cd /System/Library/Extensions
sudo rm -r VexCortexCDC.kext

.dmg with separate installers for 10.5 and 10.6-10.8 is here.
(if I do an update this link will be dead so read further down the thread for the new one).

The driver is based on the Apple driver that shipped with Lion (all the Apple code is open source) that was modified by a hobbyist for the Texas Instruments MSP430 launchpad eval board and then further modified by me for the cortex (quite a few mods). So far it works well but only a few hours of testing so consider it a Beta release. There were some comments with the MSP430 version about swamping the driver with data but I did not see anything like that yet. I will put the source up on github at some point when I consider it stable. Purdue, include it with PROS if you want to.

If you run into issues let me know but this will probably be unsupported code, testing on multiple system software versions is a real PITA and not something I want to be doing much. I wrote this mainly for my own amusement but probably won’t actually use it much as I always download through the joystick.

1 Like

A version compatible with 10.9 was released today, I’ve moved discussion of the driver to this thread to help the forum search function.
10.9 (and previous OS versions) driver is here, the old link is dead.

1 Like