Saturday 27 October 2012

AVR development in Linux


* Install necessary packages

$ sudo apt-get install gcc-avr
$ sudo apt-get install avrdude
$ sudo apt-get install avr-libc

* Compiling code

Steps(2) -> .c => .elf => .hex

$ avr-gcc -Os -mmcu=$2 file_name.c -o file_name.elf
 $ avr-objcopy -j .text -O ihex file_name.elf file_name.hex

* Uploading code

$ sudo avrdude -p part_name -c programmer_id \
     -U flash:w:file_name.hex
  •  part_name => m16, m8
  •  prog_id => usbasp
  •  "flash" => programs flash
  •  "w" => write mode
  •  shld be run as super user => "sudo"
* Compiler optimization
  • specify an option -Ox while compiling (avr-gcc -Ox ... )
  • x => optimization levels
  • "-Os" => "s"=> small - for smaller code

Made a video of LED blinking @ 900ms


* FUSE BITS:

 # read
$ avrdude -p m16 -c usbasp -U fuse_name:r:file_name.txt:h
  •  fuse_name => lfuse,hfuse,lock
  •  "r" => read
  •  fuse value "h" in hex format
  • stored in file_name.txt file
# write
$ avrdude -p m16 -c usbasp -U fuse_name:w:0x82:m

  •  "0x82" => sample fuse value
  •  "m" => immediate ( use value in cmd directly )
  •  "w" => write
* Note: make use of AVR fuse CALC available online



Friday 26 October 2012

Running Raspberry Pi Headless


Raspberry Pi, normally needs a keyboard, mouse and a display ( a hdmi-compatible monitor or tv) for input/output. But it is possible to avoid all of these and still use pi with a lot of ease. This can be done by tunneling through pi using SSH - Secure Shell. It is similar to telnet but its more secure. It uses port22 (by default) for transferring data/info from one system to another. Remember that, these systems are connected to a network - LAN.




Any account in a system connected to LAN can be accessed from any other system by knowing 1. IP address of the system, 2. Username and password of the account.

Raspberry Pi running Wheezy: Default login:

username: pi
password: raspberry

We can login to pi using the following command:

$ ssh pi@IP_address_pi

* Note: The IP address of pi can be found by guessing. Follow the video below to successfully login to pi: ( click here for notes/hints )





So, we have logged on to pi successfully. Lets now do more with SSH. The video below demonstrates the following:

1. login to pi thro' ssh
2. editing pi's password
3. navigating filesystem on debian Wheezy
4. Copying files on network
5. Shutdown, Reboot
6. Compile, run C program

click here for notes/hints



Now, lets move on to the PART2 of this tutorial. We could access pi thro' cmd line. But we need GUI - Graphic User Interface for more flexibility and ease of access. The video below walks you thro' the steps involved in accessing pi using a remote GUI (or GUI in remote system):



Thats it i guess... Bye Bye!


Monday 22 October 2012

Git - Getting started



1. Backup any existing ssh keys
     $ cd ~/.ssh/
     $ mkdir key_backup
     $ mv *.pub ./key_backup/

2. Generate private ssh keys
     $ ssh-keygen -t rsa -C "developer.rps@gmail.com"
     $ Enter file in which to save the key: filename
     $ Enter passphrase : *****

3. Add private ssh key to git.gitorious.org account
     $ sudo apt-get install xclip
     $ xclip -sel clip < ~/.ssh/filename.pub
   



       - go to account setting in the user page of git.gitorious.org     
       - Go to your Account Settings
       - Click ssh keys
       - Click "Add SSH key"
       - Paste your key into keyfield
       - Click Add key


4. Check whether ssh key is successfully added
     $  ssh -v git@gitorious.org


5. Clone the remote repo
     $ mkdir ~/workspace/
     $ cd ~/workspace
     $ git clone git://gitorious.org/project_name/repo_name

6. Adding files to remote repo
     $ cd ~/workspace/athena
     $ nano someFile.txt

7. Add some msg to it, save and exit
     $ git add someFile.txt
     $ git status
     $ git commit -a
     $ git remote set-url --push origin git@gitorious.org:athena/athena.git
     $ git push origin master #only for the first time,
     $ #next time onwards just use "git push")

   If the step 7 throws an error like this,
          $ Permission denied(publickey).fatal:The remote end hung up unexpectedly

  do the following, then try pushing
     $ ssh-add ~/.ssh/id_rsa.pub
     $ git push

8. Getting files from remote repo
     $ git pull

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More