ADAM'S WEB PRESENCE

30 March 2007

Verifying DVD Shrink discs using MultiComp

Filed under: Nerd Notes — adam @ 11:39 am

Multicomp-dvdshrink.pngI’ve been using DVD Shrink a bit lately. It is a very nice piece of software. It can strip all the annoying menus, ads and copyright screens from a DVD and burn a new DVD containing just the movie. Luxury!

Because I’m a nerd, I always like to verify the disc has burnt properly so of course I use my very handy tool, MultiComp. Here are the settings you would use to verify a DVD created with DVD Shrink:

Source: C:\SW_I
Compare with: D:\VIDEO_TS

NOTE: This example assumes you used the default location for your DVD Shrink temporary folder and that your DVD burner is drive D:

Click here to get a free copy of MultiComp for Windows. It really is a very handy tool.


29 March 2007

Kid scribble

Filed under: General — adam @ 10:40 am

Scraggle.pngI really like this picture of me that Kai drew (sorry about the bad scan). I love the messy hair and the facial hair and the slightly insane expression. He’s really captured me well I think.

And look. He’s also drawn a chibi-version of me at the top of the page. How cool is that! Hmm maybe I’ve been showing the kid too much Anime.


PS. Kai says this picture is about the time I went upstairs to his bedroom and brought one of his toys down for him. So there’s a picture of me downstairs and a little picture of me upstairs in Kai’s bedroom. The hoops down the left are the stairs!


28 March 2007

Resending mail with Exim4

Filed under: Nerd Notes — adam @ 10:50 pm

Today’s challenge is to take all the email in a mailbox and send it on to a new address. I need to do this because of a friend I had been hosting email for on my home box. He now has a new email address and I want to forward all the mail in his account to his new address before shutting down the old account.

I am running Debian Etch and using exim4 which is the default mailer for Etch. Fortunately for me, exim4 stores each mail in a separate file in the directory ~/Maildir/cur. The files are already in MIME format so all I need to do is pipe them back to exim with a new address.

Here are the magic commands to do it. In this example, I am sending all messages for user “bobp” to the new address “bob@boogermail.com”. You will obviously need to replace these with more relevant names.

cd /home/bobp/Maildir/cur

for file in `ls`; do exim4 bob@boogermail.com < $file; done

Don’t forget the back-ticks on the ls command!


20 March 2007

Getting Started with the Olimex SAM7-P256

Filed under: Nerd Notes — adam @ 10:59 pm

sam7-p64-smaller.jpg I recently bought a SAM7-P256 microcontroller kit from Olimex. It’s a nice little board but it was quite a challenge to get something running on it. All the information I could find was either a) for experienced ARM programmers, b) for completely different ARM variants or c) for Windows users.

I am an experienced C programmer but I have no ARM experience. What I really wanted was a fairly straightforward step-by-step guide to getting something simple running for this particular board using a cross-compiler on Linux. I guess I’ll have to write it myself.

So here is my simple step-by-step to get you up and running with a simple blinking LED program using free tools.

Summary
Here is what we’ll be doing:

  1. Build a toolchain (assembler, C compiler and linker) on a Linux PC.
  2. Obtain header files specific to the Atmel chip and Olimex board.
  3. Create the C runtime environment so we can run a C program.
  4. Create a simple C program and compile it.
  5. Download the compiled code via USB into the board’s RAM and run it.

Note that I will not be covering how to load a program into flash memory or how to load an operating system onto the ARM.

STEP 1 – Create the GCC toolchain

We’ll be using GCC as our cross-compiler. I found a good step-by-step on setting up GCC for ARM here which I will now summarise.

First you need to visit http://www.gnuarm.com/, go to the files section and download the latest source code for gcc and binutils. I am using binutils-2.17 and gcc-4.1.1 for my example.

Unpack and compile binutils first using the following commands:

tar jxvf binutils-2.17.tar.bz2

mkdir build-binutils

cd build-binutils

../binutils-2.17/configure --disable-werror --target=arm-elf --prefix=/usr/local/arm7

sudo make all install

Next set the path to include the new binutils.

export PATH=$PATH:/usr/local/arm7/bin

