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’:
This will ask me to sign into my P&E user account. You can request your own user account with ‘Create New Account’ link:
The next step is to download the firmware_updater_install.exe (around 8.2 MB):
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:
I have my board connected to my laptop, and I use in the screenshots the TWR-MCF52259. Under point 1) I select OSBDM/OSJTAG:
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:
The bootloader jumper is labeled BTLD on my board:
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:
After that, a dialog asks to enter run mode again:
So unpower again, removing the bootloader jumper, power the board again.
If everything was going fine, this is indicated in the dialog:
Connecting the board to the host will start a new USB enumeration, and drivers get installed:
Now the board should enumerate as CDC Serial Port in the Windows 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:
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:
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:
The TWR-MCF52259 board is using the UART0 for the on-board serial connector, and I configure it for 38400 baud:
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:
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 :-):
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:
Now connecting to the virtual COM port 37, and it works through OSBDM and USB too :-):
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:
The schematics tell me that TX and RX lines are connected to PTE8 and PTE9 of UART5 on the K60 microcontroller:
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:
The new Serial_LDD is configured to use the UART5:
And within minutes, I have the application running on the board, using the virtual 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:
🙂
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 🙂
Pingback: A Shell for the Freedom KL25Z Board | MCU on Eclipse
Pingback: OpenSDA on the Freedom KL25Z Board | MCU on Eclipse
Pingback: Fixing the USB Drivers | MCU on Eclipse
Pingback: Tutorial: printf() and “Hello World!” with the Freedom KL25Z Board | MCU on Eclipse
Pingback: DIY Free Toolchain for Kinetis: Part 3 – Debugger (GDB Server with P&E and Segger) | MCU on Eclipse
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.
LikeLike
Thanks. This might be because of Windows XP. I have seen recently a growing number of issues with XP especially with driver installations. The 3121 works for me under Windows 7. But there is a known issue with the bootloader and Windows 8.1 (it works on 8.0): https://mcuoneclipse.com/2013/10/12/frdm-board-bootloader-fails-with-windows-8-1-preview/
as of today, there is no fix for it yet. So to me still Windows 7 is the best choice.
LikeLike
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
LikeLike
Pingback: TWR-K60N512 full debug with OpenOCD and GNU-ARM in Linux >> Karibe
Pingback: Step-by-Step: Updating OSBDM/OSJTAG Debug Firmware | MCU on Eclipse
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
LikeLike
Have a look at https://mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/
The article is for the FRDM-KL25Z, but things are applicable for your board too (just use different pins for your LED’s).
I hope this helps,
Erich
LikeLike
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.
LikeLike
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?
LikeLike
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
LikeLike
Hi Bernd,
there are a few zero ohm resistors on the board (e.g. R39) you could remove. Not sure if this would be enough.
Erich
LikeLike
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
LikeLike
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
LikeLike
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
LikeLike
Freescale did, there is as well a forum
LikeLike
Pingback: TWR-K60N512 full debug with OpenOCD and GNU-ARM in Linux >> Karibe