Friday, November 2, 2012

Embedded Artists LPC2103


Some resources for using the Embedded Artists LPC2103 educational board.

Monday, October 29, 2012

Prepare GNUARM compiler toolchain for Windows

Copied verbatim from http://winarm.scienceprog.com/winarm-tools/prepare-gnuarm-compiler-toolchain-for-windows.html

Look at the date. I'll update and modify this posting when/if I get around to it.

Prepare GNUARM compiler toolchain for Windows

GNUARM is a toolchain for developing ARM microcontroller projects based on open source compiler GCC.
GNUARM logo
GNUARM works on windows (requires Cygwin), Linux and MacOS. GNUARM doesn't have any GUI, but you can adapt any GUI that supports commands from command line. One of good project is WinARM where you get all tools needed in one package. Thiswill be discussed later.
GNUARM package consists of the GNU binutils, GCC compiler set and debugger (Insight for Windows and Linux, GDB only for MacOS). Newlib is used for the C library. With GNUARM yo uhave ability compile C and C++ programs.
Let's set up toolchain for windows environment. First of all download compiled toolset fromhttp://www.gnuarm.com:
Download the newest GNUARM stabile compilation:
Then start installation:
  • Start window:
Gnuarm start install 
  • Accept license agreement:
Gnuarm license 
  • Select folder where do you want GNUARM to be installed. I recommend to select C:/GNUARM:
Gnu arm install location 
  •  Select the components. You can select all of them:
Gnuarm components 
  • Chose Start menu folder name:
Start menu of Gnuarm 
  • Select desktop shortcut to be placed. I highly recommend to check Cygwin DLL:
Gnuarm installation tasks
  • And press install..
  • Select checkbox in order to create system variable: PATH=c:\gnuarm\bin:
Gnuarm PAHT 
After we have GNUARM installed, download binutils from http://optimize.ath.cx/ARM7/src/utils.zip. Download this archive and unpack all contents to c:\gnuarm\bin folder. Also You can downloadhttp://optimize.ath.cx/ARM7/src/cygncurses-8.dll and put it in c:\gnuarm\bin folder if there is no any. Now we are ready to start building projects.
Lets try some test compilation. Just example download LPC2214 project package fromhttp://optimize.ath.cx/ARM7/src/lpc2214_blink.zip and extract in any folder. In the package you’ll find following files:
  • lpc2214.h LPC2214 header. You can also download header files from www.gnuarm.com
  • blink.c LED blink example routine.
  • boot.s The startup routine which is first executed after the CPU is reset. After it main function is called.
  • Makfile makefile
  • lpc2214-rom.ld The script file which used by linker. The start address size and the ROM/RAM is described. If there is needed - ROM binary is built.
  • setenv.cmd Configuration file, where you have to show path to C:\GNUARM\bin and bin C:\GNUARM\bin\utils
  • jtag_flash.exe The tool, which writes the flash by JTAG and executes on demand.
  • jtag_stub.exe The JTAG debugger for GDB/Insight.
Because setenv.cmd is used to show path to C: when GCC is installed in different location, you have to edit it. If you left default settings, then don’t edit this file.
Lets try to compile this program. Start DOS console window (Start->Run and type CMD):
Lets compile project to hex file. Leave make file not edited as it is ready for this. So I will have to use commands: make and once again make hex.
making ARM project with GNUARM 
That’s it hex is built and placed in project directory. It can be uploaded ARM MCU.
Here is a table with most common make commands:
Command Target (function)
  • Make Compiling, linking and forming the elf file;
  • Make clean Clearing compiled o, lst, elf, hex and bin files;
  • Make hex forming the hex file;
  • Make bin forming Bin file;
  • Make lst Listing (assembling) file formation;
  • Make run Compiling, linking and it writing in to the flash after this execution starts;
  • Make debug Compiling, linking and writing in to the flash after building start Insight/GDB.
So if you already have programmer adapter connected, you can flash you ARM microcontroller with only one command - make run.

Saturday, October 13, 2012

Flashing an ARM7 Board with USB-to-Serial Converter


A simple flashing method for UNO32 (data dump via UART0)

This document will show you how to use the UART0 of the UNO32 to perform some simple flashing.
As the UART0 is used for ISP download at NXP chip, UART0 will reserved for those application that don't need two UART and don't need all GPIO.

Setup

