My Work Log


Upgrade Uboot and Linux Kernel Images on Atmel NGW100

I've been struggling to upgrade my Atmel NGW firmware for 4 days, and finally I got the whole thing running. I was trying to load the kernel images from an Kingston 2G SD Card. I followed the instruction, but the uboot kept sending me the error message of "Bad Magic Number, bad partition table". Apparently uboot couldn't recognize the filesystem on the card. The problem of this is because the uboot v1.1.4 poorly supports SD Card with size larger than 1 Gigabytes. I borrowed a Atmel JTAGICE Mark II to upgrade the uboot to a newer version(1.3.4), then the card is correctly read. There is some instructions on how to do it on the AVRFreaks wiki. But I used a little different command:

First you need to erase the entire flash:
avr32program erase -fcfi@0

Then, use the following command to write the uboot into the on board flash:
avr32program program -e -v -fcfi@0 your_uboot_img.bin

Note that I found out although the -e argument tells the avr32program to unlock and erase before programming, but it will not erase certain part of the memory for some reason. The first command gives you a complete erase of the flash.

Further problems I encountered:

1/ When finishing upgrading uboot through JTAGICEmkII, you will need to load the Linux /root and /usr images to the onboard Flash(Instructions). At the end, u might see an error message like the following:
Writing environment variables Warning: Bad CRC1, using default environment Segmentation fault

I don't know exactly why, but certainly something to do with the environment variables. I looked back to the original setting when I got the NGW, and set the environment variables in uboot exactly like it. Reloaded the images, and the error message went away. My original setting was the following, set whatever is missing.

baudrate=115200 ethaddr= (calculate your own MAC address here, instructions) bootdelay=1 ethact=macb0 serverip= tftpip= eth1addr= (calculate your own MAC address here) bootargs=console=ttyS0 root=/dev/mtdblock1 rootfstype=jffs2 bootcmd=fsload;bootm stdin=serial stdout=serial stderr=serial

2/ When you try to access the Linux filesystem under Busybox, you may see the file system is listed strangely:

