Virtual COM/USB CDC for OSBDM/OSJTAG

Many new notebooks do not have a serial port any more: everything is USB. This can lead to problems (see USB or not: CDC with Processor Expert) as many embedded targets  use normal RS-232. In my classes I’m using the Tower boards: some Tower boards have an on-board 2 pin RS-232 header, e.g. the Tower TWR-MCF52259. Others like the TWR-K60N512 use the added TWR-SER board. The Tower boards have as well a USB capable S08JM60 which is used for debugging (OSBDM/OSJTAG), so why not using the OSBDM microcontroller as Serial-to-USB gateway?

The good news is: P&E just has released a new version of the Open Source OSBDM/OSJTAG firmware which enumerates as a USB CDC device on the host PC: that way the target microcontroller can use the OSBDM/OSJTAG device on the board to communicate with the host. OSJTAG/OSBDM acts as a Serial-to-USB converter :-).

The steps below explain how to install and use the feature with CodeWarrior for MCU10.2.

Downloading new Firmware

First, I need updated OSBDM/OSJTAG firmware. It is available from http://www.pemicro.com/osbdm. On that site I select ‘Firmware Updates & Recovery’:

PnE Firmware Updates and Recovery

P&E Firmware Updates and Recovery

This will ask me to sign into my P&E user account. You can request your own user account with ‘Create New Account’ link:

P&E Login

P&E Login

The next step is to download the firmware_updater_install.exe (around 8.2 MB):

P&E File Download

P&E File Download

The next step is to install the software. If there is an earlier version of the firmware updater, it needs to be uninstalled first: the installer will take care about this.

Flashing new Firmware

After everything is installed: let’s run the P&E Firmware Updater Utility from the shortcut created:

Run P&E Firmware Updater Utility

Run P&E Firmware Updater Utility

I have my board connected to my laptop, and I use in the screenshots the TWR-MCF52259. Under point 1) I select OSBDM/OSJTAG:

Upgrading OSBDM/OSJTAG Firmware from V30 to V31

Upgrading OSBDM/OSJTAG Firmware from V30 to V31

Under point 2) it lists my connected board with the firmware version (30 in this case). The firmware version which has USB CDC support is version 31 (point 4). So I’m going to update my existing firmware version 30.21 to the new version 31.

I press the ‘Update Firmware‘ button. This will prompt a dialog to set the OSBDM/OSJTAG bootloader jumper:

Dialog to enable bootloader mode

Dialog to enable bootloader mode

The bootloader jumper is labeled BTLD on my board:

TWR-MCF52259 with OSBM Bootloader Jumper

TWR-MCF52259 with OSBM Bootloader Jumper

Tip: In case no jumper is at hand, there is a trick. The bootloader jumper is only checked at power-up of OSBDM. No need to shortcut it all the time. I help myself with a paperclip to shortcut the jumper right at power-on-reset 🙂

I disconnect the board, set the jumper and power again the board.

Note: All LEDs on the board will be off!

Windows will install the drivers for the bootloader (if not already installed). Then after pressing OK, the bootloader will flash the new firmware:

Updating Firmware

Updating Firmware

After that, a dialog asks to enter run mode again:

Dialog to enter run mode

Dialog to enter run mode

So unpower again, removing the bootloader jumper, power the board again.

If everything was going fine, this is indicated in the dialog:

Success

Success

Connecting the board to the host will start a new USB enumeration, and drivers get installed:

Driver Software Installation

Driver Software Installation

Now the board should enumerate as CDC Serial Port in the Windows Device Manager:

CDC Serial Port in Device Manager

CDC Serial Port in Device Manager

Ready to use that board with that CDC Serial Port…

USB CDC with OSBDM on TWR-MCF52259

First I need to find out how the RX an TX lines of the OSBDM/OSJTAG are connected to my microcontroller. For the TWR-MCF52259 this looks like this:

TX and RX on OSBDM JM60 (Source: Freescale, TRW-MCF52259 Schematics)

TX and RX on OSBDM JM60 (Source: Freescale, TRW-MCF52259 Schematics)

Following the signals: I need to set the jumpers J12 and J13 to the 2-3 position to connect the MCU_TXD0 and MCU_TXD0 lines to the S08JM60 which runs the OSBDM:

TXD and RXD jumpers on TWR-MCF52259 Board (Source: Freescale, TWR-MCF52259 Schematics)

TXD and RXD jumpers on TWR-MCF52259 Board (Source: Freescale, TWR-MCF52259 Schematics)

