Monday, December 22, 2014

Ubuntu 13.04/13.10 - W: Failed to fetch [source] 404 Not Found

So you're running Ubuntu 13.04 or Ubuntu 13.10, or something else, and one day, when using apt-get, this happened:

W: Failed to fetch  404  Not Found [IP: 80]

W: Failed to fetch  404  Not Found [IP: 80]

W: Failed to fetch  404  Not Found [IP: 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

Has lightning struck all the servers?  What's actually happening is that the distro has reached EOL - end of life.

What EOL means is that a lot of applications are not supported or updated anymore.  It also means that when you do an apt-get update, you might get a whole bunch of 404's, and if you try to use the Software Center, it might hang or error out with "Failed to download repository information".

Repositories contain packages which are tested and built specifically  for your version of Ubuntu.  Eventually support dies out in favour of newer releases and long term support (LTS) releases.

One option is to upgrade.  Another option is to edit your /etc/apt/sources.list file like so:

That'll keep you synced with the old versions of the packages for your release.  I used vim with the text replace commands:
(plus 'y' for every replacement).  You might need to adjust that depending on which server you're using.
More about Ubuntu repositories and servers:

Monday, November 24, 2014

Serio: A serial file transfer program without needing z/y/xmodem

In one of my previous posts I talked about using zmodem as a backup/emergency method to transfer files onto an embedded device using the serial console.  This technique requires you to have the lrz binary on the target to initiate the transfer.  But what happens if you have no way of getting lrz onto the target in the first place?  In this post I show you a method of serial transfer requiring no binaries to be on the target, and absolutely no setup on the target-side.

First, check that you have a Python 2.x version installed.  If you don't, apt-get or yum install it onto your host OS.  Check the version with python --version.

Now get the utility, which is called 'serio'.  Get it with hg clone Before you go ahead, there are two patches you need to apply (by hand):

Patch 1:
Insert self.last_size = 0 at the location shown, highlighted in green:
if callable( and callable(fp.write) and callable(fp.readline) and callable (fp.readlines):
                        self.fp = fp
                        self.current = 0
                        self.showprogress = progress

                        self.last_size = 0 

Patch 2:
Get rid of this line, on line 19:

and insert these lines instead:
already_open = self.s.isOpen()
if not already_open:

Update (14 June 2015): I tried this again recently.  It seems you may need to use self.serial.isOpen() and instead.

That patch above is for people who get the "Port is already open" error.  Now you can run the utility:

sudo ./serio -s lrz -d lrz -p /dev/ttyS0

where -s is the source file, -d is the destination, and -p is the serial (console) port.  You'll get a nice progress bar.

I recommend putting lrz onto your target (as per my example) so you can do zmodem transfers from here on in.

Help!  It transfers, but the executable doesn't work!
  • Check that the echo command on your target supports the "-n" and "-e" options (that's all you need).
  • Try cross-compiling a minimal "hello world" program with your toolchain and try transferring that, as a test.  Run it, and if you see "hello world" your settings are probably OK.  See the next point...
  • Open the source code and modify the parameter IO_TIME = .1 to be something greater than .1 (try .3 or .5).
  • In addition to the previous step, try using your toolchain's strip command to reduce the size of the binary.

Sunday, November 16, 2014

Ubuntu - Open custom terminal windows on startup or login

If you find yourself opening the same terminal windows every day, you might want to speed that up by having them automatically open up when you log in.  Here's how you do it.

Open up a terminal window, and click Edit... -> Profiles... 
Then click "New", and make a new profile.
In this case, I want to make one for  the SDK I'm working with.  I'm calling the profile "sdk", and I'm setting the title of the window to be "SDK" (in capitals).  The option under that is important.  I'm setting it to "Keep initial title" so that my custom title ("SDK") will stick, even if the terminal session tries to change it.  Here you can also change the background, text colour, and so on...

Once you've made a few profiles, navigate to Ubuntu's "startup applications" (as shown left).

Click "Add".
I like to work with tabs, so for my Command I did: gnome-terminal --maximize --tab-with-profile=sdk --working-directory=/home/andrew/sdk --tab-with-profile=kernel --working-directory=/home/andrew/kernel...

And I continued doing that for four tabs.  The --maximize option is there so they start up maximized.

The result is shown below.  This happens every time I log in.  For the profile shown I chose light grey text on a dark grey background.  Many people like to have a different background colour for each task that they're doing (maybe 'green' for debug console, 'blue' for temp directory, and so on).  You can have separate windows instead of tabs if you want, too.

Thursday, November 6, 2014

Edimax EW-7811Un Wi-fi dongle on Ubuntu

The EW-7811Un is a cheap and fairly ubiquitous Wi-fi dongle.  If your Ubuntu installation doesn't come with a driver; here's how to get it working.  I'm using Ubuntu 13.04.

This wi-fi dongle is based on the RTL8188CUS chip.  Verify that this part number shows up on lsusb (mine's on the top line):

Do a Google search for RTL8188CUS driver, download and unzip the driver (from the Realtek site is better).  It should be called (md5: 5f15575ba6ae58cae485e8060bc771ed).  You should see this:

Go to driver/, extract the .tar.gz.  Then all you should need is a make and a (sudo) make install to be in business.

Tuesday, October 21, 2014

Zmodem and minicom

Zmodem is a great "emergency backup" way of getting files on and off your target board when all other methods (SD card, ethernet, etc.) have stopped working or you don't have those functions yet.

In order to use Zmodem with Minicom, you need to first cross-compile the 'lrzsz' source code.

What happens if I can't get this file onto my target to begin with?   If this your situation, don't panic!  See my other serial transfers post.

Do a google search for lrzsz-0.12.20.tar.gz, untar it, and configure it with the following command:

CC=arm-linux-uclibc-gcc ./configure --host=arm-linux-uclibc --prefix=/home/andrew/lrzsz_out/

You'll obviously need to replace the CC, --host and --prefix with your own.  Then run:

make; make install

From all the binaries which are built, you're only going to need lrz (for receiving) and lsz (for sending).

If you want to receive a file (that is, get a file onto your target board), you first run the ./lrz binary from anywhere on the target's filesystem, and you'll get a message 'waiting to receive' (along with some ascii garble).

Then you press ctrl+a+z and then s , and then choose 'zmodem'.

After you select 'zmodem' and choose your file from the file browser, you'll see the file uploading to your target, with an ETA (time left).

Sending works similarly, except you use the ./lsz binary and select "receive" from the minicom menu instead.