At UNO32 development, your development PC will connect to UNO32 via the on-board USB to Serial adapter at most time, to download your code to UNO32. So, the idea is we use this already connected channel to dump some information to help us to debug our program. Below is the block diagram.
Connection
The USB connection will form a virtual Serial port at the PC, the actual UART signal is connected to the MCU's ISP port. To perform ISP, there are four signals used.
1) TXD (PC to MCU, for data transfer)
2) RXD (MCU to PC, for data transfer)
3) DTR (PC to MCU, to reset MCU)
4) RTS (PC to MCU, connected to ISP pin)
When programming MCU, the FlashMagic will control the DTR and RTS to make the MCU enter ISP mode. Then use TXD/RXD to transfer data.
If we want to use this Serial port, we need to make the correct state on DTR and RTS. Otherwise, the MCU cannot enter your code correctly.
Basically, any PC serial terminal program that has a function for you to control DTR/RTS can do the job. For myself, I use Termite to do it. So, I just show you how to config Termite here.
TermiteConfig
At the port config, select the port of the Virtual Serial port created by UNO32. The rest is show above (115200 N81). Then, at the Plug-ins, enable the Status LEDs. This will make Termite display all line status as a LEDs, and you can control RTS/DTR by click their LED.
Click [OK] to leave the port setting, you will connected to UNO32 and see those LEDs. To make the UNO32 not enter ISP, you need to turn off RTS all the time. For DTR, turn it on will reset the MCU. So, I will turn the DTR on, then off once to reset UNO32 to enter my code. When I need to download a new code, click the top-left button to release the Serial port. After download, click it again to get the port.
Termite
Here is the procedures
1) Use FlashMagic to download you code.
2) Use Termite get the serial port. Then reset the UNO32 via the DTR LED and test my code.
3) Modify my code and genertate a new HEX.
4) Release port at Termite.
5) Repeat step 1 until my code work.


Reference:

Monday, August 13, 2012

Install SystemC 2.3.0 in Mint 13/Fedora


Thanks to these tips from http://archive.pfb.no/2010/10/13/systemc-ubuntu-1010/ and http://noxim.sourceforge.net/pub/Noxim_User_Guide.pdf.

Begin borrowed material


Step 0: Prepare.

Obviously, you need to have a compiler. Do this step in case you haven't done so.

$ sudo apt-get install build-essential

Step 1: Download.

Next: register, and download from http://www.systemc.org using your Web browser then unpack it....but the tgz file has wrong extension. Do these steps to unpack the file:

$ mv systemc-2.2.0.tgz systemc-2.3.0.tar
$ tar xvf systemc-2.3.0.tar

In any case, create a build directory and enter into it for the following steps:

$ cd systemc-2.3.0
$ sudo mkdir /usr/local/systemc
$ mkdir objdir
$ cd objdir
$ export CXX=g++
$ sudo ../configure --prefix=/usr/local/systemc CPPFLAGS=-fpermissive

Step 2: Compile

$ make
$ sudo make install
$ make check
$ cd ..
$ rm -rf objdir

The command make check is optional. What is does is to compile SystemC source files to see if the files can run. I strongly suggest that you run it.

Step 3: Tell your compiler where to find SystemC

Since we do not install SystemC with a standard location we need to specifically tell the compiler where to look for the libraries. We do this with an environment variable.

$ export SYSTEMC=/usr/local/systemc/

This, however will disappear on the next login. To permanently add it to your environment, alter ~/.profile or ~/.bash_profile if it exists. For system wide changes, edit /etc/environment. (newline with expression: SYSTEMC_HOME=”/usr/local/systemc/“) To compile a systemC program simply use this expression:

$ g++ -I. -I$SYSTEMC/include -L. -L$SYSTEMC/lib-linux -o OUTFILE INPUT.cpp -lsystemc -lm

End borrowed/adapted material


HOWEVER, version 2.3.0 is not really ready. Any problems...you're on your own, since it's so new. That's why I'm back at 2.2.0.

Tuesday, March 20, 2012

Extracting Pages from PDF

First, install PDFTK on Linux.

Then, do this command:

pdftk foo.pdf cat 2-3 output abstract.pdf dont_ask

Where foo.pdf is the original PDF file, 2-3 is the range of pages (you can type 2-end to extract to EOF), and abstract.pdf is the output PDF file.

Saturday, March 10, 2012

FFMPEG Convert AVI to JPEG

