Monday, 22 March 2010

Recovering Corrupted/Malfunctioned GRUB in Linux

This problem is actually not related to NGW100 :) However I wanted to give solution how to recover your corrupted/crashed GRUB menu due to some reasons. Well, most common reason for GRUB to crash is a new Windows installation over Linux which is a process that writes specific information to your PC's boot sequence. People are having great difficulty if their GRUB is crashed. They may even cannot boot any of the installed operating system. So in this article I'm gonna try to help recovering your GRUB.

All the operations below must be done with administration privileges.

1. First of all you should get a Live CD of any Linux distro. In my situation I'm using Ubuntu CD to boot my computer.

2. After booting your Ubuntu using Installation CD or Live CD(earlier versions of Ubuntu, now you can use Installation CD as Live CD) you need to get yourself into Linux's terminal.

3. Well only information you need at this moment is what partition has what operating system. Fortunately GRUB's setup will help you decide those partitions. Unlike most of humans(yea, yea)
GRUB starts to count from 0 not 1. So lets say you have 2 HD's in your computer first one is hd0 and 2nd one is hd1.Same rule will be applied to your partitions. If your Linux operating system is installed in your first hard-disk and 2nd partition then you have (hd0,1).

4. Based on our previous assumption you need to get to grub interpreter by typing grub. After that follow the codes below:

grub> root (hd0,1)
grub> setup (hd0)
grub> quit


Now you can reboot your computer safely into your operating systems :)

P.S: fdisk -l will give you some information about your hard-disks, partitions and operating systems. If you're not sure where your operating system (mainly your linux partition) then I suggest you to use that information.

Thursday, 18 March 2010

C Compiler Installation on Atmel's NGW100




As a developer working in different systems is sometimes really painful. What I've encountered as a problem so far is compiler installation on NGW100. Well, if you're a beginner you might not see this as an easy job to do. First of all it's not sufficient to have programming background but you have to know a bit of UNIX operating systems in other words today's so called Linux distros.

NGW100 is one of those systems, since it has different processor you cannot use your regular compiler. Furthermore, those compiler designers probably are not supporting NGW100. So you need to know two things before you get yourself on the road:

1. What cross-compiling is
2. How to handle NGW100's configuration.

Cross compiling is a compiling process where your target machine, that your executable program work on, and your developer machine is different. What you have to do is, you need to compile your source code with a given or self-generated compiler. In Atmel's NGW100 it's called avr32-linux-gcc. Atmel actually does not provide that compiler directly but you need to do some UNIX operations under a Linux distro. In our situation that compiler is kinda cross compiler.

I've tried to overcome this problem using different distros. Unfortunately there's only one distro that I used and succeeded which is Ubuntu 9.04. I've also tried newer versions of Ubuntu without a luck. So I recommend to use Ubuntu 9.04 for developing purposes under Linux. Again I've to confess that I've no knowledge about how to handle these problems under Windows or Mac. Anyway, you can install Ubuntu 9.04 or you can use Ubuntu 9.04 as a Live CD which you can use Ubuntu without installing on your hard-drive.

First thing to do is to install toolchain and buildroot which is provided by Atmel. You can find those packages in Atmel's web-site for Ubuntu 9.04.
At this point start installing toolchain and make yourself sure that you've installed these packages:

avr32program avr32gdbproxy avr32trace avrfwupgrade libavr32ocd libavrtools libelfdwarfparser

After that download buildroot extract it to some directory before installing it you need to make some configurations.
1. First configure menuconfig under buildroot extraction folder using this compilation will open a window that you need to pick some properties of your NGW100, choose correct values for your system and save.

make menuconfig


2. Similar to that you need to prepare source by

make source

3. And final step is compiling the whole by

make

After the compilation process is completed most probably your PATH variables are not set to point avr32-linux-gcc compiler. So you need to add avr32-linux-gcc 's path to PATH variable in UNIX system by:
export PATH=$PATH:(avr32-linux-gcc's path) without paranteses.

*Your avr32-linux-gcc program is placed under (buildroot's path)/build_avr32/staging_dir/usr/bin. So you need to give your actual path to the export command above.

So, if you've done all successfully then you should be able to use your avr32-linux-gcc everywhere in your terminal.

Last thing is try some C code on your machine. Just write some hello world code in your developing machine which might be:

#include
int main(){
printf("SUCCEEDED!!");
return 0;
}


You'll compile this hello.c source code with:

avr32-linux-gcc hello.c -o hello

And you need to transfer your hello file which is executable in your NGW100 system.
Now you can execute and see your success on your screen :)

Well my purpose actually is developing Java on my NGW100 I'll also explain how to do it soon. But if you can't wait to do so I suggest you to check JamVM virtual machine that can work on Atmel's NGW100. It's just a quick hint for Java developers from me. It's somehow a bit more trickier but hopefully you'll enjoy what you're doing while using JAVA on NGW100.