Enabling NTP on Gumstix

23. March 2011

 

Gumstix doesn't come with NTP enabled, actually it does, but not quiet. It comes tedious to deal with build file issues as it relies on timestamps. To enable it completely, you should create a file called /etc/ntpd.conf

The whole file is just 3 lines, but having NTP enabled is priceless. 

Here is what I have as the file:

  
listen on 127.0.0.1
server time-a.nist.gov
server time-b.nist.gov

 

Installing Ubuntu 10.10 on Gumstix Overo

22. February 2011

There are some tutorial kind of instructions on how to install Ubuntu on Gumstix. However, they are missing one feature or the other. I couldn’t either get wireless working, or I had to do a lot of work using bitbake (which in turn failed to compile the stuff). Last night, while in the lab, I tried something I haven’t tried before, although I had doubts, it seems to work flawless so far.

So here is a step-by-step guide to install Ubuntu on an SD card.

  1. Install rootstock
    Rootstock is a utility that allows you to create the tarball of an Ubuntu root fs from scratch. You install on your PC, run it, give what packages you want, and go!

    As with everything in ubuntu, it is very easy to install it:
        	sudo apt-get install rootstock
  2. Create rootfs for your choice of Ubuntu distribution
    Now you need to specify what packages to include, what username to use and what serial port to communicate when on gumstix.
    I got the command from the references and added a bit of development related tools to make it easy once I boot the system
    sudo rootstock --serial ttyS2 -d maverick -f "hostname" -l usernamehere-p passwordhere --seed openssh-server,build-essential,cmake,libjpeg8-dev,ffmpeg,wireless-tools,libv4l-dev,subversion,git-core,git-svn,usbutils,locate --copy-package-cache --restore-package-cache
    -d maverick: This is the code name of the distribution. Since I want 10.10, I wrote maverick.
    -f “hostname”: This is the hostname of the vehicle.
    --seed p1,p2: Name of the packages you want to have installed. Not mandatory as you’ll still be able to use apt-get but a big time saver in case you want to do that thing multiple times.
    Since we are planning to do some onboard video processing and/or vehicle controls, we need to have build tools (build-essential, cmake). Although you don’t really need wireless tools, it is handy to have them for debugging purposes. We’ll be connecting the gumstix through SSH as it is really handy in many cases. We also needed to be able to checkout SVN repositories and Git repositories, hence they are also in the list.
    --copy-package-cache and --restore-package-cache flags come in handy in case you forget to include something in your package list. It will cache packages once you download them, and will retrieve them from the cache next time you use.

    Once this command executes, you should have a tar.gz file called armel-rootfs-xxxxxxxx.tgz. It will basically contain your Ubuntu files.
  3. Download Kernel, U-Boot and uImage files
    You can find a fairly updated kernel compilations etc for Gumstix at the link http://www.sakoman.com/feeds/omap3/glibc/images/overo/
    As usual, I took the risk and downloaded the latest ones.
    I downloaded omap3-console-image-overo-201011150741.tar.bz2, u-boot-overo-201011150741.bin, uImage-overo-201011150741.bin and MLO-overo-201011150741

    We’ll write those files to SD card once we format it.
  4. Extract omap3-console-image to a known location.

    Although this step is not mandatory to have ubuntu, it contains modules and driver files you’ll most probably need some modules and firmware files. It is especially necessary in case you want to use built in WiFi and possibly some USB tools.
    tar xvjf omap3-console-image-overo-201011150741.tar.bz2 omap3-console-image
  5. Partition and format the SD card.
    Nothing fancy here, I am basically following instructions here. In case they become unavailable, you can reach the instructions from my local copy. Follow the same instructions until the section “INSTALLING BOOT FILES”.

    First mount the first partition to a folder and move image files. You should follow the instructions in the order given.
    mkdir mountpoint
    sudo mount /dev/sdb1 mountpoint
    Then move files to that point
    sudo cp MLO-overo-201011150741 mountpoint/MLO
    sudo cp u-boot-overo-201011150741.bin mountpoint/u-boot.bin
    sudo cp uImage-overo-201011150741.bin mountpoint/uImage
    
  6. Extract rootfs files

    Now unmount previous partition, and then mount the second partition
    sudo umount mountpoint
    sudo mount /dev/sdb2 mountpoint
    You’ll now be extracting the rootfs tarball into that folder. In order to do that, you should cd into that folder.
    cd mountpoint
    tar xvzf ../armel-rootfs-xxxxxxxx.tgz
    7. Copy out some modules and firmware files
    You now have Ubuntu installed. However, we still have to copy out some modules and firmware files to have, say Wireless.
    sudo cp -r /path/to/omap3-console-image/lib/firmware lib/
    sudo cp -r /path/to/omap3-console-image/lib/modules lib/
    You now have everything, you should unmount the partition, unplug the SD and put it back to your overo.
  7. Test if everything is working
    You should monitor what your device is outputting using minicom or equivalent. Assuming that you can do it, we should test if we can see a login screen for ubuntu. Plug SD card into your overo and power the device.

    If you come to the ubuntu boot screen, then you passed the first test.

    As the most important capability for me is to have wireless access, I tested it first.
     sudo iwlist wlan0 scan
    if you see a list of available access points, then you’re good to go with wireless. Using /etc/network/interfaces file you can do necessary settings pretty easily.

