Difference between revisions of "HydraNFC"

From YobiWiki
Jump to navigation Jump to search
 
(33 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
* http://hydrabus.com/
 
* http://hydrabus.com/
 
* https://github.com/bvernoux/hydrabus
 
* https://github.com/bvernoux/hydrabus
** https://github.com/bvernoux/hydrabus/tree/master/firmware/hydrafw
+
* https://github.com/bvernoux/hydrafw
  +
* https://github.com/bvernoux/hydranfc
  +
 
==Getting firmware sources==
 
==Getting firmware sources==
  +
See [https://github.com/bvernoux/hydrafw/wiki/how-to-build-flash-and-use-hydrafw-on-linux here]. Personally I prefer a slightly different approach:
 
<source lang=bash>
 
<source lang=bash>
sudo apt-get install git dfu-util python
+
sudo apt-get install git dfu-util python python-git
 
cd .../path_to_hydrabus
 
cd .../path_to_hydrabus
 
wget http://www.bialix.com/intelhex/intelhex-1.4.zip
 
wget http://www.bialix.com/intelhex/intelhex-1.4.zip
Line 16: Line 19:
 
wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
 
wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
 
tar xjf gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
 
tar xjf gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
git clone https://github.com/bvernoux/hydrabus.git hydrabus
+
git clone https://github.com/bvernoux/hydrafw.git hydrafw
cd hydrabus/
+
cd hydrafw
git submodule init
 
git submodule update
 
cd firmware/hydrafw
 
 
git submodule init
 
git submodule init
 
git submodule update
 
git submodule update
Line 28: Line 28:
 
<source lang=bash>
 
<source lang=bash>
 
cd .../path_to_hydrabus
 
cd .../path_to_hydrabus
export PATH=$PATH:$(pwd)/gcc-arm-none-eabi-4_7-2013q3/bin
+
export PATH=$(pwd)/gcc-arm-none-eabi-4_7-2013q3/bin:$PATH
  +
cd hydrafw/src
cd hydrabus/firmware/hydrafw
 
 
make clean
 
make clean
 
make
 
make
 
</source>
 
</source>
  +
And if you get an error such as
  +
TypeError: __init__() got an unexpected keyword argument 'search_parent_directories'
  +
it's because your python-git version doesn't support search_parent_directories option, just remove it:
  +
<source lang=diff>
  +
diff a/scripts/hydrafw-version.py b/scripts/hydrafw-version.py
  +
--- a/scripts/hydrafw-version.py
  +
+++ b/scripts/hydrafw-version.py
  +
@@ -11,7 +11,7 @@ parser = OptionParser(usage=usage)
  +
(options, args) = parser.parse_args()
  +
if len(args)==1:
  +
sys.stdout = open(args[0], 'w')
  +
- git=Repo(search_parent_directories=True).git
  +
+ git=Repo().git
  +
</source>
  +
 
==Flashing firmware==
 
==Flashing firmware==
  +
This works only from USB1, not USB2!!
  +
  +
Since v0.5-beta, no need for wires, just press UBTN at PowerOn/RESET:
  +
* ULED blinks in normal mode and stays ON in DFU mode
 
<source lang=bash>
 
<source lang=bash>
 
cd .../path_to_hydrabus
 
cd .../path_to_hydrabus
  +
cd hydrafw/src
cd hydrabus/firmware/hydrafw
 
python dfu-convert.py -i ./build/hydrafw.hex ./build/hydrafw.dfu
 
</source>
 
Now connect HydraBus pin BOOT0 to 3V3 (using a dual female splittable jumper wire) to enter USB DFU and connect microUSB (USB1) to PC
 
<source lang=bash>
 
 
sudo dfu-util -a 0 -d 0483:df11 -D ./build/hydrafw.dfu
 
sudo dfu-util -a 0 -d 0483:df11 -D ./build/hydrafw.dfu
 
</source>
 
</source>
  +
For older firmware or if the device gets "bricked" (e.g. bad usb while flashing), UBTN is not working, do it the old way:
Disconnect MicroUsb cable from HydraBus and Disconnect 'BOOT0 to 3V3' and Reconnect microUSB to PC
 
  +
<br>Connect HydraBus pin BOOT0 to 3V3 and BOOT1 to GND (using a dual female splittable jumper wire) to enter USB DFU and connect microUSB (USB1) to PC (see [https://github.com/bvernoux/hydrafw/wiki/Getting-Started-with-HydraBus-flash-and-use-hydrafw-on-linux image])
  +
<br>After flashing, disconnect 'BOOT0 to 3V3' and 'BOOT1 to GND' and power cycle or reset board
   
 
==Getting ready to use HydraBus==
 
==Getting ready to use HydraBus==
Line 63: Line 80:
 
</source>
 
</source>
 
"h" for help, TAB for autocompletion
 
"h" for help, TAB for autocompletion
  +
==HydraBus UART==
  +
Some notes on the high speed UART:
  +
<br>USART1 (pins PA9=TX & PA10=RX) is able to run up to 10.5M bauds
  +
<br>For high baudrates you need a very recent firmware to [https://github.com/bvernoux/hydrafw/pull/14 fix a bug in ST drivers], otherwise only a few values will work as expected (2.1M, 2.625M, 3.5M, 5.25M)
  +
<br>Usage:
  +
uart1> speed 5000000
  +
Final speed: 4941176 bps(1.19% err)
  +
uart1> write 0x61:10
  +
WRITE: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
  +
  +
===FTDI C32HM-DDHSL-0 cable===
  +
To use high baudrates, one can use e.g. the FTDI C32HM-DDHSL-0 cable.
  +
<br>Connection to hydrabus UART1:
  +
* yellow ADBUS1 RX - PA9 USART1 TX
  +
* orange ADBUS0 TX - PA10 USART1 RX
  +
* black GND - GND
  +
  +
From a few tests I ran with a Picoscope as independent reference to measure the actual baudrates on the wires, the FTDI works reliably up to 6.1M, then setting values such as 6.3M will actually give 8.55M and settings of 8.3M and above will be silently downgraded to 115200.
  +
  +
So one can reliably use hydrabus & FTDI at 6M bauds, maybe 8.5M if done cautiously (setting FTDI at 6.3M).
  +
====FTDI C32HM-DDHSL-0 under Linux====
  +
Under Linux it's quite cumbersome to set arbitrary baudrates, see https://stackoverflow.com/questions/12646324/how-to-set-a-custom-baud-rate-on-linux
  +
* stty accepts only the following baudrates above 115200: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000 and 4000000.
  +
stty -F /dev/ttyUSB0 4000000
  +
cat /dev/ttyUSB0
  +
* putty accepts everything but will configure to the closest match from stty/termbits list.
  +
* screen accepts everything but downgrade to 9600 if not 230400 or 460800.
  +
* using [https://gist.github.com/sentinelt/3f1a984533556cf890d9 this code] to setup arbitrary baudrate:
  +
wget -O uart_set_baudrate.c https://gist.githubusercontent.com/sentinelt/3f1a984533556cf890d9/raw/9b3b65d33e08f6889c8553b812544fe0dab3d757/gistfile1.c
  +
gcc -o uart_set_baudrate uart_set_baudrate.c
  +
./uart_set_baudrate /dev/ttyUSB0 8400000
  +
  +
====FTDI C32HM-DDHSL-0 under Windows====
  +
under Windows 7 with putty, any baudrate up to 6M is possible, higher values lead to other measured values as explained above (e.g. set 6.3M = measured 8.55M)
  +
===To recap, how to get highest baudrates===
  +
====4M====
  +
That's the maximum I'm aware with standard Linux tools for the FTDI: use stty or putty for a bidirectional link.
  +
<br>Hydrabus:
  +
uart1> speed 4000000
  +
Final speed: 4000000 bps(0.00% err)
  +
Under Linux:
  +
stty -F /dev/ttyUSB0 4000000
  +
cat /dev/ttyUSB0
  +
or
  +
putty -serial -sercfg 4000000 /dev/ttyUSB0
  +
Under Windows simply use putty -> 4000000
  +
  +
====8.4M====
  +
That's the maximum the FTDI can reach under normal operations compatible with hydrabus (from 6.3M things go weird, FTDI doc says FT232H goes up to 12M but does not support baudrates of 7M, 9M, 10M and 11M)
  +
<br>Hydrabus:
  +
uart1> speed 8400000
  +
Final speed: 8400000 bps(0.00% err)
  +
Under Linux this requires to use the ./uart_set_bautrate code snippet above. I'm not aware of an easy way to get a bidirectional link so here just getting data from hydrabus:
  +
./uart_set_baudrate /dev/ttyUSB0 8400000
  +
cat /dev/ttyUSB0
  +
Under Windows simply use putty -> 8400000
  +
  +
====10.5M====
  +
Hydrabus:
  +
uart1> speed 10500000
  +
Final speed: 10500000 bps(0.00% err)
  +
Now finds something else than the FTDI to talk with the hydrabus ;-)
  +
  +
====12M====
  +
That's the only baudrate the FTDI can reach above 8.4M
  +
<br>Under Linux this requires to use the ./uart_set_bautrate code snippet above.
  +
./uart_set_baudrate /dev/ttyUSB0 12000000
  +
cat /dev/ttyUSB0
  +
Under Windows simply use putty -> 12000000
  +
<br>Now finds something else than the hydrabus to talk with the FTDI ;-)
  +
<br><br>Above 6M, actually the FTDI supports only two speeds: 8.6M and 12.2M (measured with picoscope) and any value in between will map to those 2 values:
  +
* 6.1M to 10.6M -> 8.6M (compatible with the 8.4M of hydrabus)
  +
* 10.7M to 12M -> 12.2M (compatible with any 12M)
   
 
=HydraNFC=
 
=HydraNFC=

Latest revision as of 16:24, 24 November 2017

Some personal notes...

HydraBus

Links

Getting firmware sources

See here. Personally I prefer a slightly different approach:

sudo apt-get install git dfu-util python python-git
cd .../path_to_hydrabus
wget http://www.bialix.com/intelhex/intelhex-1.4.zip
unzip intelhex-1.4.zip
cd intelhex-1.4
python setup.py install --user
cd .../path_to_hydrabus
wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
tar xjf gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
git clone https://github.com/bvernoux/hydrafw.git hydrafw
cd hydrafw
git submodule init
git submodule update

Compiling firmware

cd .../path_to_hydrabus
export PATH=$(pwd)/gcc-arm-none-eabi-4_7-2013q3/bin:$PATH
cd hydrafw/src
make clean
make

And if you get an error such as

TypeError: __init__() got an unexpected keyword argument 'search_parent_directories'

it's because your python-git version doesn't support search_parent_directories option, just remove it:

diff a/scripts/hydrafw-version.py b/scripts/hydrafw-version.py
--- a/scripts/hydrafw-version.py
+++ b/scripts/hydrafw-version.py
@@ -11,7 +11,7 @@ parser = OptionParser(usage=usage)
 (options, args) = parser.parse_args()
 if len(args)==1:
   sys.stdout = open(args[0], 'w')
-  git=Repo(search_parent_directories=True).git
+  git=Repo().git

Flashing firmware

This works only from USB1, not USB2!!

Since v0.5-beta, no need for wires, just press UBTN at PowerOn/RESET:

  • ULED blinks in normal mode and stays ON in DFU mode
cd .../path_to_hydrabus
cd hydrafw/src
sudo dfu-util -a 0 -d 0483:df11 -D ./build/hydrafw.dfu

For older firmware or if the device gets "bricked" (e.g. bad usb while flashing), UBTN is not working, do it the old way:
Connect HydraBus pin BOOT0 to 3V3 and BOOT1 to GND (using a dual female splittable jumper wire) to enter USB DFU and connect microUSB (USB1) to PC (see image)
After flashing, disconnect 'BOOT0 to 3V3' and 'BOOT1 to GND' and power cycle or reset board

Getting ready to use HydraBus

sudo apt-get install screen
cat |sudo tee /etc/udev/rules.d/09-hydrabus.rules << EOF
# UDEV Rules for HydraBus boards, http://www.hydrabus.com
# Avoid modem-manager to mess with this device:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"
EOF
sudo udevadm trigger

Users members of plugdev group are now ready to use HydraBus

Using HydraBus

Connect microUSB (USB1 or USB2) to PC

screen /dev/ttyACM0

"h" for help, TAB for autocompletion

HydraBus UART

Some notes on the high speed UART:
USART1 (pins PA9=TX & PA10=RX) is able to run up to 10.5M bauds
For high baudrates you need a very recent firmware to fix a bug in ST drivers, otherwise only a few values will work as expected (2.1M, 2.625M, 3.5M, 5.25M)
Usage:

uart1> speed 5000000
Final speed: 4941176 bps(1.19% err)
uart1> write 0x61:10
WRITE: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61 

FTDI C32HM-DDHSL-0 cable

To use high baudrates, one can use e.g. the FTDI C32HM-DDHSL-0 cable.
Connection to hydrabus UART1:

  • yellow ADBUS1 RX - PA9 USART1 TX
  • orange ADBUS0 TX - PA10 USART1 RX
  • black GND - GND

From a few tests I ran with a Picoscope as independent reference to measure the actual baudrates on the wires, the FTDI works reliably up to 6.1M, then setting values such as 6.3M will actually give 8.55M and settings of 8.3M and above will be silently downgraded to 115200.

So one can reliably use hydrabus & FTDI at 6M bauds, maybe 8.5M if done cautiously (setting FTDI at 6.3M).

FTDI C32HM-DDHSL-0 under Linux

Under Linux it's quite cumbersome to set arbitrary baudrates, see https://stackoverflow.com/questions/12646324/how-to-set-a-custom-baud-rate-on-linux

  • stty accepts only the following baudrates above 115200: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000 and 4000000.
stty -F /dev/ttyUSB0 4000000
cat /dev/ttyUSB0
  • putty accepts everything but will configure to the closest match from stty/termbits list.
  • screen accepts everything but downgrade to 9600 if not 230400 or 460800.
  • using this code to setup arbitrary baudrate:
wget -O uart_set_baudrate.c https://gist.githubusercontent.com/sentinelt/3f1a984533556cf890d9/raw/9b3b65d33e08f6889c8553b812544fe0dab3d757/gistfile1.c
gcc -o uart_set_baudrate uart_set_baudrate.c 
./uart_set_baudrate /dev/ttyUSB0 8400000

FTDI C32HM-DDHSL-0 under Windows

under Windows 7 with putty, any baudrate up to 6M is possible, higher values lead to other measured values as explained above (e.g. set 6.3M = measured 8.55M)

To recap, how to get highest baudrates

4M

That's the maximum I'm aware with standard Linux tools for the FTDI: use stty or putty for a bidirectional link.
Hydrabus:

uart1> speed 4000000
Final speed: 4000000 bps(0.00% err)

Under Linux:

stty -F /dev/ttyUSB0 4000000
cat /dev/ttyUSB0

or

putty -serial -sercfg 4000000 /dev/ttyUSB0

Under Windows simply use putty -> 4000000

8.4M

That's the maximum the FTDI can reach under normal operations compatible with hydrabus (from 6.3M things go weird, FTDI doc says FT232H goes up to 12M but does not support baudrates of 7M, 9M, 10M and 11M)
Hydrabus:

uart1> speed 8400000
Final speed: 8400000 bps(0.00% err)

Under Linux this requires to use the ./uart_set_bautrate code snippet above. I'm not aware of an easy way to get a bidirectional link so here just getting data from hydrabus:

./uart_set_baudrate /dev/ttyUSB0 8400000
cat /dev/ttyUSB0

Under Windows simply use putty -> 8400000

10.5M

Hydrabus:

uart1> speed 10500000
Final speed: 10500000 bps(0.00% err)

Now finds something else than the FTDI to talk with the hydrabus ;-)

12M

That's the only baudrate the FTDI can reach above 8.4M
Under Linux this requires to use the ./uart_set_bautrate code snippet above.

./uart_set_baudrate /dev/ttyUSB0 12000000
cat /dev/ttyUSB0

Under Windows simply use putty -> 12000000
Now finds something else than the hydrabus to talk with the FTDI ;-)

Above 6M, actually the FTDI supports only two speeds: 8.6M and 12.2M (measured with picoscope) and any value in between will map to those 2 values:

  • 6.1M to 10.6M -> 8.6M (compatible with the 8.4M of hydrabus)
  • 10.7M to 12M -> 12.2M (compatible with any 12M)

HydraNFC

HydraNFC must be plugged on the front side of HydraBus!

Links

Sniffing

  • "nfc_sniff" or press K3
  • Press K4 to interrupt

If a MicroSD is present, it will automatically save the trace in a txt file