Documentation:Bit-bang Programmers

From AVRFreaks Wiki

Jump to: navigation, search

Bit-bang programmers belong to those that require the least amount of external hardware, as the actual programming protocol implementation is performed by software on the host computer (typically a PC). This is done by banging single bits on a standard IO port of the computer, like a parallel or RS-232 port.

In the simplest case, the entire hardware consists of just the connectors (DB25 for the host computer's parallel port, 6-pin IDC for the AVR ISP) and wires between.

Typically, bit-bang programmers for the AVR8 are talking ISP protocol. For other microcontrollers (ARM32, TI MSP430), bit-bang programmers are also commonly in use that talk JTAG protocol directly.

Note that these ports are used in a way they have not been originally designed for. This causes certain side effects and restrictions:

  • They are often fairly slow, yet require a lot of host CPU activity. This is due to bypass capacitors the port is loaded with (for printer ports), or to the interface circuits being optmized for slow but safe operation (RS-232 ports).
  • They cannot be run at all across USB-to-RS-232 or USB-to-printer bridges, or they will become way slower across them, due to the nature of USB communication. As fewer and fewer host computers are equipped with hardware RS-232 or printer ports these days, that drastically dropped the populariy these simple programmers initially enjoyed.
  • They are occasionally less reliable than programmers that implement the programming protocol by their own separate microcontroller. This can in particular become an issue when the unreliability causes fuse bits to be misprogrammed. Features like avrdude's safemode are an attempt to add safety belts against that.
  • The Win32 operating system does not offer any OS service to talk to the parallel port except for the purpose of printing. To circumvent this, a driver is then loaded that will eventually grant the programming software IO privileges for the printer ports, so direct IN and OUT instructions can be used. As this bypasses the operating system entirely, it bears the potential of conflicts with the OS services (like the print spooler), and also imposes the risk of the programming software (or even malware that could abuse that driver) to eventually access valuable IO resources it should not be granted access to. Note that current Unix systems (Solaris, Linux, FreeBSD) all offer native drivers to use the printer port for bit-bang IO, so while they might operate a bit slower, the risks mentioned don't apply to them.
Personal tools