Example Project

First, I want to verify that things are working with the normal RS-232 UART. I create a test project which writes to the console. The simplest thing is to create a Processor Expert project and using the Term component:

Term Component

Term Component

The TWR-MCF52259 board is using the UART0 for the on-board serial connector, and I configure it for 38400 baud:

TWR-MCF52259 onboard serial port settings

TWR-MCF52259 on-board serial port settings

The test program is simple: writing a string to the terminal in an endless loop:

static void TestSerial(void) {
  int cnt = 0;

  for(;;) {
    Term1_SendNum(cnt);
    Term1_SendStr(" Hello World!\r\n");
    cnt++;
  }
}

First, I try this with the UART0 signals routed to the physical COM port on the board, having J12 and J13 set to the (default) 1-2 position:

TWR-MCF52259 with Jumpers to route SCI signals to physical COM

TWR-MCF52259 with Jumpers to route SCI signals to physical COM

The menu Window > Show View > Terminal opens a terminal program which I configure to use COM1. And voilà: my test program writes to the physical COM1 port :-):

Console output on physical COM port

Console output on physical COM port

Now the same application shall work with the serial lines routed to OSBDM. Now I change the jumpers J12 and J13 to the 2-3 position:

TWR-MCF52259 with Jumpers to route SCI signals to OSBDM

TWR-MCF52259 with Jumpers to route SCI signals to OSBDM

Now connecting to the virtual COM port 37, and it works through OSBDM and USB too :-):

Console output on virtual COM port

Console output on virtual COM port

Note: it seems that some terminal applications have problems to keep up with the traffic coming from a virtual COM port. I’m able to crash e.g. Termite, but it works fine with the the built-in Eclipse Terminal view. So if you see issues with the P&E OSBDM/OSJTAG USB CDC implementation, it is likely that there is a problem in the terminal program, not in OSBDM/OSJTAG.

USB CDC TWR-MCF51CN128

Now trying the TWR-MCF51CN128. This one was one of the first Tower boards available, and very similar to the TWR-52259 one: it has as well two jumpers to direct the UART traffic either to the on-board 10pin header or the OSBDM S08JM60. However, I was not able to get the UART  traffic routed through OSBDM. I’m not sure, but this could be a problem of the board and the circuit on it? At least it is not working for me :-(.

USB CDC with OSJTAG on TWR-K60N512

Next board to try is the TWR-K60N512. This board had no on-board serial connector. So if I want to use a terminal with this board (without the TWR-SER), I really need USB CDC over OSJTAG. As for the TWR-MCF52259 board, I need to upgrade the firmware on the board. The schematics for the board is different: no jumpers for the serial bridge:

TWR-K60N512 OSJTAG Serial Bridge

TWR-K60N512 OSJTAG Serial Bridge (Source: Freescale, TWR-K60N512 Schematics)

The schematics tell me that TX and RX lines are connected to PTE8 and PTE9 of UART5 on the K60 microcontroller:

UART5_TX and RX on TWR-K60N512 (Source: Freescale, TWR-K60N512 schematics)

UART5_TX and RX on TWR-K60N512 (Source: Freescale, TWR-K60N512 schematics)

This time I’m going to change my SD Card application for K60 to use the serial bridge. For this I disable the existing AS1 Serial_LDD (which was using the serial port on the TWR-SER) and add a AS1 to connect to the serial bridge:

K60 SD Card Application with to AS1 - one for physical serial port, and one for serial bridge

K60 SD Card Application with to AS1 – one for physical serial port, and one for serial bridge

The new Serial_LDD is configured to use the UART5:

Using UART5 for OSJTAG Serial Bridge

Using UART5 for OSJTAG Serial Bridge

And within minutes, I have the application running on the board, using the virtual bridge on COM37 :-):

FatFs Application on K60 with serial bridge on COM37

FatFs Application on K60 with serial bridge on COM37

The cool thing is that now I do not need the TWR-SER any more: I can run my application with shell support run on a single board, with a single USB connection for power, debug and console:

TWR-K60N512 with FatFs SD card application running with Serial Bridge

TWR-K60N512 with FatFs SD card application running with Serial Bridge

🙂

Summary

What P&E has added to OSJTAG/OSBDM in their latest firmware is a big step and improvement for me: Now I can use a single connection for power, debug and terminal connectivity. If I have OSBDM/OSJTAG on my board, then I can avoid to run a native USB CDC stack. That makes my life much simpler and easier. And with the exception of the TWR-MCF51CN128, it works perfectly for the TWR-K60N512 and TWR-52259.

