JTAG via OpenOCD

From InCircuit
Jump to: navigation, search

To use OpenOCD, you first need a corresponding Jtag-adaptor to connect to the hardware. A pre-patched version of the software can be found on a recent version of the support-CD for your board.


OpenOCD driver on Windows

When using Windows you need to install the appropriate libusb-1.0 (WinUSB) drivers:

  1. Visit zadig.akeo.ie and download the latest zadig software.
  2. Plug in your interface
  3. Start zadig.exe (you may be asked by UAC to allow this application to change system settings - click Yes)
  4. If your device is visible in drop-down list go to step 6
  5. Check Options > List All Devices
  6. Select your device in drop-down list ("Dual RS232")
  7. From the right (active) selector choose WinUSB (...) driver
  8. Click Install Driver or Replace Driver below (you may be asked by OS to accept driver installation - click Yes)
  9. Click Close in the message box that will appear informing you about success
  • you need to install the driver for both interfaces of your OpenOCD programmer (Interface 0 & Interface 1).
  • (this guide was provided by [1])

Configuration file

Before OpenOCD can be used a configuration-file suitable to the actual setup has to be generated. Using the ICprog OpenOCD and a ICnova SAM9G45 OEM, the following lines should be saved in a file called openocd.cfg:

 source [find interface/openocd-usb.cfg]
 source [find target/at91sam9g45.cfg]

Afterwards OpenOCD can be used by specifying this file on the command line. The devices should be connected as shown on the picture below.

Icprog openocd.jpg


The following section will provide some example commands.

Writing the bootloader

Using a ICnova SAM9G45 OEM, the following commandline will write the bootloader into the flash.

 openocd -f openocd.cfg -c “flash erase_sector 0 0 2” -c “flash write_image norflash_icnova_arm9.bin 0x10000000” -c “flash write_image u-boot.bin 0x10020000” -c shutdown

The parameter -f openocd.cfg specifies the configuration file. Any occurence of -c will tell openocd to execute the command. The commands flash erase_sector 0 0 2 deletes the the first 3 Sectors (0, 1 and 2) of the NOR-Flash (with ID 0). To delete just the U-Boot (sectors 1 and 2) flash erase_sector 0 1 2 has to be used. The command flash write_image norflash_icnova_arm9.bin 0x10000000 writes the content of the file norflash_icnova_arm9.bin into the memory at address 0x10000000. As this is the NOR-Flashs start-address, the first sector will be used. The command shutdown stops openocd. Otherwise the openocd would start its server-functionality and wait for a suitable connection.

The exact commands for other modules can be found in the corresponding Memory map for that device.

Personal tools