Hello Boston!

20. August 2010

I’ll be in Boston for at least next 2 years. Hoping to make it 5 years though (hint hint!).

A LOL Moment

4. August 2010

Found this on Sergio Pereira’s Twitter Feed

Feedback to my department (Computer Science/Bogazici University)

13. July 2010

PS: This blog post is in the oven for last 8 months, because I waited for some time to make sure it is not something I wrote because of my feelings. I don’t really think it is unique to Bogazici University, but I see some value in sharing it on Devlicio.us, too.

If you can read this, it means that I have almost finished my undergradimageuate education.

Being a good student, I believe I have a few words to say on my school and its people.

I have transferred there from another great university, namely ITU. There were several reasons behind my transfer, one of which was better instructor-student communication and better relationship with schools aboard. After 4 years, I believe it was overall a good decision but unfortunately nothing perfect, and actually I am not expecting it to be perfect, everything comes with its flaws.

What I see in Bogazici, in general, is that everything was designed to decrease bureaucracy. Compared to my former school, you can see the difference. When a class is overquota, you send a message to the instructor of that course and expect him/her to allow you into the class. In the former school, you have to write a petition to the faculty, they gather those petitions and inform the student affairs and then student affairs increase the “overall” quota. This takes several days and in the end, you may not be able to register for this course at all.

Another thing is that you are informed about every little thing that has to do something with students. We get scholarship announcements, information about campus events and so. In the older school this doesn’t hold, you have to follow everything by yourself.

Having said the above, now it comes to my department: Computer Engineering and its faculty. We have, no doubt, greatest minds of Turkey in various areas. I am going to share the points that I am not comfortable with, and I hope this is a constructive critic.

Your students you give reference are your face abroad! And it is your “duty” to give referenceimage

Every student, for some reasons like for a job or for a grad school application, needs references from the instructors/professors s/he took from. It is a very natural process especially during fall terms of sophomore year to ask for it. Professors should be aware of these very tough times, and should be constructive at those times. I have taken references from 3 professors (which is the bare minimum for universities) from whom I took a class from or worked with, I am very thankful to every single one of them. Some were very constructive, but probably more than half was not very helpful at all. I didn’t have any problem with taking reference, and I was even surprised because I was able to take reference from a professor whom I worked when I was a sophomore 2.5 years ago. He was very friendly since we met and even though I asked way too many letters of recommendations (app. 18), he sent every single recommendation letter I requested.

Anyway, going back to people from my school (with some exceptions, of course), I didn’t hear good things, I had to say. I learnt that one of them said he can’t write one because he didn’t work with this student, then he changed his mind and said he could only send online recommendations (probably for the fear of student opening a letter and read the recommendation, ie. for the sake of privacy). This student wasn’t an ordinary student, he was an exceptional one, very smart and he had really good GPA. One of them didn’t even care and “ignored” another friend of mine when he asked for letter of recommendation. That’s our experience.

We had chance to discuss about ways to improve our department. Their answer to our complaints was worse than what we thought it would. First they said every good student will get very good references from any instructor they asked. When we had told our experience about this process, they then changed their mouths and said “we cannot e nforce to make them give you one”. This is really not the case; they can do something, even if it is just a discussion between profs. One other said he gave more than hundred letters of recommendation, and if we asked one, we could get one.