$ ffmpeg -i input.avi -qscale 1 -qcomp 0 file-%03d.jpg


  • qscale[:stream_specifier] q (output,per-stream)’
    • Use fixed quality scale (VBR). The meaning of q is codec-dependent.
    • qscale constant quality buf variable bitrate. n = 1 for best quality, n = 31 for worst quality
  • qcomp compression
    • video quantizer scale compression (VBR) (default 0.5). Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0
  • qblur blur
    • video quantizer scale blur (VBR) (range 0.0 - 1.0)
    • Previously tested with qblur option of 0 and 1, and outputs were exactly the same

Friday, March 9, 2012

Converting HD720 to 320x240

$ ffmpeg -i input.avi -vcodec huffyuv -vf "crop:960;720:0:0" -y intermediate.avi
$ ffmpeg -i intermediate.avi -vcodec libx264 -s qvga -y output.m4v

HuffYUV is a lossless codec. From Wikipedia:

Huffyuv (or HuffYUV) is a lossless video codec created by Ben Rudiak-Gould which is meant to replace uncompressed YCbCr as a video capture format.

Despite the "YUV" in the name, it does not compress the YUV color space, but YCbCr.[citation needed] The codec can also compress in the RGB color space.



-vf "..." replaces -croptop, -cropbottom, -padtop, -padbottom etc of older versions of FFMPEG

Monday, February 27, 2012

KISS (Keep It Simple Stupid) FFMPEG

How to remove jitter from the first couple of seconds of Nikon DSLR video, and keep only 60 seconds.

$ lav2yuv +n DSC_0000.AVI > dsc0000.yuv
$ ffmpeg -i dsc0000.yuv -ss 3 -t 60 -y -s vga dsc0000.mp4
$ mediainfo dsc0000.mp4

...asumming you want to convert the MJPEG original to MPEG-4, of course....

By the way, my Nikon outputs 1280x720 HD video (hd720 in FFMPEG-speak). No Full HD (aka hd1080) from this baby.

Sunday, February 26, 2012

Video Quality Analysis

Things scrubbed from Internet so far:
I hope the links won't disappear before I can use them. To use the second Python program, I had to install Python Imaging Library and Python Levenshtein.
# yum install python-imaging python-Levenshtein
The Levenshtein distance is a string metric for measuring the amount of difference between two sequences (Wikipedia).

Saturday, February 25, 2012

Minimal RAR in Fedora

Working with RAR files in Fedora is not as easy as in Ubuntu.

We can download RAR package from http://www.rarlab.com/download.htm

# wget http://www.rarlab.com/rar/rarlinux-4.1.1.tar.gz

Untar file and install RAR.

# tar zxvf rarlinux-4.1.1.tar.gz
# cd rar
# make
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib

After all the above, you can use rar and unrar commands.


Creating an archive:

$ rar a archivename.rar files...

Add as many files & directories as you want.

Creating an archive with password:

$ rar a -ppassword archivename.rar files...

There is no space between -p and the password itself.

To extract, click on the right-mouse-button and use Archive Manager to extract.

Of course, for more advanced uses, refer to the RAR in Ubuntu Manual.

Friday, February 24, 2012

Fedora First Login

Here's my TO DO list on a fresh Fedora installation.

1. Update the OS and install "important" software.

$ su -
password
# yum update
# yum install -y eclipse gimp inkscape geany texmaker ffmpeg vlc opencv
# yum install gnome-tweak-tool

2. Install Google Chrome by creating the file /etc/yum.repos.d/google.repo and adding these lines.

[google-chrome]
name=google-chrome - 32-bit
baseurl=http://dl.google.com/linux/chrome/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

Then, install Chrome by:

# yum install -y yum install google-chrome-stable

3. Run gnome-tweak-tool:

$ gnome-tweak-tool

4. Enable RPMfusion repository.

# yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Then can install free software such as rar
# yum install rar

Note: it's still better to install RAR from the original site.
5. Install JabRef.

Download the JAR file.
# wget http://downloads.sourceforge.net/project/jabref/jabref/2.7.2/JabRef-2.7.2_01.jar
Then create a shortcut somewhere, like on the desktop.
[Desktop Entry]
Name=Jabref
GenericName=Jabref
Exec=java -jar /home/maczulu/JabRef-2.7.jar
Icon=jabref
Terminal=false
Type=Application

6. Install MediaInfo.

Install each RPM in the proper sequence.


7. Install Fedora Utils etc

Wednesday, February 15, 2012

Converting AVI to Dirac

