Posted on Leave a comment

Atmel STK500 mod

The post addresses Atmel STK500 starter kit mod as not only HVPP/SP and ISP but also TPI and PDI programmer.

NOTE: This post is nothing to do with GoPro nor Genlock although they are the main topics in this blog.

Introduction

Atmel STK500 is a long-lived product from Year 2001 to now. We consider nowadays most of its users are utilizing it as a simple programmer, and not as starter kit for DIP-package microcontrollers.

STK500 has two microcontrollers ATmega8535L (main) and ATtiny2313V (sub) on its board, and has following features:

  • HVPP (High Voltage Parallel Programming) programmer
  • HVSP (High Voltage Serial Programming) programmer
  • ISP (In-System Programming) programmer

Our mod replaces its main ATmega8535L to a pin-compatible microcontroller that has more flash memory, and removes its sub ATtiny2313V. The latter mod is feasible because since Atmel haven’t offered any new main microcontroller’s firmware after Year 2009 until now sub’s only role of updating main’s firmware is considered to be dead. Once the STK500 board gets a memory-rich microcontroller we can burn an open-source firmware such as ScratchMonkey originally by Matthias Neeracher (modified by Orangkucing Lab) and can also add supports for TPI and PDI.

Hardware Mod

We remove the following four parts from original STK500:

  • U200 : ATtiny2313V
  • U202 : ATmega8535L
  • C200 : Capacitor 47n
  • R200 : Resistor 10k
Remove orange parts. Add red parts.
Remove orange parts. Add red parts.

(The figure above is taken from Atmel’s original “STK500 component placement: STK500_asm.pdf”. And also the part numbers are adopted from “Atmel STK500 schematic: STK500.pdf”.)

After removing these parts the board looks like the following image:

After removing four parts from STK500
After removing four parts from STK500

Then we add the following parts:

  • U202 : ATmega1284P
  • R213 : Jumper 0ohm (or solder jumper will do)
  • J200 : 2×3 header pins

The new microcontroller will be any pin-compatible one to ATmega8535, namely ATmega16/32/64/128 or ATmega164/324/644/1284 families. We used unnecessarily-very-very-high-spec ATmega1284P here because we don’t want to remove/resolder such a delicate SMD chip again in the future.

After soldering these parts STK500 hardware mod has been completed and looks like this:

A STK500 mod board. A sticker (1) indicates the 1st pin of ISP6 connector.
A STK500 mod board. A sticker (1) indicates the 1st pin of J200 ISP6 connector.

Software

To burn a firmware to the main microcontroller sit on U202 another ISP programmer is required. We don’t explain here in detail how to upload a firmware or what is an ISP programmer or so since many reader of this post already know these kind of things better than us. 🙂

So just connect another ISP programmer to newly installed J200 pin header and burn the firmware obtained from here (this link is ScratchMonkey’s fork of us but we expect our branch will be pulled and merged to the trunk soon).

If you like to compile the source code using Arduino IDE  then its DIP-40 core (“Mighty Core”) is needed. To do this follow the instruction here.  After installation of “Mighty Core”, select Tools and board: “Mighty Core”->your microcontroller, clock: “External 7.3728MHz”, pinout: “Standard pinout”; and compile the source code in IDE, then burn the resulted hex-file to your microcontroller.

And for your information we set microcontroller’s fuses to:

  • CKDIV8/CKOUT unprogrammed
  • SPIEN programmed
  • SUT_CKSEL = FSOSC_16KCK_65MS_XOSC_SLOWPWR

Now the STK500 mod board should be recognized as an original Atmel STK500 by Atmel Studio 4/5/6/7 and by avrdude (as stk500v2 for ISP or stk500pp for HVPP or stk500sp for HVSP).

Moreover it is now usable also as a TPI or PDI programmer. The details will be in the next section.

Using STK500 mod as TPI/PDI programmer — Software

Regrettably Atmel Studio doesn’t recognize STK500 mod as a TPI/PDI programmer. The only way is to apply a patch to avrdude’s source code and always use STK500 mod from avrdude in case you need a TPI/PDI programmer.

