Skip to content

HydraFW binary UART mode guide

Benjamin Vernoux edited this page Mar 24, 2023 · 15 revisions

HydraFW binary UART mode guide

This guide is updated towards firmware release HydraFW v0.9 Beta and later

Default STM32 UART used is uart2 see https://github.com/hydrabus/hydrafw/wiki/HydraFW-UART-guide#configuration-options for more details not anymore since 463bfc5ad230e4a73c32aed6a726dd4c74997364 (it is now UART1 by default)

This mode allows to control UART1 or UART2

  • UART1 pins: TX=PA9, RX=PA10
  • UART2 pins: TX=PA2, RX=PA3

For more details see https://github.com/hydrabus/hydrafw/wiki/HydraFW-UART-guide

Commands

Once the UART mode has been selected, the following commands are available :

  • 0b00000000 Return to main mode. Returns BBIO1
  • 0b00000001 Mode identification. Returns ART1
  • 0b00000010 Start echo UART RX
  • 0b00000011 Stop echo UART RX
  • 0b00000111 Manual baud rate
  • 0b0001xxxx Bulk UART transfer
  • 0b0110xxxx Set UART speed
  • 0b1000xx00 Configure UART port (see below)
  • 0b11xxxxxx Binary Auxiliary pins

Command details

Start / Stop echo UART RX (0b00000010 / 0b00000011)

Once the local echo is started, each received byte on the UART will be sent to the user. Local echo is stopped by default. Returns 0x01

Manual baud rate (0b00000111)

This mode differs from the Bus Pirate.

This command takes 4 bytes, containing the desired baud rate value (big-endian). If the selected baud rate is not possible, the UART will be reset to 9600 bauds.

This commands returns 0x01 if successful, 0x00 in case of error.

Bulk UART transfer (0b0001xxxx)

In this mode, the last 4 bits of the command define the number of bytes to write (from 1 to 16) (Command 0b00010000 will send 1 byte). Hydrabus will read the defined number of bytes, send a 0x01 (acknowledge) after each read bytes.

Set UART speed (0b0110xxxx)

This command sets the UART device bitrate. The four last bits will select the speed (int bits/sec) within the following list :

  • 0b0000 => 640
  • 0b0001 => 1200
  • 0b0010 => 2400
  • 0b0011 => 4800
  • 0b0100 => 9600
  • 0b0101 => 19200
  • 0b0110 => 31250
  • 0b0111 => 38400
  • 0b1010 => 115200

This commands returns 0x01 if successful, 0x00 in case of error.

Configure UART port (0b1000xx00)

The following value for the `xx``bits configure the following parameters :

  • 0b00 => No parity
  • 0b01 => Even parity
  • 0b10 => Odd parity

See https://github.com/hydrabus/hydrafw/wiki/HydraFW-UART-guide for explanation.

This commands returns 0x01 if successful, 0x00 in case of error.

Example script

This script will enable BBIO UART mode and listen to all incoming bytes

import serial
import os

ser = serial.Serial('/dev/hydrabus', 115200)

for i in xrange(20):
    ser.write("\x00")
if "BBIO1" not in ser.read(5):
    print "Could not get into bbIO mode"
    quit()

print "Into BBIO mode"

print "Switching to UART mode"
ser.write('\x03')
if "ART1" not in  ser.read(4):
    print "Cannot set UART mode"
    quit()

print "Setting speed"
ser.write('\x6a')
if ser.read(1) != '\x01':
    print "Error setting speed"
    quit()

print "Starting reader"
ser.write('\x02')
if ser.read(1) != '\x01':
    print "Error starting reader"
    quit()

while 1:
    print ser.read(1),

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally