Making EEPROM non-volatile on YUN

The Arduino YUN is one of my favorite prototyping platforms for Wi-Fi connected microcontroller applications, but for unclear reasons the originators felt that by default the EEPROM contents should be lost when reprogramming code images.  Let’s fix that.

I typically use EEPROM to store board-specific identification, configuration, and calibration information — things I’d rather not lose when updating the code.  And if you only update using the USB connection you’ll be fine.  But leverage one of the great features of the YUN — updates over Wi-Fi within the IDE — and say goodbye to your EEPROM.

It’s an easy fix, though, and you just need to ssh into the board, change two bytes, and EEPROM will then be preserved.

You’ll need to have your YUN connected to Wi-Fi, and you’ll need the IP address.  To find it, either use the IDE to select the Wi-Fi connected port, or use a Bonjour browser such as this one for Windows.

Once you have an IP address. ssh into the board using a tool such as Putty.  Then navigate to /usr/bin and edit (I use vi) run-avrdude, changing the 0xD8 after hfuse to be 0xD0.  Save the file and your Wi-Fi code updates will no longer clear out your EEPROM settings.

root@MyYunName:/usr/bin# cd /usr/bin
root@MyYunName:/usr/bin# vi run-avrdude
#!/bin/sh
echo 1 > /sys/class/gpio/gpio21/value
avrdude  -q -q -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U efuse:r:/tmp/efuse:d
read EFUSE < /tmp/efuse
rm -f /tmp/efuse
if [ “x$EFUSE” = “x203” ] # 203 = 0xCB
then
        avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD0:m -U efuse:w:0xCB:m -Uflash:w:$1:i $2
else
        avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD0:m -U efuse:w:0xFB:m -Uflash:w:$1:i $2
fi
echo 0 > /sys/class/gpio/gpio21/value
Advertisements

High resolution run-time delays on ATmega (Arudino) platforms

I recently encountered a need to dynamically generate high resolution time delays on an Arduino platform (YUN, ATmega), and this thread is to share the solution in case it helps others.
This gives run-time adjustable delays as low as 625ns and with resolution steps of 62.5ns to 96.25us.
If others have superior solutions, I’m all ears.
/*————————————————————–*/
/* Delay loop functions so we can do single cycle programmable  */
/* delays (62.5ns resolution).                                  */
/*————————————————————–*/
 
byte tune_delay=20;                  // nominal starting value
unsigned long freq;
 
void Delay_Plus0(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
}
 
void Delay_Plus1(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
  DELAY_63NS;
}
 
void Delay_Plus2(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
  DELAY_63NS; DELAY_63NS;
}
 
void Delay_Plus3(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
  DELAY_63NS; DELAY_63NS; DELAY_63NS;
}
 
void Delay_Plus4(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
  DELAY_63NS; DELAY_63NS; DELAY_63NS; DELAY_63NS;
}
 
void Delay_Plus5(byte ticks)
{
  for (; ticks; ticks–) DELAY_63NS; // 375ns/tick
  DELAY_63NS; DELAY_63NS; DELAY_63NS; DELAY_63NS; DELAY_63NS;
}
 
 
 
// —————- Setup for changing the delay:
 
    byte tune_delay_div;
    void (*delay_func_ptr)(byte);
    switch (tune_delay%6) {
      case 0 : delay_func_ptr = &Delay_Plus0; break;
      case 1 : delay_func_ptr = &Delay_Plus1; break;
      case 2 : delay_func_ptr = &Delay_Plus2; break;
      case 3 : delay_func_ptr = &Delay_Plus3; break;
      case 4 : delay_func_ptr = &Delay_Plus4; break;
      case 5 : delay_func_ptr = &Delay_Plus5; break;
    }
    tune_delay_div = tune_delay/6

// —————- Using the delay in the timing critical section

 
      (*delay_func_ptr)(tune_delay_div); // (625 + tune_delay*62.5) ns

You know what they say about people with big hands?

They need big mice.

In this era of making everything smaller, some things aren’t getting smaller.  Us.

For me it’s always been a challenge to find a mouse that fit well as most of mice out there are too small.  Years ago there was the Whale Mouse, but alas, that can only be found in dark alleys and surplus stores now and even it wasn’t perfect having lacked side buttons.

The rest of this story is a quick review of larger mice that can be found in active production, and what I found to be the winners in the group. Continue reading

Tagged , , , , ,

Google SearchNinja tips

I often dismiss these type of articles as a collection of “secrets” that aren’t actually so secret.  Like that exit on I-80 for Secret Town Road – how secret can that be?

Well, this article has some great Google Search tricks that are quite useful.

 

My two top favorites:

  • Image search by uploading an image. Wow. Very cool. Upload an image and the Goog will find images that are similar. Looking for a higher resolution of an image you already have? Use this. Like your image of the horned frog but want to find it in a different pose? Use this.
  • Block sites from your searches…always. Have a grudge against Amazon.com? Put them on your list of sites to never search against and you don’t have to see them again.


Tagged , , , ,

Tufte-isms: Great words from a man of great graphs

Engineering is a marvelous thing.  We get the joy of creating the amazing things that make life better and often more interesting, or at least more entertaining at times.  We don’t live in a vacuum, though, we the engineers, and as such we need to be good communicators.

Enter Edward Tufte.

If you’ve not been to one of his presentations, I highly recommend you put one on your schedule — he is the master evangelist of the power of quality graphics.  His point being that the data, no matter how good, is worthless unless you can convey the messages within.

What brings him up in my mind today, is an entertaining article from IEEE Spectrum in which the author talks about not the graphs of Tufte, but rather the words of Tufte.

Worth a read here.

Tagged , , , , ,

Sometimes it *is* all about the blinky light

This is a great story of an amazingly innovative solution to a difficult and expensive problem.

Continue reading

Tagged , , , , , , , , ,

CES 2012 – Armageddon Year?

CES 2012 – Armageddon Year?

According to the Mayans the calendar comes to an end this year.  Does this mean the world ends?  Probably not.  But maybe they were thinking of CES. Continue reading

Tagged , , , , , , ,