I also put this line into my ~/.bashrc so the tools are always available. Now we can unpack and compile:

tar jxvf gcc-4.1.1.tar.bz2

mkdir build-gcc

cd build-gcc

../gcc-4.1.1/configure --target=arm-elf --prefix=/usr/local/arm7 --enable-languages=c --with-newlib

sudo -s
make all-gcc install-gcc
exit

If all that worked, you will now have the following useful programs installed in /usr/local/arm7/bin:

arm-elf-as - Assembler
arm-elf-gcc - C compiler
arm-elf-ld - Linker
arm-elf-objcopy - Utility to convert ELF binary into a raw binary or HEX image

STEP 2 – Download example files

Download and unpack my example files ARMBlinkExample.tar.bz2, you will see the following files:

AT91SAM7S256.h - Definition of the ARM chip and on-chip peripherals.
SAM7-P256.h - Definition of additional peripherals on the Olimex board.
Makefile - Makefile used to compile and link blink.c
ram-ln.cmd - Linker options. Defines the memory areas we can use.
ram-crt.s - C runtime code written in assembly language.
blink.c - The blinking LED example program written in C.

Please take some time to read through these files or you will not learn anything! The best place to start reading is the Makefile.

I have tried to make this code as simple and easy to follow as I can.

STEP 3 – Connect the board

Now it is time to plug the board into your USB port. Once plugged in, you will need to establish communication with it. There is an excellent free program called Sam_I_Am which provides a good front end. You can download it from http://claymore.engineer.gvsu.edu/~steriana/Software/.

Once unpacked, install it with the following command:

sudo python setup.py install

You will also need a configuration file. I have included one in my example files. Copy it to your home directory:

cp <path_to_example_files>/.samiamrc ~/

Now we need to set up the USB port. Type this command:

sudo modprobe usbserial vendor=0x3eb product=0x6124

Cryptic, you bet. But you need to do this to get Linux to detect the Olimex board. If this is successful, the board will be mapped to device /dev/ttyUSB0 (unless you have other USB serial devices in which case it will have a different number and you will need to modify ~/.samiamrc appropriately).

You should now be able to run Sam_I_Am and test it by typing the version command as in this example:

$ Sam_I_Am 

>version

v1.4 Nov 10 2004 14:49:33

NOTE: If your SAM-BA is not working because you have overwritten it by trying to download to the Flash memory, there are some instructions for restoring it here.

STEP 4 – Compile and download the example program

The blink example is intended to be loaded into RAM (not Flash memory). The SAM-BA bootloader has already set up the chip for us so my crt.s code is much simpler than you would find in a production application. There is also no operating system or even a C library! This is real basic stuff.

So now we can compile the example code:

make

This will spit out a file called blink.hex which is in the Intel HEX format that Sam_I_Am requires. Next we can use Sam_I_Am to download it to the board and run it. Use the send command to download the HEX file to RAM and then use the go command to run it as in this example session:

$ Sam_I_Am

v1.4 Nov 10 2004 14:49:33

>send blink.hex
0x00202000-0x00202147: 328 bytes
Start Address: 0x202000
>go 202000
>exit

You should now have some blinking LEDs, woohoo!

There is no function in this simple example to exit back to SAM-BA. You will need to press the board’s reset button. I found that when you do this, Linux will re-map the serial port to /dev/ttyUSB1 which was a bit confusing the first time. The trick is to wait a second or so and then press reset again. It will re-map back to /dev/ttyUSB0.

I hope this tutorial has been useful to you and that the example code provided can make a good starting point for your own embedded applications. If you have any comments, please post them below.

UPDATE

I now have a step-by-step on how to add on a standard C library. Click here.


9 March 2007

Using a Phone Camera to test a Remote Control

Filed under: General, Homemade Creations, Nerd Notes — adam @ 10:20 pm

Making the invisible visibleHere’s another unusual use for a phone camera. It’s a simple test to see if your TV remote control is working.

Since digital cameras are sensitive to infra-red light, you can simply point your remote at the camera and you will see the flashing of the infra-red beam on the phone’s screen, digital technology making the invisible visible!


Powered by WordPress