Debug External Processors with USBDM and Freedom Board
Join the DZone community and get the full member experience.
Join For Freeteaching at a university means to work in a very special environment. what students love is ‘open source’: because it allows them to ‘see’ things and learn from the technology. the other thing is: students have a low budgets, so they appreciate if they can use inexpensive or low-cost hardware and software. the frdm-kl25z freedom board for sure meets that low price, and no extra programming device needed.
now they are building their own boards, and they wish to program and debug it. they can borrow the segger j-links and p&e multilinks we have available at the university. but why not use the freedom board as ‘hobby’ debug and programming solution? as explored in “ using the freedom board as swd programmer “, they can use the default factory installed opensda to program another microcontroller of same type. but not to debug it.
while writing the ”
using the freedom board as swd programmer
” article, i was looking into
usbdm.
usbdm has added in january 2013 support for opensda. but at that time, it was somehow not working for me, and i had not enough time to find out what the problem was. time to get that fixed. good news: with help and tips from the usbdm community, i have it finally working
usbdm is a free open source (gplv2) debugging/programming interface for a range of freescale microntrollers.
note: usbdm is *not* o sbdm. osbdm (or osjtag) is an older ‘free’ debugging interface present on many of the freescale tower boards .
it currently supports codewarrior and codesourcery eclipse. with it, i wanted to overcome the opensda limitation and using it as general purpose debug/programming device with codewarrior for mcu10.3 .
usbdm comes with a standalone flash programmer and scripting engine. but i had not had the time to look into that (yet).
installation
the installer is available for download from http://sourceforge.net/projects/usbdm/files/version%204.10.4/installation/ (usbdm_4_10_4a_win.msi).
initially i had used the usbdm_4_10_1_win.msi (the one without the ‘a’. it worked at the beginning, somehow i ran into connection problems later on. note sure what has caused this, maybe the problem i describe at the end of this post. so i decided to go with a fresh mcu10.3 (b121211), installed the usbdm_4_10_4a_win.msi, and since then things are working ok.
the setup provides the flexibility only to install what is needed:
in above dialog, i need to verify/specify the path to my codewarrior installation.
i would have expected that this would install the drivers for me too. maybe it does, but it did not work for me. what i had to do is download the usbdm_drivers file ( usbdm_drivers_1_0_1_win_x64.msi for my windows7 64bit machine) from http://sourceforge.net/projects/usbdm/files/version%204.10.4/installation/ and to install it.
not sure if this was just a problem with my machine, but: afterwards my opensda/osbdm/osjtag device drivers did not enumerate properly. i had to browse to the driver files e.g. in c:\freescale\cw mcu v10.3\drivers\p&e\drivers\osbdm to have them installed again.
opensda usbdm firmware installation
for opensda, i need a special firmware. i did download the usbdm_opensda firmware zip file:
then updated the firmware on the freedom board, following the instructions in the opensda.txt in the archive. after that, the device should enumerate properly as “usbdm bdm interface”:
codewarrior for mcu10.3
if everything is working out, you should have now an extra connection setting in the ‘new bareboard project’ wizard:
i don’t know why, but for whatever reason this option and the corresponding functions (debug connections) were not showing up in codewarrior first. since i tried it the first time (and it did not work), i have for sure rebooted my machine. fact is: it is working now
. so if you see the same issue, maybe a reboot or re-running the setup will help.
to verify that things are properly installed, i can check the plugin using the help > about dialog, then press ‘ installation details ‘ button:
it adds a new connection type to the codewarrior debugger: usbdm arm interface
it is very easy to switch between the original opensda and usbdm: simply ‘usbdm arm device’ from that drop-down box.
by default, it has set up a connection speed of 1.5 mhz: i was able to increase it to 12 mhz and that worked fine:
using usbdm as swd debugging probe (frdm-kl25z to frdm-kl25z)
to use usbdm on frdm-kl25z to debug another external processor, following is needed
- having a 10pin arm cortex debug (swd) header populated on two boards
- connecting the two boards with a 10pin flat cable
- having j11 cut on the ‘master’ board to disconnect the swd clock from the resident processor
- no change needed on the ‘slave’ board to be debugged.
and indeed: this worked
: i’m able to use my usbdm to debug the other kl25z freedom board:
frdm-kl25z debugging frdm-k20d50m
debugging the frdm-k20d50m with the frdm-kl25z the same way as debugging the the frdm-kl25z above:
as above, the ‘master’ boards needs to have the j11 trace disconnected.
using frdm-kl05z to debug an external board
next one is the
frdm-kl05z
. however, this did not work out of the box. until i have found
this post in the freescale forum
: the problem is a wrong wiring to the j6 header: the opensda signal from u4 goes to pin1 of j6, and this pin1 goes as well to the kl05z. this means that it is not possible to disconnect the opensda from the kl05z
. the solution is to cut a trace and connect it to either pin 4 of j1 (swd header) or to pin2 of j1. i did the second solution.
first, i need to cut the j6 trace:
i always install a jumper afterwards so i can ‘undo’ the cut.
for the next step, a magnifying glass or a microscope is a good thing, plus some good soldering skills
: i need to re-route the pin11 from u4 to pin2 of j6. for this i need to cut the trace just before the via hole to the kl05z:
after that, install a wire to route the pin11 of u4 to pin2 of j6:
instead to pin2 of j6, the signal can be routed to pin4 of j1 instead. but j6 was much easier to do for me.
with this, the frdm-kl05z is prepared to debug an external processor:
- with j6 removed, i can debug an external processor
- with j6 installed, i debug the kl05z processor on the frdm-kl05z board
same way it works to debug the frdm-k20d50m:
note:
i have not managed to debug the changed frdm-kl05z say from the frdm-kl25z or frdm-k20d50m. i’m using a pre-production board here, so this might be the reasons. i can debug the other freedom boards with the frdm-kl05z, just not the other way round.i have solved this problem, see “ debugging frdm-kl05z with usbdm “.
frdm-k20d50m debugging frdm-kl25z
this time the frdm-k20d50m hooked up to the frdm-kl25z: for this i have to cut/remove the jumper j11 on the frdm-k20d50m:
why a ‘professional’ probe is a good thing: ‘bad’ frdm-kl25z board
then i tried it with another frdm-kl25z board: a student used that board in my class, and somehow managed to break the opensda on it: it keeps staying in msd bootloader mode, and cannot be debugged through opensda.
so tried to debug that board with usbdm too, but i received “failed to resume target process” error message:
i tried different powering (just in case) and even have cut the j11 and j3 to disconnect opensda power and swd clock:
but this did not help
.
however, with the p&e multilink i’m still able to debug that board with the swd debug header
. so there are definitely good reasons to use a probe like this: to recover from cases where usbdm cannot help. as always: as second source and backup is what an engineer always needs.
the other problem i was running into was this one with a 60 kbyte application:
not sure if i have hit a limit, but after that i had to restart eclipse to recover from this issue, as any other usbdm debug session failed. maybe it has corrupted the dll? in any case, i need to follow up on this.
summary
with usbdm, i have an open source run control solution with codewarrior and the freedom boards. so far i just have explored opensda freedom boards, but it should support boards and microcontroller beyond that: i can now download *and* debug other microcontroller with the freedom board
. what i’m missing with usbdm is the
usb cdc support which the original opensda provides
(or i have not seen how to enable that).
while ‘professional’ solutions like p&e and segger worked for me out of the box, i had to invest time to get usbdm up and running. after that, it was working nicely. spending that extra time is like with any other open source projects i did or used: i trade in time for less costs, or to learn new things on return. i hope that this article saves you some time and is useful for you.
many thanks and kudos to pgo , dieter and brion for their help and posts, and all the ones who developed usbdm!
happy usbdming
links
- usbdm version 4.10.4 announcement: https://community.freescale.com/thread/303257
- usbdm documentation on sourceforge: http://usbdm.sourceforge.net/
- usbdm project on sourceforge: http://sourceforge.net/projects/usbdm/
- usbdm sources on github: https://github.com/podonoghue
- usbdm/osbdm discussion forum: https://community.freescale.com/community/bdm
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments