Getting Started

Mike edited this page Nov 2, 2013 · 27 revisions

The following list are generic instructions, regardless of your choice of bootstrap programmer. See below for instructions specific to the different bootstrapping methods.

Main steps

  1. Assemble board
  2. Install toolchain software
  3. Flash USB bootloader using external programmer
  4. Flash application code using bootloader via USB

Install toolchain software

  1. Download SAT (summon-arm-toolchain) from https://mchck.s3.amazonaws.com/sat-e35a85d-32bit.tar.bz2. gcc-arm-embedded will also work as long as you add NO_LTO=1 to make commands below. (see here for details)
  2. Extract SAT in your ~ (will create ~/sat)
  3. Clone git repo from git://github.com/mchck/mchck.git
  4. Install dependencies for the toolchain:
    1. ruby 1.9 (or 2.0)
      • Check your default version with ruby --version
    2. dfu-util

Flash USB bootloader using external programmer

If your MC HCK already has a bootloader pre-programmed, you can skip this section.

First follow the Per-programmer instructions below.

  1. Connect programmer to MC HCK (see Per-programmer instructions)
  2. Run make in bootloader/usb-dfu to build the DFU bootloader
  3. Flash the bootloader with make swd-flash MCHCKADAPTER=$BACKEND

Flash application code

  1. Plug the MC HCK into USB (pad with folded paper to get solid contact)
  2. Press the program button - the MC HCK will attach as DFU device to USB: Bus 001 Device 125: ID 2323:0001
  3. Run make in examples/blink to build the blink demo
  4. Flash the blink demo with make flash. Alternately, you can flash via an external programmer using make swd-flash MCHCKADAPTER=$BACKEND.

Further steps

Remote debugging

Run make gdb MCHCKADAPTER=$BACKEND to start gdb.

Reset or other exceptions will break into gdb as SIGSEGV, even tho the exception might not have been a segment violation.

Use run to trigger a reset and restart the firmware.

You can use breakpoints and hardware watchpoints. If you use a write watchpoint (default when using watch), it will not work well for registers that do not change content after a write – gdb will automatically filter such accesses. Use awatch instead.

Per-programmer instructions

Optional: Create the file .mchckrc in the repository root, with the contents MCHCKADAPTER?=$BACKEND. After this, you can drop the MCHCKADAPTER=$BACKEND arguments in the following instructions.

MC HCK

ModemManager must be told to ignore our device, make sure to have this udev rule:

# mchck
ATTRS{idVendor}=="2323", ENV{ID_MM_DEVICE_IGNORE}="1"

Extra dependencies

  • serialport gem:
    gem install serialport
        

Hooking up the programmer

The following pinout is for R4 MC HCKs

  • PL14 to DBG1 (topmost, just below upper row)
  • PL13 to DBG2
  • PL12 to DBG3
  • PL11 to DBG4

Toolchain config

The MC HCK can act as SWD programmer; for this, flash the bootloader/swd-adapter firmware on the MC HCK. This firmware attaches as USB serial device. Find its device node in /dev/serial/by-id/; use the full path for $DEV. Use name=mchck:dev=$DEV as $BACKEND.

Bus Pirate

Extra dependencies

  • serialport gem:
    gem install serialport
        

Hooking up the programmer

  • 3V3 to DBG1 (topmost, just below upper row)
  • GND to DBG2
  • MOSI to DBG3
  • CLK to DBG4

Toolchain config

The Bus Pirate attaches as USB serial device. Find its device node in /dev/serial/by-id/; use the full path for $DEV. Use name=buspirate:dev=$DEV as $BACKEND.

Bus Blaster

The Bus Blaster’s CPLD must be flashed with a KT-Link buffer. Instructions for updating v2 Bus Blasters are at the bottom of the linked page. Buffers are also available for v3 and v4 Bus Blasters.

Extra dependencies

  • libftdi-ruby gem:
    gem install libftdi-ruby
        

Hooking up the programmer

  • VTG to DBG1 (topmost, just below upper row)
  • GND to DBG2
  • TMS to DBG3
  • TCK to DBG4

Toolchain config

The Bus Blaster is used directly via libusb/libftdi. You will have to specify the USB VID and PID in the backend config. Let’s hope you don’t have more than one Bus Blaster attached, or it probably won’t work. Set $BACKEND to name=ftdi:vid=0x0403:pid=0x6010.