Thursday, October 29, 2015

Lattic iCEcube2 on Debian

I recently started looking at Lattice chips for a project that needs a fairly small FPGA. They have small devices that are significantly lower in cost than the larger Xilinx Spartan chips I've used in the past. To explore further, I ordered the ICE40HX1K eval board ($22) and downloaded the free iCEcube2 IDE for my Debian stable(Jessie) 64-bit PC.
The first try at installing the IDE hit issues:
 error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory
The library is installed, so obviously the IDE wants the 32-bit version. I haven't tried to work with 32-bit stuff since Debian went to the multiarch approach, so that led to a new learning experience. Previously one would install ia32 versions of the needed libraries. After a bit of googling, I found that the current approach is (as root, or using sudo):
dpkg --add-architecture i386 # Include 32-bit stuff
apt-get update  # Add in the lists of 32-bit packages.
apt-file search libXext.so.6 # Find out what package I need - libxext6 in this case.
apt-get install libxext6:i386 # Add the 32-bit version of thepackage.
Now, the install fails because it's missing libpng12.so.0, so repeat the apt-file search and apt-get install steps for that. In Total I ended up installing  libpng12-0:i386, libsm6:i386, libxi6:i386, libxrender1:i386, libxrandr2:i386, libxfixes3:i386, libxcursor1:i386, libxinerama1:i386, libfreetype6:i386, libfontconfig1:i386, libglib2.0-0:i386.
With that, iCEcube2 installs and runs.

Now I can start playing with the eval board when it shows up.


Notes:

hackaday.io/project/6592-dipsy/log/24272-installing-icecube-2-on-ubuntu-14042-lts  Pointed me in the right direction to complete the install. Their Dipsy project uses the Lattice chip, and looks interesting.

Monday, October 5, 2015

Pebble watch programming to extend battery life.

These are my observations to date on battery life with the Pebble classic watch. I figure the data will be of interest to other watch face developers.

For my own Pebble watchface I wanted:
  • Simple digital display with seconds counter.
  • Show current date.
  • Large characters to be readable in poor light conditions.
Once it was running, I wanted to measure and optimize battery life. The watch reports battery state in 10% increments, so I track the level changes as a function of time.
Pebble has some hints online at developer.getpebble.com/guides/best-practices/battery-perform-guide/ . Basically, they say to do as little as possible when servicing the timer ticks, and minimize the portion of the screen that's updated.
The plot here was obtained with the watchface shown in my previous post: blog.sensicomm.com/2015/09/pebble-watch-programming.html . The green lines are the first version: I call the routines to update everything on the screen every second. For the blue line, I update the seconds display every second, but the rest of the display only updates every minute. For the red line, I update the seconds every second (obviously), the hour and minute update when the minute changes, and the day updates every hour. The short magenta line is like red, except I turn the backlight off (instead of auto) and turn the watch off at night. Bluetooth was off in all cases.
Observations:
  • The time from end-of-charging to 90% battery level varies widely, from a few minutes to many hours. My guess is that the battery keeps trickle charging even after the display shows charge is complete: the shortest times to 90% were when I took the watch off charge immediately, and the longest were when it was connected for an hour or so after the indicated completion of charge.
  • That said, minimizing unnecessary screen updates appears to make a significant difference in power use: an additional day or so before the battery drops to 40% remaining power.
  • I probably won't bother keeping the backlight off or turning the watch off at night: the savings don't seem that great and the inconvenience is significant.
  • The screen backlight was in auto mode: it comes on for a few seconds when the watch shakes. It did occasionally come on during all tests (except magenta). No sure how much difference it made.
Again, this is for the Pebble Classic; no idea how it works on other Pebbles.

Tuesday, September 22, 2015

Pebble watch programming.

Time for a new watch. I chose the Pebble classic because I like the idea of a daylight-readable (e-paper) display and multi-day battery life between charges. The fact that several were available on ebay at good prices didn't hurt either.
Yes, I do love the display. It's a crisp and clear monochrome, easily readable in sunlight. In the photo, you may notice a bit of "rainbow" effect to the left of the time and date. That seems to be a polarization effect: it's noticeable when wearing polarized sunglasses or with indirect illumination from a clear sky. In direct sunlight or artificial light the rainbows go away.

Programming

The watch has an ARM chip in it, so of course I have to develop my own watch face. Pebble has an online development platform, but I decided to install the SDK on my Debian PC. I got the SDK from developer.getpebble.com/sdk/ and installed it per the instructions, which includes installing several libraries and python packages. A couple of notes:
  • The "pip install -r requirements.txt" command takes a long time to run -- several minutes.
  • I did not install the Pebble-supplied ARM compiler: it requires a later version of glibc than I have installed. I already had a compiler installed (blog.sensicomm.com/2014/02/stm32-on-linux-again.html), and it seems to work fine.
  • To tell the SDK where the existing compiler is:
    • cd $HOME/pebble-dev/PebbleSDK-3.3/
    • ln -s  /opt/gcc-arm-none-eabi arm-cs-tools
And it works. I was able to compile a sample program using the "pebble build" command and install it using Bluetooth and an Android phone.