Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

So, the main goal here is to set up OpenOCD to flash firmware using an STLinkV2 debugger.

Installation

The text suggests building OpenOCD from source because packaged versions in Linux distributions might be outdated and lack support for NRF52. Here are the steps:

  1. Install dependency:

     sudo apt-get update
     sudo apt install make
     sudo apt-get install git
     sudo apt install openocd
     sudo apt-get install pkg-config autoconf automake libtool make
    git clone https://git.code.sf.net/p/openocd/code openocd-code
  2. Change directory:

    cd openocd-code
  3. Prepare the build environment:

    ./bootstrap
  4. Configure the build:

    ./configure --enable-stlink
  5. Build the project:

    make -j4
  6. Install it:

    sudo make install

After installation, it's necessary to configure UDEV to allow OpenOCD to access the STLinkV2 via USB:

  1. Copy the UDEV rule:

    sudo cp contrib/60-openocd.rules /etc/udev/rules.d/
  2. Reload the UDEV rules:

    sudo udevadm control --reload-rules

Once that's done, you can plug in the STLinkV2 and run OpenOCD to test the connection:

openocd -f interface/stlink.cfg -f target/nrf52.cfg

The output should show that OpenOCD is running and detects the STLinkV2. However, it might give an error about not being able to connect to the target if the STLinkV2 isn't connected to the PineTime yet.

Configuration Files

OpenOCD uses configuration files to specify how it should interact with the debugger and the target device. The text mentions two types of configuration files:

  1. Common configuration file: openocd-stlink.ocd

    This file includes:

    • interface/stlink.cfg: Specifies the STLink interface.

    • target/nrf52.cfg: Specifies the NRF52 target.

    Additionally, it enables flashing via GDB and overrides breakpoints to be hard.

  2. User files for specific flashing operations:

    • flash_bootloader_app.ocd: Flashes the bootloader and the application firmware.

    • flash_graphics.ocd: Flashes the graphics flasher.

These files contain commands to initialize the debugger, program specific binary files to memory addresses, and reset the target.

Examples

Jtag for RK3566 using STLinkV2: stlink.cfg rk3566.cfg

~/openocd-code/tcl$ openocd -f interface/stlink.cfg -f target/rk3566.cfg

The text provides examples of how to use these configuration files:

  1. Flashing bootloader and application:

    openocd -f ./openocd-stlink.cfg -f ./flash_bootloader_app.ocd
  2. Flashing graphics flasher:

    openocd -f ./openocd-stlink.cfg -f ./flash_graphics.ocd

Connecting the STLinkV2 to the PineTime

There's a mention of using pogo pins to connect the STLinkV2 to the PineTime, along with images showing the SWD pinout and the pogo pins. It also refers to additional wiring information on a wiki page.

Conclusion

Overall, this text provides a detailed guide on how to set up and use OpenOCD with an STLinkV2 debugger to flash firmware onto the PineTime device. It covers installation, configuration, and practical examples of flashing different components of the firmware.

Personal Notes

  • Building from source: This is often necessary for up-to-date features, especially with rapidly evolving hardware like the NRF52.

  • UDEV rules: Important for permissions when accessing USB devices from non-root users.

  • Configuration files: Key to telling OpenOCD what to do. Need to make sure the paths to the binary files are correct.

  • Pogo pins: A convenient way to make SWD connections without soldering, though they might require steady hands or some form of jig to hold everything in place.

  • Error handling: The initial error about not connecting to the target is expected if the STLinkV2 isn't properly connected to the PineTime.

  • Safety precautions: When working with hardware, always ensure that the device is powered off and handled carefully to avoid damage.