Saturday, March 17, 2018

Why sometime ...

... simple things does not work or just make you crazy losing hours and hours if not days  ?

Who work in the magical world of the software development, especially embedded or firmware, sometime find himself in weird situation, when something incredibly simple and trivial, simply does not work.
Why ?

Well, many of us attribute the fault to Murphy :), or the fate, or the BluBugEater.
The truth is ... nobody knows, every time is a challenge.

So, let see an example.
Here a simple task I wanted to do : writing a simple sketch for Energia, using a MSP430 to drive an Adafruit Ring LED.

I did grab the first Launchpad board I had around, with a MSP430G2452 and I connected with the Adafruit Neopixel ring.
Then I wrote a simple sketch to turn on some LEDs.


Then I started to cut code and put simple I/O manipulation and I had weird behavior.
So I changed Launchpad, same chip, the same.
Then I loaded some example sketch to see if the board was OK ... it was.

I started to scratch my head.
So usual things then, update everything that can be updated, check libraries version, install older versions. Nothing.

Again, is important to remember that my goal was to do a quick test !
Not spending weeks on it !!!!
So I decided to see if somebody else did something on the issue.
After a brief google search I found exactly what I wanted on : LED Hat with MSP430

So I followed the instructions, connected everything and ... nothing !!!

Time to put hand on some instrumentation.
Fired up my oscilloscope and I discovered the signal generated by the MSP430 was totally out of timing.
Instead of a period of 1.2 uSec, I had something around milliseconds !
No wonder the ring was dead.

So back again, replace Launchpad with a new one. The ones I was using had the crystal soldered, I though that maybe something was wrong with that (should not).
But as you can guess .. no luck.

Ok, at this point I decided to change chip.
I had around a MSP430G2231 but it was too small for the sketch.
So after more digging in my "rufo box" (rufo is an "Italian/dialect word to indicate junk :) ) I did found an MSP430G2553, installed it on one of the boards, recompiled the code and ... voila' !
It worked immediately.

In the end I spent almost two days  for a stupid damaged chip to do a test that would have required 5 minutes to be done.

Saturday, March 10, 2018


Years ago I did a very quick project with a MSP430F2013 capable to generate a signal to drive a magnetic clock like the one below

(the video does not represent the actual clock, just an example).

The code, few lines in C, is in the magclock repo on my github account.

The idea is quite simple.
Three coils are controlled by the MSP430 in a sequence, like the brushless hard disk motors, same principle but much much slower.
Basically the system is designed to move a dented wheel one notch every second.
That wheel then controls the other gears of the clock.

The only thing is to have an accurate timing, so better to use a crystal on the MSP430.
This article give some other information about the MSP430 clock capabilities and settings.

Friday, March 9, 2018

Update firmware of a GXV3000

The GXV3000 is an old phone from Grandstream, not anymore in production and supported, but still available on Ebay at a decent price.
It is possible to even find in Ebay "new" GXV3000, i.e. never used before, like one I bought recently as a replacement for a broken one.
So I had to go back on memory lane in order to update the firmware in it to the last available one (high recommended in order to fix the SPIT problem)
Here what is needed to do the job.

Initial requirements

It is necessary to have few things available in order to start :

  • a GXV3000 (of course)
  • a Linux server  (probably also a Windows machine acting as server works, but I prefer to use Linux).
    Can be a normal PC or a Raspberry Pi or similar small machine
  • Ubuntu or Debian.
    The examples in this article are based on Ubuntu 16.04 LTS running on a System76 server
  • both phone and server need to be on the same network

Preparing the server

The first thing to do is to prepare the server.
The server has to run the TFTP server, so first of all, install TFTP.

sudo apt-get install xinetd tftpd tftp

This should take care of the installation of the TFTP server.
Be sure to have a directory called tftpboot from the root.
If the installation didn't create one, do it manually as superuser.

sudo ls /tftpboot

if the directory is missing :

sudo mkdir /tftpboot

At this point we need to populate the tftpboot with the new firmware for the phone.
The latest available firmware for the GXV3000 family is the version and is still available here :

Download the zip file and extract it in a subdirectory under /tftpboot.
Below a suggestion about how to proceed.  Note, I suggest to create a gxv3000/fw directory under tftpboot because the TFTP can be used also for other settings on the phone, not only firmware, so better to keep things separated. 

mkdir test
cd test
mkdir -p gxv3000/fw
unzip -d gxv3000/fw

Now under the ~/test/gxv3000/fw  there are 3 files.

ls ~/test/gxv3000/fw/
boot64b.bin  gxv3000b.bin  load64b.bin

These 3 files are the ones needed to be loaded in the phone.
To do so let move them under tftpboot

sudo mv ~/test/gxv3000 /tftpboot

Verify to have /tftpboot/gxv3000 present

sudo ls /tftpboot

Now that tftpboot is populated, start the TFTP server (or restart it if it was already running)

sudo service xinetd restart

The server is ready.

Preparing the phone

Normally the phone by default is coming with the DHCP set, thus just plug in on the network and turn it on.
It should boot and an IP assigned. Wait few minutes since it is possible some old settings are in place trying to update or doing something strange :)
Locate the IP of the phone (usually is on the lower right corner) and on a browser just digit the phone IP address.
It should appear a password request :

Let's hope the default password is set, should be : admin
If not ... well, you need to factory reset the phone (see the section Factory reset below).

If you can log in then ...

Update the firmware

After the login you need to go on the tab called Advanced Settings.
Locate in the page the section called  Firmware Upgrade and Provisioning

Select the TFTP option and in the Firmware Server path put the address of the server in your network (for example and the path in the server where the firmware exists.
For example :

Then simply select the Automatic Upgrade option on Yes, and Always Check for New Firmware option.
Then click on the Update button (on the end of the page) and when asked, Reboot.

If everything is set correctly, the phone will reboot and will look for the new firmware, starting to download it.
It will take few minutes since the phone has first to download the firmware from the server and then install it in the Flash memory on board.

If everything is OK after a while the phone will reboot with the new firmware.

Repeat at this point what done before (login - go to the Advanced Setting page) and disable the check for the new firmware, also because there is no new firmware available anymore.

Done. The phone now is updated to the latest firmware.

Factory reset the phone

The Factory reset procedure allows to restore the initial phone setting, leaving it in DHCP mode.
This is important since after the Factory reset the phone will be able to automatic connect to the router and have assigned a valid IP.
The Factory reset procedure is quite simple but there is a trick.
If you have an USB keyboard, connect it to the phone.
It is necessary to enter in the phone it's own MAC address as confirmation for the Factory reset.
Is much easier to digit the MAC address on a full keyboard rather using the phone keypad.