I just received an Analog MetaWatch. Cool. Let’s hack it.
This page discusses updating the firmware on both Linux and Windows-based Operating Systems. I also talk about installing the toolchain for Linux,
First step: Upgrade the Firmware to 0.8.0
Hmm. After reading the notes on the wiki and the PDF from the developer site, I downloaded the updated firmware and firmware updated, and FET-Pro430 Lite. I tried to reflash my watch. I was not able to select the box that said “Verify Security Fuse” or “Auto Prog.”
Aha! I was fooled by the diagram in the reflashing manual. You cannot check those boxes. Instead, you have to press the “Verify Security Fuse” and then press “Auto Prog”.
I also tried to reflash the watch using Linux. See below.
I was reading some documents, and it suggested installing the MSP430 toolchain. This is not needed if you just want to reflash the watch because you can use apt-get to install msdebug.
However, see below, I had problems flashing with Linux. See below.
Install the Linux toolchain
I typed
sudo apt-get install subversion gcc-4.4 texinfo patch libncurses5-dev zlibc zlib1g-dev libx11-dev libusb-dev libreadline6-dev
Since I am in the “admin” group, I did the following so I don;t have to be root to update the software. So I typed
sudo mkdir /opt; sudo chgrp admin /opt; sudo chmod 775 /opt
This way I do not have to compile the toolchain using sudo. In a new directory, I typed svn checkout https://mspgcc4.svn.sourceforge.net/svnroot/mspgcc4cd mspgcZsh buildgcc.sh
This took a while to run. It failed when it tried to downloadhttp://gd.tuwien.ac.at/gnu/sourceware/insight/releases/insight-6.8-1.tar.bz2This file did not exist. So I searched for this file and found it herehttp://pkgs.fedoraproject.org/repo/pkgs/insight/insight-6.8-1.tar.bz2/4ee9824c1e8d6108d886c6c09b24f0ac/insight-6.8-1.tar.bz2So I downloaded and unpacked it into a new directory with tar xvfj insight-6.8-1.tar.bz2cd insight-6.8-1./configuremake This failed at the following
gcc -c -g -O2 -I. -I.././gdb -I.././gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd -I.././gdb/../bfd -I.././gdb/../include -I../libdecnumber -I.././gdb/../libdecnumber -DMI_OUT=1 -DGDBTK -DTUI=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wno-switch -Wno-char-subscripts -Werror linux-nat.ccc1: warnings being treated as errorslinux-nat.c: In function ‘linux_nat_info_proc_cmd’:linux-nat.c:2879: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result There were several errors. Gcc was configured to give an error for any warning. Rather than chnage the compile option, I just fixed the code. In most cases error returns were ignored. Example - I changed
fgets (buffer, sizeof (buffer), procfile);to if (fgets (buffer, sizeof (buffer), procfile)) { printf_filtered ("cmdline = '%s'\n", buffer); }
Here is the patch file I used for the changes to insight
———————–
*** ./eval.c 2011-12-25 14:09:58.000000000 -0500--- ./eval.c.~1~ 2008-02-03 19:23:04.000000000 -0500****************** 1647,1656 **** struct type *tmp_type; int offset_item; /* The array offset where the item lives */ - i=0;- while (i<=MAX_FORTRAN_DIMS) {- subscript_array[i++]=0;- } if (nargs > MAX_FORTRAN_DIMS) error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); --- 1647,1652 ----*** ./utils.c 2011-12-25 14:07:47.000000000 -0500--- ./utils.c.~1~ 2008-01-01 17:53:13.000000000 -0500****************** 704,712 **** abort (); /* NOTE: GDB has only three calls to abort(). */ default: dejavu = 3;! if (write (STDERR_FILENO, msg, sizeof (msg))==-1) {! error( ("write failed."));! } exit (1); } }--- 704,710 ---- abort (); /* NOTE: GDB has only three calls to abort(). */ default: dejavu = 3;! write (STDERR_FILENO, msg, sizeof (msg)); exit (1); } }*** ./mi/mi-cmd-env.c 2011-12-25 14:03:43.000000000 -0500--- ./mi/mi-cmd-env.c.~1~ 2008-01-01 17:53:14.000000000 -0500****************** 78,86 **** /* Otherwise the mi level is 2 or higher. */ ! if (!getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) {! error( ("getcwd failed."));! }; ui_out_field_string (uiout, "cwd", gdb_dirbuf); return MI_CMD_DONE;--- 78,84 ---- /* Otherwise the mi level is 2 or higher. */ ! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); ui_out_field_string (uiout, "cwd", gdb_dirbuf); return MI_CMD_DONE;*** ./linux-nat.c 2011-12-25 13:52:59.000000000 -0500--- ./linux-nat.c.~1~ 2008-01-29 17:47:20.000000000 -0500****************** 2876,2884 **** sprintf (fname1, "/proc/%lld/cmdline", pid); if ((procfile = fopen (fname1, "r")) != NULL) {! if (fgets (buffer, sizeof (buffer), procfile)) {! printf_filtered ("cmdline = '%s'\n", buffer);! } fclose (procfile); } else--- 2876,2883 ---- sprintf (fname1, "/proc/%lld/cmdline", pid); if ((procfile = fopen (fname1, "r")) != NULL) {! fgets (buffer, sizeof (buffer), procfile);! printf_filtered ("cmdline = '%s'\n", buffer); fclose (procfile); } else*** ./main.c 2011-12-25 14:03:43.000000000 -0500--- ./main.c.~1~ 2008-01-05 11:49:53.000000000 -0500****************** 188,196 **** line[0] = ''; /* Terminate saved (now empty) cmd line */ instream = stdin; ! if (!getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) {! error( ("getcwd failed."));! }; current_directory = gdb_dirbuf; gdb_stdout = stdio_fileopen (stdout);--- 188,194 ---- line[0] = ''; /* Terminate saved (now empty) cmd line */ instream = stdin; ! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); current_directory = gdb_dirbuf; gdb_stdout = stdio_fileopen (stdout);*** ./cli/cli-cmds.c 2011-12-25 14:03:44.000000000 -0500--- ./cli/cli-cmds.c.~1~ 2008-01-01 17:53:14.000000000 -0500****************** 320,328 **** { if (args) error (_("The \"pwd\" command does not take an argument: %s"), args);! if (!getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) {! error( ("getcwd failed."));! } if (strcmp (gdb_dirbuf, current_directory) != 0) printf_unfiltered (_("Working directory %s\n (canonically %s).\n"),--- 320,326 ---- { if (args) error (_("The \"pwd\" command does not take an argument: %s"), args);! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); if (strcmp (gdb_dirbuf, current_directory) != 0) printf_unfiltered (_("Working directory %s\n (canonically %s).\n"),*** ./inflow.c 2011-12-25 14:06:53.000000000 -0500--- ./inflow.c.~1~ 2008-01-01 17:53:11.000000000 -0500****************** 545,567 **** if (tty != 0) { close (0);! if (dup (tty)==-1) {! error(("dup(tty) failed."));! } } if (tty != 1) { close (1);! if (dup (tty)==-1) {! error(("dup(tty) failed."));! } } if (tty != 2) { close (2);! if (dup (tty)==-1) {! error(("dup(tty) failed."));! } } if (tty > 2) close (tty);--- 545,561 ---- if (tty != 0) { close (0);! dup (tty); } if (tty != 1) { close (1);! dup (tty); } if (tty != 2) { close (2);! dup (tty); } if (tty > 2) close (tty);*** ./top.c 2011-12-25 14:03:42.000000000 -0500--- ./top.c.~1~ 2008-01-01 17:53:13.000000000 -0500****************** 1628,1636 **** /* Run the init function of each source file */ ! if (!getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) {! error( ("getcwd failed."));! }; current_directory = gdb_dirbuf; #ifdef __MSDOS__--- 1628,1634 ---- /* Run the init function of each source file */ ! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); current_directory = gdb_dirbuf; #ifdef __MSDOS__
———
I then installed the gdbserver software (which apparently insight does this).
Next I went back to the previous step, and told it to not install insight (as it was already installed).
I used
perl buildgcc.pl
as the previous step said this was preferred.
I added the compiler to the searchpath by executing the following as root
echo ‘export PATH=${PATH}:/opt/msp430-gcc-4.4.3/bin;’ >/etc/profile.d/msp430.sh
Next I downloaded Next I downloaded the tar file for mspdebug from sourceforge.
And did the following
- tar xvfz mspdebug-version.tar.gzhttp://getsatisfaction.com/thingm/topics/fatory_settings_for_blinkm
- cd mspdebug-version
- make
- sudo make install
This worked. However,m I also read that I could have just installed this program using apt-get.
So I downloaded the firmware and typed
unzip MetaWatch_Analog_FW_WDS111_V0_8_0.zip
ANd then to reprogram the firmware, I typed
sudo mspdebug rf2500
and it responded
MSPDebug version 0.18 – debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Trying to open interface 1 on 002
Initializing FET…
FET protocol version is 30263144
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
Device ID: 0×0580
Device: MSP430F5438A
Code memory starts at 0x5c00
Number of breakpoints: 8
I next typed
prog AnalogWatchV0_8_0.txt
This took a while, and the system printed severla lines like
Erasing…
Programming…
Writing 4096 bytes to 5c00…
Writing 4096 bytes to 6c00…
Writing 4096 bytes to 7c00…
[snip]]]
Writing 4096 bytes to 29ff0…
Writing 4096 bytes to 2aff0…
Writing 4096 bytes to 2bff0…
Writing 4096 bytes to 2cff0…
Writing 2138 bytes to 2dff0…
And then I got the prompt again. I tried pressing the buttons with the USB connector attached, and I saw nothing. I was worried I bricked the device at first. But when I disconnected and reconnected the clip, the watch returned to normal, and when I pressed the status button, It reported it was using the 0.8.0 firmware version…
I reread the forum, and I did not update all of the flash. The text files goes up to @2E800 and beyond. But according to Daniel Beer, this is normal. 2138 bytes past
0x2dff0 is 0x2e84a, which appears to be the upper limit of the firmware.
So both Linux and Windows were successfully able to upload the firmware.
References