It’s true that they may not give a LOR if they haven’t worked with this student, but think of it for a second. Our curriculum is fixed until we are senior student! They don’t leave much chance to take elective courses until we are senior student. The pool of professors we can take LOR from is fixed, and I can say there aren’t many who will give LOR without any problem. With all due respect, we don’t really deserve this. Time is valuable for you, so are ours to us. There is a method that I have seen in both US professors I worked with. They ask you to write a draft as if the Prof is writing to him. This is very beneficial in many ways: It informs the prof about what the student did and achieved during his undergraduate life, it significantly decreases the time to write a LOR, the LOR will be unique (it won’t be a generic one like “he took my class got an A, he is smart and handsome”) which admission offices say to be very important. It also gives an idea about how he think he is in the eye of the professor.

Moreover, comparing my department with some others, I can say my profs are not very doing good at this. I’ve heard that Profs from electronics department, for example are very helpful, they look for what professor to choose, whom to ask for funding etc. They even try to establish some kind of meeting with professors abroad. I haven’t seen and heard such behavior from my department. This will hurt our education a lot.

It is, in my opinion, the responsibility of an instructor to raise interest

image After my internship at MIT, one of the instructors, namely Ayse Basar Bener, asked me if I am interested in taking CMPE 491 (the complementary project course). I was surprised and I have to say I like the way she approached me. She suggested me to talk with Cem Ersoy and Levent Akin for that because she believed I would be interested in their areas of research based on my internship. This was what I had been thinking for a while, to get involved in some academic research in my current school but I was sort of busy with other things(as Baris Gokce says, if you are not enforced to do things, you are most likely not going to do it). Sometimes you need a good motivator, and a suggestion may be the one you’re looking for.

When I talked with Cem Ersoy and Levent Akin, all was kind enough to spend half an hour on discussion. They told what they do, and I told them what I was interested in. Cem Ersoy, while we were talking, mentioned that they always appreciate newcomers but they don’t have enough energy and time to draw people’s attention. This is what I don’t get at all (don’t get me wrong, he is one of the most amazing instructors over there).

Being the department with highest ranked students, all the students we have in department are extremely smart and talented. Some are less focused but they can do very well if they pay attention. I believe that it is the responsibility of an instructor to draw attention to their field. They don’t have to do much; it suffices to tell about what they really do and how students could contribute into their research. Freshman orientation is definitely not the best time for such things. Some people don’t even know what network really means, for example. It should be done sometime in 3rd year. They can even ask students to come by and ask their questions. Some of the instructors I know did this very well, but some didn’t even care. This is also directly related with interaction, and it is really important.

Feedback/Interaction is an essential part of education

Everybody would agree that feedback is an important process in everything in life, and it is even more important in the context of education. By feedback, I don’t mean the course evaluation forms we fill at the end of each semester. Those are actually what I care the least. Every term, the results of previous survey is being announced but I don’t know if people care for them (except for the ABET. I try to be optimistic in that forms)

What I mean by feedback is the feedback mechanism imageright in the classroom. It is the ability to be flexible in the course schedule (definitely not a drastic change in syllabus). Depending on what students do understand and don’t understand, it is the ability to spend more attention on some topics and less on others. It is the ability to give the students the feeling that they are important and their thoughts are important.

From what I saw and heard about several instructors, I can say that some are really openminded and open to what I said above. However, some of them just write on the board what is exactly on the book. No matter how well you do in your field of area, and no matter how famous you are, you’re definitely not doing good in teaching. Teaching is an interactive process that consists of students. Students are the main part of the process and instructors are responsible from making them understand. One can do that in many ways, the simplest one is asking questions. Please, dear instructor, don’t hesitate to ask questions in the class, and please talk on interesting topics, not just write everything on the board and leave the room after the class is over.

Our time is valuable, please think about us.

