(Configuring Open OCD)
(Using Open OCD)
Line 52: Line 52:
  
 
==Using Open OCD==  
 
==Using Open OCD==  
After doing all the setup for openOCD, first step is to write a configuration file for NRF51822. Keep this config file in '''bin-x64''' <br/>folder and open command window in the same folder and open session as shown below
+
After doing all the setup for openOCD, first step is to write a configuration file for NRF51822. Keep this config file in '''bin-x64''' folder and open command window in the same folder and open session as shown below
 +
 
 +
[[File:f.png|550x400px]] 
 +
 
 +
#If configuration file and all the connections are correct openOCD session will start
 +
 
 +
[[File:g.png|550x400px]]
 +
 
 +
#Once the session is started we have to start '''Telnet'''. For this open another terminal from anywhere and start telnet by using '''telnet localhost 4444''' command and click enter.
 +
 
 +
[[File:h.png|550x400px]]
 +
 
  
[[File:path1.png|850x600px]]
 
 
===Open OCD as debugger===
 
===Open OCD as debugger===
 +
 +
#Once the telnet session is opened, we can use OpenOCD debugger. For flashing a program in the target device that is NRF51822, first halt the device using '''halt''' command. Then use '''flash write_image erase File_name.bin''' command to flash device and reset the device using '''reset''' command.
 +
 +
[[File:i.png|550x400px]]
 +
 
===Open OCD as programmer/flasher===
 
===Open OCD as programmer/flasher===
  

Revision as of 16:52, 30 September 2015

Sandeep (talk) and Vaibhav Katkar (talk) 17:43, 10 September 2015 (IST)


Getting STlink v1 working with openOCD is a pain. The USB driver implementation has flaws. The PC picks different drivers for the same device depending on its mood! Initially I got it working on my computer and to check I asked Vaibhav to try on his computer. He too wanted to use it to debug the LPC1114 MCU that he is working on for a last few weeks. It did not work, even after following the exact same steps. So we debugged and found out what the issue was.

Configuring Open OCD

  1. Download OpenOCD zip file and extract its contents in any directory. There are two bin folders "bin" and "bin-x64" inside this directory. Depending on the version of the OS utilize the OpenOCD version.

Setting OpenOCD path

  1. Right click on This PC and select properties. this will open "System" window, in system window click on Advanced System
    Settings
    , it will open system properties. Now click on Environment Variables.
    In this window select Path under System variables and click on Edit button as shown below

Path1.png


  1. Give the path of bin file in openocd as C:\openocd\bin-x64, if you are usin 64-bit OS or C:\openocd\bin, if you are using 32-bit OS and click OK


Path2.png

Connecting STlink with nRF51822

Do the following connections

  1. Remove links on CN3 connector of STlink
  2. Power up NRF board from STlink
  3. Do the connections of CN2 connector as shown in diagram

K.png

Reassigning the Driver

  1. Now we have to install necessary drivers for STlink for working with openOCD. When we connect STM32 board to laptop drivers
    gets automatically installed and STM32 detected as a USB mass storage device
  2. If we start openOCD session it will not start as drivers are not supported and we will get error message on terminal


Usb err.png

Reassigning Drivers

  1. Download Zadig software to convert the driver
  2. Open Zadig, click on Options and select List All Devices. Select STM32 Mass Storage among available devices.

A.png

  1. Select WinUSB(v6.1.7600.16385) and click on Install WCID Driver. You will get a warning message for permission, simply click on Yes

B.png


  1. Now you can check, the STlink will be detected under Universal Serial Bus Devices

E.png

Using Open OCD

After doing all the setup for openOCD, first step is to write a configuration file for NRF51822. Keep this config file in bin-x64 folder and open command window in the same folder and open session as shown below

F.png

  1. If configuration file and all the connections are correct openOCD session will start

G.png

  1. Once the session is started we have to start Telnet. For this open another terminal from anywhere and start telnet by using telnet localhost 4444 command and click enter.

H.png


Open OCD as debugger

  1. Once the telnet session is opened, we can use OpenOCD debugger. For flashing a program in the target device that is NRF51822, first halt the device using halt command. Then use flash write_image erase File_name.bin command to flash device and reset the device using reset command.

I.png

Open OCD as programmer/flasher

References

K.png

A.png

B.png

C.png

E.png

F.png

G.png

H.png

I.png