Thursday, November 25, 2010

How to program an AVR Microcontroler in Ubuntu linux !

In windows , CodeVision which costs $300 is used to program AVR Microcontrollers,
but how to do it in Ubuntu for free ?

First of all we need to have a USB AVR Dragon tool.
What is AVR Dragon ?
It is a cheap tool which connects our microcontroler to a PC via USB. The AVR Dragon can program all AVRs via JTAG, HVP or ICSP.

Then we need to install two applications gcc-avr and avrdude .
to install both enter this in terminal :
sudo apt-get install gcc-avr & avrdude
What does gcc-avr do ? as you know , you can not compile a code for AVR by PC compilers , therefore we need gcc-avr which is a cross C compiler for avr.

What does Avr-dude do ? after we made machine code by gcc-avr we need an application to load the files to our microcontorler using Dragon is the program that
now that we installed both , go to the folder that your code is there and enter :

avr-gcc -g -Os -mmcu=atmega8 -c flash.c
this produces an object file called flash.o which then needs to be linked , it is obvious that if your avr is atmega16 or 32, you replace atmega8 with your avr model.

avr-gcc -g -mmcu=atmega8 -o flash.elf flash.o
now we produced a binary file called flash.elf, which is a GNU executable file. we need to change it bit more and grab some bits out of it to make the hex file

avr-objcopy -j .text -j .data -O ihex flash.elf flash.hex
congratulation now have a hex file which is suitable for putting onto the atmega8 !
now we need to hook up our AVR dragon circut and connect it to our PC , if you never hooked up a AVR dragon circuit , it can be tricky at first , read the manuals carefuly.

after connecting the AVR Dragon to USB port of the computer run this in the code folder :

sudo avrdude -p m8 -c dragon_isp -P usb -e -U flash:w:flash.hex
Thats it ! we are done .

Avrdude has many options, to learn all the options

avrdude --help
p.s : if you get errors , don't freak out , you probably need to change the speed options .

Thursday, June 3, 2010

When Nautilus is wrong , the confusion of GiB and GB !

Today I tried to burn a folder on my computer , which Nautilus said it is 4.5 GB and strangely it wouldn't fit on a 4.7 GB blank DVD-R !

Using another file manger , I found out my actual folder size is 4.5 GiB which is equal to 4.83 GB , and I was convinced that it wouldn't fit on a 4.7 GB blank DVD .

it seems that Nautilus the File manager of Ubuntu doesn't care about difference of GB and GiB .

so whats the difference of GB , and GiB ?

Giga in math means 1 billion . we all know digital world is binary , and computers work by binary numbers, while the humans use decimal numbers.
GB =Decimal Giga Byte = one billion bytes
GiB=Binary Giga Byte = 2^20 billion bytes

The capacity of storage devices [for i.e blank dvd , or hard disk] are measured in Decimal GB .
probably because it is meant to be read by a humans .
for instance , you buy a 300 GB hard disk which literally means 300 hundred billion bytes . [but for the binary world of computers it is actually 2^20*300= 279 GiB]
therefore a 4.7 GB DVD-ROM is actualy 4.3772 GiB for a computer .

IEC Standard :
"MiB [Meby Byte] GiB (Geby Byte) is a standard that was defined by the International Electrotechnical Commission (IEC) in December 1998 to solve the confusion of Decimal and Binary Giga Byte." (src : wikipedia)

Nautilus is not following the IEC Standard but KDE applications are already using IEC standard . Hi5 to KDE fans ;)

I submitted a Bug in Launchpad .

+ P.S :Here is online convertor to calculate GiB and GB .

Friday, April 30, 2010

[MD5SUM] Check downloaded ISO 's integrity

I never thought I would ever be have to use this command till today .

Today I downloaded Ubuntu 10.04 Alternate CD from and it was acting weird , I checked many things finally I tried to check if the ISO that I downloaded is corrupted or not .

to check if an ISO image CD is downloded correctly you can check it this way .

you can mount the ISO or burn it ,
to mount it without burning use this command : (ofcuorse you gotta relace 'youriso')
sudo mount -o loop youriso.iso /media/cdrom0