The patch for avrdude consists of eight parts:

Since avrdude has been distributed in many forms/versions the patch is for your reference only and it usually cannot be applied automatically by using the patch tool. So it is normal that you need to edit the stk500v2.c file manually by yourself.

(16 Aug. 2021 Edit: Here is a fork of mariusgreuel’s avrdude v6.3.1.1 whose stk500v2.c has been patched.  Also its compiled binary for Windows is in Releases.)

The first section (1254,1263) of patch enables PGMTYPE_STK500 for XPROG (TPI and PDI).

The second (3712,3719) and third (3724,3736) sections for calculating flash/eeprom sizes, and the fourth (3795,3801) and fifth (3806,3811) are modified to reporting these sizes to the STK500 mod.

And the rest of patch is for TPI fuse programming that needs “a mystic erase prior to writing”.

Using STK500 mod as TPI/PDI programmer — Connections

After avrdude has been patched you can program any TPI/PDI chips.


To program a TPI microcontroller two external 510 ohm resistors are required. And use the connection in the following schematic:
TPI
5V, MOSI, MISO, SCK, and GND are located at J200 ISP6 connector. And VTARGET is at any pin marked “VTG” (jumper “VTARGET” must be set), RESET5V at pin 5 of “PROG DATA”, and RESET12V at “ISP6PIN” or “ISP10PIN” connector. Use signals in TPI connector of the schematic if the reset disable fuse is not programmed. Otherwise use signals in TPI HV connector since high voltage TPI requires the target voltage to be controlled.


To program PDI not only two external 510 ohm resistors but also a quad 5V-tolerant 3-state buffer 74LVX125 are required. And use the connection in the following schematic:
PDI2
3V3 is at “VADJ” or pin 13 of “EXPAND0” connector (jumper “AREF” must be set), and MOSI, MISO, SCK, and GND are at J200 or “ISP6PIN” or “ISP10PIN”. MOSI_GATE is located at RESET pin of “ISP6PIN” or “ISP10PIN”.

Note: The PDI programming voltage is 3.3V. Since STK500 is in 5V logic some kind of logic level translation is necessary. Thus we tried to use automatic level conversion chips such as MAX3002, GTL2003, TXB0104, and FXMA108 but NONE OF THEM WORKED RELIABLY. It’s a pity we must use a 3-state buffer like 74LVX125. What naive/stupid signals Atmel’s PDI protocol uses!!


Lastly we show example invocations of avrdude:

avrdude -c stk500v2 -p t10 -P /dev/tty.usbXXXXX -vvvv # show detailed transaction and tiny10's signature
avrdude -c stk500v2 -p x128a1 -P /dev/tty.usbXXXXX -U flash:w:hehehe.hex:i # flash hehehe.hex to xmega128a1

where tty.usbXXXXX is the serial port your STK500 mod is connected.

Enjoy!

Posted on Leave a comment

No Master Configuration For Genlocking

A PC controlled genlock system support is added to Dongle’s source code.

For genlock rigs we’ve offered two configurations, namely

  1. Single Dongle configuration
  2. Double Dongle configuration

and these are described in this post. The latter is usable with PC by connecting MewPro #0 to FTDI serial USB breakout and by sending commands from its console.

Shāndōng University – Virginia Tech researchers use a double dongle configuration, as I know so far, and also use a PC that is connected to MewPro #0 in order to control the whole system. (For their recent progress, a blog post is here: Matt Bender, Mincan Cao, Yu Wei, Shaoxu Xing “Tracking of Fiducial Markers for Bat Flight Motion Capture Experiments)

To control the whole system from PC, today we added support for

  • 3. no master configuration.

Control everything from PC. No master camera.
Control everything from PC. No master camera.

(DTR connection between Dongle #0 and FTDI is for resetting Dongle #0 when uploading a sketch to the dongle or opening the Arduino Monitor in PC.)

As you can see this is the same to the single dongle configuration but GoPro #0 is replaced by Genlock Dongle #0 connected to PC through FTDI serial USB breakout board.

The no master configuration is completely symmetric and everything is PC controllable but there is no master camera that you might be accustomed to push mode/shutter buttons or to browse through menus on LCD.

How To Use No Master Configuration

You should follow the instructions for single dongle configuration first. And don’t forget to prepare/buy one more Genlock Dongle for Genlock Dongle #0 in the figure above.

You must update the dongles with the latest version of Dongle source code that supports no master configuration. It is always available at the GitHub repo.

For dongles the initial value of bool debug and the directive UART_RECEIVER_DISABLE should be set as follows:

bool debug UART_RECEIVER_DISABLE
Dongle #0 true or false #undef
Dongle #1 false #undef or #define

(Bold face is the default in the GitHub source code.)

In this configuration usable commands from PC are those which are listed in the I2C command list and its label contains _BACPAC_.

Example:

  • SH1 start recording/shutter
  • SH0 stop recording
  • CM1 change mode to camera
  • VV0A change video resolution to 720p Super
  • etc., etc.

The dongle also suports two more commands:

  • @ power on
  • & toggle debug output

Enjoy!

Posted on Leave a comment

Mounting GoPro’s microSD thru Side USB

By installing a slide switch or an alternate push button to the reset line of our genlock system, GoPro’s microSDs get easily accessible from PC through the USB on the side.

The customer in Germany recently told us that they succeeded in mounting GoPro’s microSDs without detaching MewPros nor soldering additional wires. They’ve got two key ideas: 1. If the reset line is kept LOW then MewPros don’t logically exist on Herobus; 2. If Dual Hero bacpac (or MewPro) is attached to Herobus then the side USB cannot be used to mount GoPro’s microSD from PC.

We misunderstood that the I2C command “UM0” enabled access to internal microSD from the side USB. The truth is the command only disables access from the back USB that have been enabled by “UM2”, and resumes the 3D mode.

The following is a demo to mount all the microSDs in a sample rig.

Example Session

The rig is in a single-dongle configuration with one master camera and, for simplicity sake, only one slave camera. All cameras and the Dual Hero bacpac are powered/charged by a self-powered USB 2.0 hub. An alternate push button switch is installed on the reset line (the red part in the photos below. When the button is pushed/latched its red rod is seen shorter).

Step 0: Let’s start this session with normal charging state: Master camera is OFF; Slave camera(s) OFF; USB hub’s power is ON; Reset line HIGH, i.e., reset is OFF.

Master OFF. Slave OFF. USB hub ON. Reset OFF.
Master OFF. Slave OFF. USB hub ON. Reset OFF.

Step 1: Push the master camera’s power button. Then the system enters in 3D shooting state.

Master ON (3D). Slave ON (3D). USB hub ON. RESET OFF.
Master ON (3D). Slave ON (3D). USB hub ON. Reset OFF.

Step 2: Push and hold the reset switch to keep the reset line LOW. And temporally detach power from the USB hub. Then the master camera becomes automatically OFF because the peer Dongle has lost its power.

Master OFF. Slave ON (not 3D). USB hub OFF. Reset ON.
Master OFF. Slave ON (not 3D). USB hub OFF. Reset ON.

Step 3: Plug a USB cable to PC and hub. And power on the USB hub.
Then the slave camera(s) become(s) hard disk mode and they are accessible from PC simultaneously.

Master OFF. Slave ON (disk). USB hub ON and connected to PC. Reset ON.
Master OFF. Slave ON (disk). USB hub ON and connected to PC. Reset ON.

Step 4: After downloading video/image data from slave GoPros unmount these disks on PC. And push release the reset line.

Master OFF. Slave ON (3D). USB hub ON and connected to PC. Reset OFF.
Master OFF. Slave ON (3D). USB hub ON and connected to PC. Reset OFF.

Step 5: We have downloaded data from all the cameras but the master. Now push the master camera’s power button again. Then we will be able to do the job.

Master ON (disk). Slave ON (3D). USB hub ON and connected to PC. Reset OFF.
Master ON (disk). Slave ON (3D). USB hub ON and connected to PC. Reset OFF.