I have been to two different undergraduate colleges, and I know their systems more or less. I imageam a big fan of “self-improvement”. I believe that people learn best what they do when they are not enforced to. Giving assignments just to keep students busy does not make any sense. Quite often, I hear TA’s giving homework (usually the first one) tell that this is just a warm up. What I talk is for the majority of courses that has homeworks, but to give a special example one would be the embedded system assignment. The instructor is a very good one, and I really learnt a lot (I don’t say this much for courses). In that assignment we are asked to implement spline interpolations in a limited amount of memory. Code took only 1-2 hours to finalize, while its report took forever to finish. In the report, we had to take the output of the spline for 100 points (in which we have to use copy & paste and do some processing to get the data, there wasn’t an easy way really. If we are talking about an embedded system, give something that really makes sense, and do not expect us to write report that is of little value. Part of that report really made sense, like optimizations, like constraints etc but those parts took only a couple of hours to write.

Another thing that I would like to mention is the overhead we have been given in our lab experiments (hardware labs, to name one, embedded systems and digital design). In those experiments and assignments, we are asked to make “good looking circuits”. By good looking, I mean straight cables, cables not crossing each other etc. The reason they want us to do such thing, they say, is that circle-like wire might act as a coil and induce magnetic field. This is completely senseless. It might be true that it can cause magnetic field, but it is negligible for “our purposes”. Cutting those wires in appropriate length takes a lot of valuable time. Sometimes you cut it short, sometimes you cut it long. The time we spent on just cutting wires is basically at least 3/5 of the lab time. This time could be spend for more valuable things, like learning new stuff, or combining many components for new circuits.

I am not complaining, in fact, I was probably one of few people who had completed his all assignments with high grades; this is because I care about them a lot. However, this also comes at a cost: You have to sacrifice from other things. This sort of stuff usually steals from the time that I spend with my family, girlfriend or self-improvement. For the first couple of weeks of the first term, I was extremely busy with just doing homeworks. Spending less time for sleep, less time for self-improvement (I have no commits to any OSS during that period), less time for my beloved one.

Another point I criticize about embedded system course is that so-called lab hours. In theory, this is a 3 credit course. We also have 2 hour demonstration for the assignment we did that time. We spend 5 hours just to satisfy course requirements. All is okay up to now. The problem is the assignment itself. This assignment takes at least 1.5 full day of cutting wires, connecting cables and debugging. Those assignments are weekly, meaning that the same busy days every week. Result? Sleepless nights. Should it be like this? I don’t know. Will I do such thing if I ever become an instructor? Surely NOT.

I will quote one of the professionals that I respect, Karl Seguin : “You learn so much more from your own project, because you aren't constrained by technology or risk, or time lines. You implement BDD, NoSQL, Python, memcached, NHibernate, etc.. on your own projects first, then use them at work. Maybe that's why the 15% rule at Google, 3M and Atlassian works so well...its the ultimate training opportunity “ (can be found on his public profile). I put my name under it. This is what it has to be like. I completely agree with giving assignments but I also support to keep the overhead at a minimum level.

I may add some other things as the time goes by, but this is what I can remember for now. I hope someday people will read this material and benefit from it. This is my feedback to my school.

Not So Hidden Gems of NHibernate – Formula Discriminators

13. July 2010

A friend of mine, Cristian Prieto, told me that he didn’t know how to do mapping of some entities to (in his terms) an evil legacy database.

There were two entities: Advertiser and Affiliate. As I said, this was a crazy legacy database. Both shares the same table with only one difference: If an entity is Affiliate, then it’s affiliate_id column will have a value, otherwise, a non-empty advertiser_id means it’s an Advertiser. Both cannot be the same at the same time.

Having gone through NHibernate code a while ago, I remember being able to discriminate on an expression (or in NH terms: Formula). I wasn’t sure about it, but Cristian verified that there is such thing that exists, and you can use it for such thing.

Here is the description of formula discriminator from the documentation.

<discriminator
        column="discriminator_column"  
        type="discriminator_type"      
        force="true|false"             
        insert="true|false"            
        formula="arbitrary SQL expression"
/>

formula (optional) an arbitrary SQL expression that is executed when a type has to be evaluated. Allows content-based discrimination

Bingo! “an arbitrary sql expression” is just what we wanted.

Going back to Cristian’s problem, we can now use this:

<discriminator 
        type="Int32" 
        formula="(case when not affiliate_id is null then 0 else 1 end)"
/>
The rest is left as an exercise for the reader (I always wanted to say this!)

Support Castle Project – One Click Away

21. March 2010

(I wouldn’t have noticed such thing if I hadn’t visited Castle Blogs and noticed Ken Egozi’s post)

Stackoverflow decided to publish advertisements of OpenSource projects, and it is a vote based system. If you use castle, please vote for it.

Tekpub’s Mastering Linq Challenge

9. January 2010

Update 6: When you think you’re done, think twice. The code should be valid even when the range contains some negative value

var primes =
    Enumerable.Range(-10, 34).Aggregate<int , IEnumerable<int>>(new int[] {},
                         (list, x) =>
                         x >1 && list.All(y => x%y != 0)
                             ? list.Union(new[] {x})
                             : list);

End update

Update 5: Long story short, Linq is not the type of thing you’d use when finding primes.

Update 4: Removing “if” in expense of reduced speed

Enumerable.Range(1, 34).Aggregate<int , IEnumerable><int>>(new int[] {},
                         (list, x) =>
                         x != 1 && list.All(y => x%y != 0)
                             ? list.Union(new[] {x})
                             : list);

End update

Update 3: Making the code a bit faster by dividing only primes found so far

var primes =
    Enumerable.Range(1, 34).Aggregate(new List<int>(), (list, x) =>
{
    if(x!=1&&list.All(y=>x%y!=0))
    {
        list.Add(x);
    }
    return list;
});

End update

Update 2: Using all, one can have one step cleaner code.

var primes =
        Enumerable.Range(1, 34).Where(x =>
                         x == 2 || (x != 1 &&
                                    Enumerable.Range(2, (int) (Math.Sqrt(x)))
                                                           .All(y=>x%y!=0)));

End update

Update: Using any, one can make a bit faster implementation of it

var primes =
                Enumerable.Range(1, 34).Where(x =>
                                              x == 2 || (x != 1 &&
                                                         !Enumerable.Range(2, (int) (Math.Sqrt(x)))
                                                             .Any(y=>x%y==0)));

End update

Here is my solution to TekPub’s Mastering Linq Challenge appeared on Justin Etheredge’s blog

            var primes =
                Enumerable.Range(1, 34).Where(x =>
                                              x == 2 || (x != 1 &&
                                                         Enumerable.Range(2, (int) (Math.Sqrt(x)))
                                                             .Where(y => (x%y) == 0).Count() == 0));
Not very efficient, but simple :)

