28 November 2013

This is an introduction to pyOCD, my very first steps getting familiar with pyOCD. Two mbed users reported locking of their KL25Z chips with pyOCD. I hope we find out why!

The pyOCD used to be part of mbed github repository, but not anymore. It was separated, can be found here pyOCD repo [github.com/mbedmicro/pyOCD]. It has awesome readme file there, which serves as documentation.

the official mbed page for pyOCD Debuging from GDB using pyOCD [mbed.org/blog].

I started with pywinusb (using windows on my laptop), installed via easy_install.


The second step was to build pyOCD, run from the pyOCD root directory python setup.py install.


Connect KL25Z to your PC, be certain it has mbed interface! Time to start gdb session, either gdb from toolchain or from pyOCD. I chose to run gdb_test.py which is in pyOCD/test folder.


KL25Z detected, presume to flashing part. To be save, I opened basic_test.py located in test directory and commented out line 156 flash.flashBinary(binary_file). This prevents from flashing (locking alert which I explain later).


Everything went ok according to the console, flashing was skipped though. Now return the line 156 to test flashing part. Have ready compiled GCC program (I use bin file from the example I created for mbed GCC KL25Z demo).

If you run it without arguments, the default path is /binaries/l1_target.bin, the name of bin file for KL25Z is l1_kl25z.bin . Flashing was successful but program was not running correctly and chip got to secured state. I restarted gdb test script, received an error. I opened uVision, it displays a warning that chip is locked, but not permanently, fortunately! I have to get my prototype board, to continue with testing.

I'll share more once I explore what's going on and why chip got locked once.

Update 1st of December:
I have been debugging it for a while, I added some extra code which completely messed connection to the chip, gdb returned error. Once I found out what I did wrong, everything seems to be functional.
Even flashing different binaries does not lock chip, still using pyOCD scripts, not directly its gdb implementation.





blog comments powered by Disqus