Self-Motivation: I write this post in the hope to cut the number of ‘please help me’ emails in my inbox ;-):
If you want to debug one of the Freescale boards with OpenSDA (FRDM-KL25Z, FRDM-K20, FRDM-KL05Z, FRDM-KL46Z48M, FRDM-KL02Z, TWR-KL47Z48M, …), and if you get this dialog …
… then read on.
The error in CodeWarrior says
“An error occurred while connecting to the interface hardware or target specified in the Launch Configuration Dialog. For this launch, you may retry/re-specify the connection with the following parameters: OpenSDA – USB Port, (No Device Available).”
A different but similar dialog is shown by IAR debugger:
The problem is: the debugger cannot find the board. You get that error as well if the board is not connected. Assuming that the board is ok, connected and powered, then the problem is a not obvious one (at least not to new users of the Freedom boards or OpenSDA):
❗ The Problem is that the board is in OpenSDA MSD Bootloader mode ❗
What is that? You might have read my OpenSDA article, and then you probably know by know. The board is shipped by default with the ‘MSD (Mass Storage Device’ Bootloader) on it. That MSD Bootloader allows to program an application (S19 file) to the board without debugger. You can see this with the board showing up as a drive with files on it:
Why is that the default? I don’t know! I really don’t know, as I would expect debugging is the first thing I would do with a board? In order to debug the board, it needs to be loaded with the P&E Debug-APP_Pemicro*.SDA application.
💡 The P&E Debug-APP is not the only possible debug application (firmware). Other alternatives are for example Segger OpenSDA, USBDM, or CMSIS-DAP OpenSDA.
Changing the Board for Debugging (P&E OpenSDA)
To debug the board, the OpenSDA Debug Application needs to be programmed first:
- Make sure the board is not powered
- While pressing the reset button, power the board with the OpenSDA USB port
- The board enumerates as BOOTLOADER drive on the host, and the green LED is flashing.
- Download the FRDM-KL25Z quickstart package from http://www.freescale.com/freedom web page (for your board). That package has an older P&E OpenSDA debug firmware (the most recent is on P&E OpenSDA site, I have DEBUG-APP_Pemicro_v106.SDA).
- Copy DEBUG-APP_Pemicro_vxxx.SDA file from the pack to the BOOTLOADER drive. You need to unpack the file to your hard disk first. You can copy the file with the windows explorer, but on some systems this fails. Use the DOS shell copy command instead in this case.
- Unplug the cable and repower the board with the OpenSDA debug port (without pressing the reset button!)
Then finally you can debug the board. In the debugger, you might need to press the Refresh button:
Changing the Board back to MSD Bootloader (P&E OpenSDA)
To revert the board back to the MSD Bootloader mode (as originally shipped):
- Make sure the board is not powered
- While pressing the reset button, power the board with the OpenSDA USB port
- The green LED is flashing and the board enumerates as ‘BOOTLOADER’ drive
- Download the FRDM-KL25Z quickstart package from http://www.freescale.com/freedom web page (for your board).
- Copy MSD-FRDM-KL25Z_Pemicro_vxxx.SDA (e.g. MSD-FRDM-KL25Z_Pemicro_v105.SDA) MSD file from the pack to the BOOTLOADER drive. You need to unpack the file to your hard disk first. You can copy the file with the windows explorer, but on some systems this fails. Use the DOS shell copy command instead in this case. There are *different* files for each board, so be careful you select the right file for your board.
- Unplug the cable and repower the board with the OpenSDA debug port
- The board shall now enumerate as ‘FRDM-KL25Z’ drive
Now the board is in MSD mode, and you can copy S19 files to it.
❗ In case there are problems to copy files to the board (e.g. green LED is flashing with an error code: make sure you do not use an Explorer extension like File Manager or similar. The bootloader expects the file blocks in a given order, and virus scanner or file manager might interfere with this. In that case, use the DOS cmd shell copy command. The ‘copy’ command always worked for me.
Summary
With this post, I hope I can cut my inbox by several incoming emails a week of desperate OpenSDA users who are not able to debug their board. That would be a very good thing. And I wish boards would be shipped for debugging out of the box. I mean that MSD bootloader is a nice thing, but is not debugging the first thing I want to do with a board?
❗ UPDATE: There is a new firmware available (v114 or later) which solves the problem described here: that new firmware has a combined MSD bootloader and debug interface :-).
Happy Debugging (finally) 🙂
Just encountered today and finally digging little bit, followed like above earlier and now I see the article. good post 🙂
LikeLike
Good post Erich. Ran into that back in January and opened a ticket on it. All the student boards but 3 came back with no issue. We sent one back for factory test because it locked up completely.
LikeLike
Thanks man, this post helped me alot.
LikeLike
Good to hear that 🙂
LikeLike
excelente tutorial muchas gracias por compartir tu conocimiento!!!
LikeLike
what a waste of time I spent, and a zillion doc’s I read before I found this answer 😦
I was about to give up and go to another brand after 30+ years…
Surely a pdf with these details should ship with the board. And make it
clear that OpenSDA has multiple modes. i.e. debug and MSD.
LikeLike
Hi djam,
you are not the first one with this problem :-(. That’s why I wrote that article, and hoped that if someone googles for that error messsage, he might find the solution.
LikeLike
Hi Erich,
I’m experiencing this some error. I’m using Code Warrior 10.5 with a KL25Z. If confirmed that I have the PE Debug App loaded on the KL25Z, but I’m still unable to connect to the debugger to the board.
Can you suggest anything else I should check?
LikeLike
OK, I figured this out. Once I loaded the Debug App, I had to reconnect the USB cable to the FRDM board WITHOUT pressing the reset button.
LikeLike
Hi John,
ah, ok, problem solved :-). It was clear to me (but not to everyone) that the reset button has to be not pressed in the final step. I have added that to the instructions now, so thanks for this one!
LikeLike
Hey Erich,
I’ve followed your steps to set up the board for debugging but it’s not working. I’m copying the debug file to the bootloader directory, unplugging, plugging back in without pressing reset, but the bootloader directory just pops up again and I can’t debug in CodeWarrior. The green LED keeps blinking. I tried loading the MSD back as well and nothing happened there either. Any ideas?
LikeLike
Are you using Windows 8.1? That would explain the issues. Have a look at https://mcuoneclipse.com/2013/10/12/frdm-board-bootloader-fails-with-windows-8-1-preview/.
The solution is in https://mcuoneclipse.com/2013/12/14/new-pe-opensda-firmware-v114/.
But you will need a machine with a previous Windows version to change the bootloader.
LikeLike
Ah, yes I am using Windows 8.1. Thanks for the links…I used a Windows 7 machine to update the bootloader and firmware. I’m now happily debugging! Thanks so much Erich!
LikeLike
You are welcome. So yes, that Windows 8.1 change has suprised many (including myself) 😦
LikeLike
Thank you so much for writing this! Would you mind adding an update section to this post referencing your newer post (https://mcuoneclipse.com/2013/12/14/new-pe-opensda-firmware-v114)? I think it would be very valuable to anyone who finds this post to also be aware of the simultaneous debug & MSD interfaces present in the latest version. Thanks again!
LikeLike
Hi Steven,
thank you for that suggestion! I have updated the post and added a link.
LikeLike
Hi, I followed the steps in this post, but still cannot debug my frdm-kl25z board. I am on 64-bit ubuntu 15.10. Any other suggestions?
LikeLike
Hi aheak,
does the board properly enumerate? Did you try either the Segger or P&E firmware?
Erich
LikeLike
Erich, thank you for replying! I finally got it to work. I had to update bootloader firmware and app following your other posts. Now I am able debug and step the code and learn. Thank you for your posts.
LikeLike
Hi
I am also facing this kind of problem but my case is little bit different.
I am working with FRDM-KE02 board and had update the SDA and it was working fine, but after some time it stopped working.
Now, IAR is detecting the board but when I press connect it again asks to connect and so on.
same as the last pic of you post.
Pls let me know the solution…
LikeLike
I’m aware of cases where it is possible to lock/secure the board. See:
Maybe this is your problem? You might try to use CodeWarrior for MCU10 it can connect to your board.
LikeLike
Hmm, does not work. Itried Explorer and I tried cmd using copy. The files disappear. Now I’m sure freescale is having a laugh on me. I’m done with this crap, KL05Z & KE02Z for free anyone ?
LikeLike
Are you sure you have put the board into bootloader mode? What host OS are you using? if it is Windows 8.1, then there is this: https://mcuoneclipse.com/2013/10/12/frdm-board-bootloader-fails-with-windows-8-1-preview/
You need the V1.14 firmware and a Win7 PC, see https://mcuoneclipse.com/2013/12/14/new-pe-opensda-firmware-v114/
I hope this helps?
LikeLike
Yup, anything is fine now (why do I always have to get whiny first). I was stuck in the ‘hold reset down while plugging’ routine 🙂 Found out by accident and ‘bim-bam-bum – new hardware found’. Blinky actually blinks now. I also found some more documentation.
Thanks and again
have a nice weekend,
Stephan
PS: It’s Windows 7 HP
LikeLike
Alright then, good to hear you are up and running. I was worried you have Windows 8.1 😉
Seriously, I know that these little things can drive me cracy too. The good thing is that this gives a lot of experience over time, and can be used in other situations. So everything has a purpose 🙂
LikeLike
After two hours, Finally!! … Thanks man 🙂
LikeLike
i have been trying to debug for hours. I appreciated your post. Thanks a lot.
LikeLike
Hello,
you are welcome. I hope you are able now to debug?
Erich
LikeLike
Hi Erich
I have a bit of a weird problem here, wonder if you have come across it before.
I run OSX on the desktop, previously Linux. In the past, I have quite successfully run CodeWarrior on Windows XP virtual machines.
Trying to do the same, so I can play with a FRDM-KL46Z. If I boot the board, holding the reset button, it appears as a mass-storage device, and I can see all the USB details in the Mac’s System Information report. Likewise, if I plug into the other USB socket, it flags as USB-UART. (I can also connect to the demo code that reads the touch sensor, using screen.)
However, I have dropped DEBUG-APP_Pemicro_v108.SDA into the BOOTLOADER device, ejected it, reconnected the board – and it simply doesn’t enumerate. Nothing at all shows of it in the USB part of System Report – not even “unknown device.”
If I plug the board into a Linux server, nothing shows up in dmesg, or lsusb – exactly the same as it is for the Mac System Information.
I saw your article on issues with Windows 8.1, wondered if there’s something weird about the firmware the boards ship with. I therefore connected to a Windows XP virtual machine (still on the Mac) with the board in MSD mode, to attempt to repeat the operation. The file still appears to copy, but is no longer there after reboot, and the board remains “invisible.” (I even tried ejecting the MSD in Windows before disconnecting – no different.)
It’s like the firmware update simply isn’t happening. Restart, it’s gone.
Ideas?
M
LikeLike
I’ve answered my own question – it’s a known issue with Linux, OSX, Win8.1:
From P&E FAQ:
“Latest issue: Bootloader versions 1.10 and earlier are not allowing firmware update and MSD FLASH programming on my OpenSDA board, with the Linux, MacOS, or Windows 8/8.1 operating systems.”
My board appears to be old stock – the bootloader that came on the board is 1.09.
P&E again:
“Solution: Support for Windows 8/8.1, MacOS and Linux operating systems was added to Bootloader version 1.11 and MSD firmware version 1.14. Please make sure that your board is programmed with Bootloader version 1.11 or higher prior to attempting to update your OpenSDA board with a new firmware application.
Important: If you are currently running Bootloader version 1.10 or earlier, you will need to find a Windows XP or Windows 7 PC to perform this update.”
And looks like a Windows XP Virtual Machine isn’t up to the job 😦
M
LikeLike
Yes, boards from the factory have the old/original firmware on it. I use a Windows7 machine to update the bootloader (https://mcuoneclipse.com/2014/11/01/illustrated-step-by-step-instructions-updating-the-freescale-freedom-board-firmware/)
LikeLike
This is going to be interesting. The one physical Windows machine in the house – an old XP laptop – doesn’t recognise the MSD, even after installing latest P&E drivers
Think I might have to post my boards off to a friend who has Windows machines and get him to change the bootloaders for me.
Once again, P&E breaks a good Freescale product 😦
LikeLike
I disagree that this is the fault of P&E. We need to be fair here: It is is the fault of Windows/operating system in my view. Microsoft changed things. At the time when that bootloader had been developed, there was no Windows 8.x. Microsoft decided to write hidden folders to any MSD device to ‘accelerate’ the access. This confuses many MSD bootloaders, not only th P&E one. E.g. mbed has tons of problems with that issue too. Similar to MAC machines where the host tries to write files to the device. Conceptually this is a problem of MSD bootloaders. And as an implementer of such a bootloader you cannot know what Microsoft or Apple or whoever might change in the future. And it is in my view more of a Freescale fault that they still ship boards with old firmware on it (other vendors have that probelm too, btw) :-(.
LikeLike
I copied my Windows 7 VM (Virtualbox) over to my laptop, just to see if that would allow me to update the bootloader, and can confirm it does NOT.
So this is not possible with Windows XP or Windows 7 VMs, running on VirtualBox, on an OSX (Yosemite) host.
I think I may just return these boards to the vendor (Element14) and request replacement with parts with current firmware.
LikeLike
I cannot comment about Windows 7 in a virtual box, but it works for me with normal Windows 7.
LikeLike
My point was that, testing with the tools I have available, it appears that you have to have a PHYSICAL Windows 7 (XP/Vista) box to do this (which I don’t have.) Unlike a lot of other things that work under a virtual machine, like the P&E Multilink with older versions of CodeWarrior which works just fine, this doesn’t work at all. But I thought I should test it, just in case there was a way for those without direct access to a Windows system.
LikeLike
Hi Erich
FIXED! I have found out why this wasn’t working on OSX; what you said about the 1Hz blink made me suspicious, because that kept stopping. Also, I never saw the “copying” notification on the Windows VM.
The problem lies in OSX auto-mounting anything that looks like an MSD. Even ejecting, whilst the file system is visible in Windows, copying to it fails silently. The fix is to prevent the auto-mount the auto-mount from happening, allowing the Windows (I tried with 7) VM to get first and only access to the device. Bootloader update was then EXACTLY as described in your step-by-step post.
To prevent auto-mounting, you need a line like this in /etc/fstab:
UUID=443E64D9-F332-3461-9FEB-CA3A40D1DC65 none msdos rw,noauto 0 0
…although I’m not sure if the UUID is the same for every board, may need to check and change, if required.
But I now have a 1.11 bootloader 🙂
Thanks all your exhaustive documentation, which helped me find the solution – hopefully someone else will find this useful.
Cheers
M
LikeLike
Hello,
I have followed steps as per directed, but still I am getting “No Device Available”.
My device detected as OpenSDA-CDC Serial Port.
I am using code warrior and 32bit WIN7 OS.
Please suggest.
LikeLike
Are the devices showing up properly in the device manager? See
Otherwise this one might be helpful:
LikeLike
My KL25Z board is not detected by the operative system (neither Windows or Linux). When I plug the USB, board blinks 8 times, 2-seconds pause, another 8 blinks and continues. I can’t upgrade/rewrite SDA because I don’t get a new windows device.
What can I do?
Thanks.
LikeLike
Hi Daniel,
is the board not detected even if you plugin it in while the reset button pressed? That blinking is an error code, so definitely no firmware is loaded on the device.
Erich
LikeLike
Now, I don’t know how, Windows detects KL25Z but always starts as BOOTLOADER unit even if I don’t press reset button. If I copy a new sda file and unplug/plug USB, system detects again a bootloader unit and not a kl25z unit… so it seems units is not getting a new sda file.
LikeLike
Daniel,
see https://mcuoneclipse.com/2014/11/01/illustrated-step-by-step-instructions-updating-the-freescale-freedom-board-firmware/.
– unpack the archive first (do not copy from the archive/zip)
– use DOS shell/prompt to copy the file (file mangers are a problem)
– disable virus scanners
I hope this helps.
LikeLike
No, your solution has not worked for me. My board, after updating firmware and SDA, continues booting as BOOTLOADER and not recognizes new SDA and FW versions. 😦
Buffff, what can I do?
LikeLike
Daniel,
are you sure that it is not your virus scanner, or a possible Explorer extension?
Make sure you unzip the firmware file first, then copy with the DOS shell/cmd.exe to the bootloader device.
I hope this helps,
Erich
LikeLike
Hi,
I cant get my FRDM_KL02Z board to connect. THE P&E connection assistant can see the Open SDA on USB1 but when I press Retry it just keeps coming back with the same screen
LikeLike
What host operating system are you using? It seems that the driver is properly loaded, but the debugger cannot connect to the device.
Is the option ‘Use SWD protocol’ enabled in your debugger settings panel of the debug configuration?
LikeLike
Hi,
Im running windows 7 and CW 10.6 by “Use SWD Protocol” do you mean “Use SWD reduced pin protocol for comminications”, if so then I have tried it checked and not checked and still get the same issue.
When I get P&E connection assistant popping up the device name-DBFC7E11, does this look right?
LikeLike
You only can use SWD with openSDA (JTAG is not supported). So yes, that option is the same. I mentioned the text inside my Kinetis Design Studio, so yes, that text is different in CodeWarrior.
LikeLike
In the connection assistant you should see as port something like “USB1: OpenSDA (DBF94E01)” where that number at the end is the USB ID. Make sure you have “OpenSDA Embedded Debug – USB Port” selected as interface.
LikeLike
I have updated to the latest windows drivers and SDA drivers. I dont have anoy other hardware to test it on. How can I prove that there is a hardware issue?
LikeLike
You would need a second hardware/board 😦
Or at least a Segger or J-Link probe to directly talk to the microcontroller.
Or do you have a second host machine (Windows 7) you could try?
LikeLike
I have also enabled logging and get the following lines on the console output……
INF: OpenSDA detected – Flash Version 1.08
ERR: Can not enter background mode.
LikeLike
“Can not enter background mode” indicates that it cannot communicate/talk/reset the device. Have you secured your device? Maybe you have a hardware problem? Are you able to debug other boards with OpenSDA without problems (to be sure it is not a Windows driver problem)?
LikeLike
Hi!
I kept having this problem despite the new FW (in Ubuntu).
I found out the USB driver was copied to /usr/lib64, but should have been to /usr/lib.
I explain it better in the answer: https://community.nxp.com/t5/S32K/OpenSDA-s32k144evb-Linux-Ubuntu-20-04-port-not-found/m-p/1050057/highlight/false#M6934
LikeLiked by 1 person
Interesting, thanks for sharing! BTW, that ‘post and login with lost post’ happened to me many times too 😦
LikeLiked by 1 person