Then go to the root folder of CD , there should be a file like md5sum.txt or something like that
in terminal shoot his :
md5sum -c md5sum.txt

it will tell you if the folders and files are the same size as the original .

in my case it showed that some files failed and the CD was corrupted .

Tuesday, February 16, 2010

[Wget] [Tip]How to force to resume partially-downloaded file

it is funny, in iran there tons of sites that are blocked by government, and there are tens of forigen sites that block iranians to use their site.poor iranians have to use all diffrent kind of proxies and work-arrounds to get through reall internet. one of these sites is Sun, which doesnt let iranians to download virtualbox, and I want it so bad !

Today I used wget [an excellent terminal based download manager] to download the newest version of virtualbox , but as sun doesnt let iranians to download their Virtualbox, it stopped in 90% and I kept re-dowloading and the same thing happend.

Wget normally Automaticly resumes the partial downloaded file.
but in this case Sun websites gives a Random File Name each time you download it . [add some kind of ID]

to force wget to resme a download file in another name , I did this :

wget -O virtualbox-3.1_3.1.4-57640_Ubuntu_karmic_i386.deb -c

the -O forces the download file name in Output.
the -c forces wget to continue partial download

Wednesday, February 10, 2010

[Virtualbox][Tip] : Disable super key in the Guest Windows

I am gonna write series of small tips for using virtualbox for now on , so don't forget to add me to your rss reader .

here is my todays small little tip :

In linux there are lots of compiz effects that use the super key on the keyboard , such as "enhacned zoom desktop" effect of compiz. and the same key shows the start menu in all windows operation systems .

if you have windows as guest on your linux host, using virtualbox, I think you will feel more comfortable to disable windows start menu showing up by pressing Super key.
because whenever you want to zoom on your desktop, you wont see windows start menu showing up .

  • to disable super key in windows, you need to download this reg file and run it . [it affects the windows registry]

you need to restart your windows to take effect.

Thursday, January 28, 2010

UML generators for Ubuntu

This semster I had a sweet course in university named , Software Engineering 2 , with Professor Ostadzade.

in ubuntu I found some great softwares which can ease usage of UML . I introduce them for you:


Umbrello UML Modeller is a Unified Modelling Language diagram programme for Linux (KDE), Windows and MacOS .

the most exciting thing that I liekd about Umbrello is their Manual Handbook, which they explain all the cool things you can do with Umbrello .

as I read in the handbook, you can Import and Export Codes,
it means you can give a C++ Code to Umbrello and it will draw all the diagrams ! (class , state, squeience ,...)


this is simple application, which at first you have to configure everything, like your browser, your editor , ... (it doesn't automaticly recognise your default applications)

you can define Classes, objects, their state and operations nd then generate their C++ or JAVA code .you can even generate diagrams for it
it is very fast and doesn't require much memory to manage several thousands of classes,

Dia Diagram Editor

this is another simple aplliciation which doesn't do much but it is a good Drawing application,

it has all the UML arrows and figures , if you want to draw a UML diagram by yourself , then it can give you a good hand !

Friday, January 22, 2010

Nessecary Tools for Booting Issues on ubuntu and windows , Bootloader, Grub , MBR

Sorry guys that I dont update that much, I am stuck with my university in Iran, it is funny I fail my courses with bad scores and those guys who dont know a thing about comptuer get best scores okay enough nagging let read my newest article !

Having Windows Xp, Windows Vista, Windows Seven , ubuntu 8.04 and ubuntu 9.10 on two hard disks , has made me an expertise in facing all kind of problem with Dual booting (I guess I should say Quad booting) .

I had written an article about grub three years ago and I still receive emails saying "Thank you that saved my ass".

here I want to introduce some links and applications to save more asses ;)

