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.


Sunday, November 29, 2015

Raspberry Pi and Arduino

I guess I've been in hibernation for a while. However, recently I stumbled upon Raspberry Pi and Arduino.

The Raspberry Pi is a single board computer that sells for under $35. The Raspberry Pi 2 Model B has a 900MHz quad core ARM CPU and 1 GB of RAM and can run a Debian Linux variant called Raspbian. Since the Debian linux distro already has all your web browsing and office productivity applications, you get a fully functional computer for $35 + monitor + keyboard and mouse:

The Arduino on the other hand is a micro-controller. What that means is, it is a complete computer - microprocessor, memory etc, on a single chip. However, that also means it's not all that powerful as a computer, and is usually used for a single task. Usually, the micro-controller does not run an operating system - since that would be a waste of the precious resource of memory. Rather it runs the single task directly as a program, so that it is essentially a one-program-computer. Normally that means, you will need complicated hardware to "flash" that program onto the micro-controller's "PROM" - Programmable Read Only Memory. However, in the Arduino's case, it has a "boot loader" - the OptiLoader. So in a sense, the Arduino can be considered a two-program-computer. The boot loader allows you to connect to the Arduino on the USB interface, and program the second program - your program - onto it's program memory. After that, until you change the program, the Arduino will keep running your program whenever and as long as it has power:

This past thanksgiving weekend, I ordered a Raspberry Pi unit on Amazon. I haven't received this yet, but I'm super pumped and have been researching Raspberry Pi quite a bit over the last few days. Also the Arduino - although I haven't ordered one yet. It should come before end of the week, and I will be posting new material on my journey with the Raspberry Pi and soon also the Arduino.

One cool thing is, since the Raspberry Pi is a full computer and can run Raspbian/Debian, it can run the Arduino IDE used to program the Arduino. So I can connect an Arduino to the Raspberry Pi via USB and work on it.

Also, I found these two cool videos about the Arduino. The former is an Arduino's essential circuit on just the ATMega328 chip: The latter is how to make your own Arduino: Notice how the latter video includes the USB for the Arduino, whereas since the former one-chip Arduino doesn't include a USB connecter, you have to program it by plugging it onto a standard Arduino board. I want to make a hybrid of these two, where I have a one-chip Arduino, but with a USB interface as well (may or may not be detachable).


Wednesday, July 29, 2015

Screen video GIF

Use this software - LICEcap from
to get a video screen capture of a portion of your screen and save in a GIF file.


Friday, January 9, 2015

Keeping a web page out of the cache

Recently I started maintaining a server for internal testing at work. This hosts, among other things, many web pages that we often modify.

Trying to make sure that we can modify the page and not have to wait an ungodly amount of time before the page goes out of the server's cache (not the client side browser cache) thereby now showing our changes, turned out to be a problem.

The solution we finally figured out was to add these meta tags to the head of the HTML.

<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Web Page Title< /title>
And while on the subject of Meta Tags, here's a meta tag to force the newer IE compatibility mode on a web page:
<meta content="IE=edge" http-equiv="X-UA-Compatible" />