BusyBox v1.4.2 (2007-04-17 15:34:55 CEST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # ls 1;34mbin0m 1;34metc0m 1;36mlinuxrc0m 1;34mproc0m 1;34mtmp0m 1;34mvar0m 1;34mconfig0m 1;34mhome0m 1;34mmedia0m 1;34msbin0m 0;0muImage0m 1;34mwww0m 1;34mdev0m 1;34mlib0m 1;34mmnt0m 1;34msys0m 1;34musr0m

Something I couldn't explain happened to your console - didn't parse the right characters. Just close the console, and open a new one. It should be fine.

Good Luck!

"Out of Memory" Error, Matlab

When doing large data array operations in MATLAB(like in Image and Video processing), it's largely possible to come across the "Out of Memory" error. Matlab eats about 800 Megabytes of memory just to start and be idle. If you want to do a memory-killing computation, you'd better increasing the maximum memory limit for MATLAB in Windows. (Note: Only tried on 32bit Windows XP, no Linux experience on this. I would like to hear if someone did the same thing on Linux or other platforms.)

Read through this article first. It tells you how to avoid the "Out of Memory" Error :

This is the article tells you how to increase the maximum memory limit on Windows (Note: Windows XP is not mentioned, but it's applicable. Take the procedure of: To Set the /3GB Startup Switch in Windows Server 2003 ) When I did the modification on my Windows and restarted the machine, my graphic card driver got lost somehow, and some default startup options got changed. No big deal.. Reinstall and reset, and you are all set.

Don't forget to read through this:, which gives you programming tips in Matlab to minimize memory usage.


Matlab on Linux, no toolbar displayed, problem solved

I had Matlab R2007a installed on my computer, running Ubuntu 8.04 Beta. But matlab can't display the toolbar, nor can the Matlab editor show up correctly. A solution can be found at:

If you are running Matlab on Linux, and with Compiz installed. You should add up one line in bash before running Matlab.

$ export AWT_TOOLKIT=MToolkit ; matlab


UNITAR 2007 Webseminar series Minutes

Preparatory Event for the Global Forum on Youth and ICT for Development, Sept.12nd. New York City, USA. UN Headquarters.

Event webpage:
(Ran: You could actually watch the recorded video on the web!)

1/ Keynote Speech
by Ms. Jennifer Corriero - ED of TakeITGlobal

Examples of Youth-led projects
Household Wastewater Recycling - by Wu in China
Media - Nigeria
etc... // Ran: I can not write all down, plz refer to her slides, which could be found on the website provided above.

Introduction to TakingITGlobal, a Toronto-based NGO
a/ support and motivation
b/ networking and information
c/ mobilizing and organizing to real world action

cooperating with UN Millennium Campaign, UN Habitat

World Youth Congress in Quebec 2008 // Ran: Take a look and apply if you want.
International Aids Conference
GYCA - global youth coalition on hiv/aids
digital divide network
National Information Youth Campaign

TakeITGlobal website: multi-linguistism - voluntarily translations, done by volunteers.

UNESCO - Language as Violence, Violence as Language

Creating local connections in West Africa

Problems addressed:
How to make sure the continuity of leadership, esp. when the youth aged out
A: The aged-out youth is kind of great resource for youth(later generations)

2/ Introduction of the GAID/ITU Global Forum in Geneva
by Mr. Sarbuland Khan - GAID

received thousands of application

visa, funding problems

Marketplace: various forms - open place// NGOs, Sponsors(like Google and Mircosoft etc.)


Topic I: Decision-making and Empowerment
Speaker: Ms. Priscilla Neri, CDI New York

Introduction to CDI: Brazil based NGO

The most powerful catalyst of change is the technology.
100-dollar laptop, not about hardware - it's about access
training in technology and civic engagement

Initiatives took place in the country of Colombia
complete absence of state - slums
lack of infrastructure -- weird relationship between the community and the drag dealers(drag dealer sell drag to people who need medicine)

Committee for Democracy in Information Technology - is the communities decide which is important, rather than the guys in the CDI // comment by Ran: good modal!!

tons of success stories: "micro-revolutions" // Ran: I love this word!

the solutions worked out by the CDI communities, and these solutions could be replicated elsewhere. // Ran: but you need to adjust the modal to cater cultural, technological and political needs.

CDI initiated the first Computer donation project in Latin America // Ran: I think some of our fellows are working on equipment donation. Good example!

In Brazil, 77% NGOs don't have an employee
New project idea: train technicians(some kind of certificate) in those countries to refurbish the computers donated to the schools and NGOs, called the "Factory of our Home Project" // Ran: very interesting idea!!

computers are donated locally, NOT shipped from other countries...
the idea about donations from developed countries - custom laws and domestic IT industries make it quite infeasible. // Points from Mr. Peter Broffman from Intel: we could not influence custom laws, but we could influence custom officials. experience from Intel! // Ran: exactly!
Brazilian government involved?

CDI structure - three cycles // decentralized
inner cycle: CDI headquarter
middle cycle: CDI Regional offices - 60+
outside cycle: CDI communities

Only 3% population in Brazil go to college - they are called Doctor.. :P
Most people don't feel that are opportunities - little glimpse makes a difference, just give them hopes and feasible start point to do that!!

Topic II: Entrepreneurship/Employment
Ms. Audrey Codera, Youth Works, Philippines

severe problems in Philippines:
unemployment, crime, gang etc.
40% are living below poverty line

SOLUTION: microfinance to young people through ICT

how to select: youth submit the proposal online which would be reviewed online and proved online

eample of the organic farms. 100$ loan created 1,000 jobs in months // Ran: Excellent example!! Unbelievable!! The significance of this example is that it's not only about ICT! It's about intra-sector cooperation. We should all pay much attention on this!!

Dr. Jean-Claude Healy, Senior Advisor, UN-GAID
people is alone in the global information society, even it's plenty of information surrounded.. // that's true!

citizen-centric, rather than patient-centric. // Ran: novel point!!

Youth and ICT: eHealth

"The reasonable man adapts himself to the world, the unreasonable on persist in trying to adapt the world to himself... Therefore, all progress depend of the unreasonable ones." -- George Bernard Shaw // Ran: brilliant remarks!!

Ms. Xuesong Shen, UNESCO New York Office

Education for All (EFA) project
exchange information in electronic means - through ICTs
development of content
Q: Is there any example of UNESCO cooperate with local youth-led initiatives to implement a program? or achieve the MDG?

Virtual Universities

Ran's question: Open Education Resource

UNESCO Youth Forum // Ran: Similar to ITU Youth Forum, interesting! The difference is: UNESCO YF is a long-time committee. discuss issues before the general conferences. And after the conferences, YF fellows could vote for the resolution. That's a fresh part!

Higher Education Open and Distance Learning Knowledge Base


NS-2.27+LEACH test failure problem solved

The last post of my work log summrized the instructions for implementing LEACH on NS-2.27 on Ubuntu 7.04 operating system. But, I didn't noticed the LEACH test was actually failed due to the error below:

invalid command name "Resource/Energy"
while executing
"Resource/Energy instproc setParams {args} {
$self instvar energyLevel_ alarmLevel_
set energyLevel_ [lindex $args 0]
set alarmLevel_ [lind..."
(file "/home/ran/ns- allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tcl" line 13)
invoked from within
"source.orig /home/ran/ns-allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tcl"
("uplevel" body line 1)
invoked from within
"uplevel source.orig [list $fileName]"
invoked from within
"if [$instance_ is_http_url $fileName] {
set buffer [$instance_ read_url $fileName]
uplevel eval $buffer
} else {
uplevel source.orig [list $fileName]
(procedure "source" line 8)
invoked from within
"source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl"
(file " uamps.tcl" line 18)

The problem was also reported by a guy to ISI NS mailing list one month earlier(Apr.2007) but no reply. So I was trying to solve it myself. Actually I tried to use Cygwin under windows, but frankly that brought more problems. And I tried to install Ubuntu 7.04 freshly. And I installed NS-2.27 and LEACH by exactly following the instructions in the previous post. And then, guess what! The LEACH test is passed, with no error.

I guess the problem maybe lies in my gcc. In Ubuntu 7.04, the version of gcc is 4.1.2, and the gcc version of Ubuntu 6.10 is 4.1.1. Although I've updated my system to 7.04, but I failed to update the source.list(I only followed through the "new distribution available" buttion in the synaptic package manager. Didn't really run sudo apt-get dist-upgrade and sudo apt-get upgrade), so perhaps *something* was missing during the update procedure. Perhaps the LEACH code do not work with gcc 4.1.1 ? But this's only my idea, not proven to be correct. Comments are welcome as always.

Install Scim Pinyin Input for Chinese under Ubuntu 7.04 English Desktop environment

1. install Scim Pinyin using System/Administration/Synaptic Package Manager
Type Scim to search, select Scim Pinyin to install

2. Set up Scim to run automatically when your desktop starts

Create a file called 75custom-scim_init in /etc/X11/Xsession.d
From terminal,

sudo gedit etc/X11/Xsession.d/75custom-scim_init

Paste the following and save

export XMODIFIERS="@im=SCIM"
export GTK_IM_MODULE="scim"
export XIM_PROGRAM="scim -d"

Note: the above instruction is for Ubuntu Gnome desktop, for other desktop, see:

<I found the solution here:>


NS-2.27+LEACH on Ubuntu 7.04 installation guide

Step 1: Download NS-2.27 allinone package, extract it
tar zxvf ns-allinone-2.27.tar.gz

Step 2: You need to apply a patch to ns-2.27 to make it works with gcc4.1. You can get the patch here
To apply the patch, type patch -p0 <ns-2.27-gcc410.patch in bash

Step 3 : Download LEACH code, extract it under ~ns-2.27/ directory.
tar zxvf mit.tar.gz

Step 4: Add the following line in ~ns2.27/mac/, line 59, that is, after the line #define max(a,b) (((a)<(b))?(b):(a))
#define min(a,b) (((a)>(b))?(b):(a))

Step 5 : Install the LEACH code by following instructions below:
Step 5.1: Edit the Makefile as follows:
Add DMIT_uAMPS to the DEFINE list
Add -I./mit/rca -I./mit/uAMPS to the INCLUDE list
Add the following just prior to the line gaf/gaf.o \
mit/rca/energy.o mit/rca/rcagent.o \
mit/rca/rca-ll.o mit/rca/resource.o \

mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPS/bsagent.o \
Step 5.2
: Add the environmental variables to /etc/profile
export RCA_LIBRARY=$NS_HOME/ns-2.27/mit/rca
export uAMPS_LIBRARY=$NS_HOME/ns-2.27/mit/uAMPS

Step 5.3: source /etc/profile and clean up previous build
source /etc/profile
make clean

Step 5.4: Rebuild ns2, redirecting output
nohup make 2>error.log >make.log &

Step 6: Test default wireless demo and LEACH

Step 7: Validate the full installation, redirect the output
nohup ./validate-full 2> validate.error >validate.log &

DONE, Enjoy!