FRDM-KL05Z

This post is a guide for setting up the Freescale’s version of OpenOCD used for the kinetis microcontroller without installing Freescale’s KDS IDE. We were able to do this, because we’ve already take a copy of the OpenOCD which is bundled with freescale’s KDS installer and added to our git repository. This guide simple takes you through the process of downloading the git files and installing and configuring your copy of Ubuntu to allow OpenOCD to operate.

This post is particularly useful for people who don’t want to used Freescale’s KDS or if you want to use an existing copy of Eclipse. The latter is likely to be the case when you already have an environment setup for other vendor microcontroller such as ST microcontrollers.

You will most likely be asking yourself why don’t I just installed a fresh copy of OpenOCD via Ubuntu’s package manager. For example “apt-get install openocd”.

Unfortunately, at the time of writing this post the current version of Ubuntu OpenOCD is out of date and doesn’t have support for the most recent microcontrollers. One such example is the STM32 NUCLEO boards.

Then you are likely to ask, why don’t I just compile and install OpenOCD for my self by using this guide you posted here about compiling And Installing OpenOCD With CMCSIS-DAP Support.

Unfortunately Freescale haven’t been quick to submit patches to OpenOCD project on the changes that are needed for their kinetis microcontroller.

With regard to testing, I will be using the FRDM-KL05Z board to test the openOCD interface.

Key Notes and Assumptions

Throughout this guide we will be using colour boxes to highlight terminal command and notes. This will make it easier for us to highlight useful information.

The following are the colour boxes keys:

Linux Terminal Commands
Interesting Notes
Warning Notes

Assumptions

Installing OpenOCD

Adding udev rule

At this point you might be able to use OpenOCD without any issue, however, chances are that you will face this error message when trying to use OpenOCD.

udev CMSIS Error Message

Assuming that you have your board connected, this is likely to be caused by the current user not having the right access permission to your board USB HID driver. You can verify this by running OpenOCD as root.

However, if we are planning on using OpenOCD with an IDE (for example Eclipse) or some other development environment, then to make our life a little easier then we should add a system rule that will automatically mount the our board usb with an open permission so that any user can use the it.

To do this, we need to first find out our board USB vendor and product id.
We can do this by running the USB list command. However, we may need to run this command a few times with and without the board connected to identify which of the USB devices listed belong to our board.

lsusb

You should get a message like this.

lsusb

These are two set of hexadecimal characters that you need to make a note of for your device.
lsusb - with lable

Using this command we are going to create a new udev rule for our USB device. This command will simply create a new text file in the udev rule.d folder which will be invoked when ever out board is connected.

sudo nano /etc/udev/rules.d/CMSIS.rules

linux CMSIS rules nano

Type in the following line into the new file. Make sure that you replace the idVendor and idProduct hexidecmal values between the double quotes with the ones that you noted earlier.

KERNEL=="hidraw*", ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="0666"

Save CMSIS Rules

To save the file, press Ctrl+X.
Save CMSIS Rules Yes
Press Y and then Enter to accept and exit the editor.

You will need to reboot your computer for the new changes to take effect but apart from that you are ready to start using OpenOCD.

Test OpenOCD

This section will go run through quick test to verify our setup. We will simply check that OpenOCD is working by getting it to connect to our board via CMSIS-DAP interface using the kinetics configuration file.

Connect you board to the computer and then Run the following terminal command.

~/FreescaleEssential/openocd/bin/openocd -f ~/FreescaleEssential/openocd/scripts/kinetis.cfg

You should get this message follow by a cursor waiting for further commands if everything is working correctly. Notice the lines where it says Info, it tell you useful information about the connect device. For example, the CPU type code and the number of supported breakpoints.

Freescale OpenOCD Kinetis test

Are you looking for help?

If you are having issues with your project or are looking for some advice to get your next project started then feel free to contact us. We can provide a bespoke services that suite your needs.

Alternatively, if you are new to electronics and are interesting in learning more about developing your own embedded software and hardware then Contextual electronics is the perfect place to go to. its a pay service that I am part of that provides an apprenticeship style of teaching. You can work at your own pace and have access to any of the instructors for help you may need for your projects.

Comment(2). Leave comment

  • Pingback: #Define Electronics | Electronic and Mechanical Design | Proof of Concept | Turnkey Solutions | ATEX Compliance | Leeds | Mechatronic | Freelance | Ronald Sousa | Hash Define Electronics Ltd | limtied

  • Pingback: #Define Electronics | Electronic and Mechanical Design | Proof of Concept | Turnkey Solutions | ATEX Compliance | Leeds | Mechatronic | Freelance | Ronald Sousa | Hash Define Electronics Ltd | limtied

  • Leave a comment.

    Please note that all comments are moderated by a person and so it may take some time for it to show on the site. if you have an urgent issue then please feel free send us a message via our contact form below.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    Get in touch.

    Whether you have an existing project that you need help with or if you want us to take care of the whole design process, we are happy to talk to you about your project and see if we can help. At the very least we should be able to point you in the right direction.

    Comments or questions are welcome.