Happy Virtualizing 🙂

Advertisements

21 thoughts on “Virtual COM/USB CDC for OSBDM/OSJTAG

  1. Pingback: A Shell for the Freedom KL25Z Board | MCU on Eclipse

  2. Pingback: OpenSDA on the Freedom KL25Z Board | MCU on Eclipse

  3. Pingback: Fixing the USB Drivers | MCU on Eclipse

  4. Pingback: Tutorial: printf() and “Hello World!” with the Freedom KL25Z Board | MCU on Eclipse

  5. Pingback: DIY Free Toolchain for Kinetis: Part 3 – Debugger (GDB Server with P&E and Segger) | MCU on Eclipse

  6. Just wanted to add here: I couldn’t get the firmware 3121 (latest as of 11/2013) to work – it actually directly adds a serial COM port, but it won’t start. When I went back to the 3021 firmware, which shows up under Jungo as a PEMicro USB Serial port, then it works properly. This is with Windows XP Pro SP2, and a TWR-K20D50M. Fortunately the latest firmware download from PEMicro has the old firmware in an archive folder, so it’s easy to update.

    Like

  7. Wow, this is a very enlightening post, I was looking for a way to upgrade my TWR-K60N512 kits (I have 15 of them for a lab) and I ‘stumbled upon’ this post. I love the USB CDC over OSJTAG.
    I am actually writing a blogpost, I managed to run OpenOCD and GNU-ARM to debug this kits in Linux without using the other FRDM-KL25Z kits, directly using the onboard debugger. I dont know why for a long time i had no idea i could do that, no idea OpenOCD supports osbdm :), it was an Eureka moment

    Like

  8. Pingback: TWR-K60N512 full debug with OpenOCD and GNU-ARM in Linux >> Karibe

  9. Pingback: Step-by-Step: Updating OSBDM/OSJTAG Debug Firmware | MCU on Eclipse

  10. I’m new in the freescale and i have k60f120m board , i want to know how i can write a code to blink the LEDs without using the MQX .Thank you

    Like

  11. Hello,

    I have TWR-MCF51CN board and I have problem with bootloader mode in it. When I want to update my firmware by P&E firmware updater I have to use jumper on J16. When I’ve done it my device become undetected. When I use CodeWarrior v10.6.4 it also makes update of my firmware and it’s the same problem. It happens when I reconnect my board with jumper on. Any LEDs light off. Without jumper on J16 my device is detected. I’m using Mini USB cable as debugger.
    Greetings,

    Pawel.

    Like

    • Hi Pawel,
      I have not used my TWR-MCF51CN board for a while. But this was one of the first tower boards, and I remember that I had issues with updating the bootloader/firmware. If I remember correctly, I had to use the P&E firmware upgrade utility with a P&E Multilink/programmer with using the BDM connector on the board. Updating through the debugger/bootloader was not possible at least with newer versions of the P&E software. Maybe this is the problem you are facing?

      Like

  12. Thanks for the good documentation.

    Now I have a TWR-K21F120M and will only use the serial port. I have a iSystem debugger connectet to the JTAG/TRACE.
    When I connect the USB to the OSJTAG than is the JTAG enabled wihtout connection of a debugger to this.
    How can I disable this? At the moment exists no jumper or resister which I can use to disable the OSJTAG JTAG interface.
    I need only the RS232 interface.

    Regards,
    Bernd

    Like

      • Hi Erich,

        that disable only the TDO signal from JTAG. Disabled this also inside of the OSJTAG firmeware the JTAG OUT_EN signal?

        It would be better if the signal OUT_EN (U200 Pin 15) can be disabled via a jumper.
        Or when the OSJTAG firmeware dosn’t enable the JTAG signals when no debugger is connected via USB.

        At the moment I can’t remove this resistor, other users of this hardware need this JTAG interface. Exists a firmeware, which only supports the UART via USB?

        Bernd

        Like

      • Hi Bernd,
        you can reprogram the JM60 on the board with any firmware you want, there is a BDM connector for it on the board. The OSBDM firmware itself is open source too, it should be available somewhere in the Freescale forums.
        Erich

        Like

  13. Hi Erich,
    OK, I can write my own firmeware for this CPU. That is not what I will do.
    Who created the OSJTAG firmeware? So I can ask directly for this changes.
    Bernd

    Like

  14. Pingback: TWR-K60N512 full debug with OpenOCD and GNU-ARM in Linux >> Karibe

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s