Sunday, December 20, 2015

Raspberry Pi and Electronics

Recently I bought a few interesting things from Amazon.
  1. Of course, the Raspberry Pi 2 - I think I mentioned that already
  2. SunFounder project super-starter kit for Raspberry Pi 2
  3. A book titled "Make: Electronics" by Charles Platt
  4. Companion pack 1 and pack 2 for the book
With all of that I have been working through learning electronics and the Raspberry Pi 2 (and I also have an Arduino, although I'm keeping it aside for now until I am done with the other two).

The goal? In my undergraduate days, I learned Computer Architecture using Hennessy and Patterson Computer Architecture 3rd edition, and was inspired by the book as well as NACHOS which we used in our Operating System class, to write a MIPS R2000 5-stage pipeline simulator for one of my undergraduate projects. Recently, I put it up on Github under the name Coconut (in keeping with choosing fruit names for computers). Now I would like to make the same in hardware, as an educational processor.

Looking into the world of home built processors, I found a pointer to Bill Buzbee's Magic-1 which can be found at From there I found his main page and a link to Dave Brook's iiNet Ring of home built CPUs ! All of it looks pretty cool.

Anyhow, maybe I can do this - we'll see. I also found this rather interesting pair of books
  1. James Hendrix: A small C compiler. This book seems to be about writing a compiler for a trimmed down version of C. If I make a CPU, I'll need a compiler for it. Unfortunately, this book is not in print, and used copies are rather pricey. However, it seems like this github project is essentially the code from that?
  2. Ronald Mak: Writing compilers and interpreters. The first edition of this book writes a Pascal compiler in C. Unfortunately the author ported it in a rather ad hoc and unsuccessful fashion into C++ for the 2nd edition and into Java (really?) for the 3rd edition. Anyhow, I found a used copy of the first edition rather cheap. 
Maybe that will be my resources for writing a compiler for a more advanced language (I wrote an assembler for my simulator) if and when I do get to create my not-so-micro processor!

Anyhow, on a side note, here is a 101 project I did using the Raspberry Pi.

I found this amazing program Fritzing ( which helps you design electronic circuits rather easily. Here's a schematic of the project that I made using fritzing:
And here's the breadboard layout.

The schematic and breadboard layout can also be found at


Saturday, December 12, 2015

WiFi on Raspberry Pi 2 Raspbian Linux

Basically, all wireless networks that your Raspberry Pi 2 connects to automatically on Raspbian are listed in
 For example, here is my wpa_supplicant.conf file with the networks and passphrases masked out.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Look at the two network entries there. The first one is a simple guest network like the kind you'd find at a hotel lobby. It just has a wireless password ("your-key") to it.

The latter is my home network. The SSID is hidden (therefore: scan_ssid=1). The key_mgmt, pairwise, and auth_alg are parameters for WPA2-Personal security with TKIP (usually this is CCMP but I set my router up with TKIP).

PS: if you use Ubuntu MATE for the Raspberry Pi 2 ( ) rather than Raspbian, you have GUI wireless tools.

This web page: was the reference I used to figure out my wireless woes on Raspbian before I switched to Ubuntu-MATE.

Now note above that the passphrase is stored in plain text. Raspbian makes it so only the root user can see the wpa_supplicant.conf file by default, but is that good enough for you? If not, you can set up masking of the passphrase by using the command
wpa_passphrase [ssid] [passphrase]
then you can update /etc/wpa_supplicant/wpa_supplicant.conf
and change
This encrypts the key with an encryption algorithm using the SSID as a seed to the encryption. So a simple glance at the psk value won't give you the key.


Tuesday, December 8, 2015

Using Git

A long time ago, I created a program to simulate a simple MIPS 5 stage pipeline. This was done as a mini project in my undergraduate days and was implemented using C++, flex and bison. The project included
  1. the 5 stage pipeline simulator
  2. a framework for simulating caches
  3. an assembler for MIPS (which is why flex and bison)
  4. a very minimal terminal to interact with the simulated machine
Recently, I decided to try put up the project on maybe, and even develop it either into a product, or an educational application. (A part of me would also like to develop a homegrown board - like the arduino - to match the simulator, but that might be too much to try).

So, on that note, I decided to try and learn git. (I use SVN, so the concepts are all pretty familiar to me.) Found this online tutorial:
 This blog post is just my notes from the tutorial.

1. Creating a git repository in a folder
git init
2. See the status
git status
3. Add files / content to git
git add [filename]
git add .   // to add everything in the current directory
4. Set user name and email
git config --global "[user's name]" 
git config --global "[email]"
5. Commit changes
git commit
git commit -m "[change comment]"
6. Clone another repository
git clone [path]
git clone[username]/[repository].git
7. pull changes from the source you cloned from
git pull
8. push commits to the source you cloned from
git push
9. if you have a local repository, specify a remote repository as origin
git remote add origin[username]/[repository].git
10. Create a branch
git branch [branchname]
11. List all branches
git branch
git branch -v
12. Switch to branch
git checkout [branchname]
or if you want to create and switch simultaneously
git checkout -b [branchname]
13. Push local branch to remote origin
git push -u origin [branchname]
14. reintegrating branches
To reintegrate, you first switch to master
git checkout master
then merge the branch onto master
git merge [branchname]
finally push changes if needed
git push
15. Delete a branch
git branch -d [branchname]
To delete on origin (Note below that  branchname is prefixed with a colon)
git push origin :[branchname]
16. Show log
git log
17. Tag a point in history as important
git tag -a [comment]
18. Any folder may contain a file named .gitignore which lists out one filename to ignore per line. The filenames listed can be unix filename regular expressions such as *.o.

Another reference:


Disable guest session in Ubuntu 15.10

Create the file /etc/lightdm/lightdm.conf
with contents


And then restart your computer.


Monday, December 7, 2015

Installing VMWare tools on linux


Make sure open-vm-tools is not installed.
sudo apt-get remove open-vm-tools

1. Make sure the updates are done:
sudo apt-get update

2. Make sure git is installed
sudo apt-get install git

3. Run the command to get the tools from repository.
sudo git clone

4. cd to vmware-tools-folder
cd vmware-tools-patches

5. Run the patch
sudo ./ 7.1.3
(open to see available options. The file recommends using the latest version, however, 7.1.3 is what worked for me)

6. Run the following patch
sudo ./

7. Run the file
sudo ./

Saturday, December 5, 2015

Hello World from the Raspberry Pi

Mapping a folder on a windows disk as a separate drive letter

For example, you can use the command
subst e: c:\myfolder
to map the folder "c:\myfolder" as the e: drive on windows.

If you put that in a .bat/.cmd file in,
C:\Users\[your username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
then this will run at startup and map the folder as a drive every time windows starts.