FFMPEG understands Dirac. So here's the command to convert MJPEG/AVI to Dirac. Use MKV extension for the output file to keep the sound.

$ ffmpeg -i t1.avi -vcodec libschroedinger t1.drc

It can be done the long way, by converting to YUV first:

$ lav2yuv +n DSC_0023.AVI > tmp.yuv
$ ffmpeg -i tmp.yuv -vcodec libschroedinger t1.drc

From a 55.2 MB AVI/MJPEG file with audio and 720x480 video, a 729.9 MB YUV420 file is produced.

Encoding to Dirac directly from AVI, results in a 562.4 KB file.
Encoding to MKV from AVI produces a 563.9 KB file.

Compare that to 6.8 MB H.264 file produced form YUV420.
$ ffmpeg -i tmp.yuv -vcodec libx264 t1.mp4
Note: FFMPEG crashes when converting directly from AVI to H.264.

Summary for File 1:

CodecMJPEGYUVDirac (.DRC)
Dirac (.MKV)
H.264
File size (MB)
55.2
729.9
0.562
0.563
6.8
Compression ratio (x)
13.22
1
1297.8
1294.4
107.3

But that's not the whole story. The quality of the Dirac video is so bad...because I used libschroedinger.

Here's the results for File 2, using libdirac switch:

CodecMJPEG
YUV
Dirac (.DRC)H.264(.MP4)
File size (MB)
47.0
1891.1
3.4
8.1
Compression ratio (x)
40.2
1
556.2
233.5

Suddenly, Dirac doesn't look so bad.

Tuesday, February 14, 2012

Converting AVI to YUV to H264

Using FFMPEG to transcode directly from AVI/MJPEG won't work:

$ ffmpeg -i input.avi -vcodec libx264 output.mp4

Still trying to get the commands from the following article to work:

http://www.linuxjournal.com/article/9005

$ mencoder -vf format=i420 -nosound -ovc raw -of rawvideo -ofps 24 -o tmp.yuv input.avi

$ x264 -o output.mp4 --fps 24 --bframes 2 --crf 26 --subme 6 --analyse p8x8,b8x8,i4x4,p4x4 --input-res 720x480 tmp.yuv

Using the lav2yuv command produces a raw YUV file of exactly the same size playable in VLC. The one from mencoder produces garbage.


Another example x264 invocation from http://mewiki.project357.com/wiki/X264_Settings:

$ x264 --output /dev/null --fps 30000/1001 --input-res 720x480 input.yuv

Monday, February 13, 2012

Install Handbrake on Fedora 16

1. Enable the Missing Box Studio repo:

# yum localinstall -y http://repo.missingbox.co.nz/repo/linux/fedora/missingboxstudio-release-1-1.noarch.rpm  --nogpgcheck
2 Install Handbrake and libdvdcss (optional, if you want to rip DVDs):

# yum install HandBrake-gui libdvdcss

Friday, February 3, 2012

Converting Nikon D90 video to YUV

Not that straightforward, as it turned out. FFMPEG won't do it for you. So here goes:

$ sudo yum install mjpegtools
$ lav2yuv +n DSC_0023.AVI > test.yuv
   INFO: [lav2yuv] Norm set to NTSC
   INFO: [lav2yuv] chroma '422' recommended with this input
   INFO: [lav2yuv] set default chroma '420jpeg'
   INFO: [lav2yuv] Repeated frames (for error concealment): 0
$ lav2yuv +p -C 422 DSC_0023.AVI > test4.yuv
   INFO: [lav2yuv] Norm set to PAL
   INFO: [lav2yuv] Repeated frames (for error concealment): 0

Wednesday, January 25, 2012

Aborting yum

If yum aborted by Ctrl-C and restarted, you'll get this message continuously and cannot proceed:

# yum update
^C
# yum update
Another app is currently holding the yum lock; waiting for it to exit...
Another app is currently holding the yum lock; waiting for it to exit...
Another app is currently holding the yum lock; waiting for it to exit...

What to do:

Look for the 'yum.pid' file and delete it.

# cd /var/run/
# dir 
# rm -f yum.pid


Alternatively, you can find out what's locking up yum by giving:

# ps aux | grep yum

Take note of the pid number, then kill the process:

# kill -9 (insert pid number)

Confirm that the 'yum.pid' file has been deleted and you should be able to restart yum.

# dir
# yum update

This should do it. In Ubuntu, the same problem requires you to search and delete two files...