[OpenTRV-interest] How to update firmware on an OpenTRV board

Alasdair Macdonald EMAIL ADDRESS HIDDEN
Fri Nov 7 18:27:44 GMT 2014


I have succeeded in flashing new firmware onto my OpenTRV boards ...
after a struggle and much time and help from Damon & Bo.

However, the key problem turned out to be my version of the Arduino
IDE, and very easily solvable.

The correct and working procedure (on my Debian PC) was as follows:

1. Download current code.

1a. sudo apt-get install subversion
1b. Create a directory for the code, in my case I created
~/data/software/opentrv
    cd ~/data/software/
    mkdir opentrv
    cd opentrv
1c. Download code. 427M of it - including plenty of pdfs and other
files that aren't necessary for the compile. perhaps Damon can advise
ways of downloading only the subset of files that are necessary, if
appropriate. The command below creates a subdirectory "opentrv-code-0"
in the current directory; everything that is downloaded will exist
within this new subdirectory.
    svn checkout svn://svn.code.sf.net/p/opentrv/code-0/trunk opentrv-code-0
1d. Verify that the ".ino" file exists:
    cd opentrv-code-0/Arduino/V0p2_Main/
    ls
There should be a file:
V0p2_Main.ino
1e. Any time that I require to update my local copies of the files:
    cd ~/data/software/opentrv-code-0/
    svn update
    ... will produce output such as:
U    Arduino/V0p2_Main/V0p2_Main.ino
U    Arduino/V0p2_Main/Unit_Tests.cpp
U    Arduino/V0p2_Main/V0p2_Generic_Config.h
U    Arduino/V0p2_Main/AltMain.cpp
U    Arduino/V0p2_Main/V0p2_Main.h
U    Arduino/V0p2_Main/Unit_Tests.h
U    Arduino/V0p2_Main/V0p2_Board_IO_Config.h
Updated to revision 3552.



2. Flash the board

2a. Connect a board via the FTDI cable, taking care to have jumpers in
appropriate positions. (Both jumpers present if power is to be
provided via the FTDI cable).
2b. Open the Arduino IDE - *VERSION NUMBER PROBABLY MATTERS A LOT - see below*
    If this is the first time that you have used the Arduino IDE, see
https://sourceforge.net/p/opentrv/wiki/Arduino/
    Select the appropriate board - "Optiboot 5 ..." as usual, if it is
not already selected
    Select the appropriate port - e.g. /dev/ttyUSB0 as usual, if it is
not already selected
    File / Open / browse to and select the file that was identified in
(1d) above - "Arduino/V0p2_Main/V0p2_Main.ino". I assume that this
MIGHT vary for different / newer revisions of the boards.
    Click on "upload" button
    Displays message "compiling ..."
    Displays message "uploading ..."
    When message shows "done" ...
2c. Open the Arduino IDE Serial monitor (Tools / Serial Monitor, or
CTRL - SHIFT - M)
    Check that the Baud rate is set to 4800 baud (at the bottom right
of the serial monitor window)
    Unit will reboot with new firmware. Depending upon how quick you
are, you may see some or all of the boot messages. The first line of
the boot output, OR the output of the "V" command, will show the
version:

For instance:
board V0.2 REV2; code $Id: V0p2_Main.ino 3548 2014-11-07 12:04:42Z
damonhd $ 2014/Nov/ 7 17:20:40


The only difficulty that I encountered was garbled output in the
serial monitor - I would be able to read the first 3 or so lines of
the boot log, then the characters would go bad. Thanks to Damon and Bo
for providing a lot of time and help in order to eliminate as many
causes as possible. But the solution was very simple; I experienced
this problem with Arduino IDE 1.0.1 on my 32 bit Debian desktop PC; it
disappeared when I used 1.0.6 on a Windows PC. I have subsequently
tested with 1.0.6 under Debian, although this had to be downloaded
manually and is NOT in the Debian (wheezy) repository at the time of
writing.

So, if you have a version of the Arduino IDE that is older than 1.0.6,
I suggest upgrading to 1.0.6. Although 1.0.1 is the version that is
currently available in the Debian Wheezy respository, manual download
turned out to be much simpler than I expected:

* IDE download page: http://arduino.cc/en/main/software
* Having downloaded arduino-1.0.6-linux32.tar , I cd'ed to the
directory where I had downloaded it:
  tar xzvf arduino-1.0.6-linux32.tar
* Created launcher shortcut to ~/data/software/ArduinoIDE/arduino-1.0.6/arduino
* See https://sourceforge.net/p/opentrv/wiki/Arduino/ for change that
is required to boards.txt; this file was found in
~/data/software/ArduinoIDE/arduino-1.0.6/hardware/arduino/boards.txt

Of course those paths may be different for anyone who follows these
instructions and chooses different download locations.


Note that the IDE 1.0.1 problem did NOT go away when I connected a
board flashed using 1.0.1 to version 1.0.6 of the IDE. I had to
*FLASH* using 1.0.6. Having done so, I can now read the serial data
correctly using 1.0.1, but we only get the behaviour that we want when
we flash with 1.0.6. (Whether 1.0.2, or 1.0.3 etc might work, I can't
say).


Thanks again to Bo and Damon for their time and suggestions.


More information about the OpenTRV-interest mailing list