Testing on Android

6. January 2010

androidFor the last couple of months, I have been working on Android platform as part of Software Engineering course(more on that later, i hope). Even though there are a lot of things I don’t like about android (like XML layouts and the ids of widgets being held in some other class etc but perhaps this is just me), I overall find it a good platform to work with.

What I really liked in Android is that it provides an Out-of-the-box environment for easy testing android applications. I don’t know how Windows Mobile projects handle this situation, but what android does is that it executes the test in the context of virtual machine. Android integrates nicely with JUnit framework, which is the java brother of NUnit.

What is more interesting than this is that Android also has UI testing framework. Being a person who hasn’t written UI tests much (as in none), I can’t say if it is a good one or not. I just liked the feature that came out of the box.

I have created a simple Activity (you can think of it as a window, but not exactly)

public class SampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final Button b=(Button)findViewById(R.id.Button01);
        final EditText t=(EditText)findViewById(R.id.EditText01);
        b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                t.setText(t.getText().toString()+"hello");
            }
        });
    }
}

And created the following test.

public class SampleActivityInstrumentation extends
		android.test.ActivityInstrumentationTestCase2 {

	public SampleActivityInstrumentation() {
		super("com.myandroid", SampleActivity.class);
		// TODO Auto-generated constructor stub
	}

	public void test_OK_button_appends_hello() throws Throwable {
		SampleActivity tne = (SampleActivity) getActivity();

		final Button btn=(Button) tne.findViewById(com.myandroid.R.id.Button01);
		final EditText titleEdit = (EditText) tne.findViewById(com.myandroid.R.id.EditText01);
		runTestOnUiThread(new Runnable() {
			public void run() {
				titleEdit.performClick();
			}
		});
		sendKeys("H E L L O");
		runTestOnUiThread(new Runnable() {
			public void run() {
				btn.performClick();
			}
		});
		assertEquals("hellohello",titleEdit.getText().toString());
		
	}

}

I found it very cool to have such a nice integration. More than that is that they use proven testing framework out of the box.

GRE Epic Fail

3. December 2009

I won’t write about how good or bad GRE exam is, I will write about how bad their customer service is.

In my previous post, I have written that they locked my account. It is probably 10+th call, and still my account is locked. Everytime I call, after approximately 20 mins of waiting, the customer representative sends an email to technical department about my issue, and I get my password has been reset. They don’t say what my new password is, and when i try forgotten password again, it again says your account has been locked.

I believe that the problem occurs because everytime I call, I talk with “different” representative. Presumably, everytime he mails to technical support, the mail is processed by another person. When I asked if I could talk directly with a technical support guy, or mail to a “specific” person, I get the answer “unfortunately”. This is a really bad way of serving to the customer.