Warning : these list items are not steps , don't do them blindly one after another, these are seprate solutions for seprate problems .

  • First of all Grub 2 Tutorial on the forum is a great reference for all !

  • if you deleted one of your partitions and the partition table became invalid then try

  • it is always a good idea to see a list of your partitions in ubuntu (you can always boot from an Ubuntu live CD)
    sudo fdisk -l
    in the results you can see the bootable partition is marked with a * and you an see their official name (the name that computer knows them by)
    for i.e :
    /dev/sdb2 * 5043 9562 36306900 7 HPFS/NTFS
    that tells me sdb2 (the second partion of my B hard disk is bootable and its filesystem is NTFS) and its address is /dev/sdb2

  • if you deleted your Windows bootloader . (in my case I deleted the first partition of windows hard disk) and windows MBR was gone, you can restore it using an Ubuntu live CD
    sudo apt-get install lilo
    sudo lilo -M /dev/sda mbr

    Replace sda with your hard disk ,for i.e if want to restore the windows MBR of your second hard disk it would be :
    sudo lilo -M /dev/sdb mbr
  • Partition Magic 8.1 Bootable CD is available on torrents , you can search and download if it is legal in your country . (I can't give you a direct link but you can search in Torrentz )
  • Gparted Live CD is an open source clone of Partition magic .
    in gparted you can , right click on the partition you want then click on "Manage Flags" then you can make a partition bootable by marking the boot flag.

  • SystemRescueCD is a great linux Live CD , that does tons of things , from partion-ing to cloning and repairing more !

  • there are Russian windows live CDs that are useful , find them on torrentz at your own legal risk (becareful they are fake virus ones too)

  • to make your grub menu beautiful , you can always try Start up Manager
    for ubuntu

  • for windows vista and windows 7 , you can out the instalation CD in and choose repair my compuer, to get back windows bootloader (yes that would destroy your linux bootloader)



computer (48) ubuntu (46) linux (28) tutorial (20) opinion (17) programming (14) software overview (13) terminal (12) troubleshooting (8) life (7) literature (7) poem (7) human languages (6) vim (6) bash (5) google (5) python (5) android (4) cars (4) phpBB (4) suggestion (4) tips (4) 12.04 (3) Chef (3) extension and addons (3) firefox (3) java (3) personal (3) russian (3) shell (3) windows (3) 64bit (2) Calligraphy (2) Chicago (2) Vagrant (2) apple (2) backup (2) bug (2) code (2) eclipse (2) funny (2) google chrome (2) idea (2) monitor (2) php (2) phpBB3 (2) shorter prompt (2) ssh (2) virtualbox (2) $_SERVER['REQUEST_URI'] (1) 2.7 (1) ALT+Backspace (1) AVR (1) Alt-Printscreen-K (1) AutoRotate (1) CTRL+ALT+DELETE (1) DRM (1) Debugging (1) Gimp (1) Gimp 2.8 (1) Microcontroler (1) Restart X (1) UML (1) Ventra (1) adsense (1) amazon (1) audio (1) aws (1) background process (1) battery (1) bing (1) blank (1) blogging (1) bmw (1) boot (1) business review (1) car (1) cd (1) chrome (1) comcast (1) computer kubuntu (1) conference (1) cookie (1) cron (1) database (1) date (1) display (1) domain name (1) download manager (1) dual boot (1) dual monitor (1) extensions (1) feature request (1) file (1) folder (1) freeze (1) gimp single window (1) git (1) gnome 3.10 (1) google docs (1) google plust (1) google+ (1) grep (1) icon (1) install (1) iterator (1) links (1) linu (1) linux links (1) list (1) mac os (1) media server (1) microsoft (1) moonlight (1) music (1) mysql (1) name (1) nautilus (1) netflix (1) notepad++ (1) parking (1) permission (1) philosophy (1) photo (1) prompt (1) protest (1) ps3mediaserver (1) putty (1) read from file (1) realtek (1) resolution (1) roku (1) samsung (1) scala (1) screenshot (1) security (1) selinux (1) server (1) skype (1) space (1) spam (1) spambot (1) sql (1) suspension (1) system monitor (1) tar (1) task manager (1) template design (1) th23 domain (1) thinking (1) ubuntu 13.10 (1) unity (1) vimrc (1) virtual machine (1) weblogic (1) wget (1) with space (1) xorg (1) xrand (1)