2008-10-30

An open source license primer

Licensing is a tricky issue, especially when it comes to software, and even experienced developers have a hard time knowing what you can and can't do with open source software. I am not a lawyer, but I've been interested in free and open source for a long time and a while ago a colleague and I held a presentation on licenses (Slides in Swedish here) at the company we work for.

To explain what this license thing is all about you need to start with Copyright, which is as old as the printing press. The whole point of copyright is to give the authors of “original works of authorship” the rights for their works so that they have control over how it will be distributed. If someone else want to distribute that piece of work, they need to obtain a license from the copyright holder, usually in exchange for a one time payment or a royalty agreement.

But what if the copyright owner doesn't want the distribution of his or her work to be limited in any way. The first thought might be to put the work into the public domain, meaning that you abandon any claim of ownership of the work. But is this really making it as “free” as possible? What if the piece of work is source code that someone will download, modify in some way and then compile to a binary program to be sold. Is the original piece of code still free?

This leads us to the use of Copyleft licenses where the idea is to use copyright law to prevent any restrictions that would limit the distribution of a piece of work, or modified versions of it.


Open source licenses are usually grouped into permissive, weak copyleft and strong copyleft. In the picture above the BSD license is a permissive one, LGPL a weak copyleft and GPL and AGPL are strong copyleft, meaning they include the “Liberty or Death” clause that was introduced in version 2 of the GNU GPL. Of course there are other common open source licenses, and OSI has a nice list of them here, but for simplicity I'll only discuss the ones mentioned above.

There are several versions of the licenses mentioned above and some are not compatible with earlier versions. Since GNU GPL is probably the most common open source license FSF have a chart showing compatibility with the latest version compared to the previous version.



Permissive licenses

It's important to note the word Modified before BSD in the image above. The original BSD license, sometimes called "BSD-old" or "4-clause BSD", had an advertising clause that required authors of derivatives of a BSD-licensed work to include an acknowledgment of the original source. This made it incompatible with GPL, and also unmanageable because so many acknowledgments were required. Code licensed under BSD can be used in closed source projects, as long as a copy of the license is included in the distribution. Other permissive licenses have similar demands.

If you release code for a new protocol or media codec, it might be a good choice to put it under a permissive license because it makes it more likely that companies that are not yet open source friendly will still implement it.

Weak copyleft

If you are using code covered by a weak copyleft license like LGPL, it gets a bit more complex. The GNU Lesser General Public License allows users to link to the LGPL program without having to put their own program under the same license. There are still restrictions, like that you have to make it possible to upgrade the LGPL program to a more recent version and if you modify any LGPL licensed code you have to release the changes.

This type of license is often used in toolkits like GTK+ and media libraries like gstreamer so that they can also be used to build proprietary products and get wider adoption.

Strong copyleft

Strong copyleft licenses like GPL or AGPL are a lot more restrictive when it comes to what you can do to the code. They are called strong because they include the “Liberty or Death” clause, meaning that all the code have to be open. This includes linking into libraries and running the code within the same process. It is precisely because of this strictness that LGPL was created and there is also several exceptions to the GPL covering for example GCC, fonts or the GNU Classpath.

There are two major versions of the GPL, 2.1 and 3. The big differences have been explained succinctly by the FSF and basically concerns these points:
  • Tivoization - Using crypto hardware to control what code is allowed to run on the device.
  • DRM - Restrictions on what code you write and distribute.
  • Patents - Using GPL code gives you right to use the patents in it.
  • Digital distribution - Physical distribution of the source code is no longer an explicit demand.
In addition to these changes, the text have become a bit easier to read and clarifies certain details concerning for example out-sourcing. It is also compatible with more licenses and gives you a chance to rectify your mistakes in case you violate the license unintentionally.

The difference between GPL and AGPL is that AGPL has an extension that covers online services like forums, blogs or online stores. This covers the “legal hole” in the GPL where you are not distributing a program but still provide a service for users over the net using GPL licensed code.

Remember

The important thing to remember is that these copyleft licenses are all distribution licenses and not user licenses. This means you are allowed to modify and use them internally within your company or home without releasing the changes to the code, as long as you do not distribute it in any form. Even if the company doesn't want to release all their code, hopefully they will still contribute to the upstream development of the copyleft code they use.

But if you do distribute code, be sure that it does not violate any of the licenses. It has been proven in court several times by GPL-Violations that a copyleft license has the same legal status as a proprietary license. If you think no one will find out that you are using copyleft licensed code because it's built into the firmware of your product you are probably wrong. There is even a manual written by Armijn Hemel describing how to detect license violations in consumer devices.

To be clear, building an application that runs on top of Linux or an open source application server like JBoss does not mean you have to open the source of your application.

If you plan to use GPL code in any way, do it right and follow the Software Freedom Law Center's excellent Guide to GPL Compliance!

2008-07-26

Minix 3.0

Was surprised to see this ad in my Gmail today:


I usually get a lot of Linux and embedded hardware related ads because of the OpenMoko mailinglists, but Minix 3 was really a surprise. I tried running it in VMWare about two years ago after reading a nice introduction to it on OSNews. Can't say I was impressed. It sure didn't look like much back then (and still doesn't, it's just X), but microkernels are very interesting.

There are a lot of L4 kernel based operating systems, and a few of them even run on the Neo1973(Video from here). Hopefully this one will too some day.

There will always be some overhead when using a microkernel compared to a monolithic kernel because of the extra IPC, but the modern implementations are not that far behind. It will be interesting to see how useful the different versions will become, although there's little hope some of them will ever be completed...

2008-05-24

Roguelike revival

I played my first roguelike JAMoria on a Mac Classic II somewhere around 1993. It's a classic black and white ASCII game where you run around with a @ using the numpad on the keyboard. In JAMoria you start in a small city, just like the classic Moria. But instead of just having one dungeon, it has multiple dungeons to descend into, both in the town and in the wilderness that surrounds it.

Like all roguelikes, if you died you had to start over again and create a completely new character to play with. Already being familiar with regular table top role playing games, rolling new stats and trying out new race and class combinations was a major part of the fun.

In early 1996, using a blazingly fast 28.8 baud modem I managed to download ADOM 8.1 and install it on my first non Macintosh pc, a Pentium 75Mhz. At first I found the game really hard, and all new characters died after just a few minutes, but I kept trying. After some newsgroup searching I found help in rec.games.roguelike.misc, and later rec.games.roguelike.adom. And I've been playing ADOM ever since. It's a very very difficult game to "win", but just trying to is fun enough. Not much has happened to ADOM since version 1.1.1 in 2002, and by that time the development of all the other rougelikes I knew had gone into maintenance mode or ceased completely.

Adom: Terinyo

One reason might be that graphical games were making it impossible to compete. One of my favourites, Dungeon Hack, was early and most roguelike of them all. The much more popular Diablo came later and was not turn based, even if the game mechanics was kind of the same. Of course people tried making graphical front ends to the classic roguelikes with varying success. Falcon's Eye was probably the most known. A fork of that project called Vulture's is still under development and it's a game I have yet to try. (The demo video looks good though!)

To get back to the title of this post; It feel there is a huge revival going on in the roguelike scene. There's new blogs, columns, news pages and games showing up everywhere and older newsgroups and pages like RogueBasin seem to have a surge in activity and popularity. Even the ADOM homepage has gotten a face lift with a new blog about Thomas Biskups new roguelike JADE, and a brand new forum.

I guess that the main reason people enjoy making roguelikes is that the games are full of tricky algorithms like dungeon generation, field of vision, monster AI and more, but still small enough for a single developer to make by themselves. The main reason is of course that there's no graphics and no sound (well, DoomRL has sound), so all the programming effort and processing power can be spent on actual game play instead of bells and whistles. If you know what to do, creating a new game from scratch can be pretty quick. 7 Day Roguelike competitions seems to be more and more popular.

Some are more ambitious than others. The crazy guys behind Dwarf Fortress have quit their jobs to work full time on their ASCII dwarf game simulator. It's not really a classic roguelike, but the features are impressive. Julian Mensch has been working on his Incursion since 1999 and the planned release is in 2011!

All in all, it's a genre of games worth trying, and I guess it's a nice way to learn a new language trying to implement a 7DRL in it. (My attempt in J2ME was never completed though. Take a look at Dweller instead.)

Also, I wonder what's the best way to control a roguelike when you only have a touchscreen. Would be nice to have one for the OpenMoko phone.

2008-05-05

Einstein quote

The fairest thing we can experience is the mysterious. It is the fundamental emotion which stands at the cradle of true art and true science. He who knows it not and can no longer wonder, no longer feel amazement, is as good as dead, a snuffed-out candle. It was the experience of mystery - even if mixed with fear - that engendered religion. A knowledge of the existence of something we cannot penetrate, of the manifestations of the profoundest reason and the most radiant beauty, which are only accessible to our reason in their most elementary forms-it is this knowledge and this emotion that constitute the truly religious attitude; in this sense, and in this alone, I am a deeply religious man. I cannot conceive of a God who rewards and punishes his creatures, or has a will of the type of which we are conscious in ourselves. An individual who should survive his physical death is also beyond my comprehension, nor do I wish it otherwise; such notions are for the fears or absurd egoism of feeble souls. Enough for me the mystery of the eternity of life, and the inkling of the marvellous structure of reality, together with the single-hearted endeavour to comprehend a portion, be it never so tiny, of the reason that manifests itself in nature.
-Albert Einstein, The world as I see it

2008-04-17

History in Zsh

Since I use Zsh with shared history, the normal history command doesn't work properly. Instead I came up with this ugly hack using cat and cut:
cm@tyst> cat ~/.zshhistory | cut -c16-40 |awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
550 ls
496 cd
322 make
224 vim
168 su
151 screen
105 ssh
91 bitbake
76 rm
58 mtn
and for root:
root@tyst> cat ~/.zshhistory | cut -c16-40 |awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
713 emerge
312 vim
247 ls
165 cd
120 screen
108 iptables
83 etc-update
60 top
59 dmesg
53 cp
Guess it's quite obvious what distro I use on my computer at home and what I spend time doing...

2008-03-09

Lies

For some strange reason studies of liars seem to pop up all over the net right now. NYmag has a long and very interesting article about why kids lie and how they learn it from their parents. Kids start as early as age 2 or 3, and the smarter the kid the earlier they start lying. Telling the truth is easy, but making a believable lie takes a lot more effort.

The always excellent Radiolab had a show last week about lies where they presented the results from several studies on the subject. They interviewed the famous psychologist Paul Ekman about facial expressions and how to tell if people are lying. The whole concept of microexpressions is fascinating. And Ekman's vow he took when his daughter was born to never lie again seems incredibly difficult to keep.

Another part of the program discusses a study Yaling Yang did on pathological liars. Brain scans of them showed that they had a lot more white brain matter in their prefrontal cortex compared to the control group, but less gray matter. The researchers believed that the huge increase in connections in the brain made lying practically effortless for these individuals and they could reply instantly with a plausible lie.

The radio show continues with a segment about a con-woman called Hope and how she used unsuspicious people by constantly lying.

People who are good at lying are generally more happy and have greater success in life. People with serious depressions are "too realistic" and seem unable to twist the truth into a brighter version. Being able to lie to yourself as well as others have many advantages even when you don't abuse it to the fullest.

I spend a lot of time thinking about how to interact with people and even more observing what people do and how they react. If I had no moral or empathy there's no limit to how much I could take advantage of peoples good will. Most people want to help and trust other peoples "good nature", but I'm afraid there's too many who don't have that in them. I'll be sure to keep my eyes open for the slightest "leakage", be it a microexpression or an inconsistency in the story. Just never let people know you caught them lying, that just makes them more careful next time and harder to catch.

This cynical post is written while listening to Billy Talent - Lies

2008-01-28

Schwartz and gllin

For some reason Andrzej "balrog-kun" Zaborowski is still missing from PlanetOpenMoko, so I'll just link to some of his recent posts instead.

Andrzej have written an ELF-loader called Schwartz that can translate OABI to EABI and his latest post shows how to use it with gllin instead of a chroot.

Very impressive! I haven't tried it myself yet, but I definitely will soon.

2007-12-19

OpenMoko Debug Board

I've had a problem with my u-boot_env since ever since I flashed a bad u-boot version in early august. The first time I tried to flash a new kernel it wrote right over the environment partition and since then I've been unable to boot without holding in AUX and use Factory Reset. Also, since the u-boot_env was overwritten I had no way to redirect the u-boot serial terminal output to USB because the limited default boot menu only includes Boot and Factory Reset.

Fortunately I managed to get my hands on a debug board. (Thanks abraxa_!) Following the instructions in the wiki I installed libftdi and started looking for an openocd ebuild. Wasn't until later that I realized I didn't need to install openocd in Gentoo at all, since it was a lot easier to use the one built by the Moko Makefile.

Next I connected the debug board to the pc but it just wouldn't show up correctly. Taking a closer look at the debug board page in the wiki I noticed I was missing kernel module. Recompile the kernel to include Device Drivers -> USB -> USB Serial Converter Support -> USB FTDI Single Port Serial Driver as a module, and after a modprobe ftdi_sio vendor=0x1457 product=0x5118 the device was detected the way it should:
drivers/usb/serial/usb-serial.c: USB Serial Driver core
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device
ftdi_sio 2-1.1:1.0: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT2232C
usb 2-1.1: FTDI USB Serial Device converter now attached to ttyUSB0
ftdi_sio 2-1.1:1.1: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT2232C
usb 2-1.1: FTDI USB Serial Device converter now attached to ttyUSB1
usbcore: registered new interface driver ftdi_sio
drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver
I updated the openocd.conf according to the wiki and it started without complaints. Did a telnet localhost 4444 and was greeted by the openocd prompt. The only problem now was that I had no real clue how to proceed. I typed help in the prompt and then tried some of the commands. After a mix of a halt and reset commands the Neo1973 went black. Trying to restart from scratch I closed openocd and unplugged the debug board. That turned out to be a bad idea. After reconnecting the USB cable and restarting openocd I constantly got the error:
Info: openocd.c:93 main(): Open On-Chip Debugger (2007-09-05 09:00 CEST)
Info: configuration.c:50 configuration_output_handler(): Command ft2232_vid_pid not found
Info: configuration.c:50 configuration_output_handler(): Command ft2232_layout not found
Error: jtag.c:1461 jtag_init(): No valid jtag interface found (ft2232)
Error: jtag.c:1462 jtag_init(): compiled-in jtag interfaces:
Error: jtag.c:1465 jtag_init(): 0: parport
The reason it failed was probably that the Neo was still on, but halted, and I guess that caused some trouble for the debug board. After disconnecting both devices and taking the battery out of the Neo, then starting over again it worked better.

Asked for some help in #openmoko for how to get that u-boot_env repaired and NineX suggested using the Devirginator since it had worked well for him. At that time the buildhost was down, so I tried to configure it to use my local repository instead. After about an hour or so fighting with the config file, only getting useless error messages, I got tired and gave up for the day.

At the same time as NineX mentioned the devirginator, Mike Montour put together a short list of steps in a pastebin explaining how to do it manually and my plan was to try that next time. While I was away during the weekend, moving to Stockholm, he wrote an awesome wiki page on how to do that manual Unbricking. Thanks a lot for the clear and helpful wiki page Mr Montour!

I followed the steps on that page straight through, using a mix of openocd, dfu-util and cu, I now have a Neo1973 that boots correctly. Rebuilding my Bad Block Table showed that I had a bad block at 0x00004000, the default u-boot_env address. Maybe that, in combination with an early August version of u-boot was the reason I got this problem in the first place.

The Debug Board itself is not so easy to use at first, especially when you're not really familiar with embedded things like JTAG and serial consoles. Despite that it is still very nice to have one around when you experiment with your Neo1973. If I knew this low level stuff was so much fun I would have bought the Advanced Kit from the start.

2007-11-24

OpenMoko is growing

I just took a quick look at the statistics for the OpenMoko project and it made me happy.

Currently there is 3500 revisions in the svn repository and bugzilla has reached 1022 bugs, 241 of them are still open. The wiki has 3685 pages and 6090 registered users, and maybe more impressively, projects has 1507 developers and 81 projects registered.

The IRC channel on freenode has stayed at around 320 people for the last six months and there's a lot of interesting discussions going on. It's a friendly atmosphere and people interested in the project are encouraged to drop by. Usually, they get pointed to the right place in the wiki, where most questions have already been answered. A good page to read if you want to know what is going on in the project is the Community Updates page. Right now it has not been updated in over a week, but I'm sure it will be soon.

Unfortunately, a hardware bug in power management with GTA02v4 has required a fifth revision of the hardware for GTA02. It's a bit of a shame that the release will be delayed even further, but I'd rather have good hardware later, than something broken right now.

The most interesting code changes in OpenMoko recently involves gsmd, PhoneKit(pdf) and the dbus interface to it. The dialer and sms handling is also being worked at in a furious pace by the OpenedHand guys. Since about a week, calling has worked without any problems for me. Power management has been improved and the phone should last at least a day now.

Also, some guys from Ixonos have been working on an alternative to gsmd, gsmd2. I haven't looked at the code, but they have some very nice documentation and a detailed specification. Still, lots to be discussed it seems.

The GPS binary driver is still not available for download. OpenMoko have been promised by Global Locate that they will be able to distribute it, but the legal terms are not yet set. Hopefully this will be solved soon.

All in all, a lot is going on and the software will be in pretty good shape for when the GTA02 is released.

2007-11-21

Our future climate concerns me

A few days ago IPCC (United Nations Intergovernmental Panel on Climate Change) released a document they "succinctly" call Policymakers' Summary of the Synthesis Report of the United Nations Intergovernmental Panel on Climate Change (IPCC) Fourth Assessment. It's a complete summary of all the data on climate change, densely packed into 23 fact filled pages. (The full reports are much longer.)

The summary quickly showed up everywhere in the news, even at my favorite Ars. Reading through the document does make you think about the future of our climate. 11 of the last 12 years rank among the 12 warmest years ever measured since they started in 1850. For me personally, it has been some great warm and long summers and not a negative thing. For people living in northern Europe like I do, global warming will mostly make things better. The forests and crops will grow better, warmer summers, less freezing winters. The only downside for us will be an increase in precipitation. Most places will not be this lucky.

Although the temperature will increase the most at the poles, it's the places that are already dry and hot that will get the most serious problems. Serious droughts will follow, an increase in wild fires and agriculture and livestock will suffer. That might eventually lead to malnutrition and on top of that, clean drinking water will become a problem. The number of cyclones and storms is likely to increase too, and in low coastal regions and river deltas, increased risk of flooding.

Global increase in temperature for 2099 compared to 1999

The study also expects that in the long term, if the warming continues, the ice caps on Greenland will melt completely and raise the sea level with about 7 meters. This will take some thousand years or so, but it will be a noticeable increase just in the next 100 years.



Fossil fuel is the pink fields in these graphs

The primal cause for the emission of green house gases (GHG) is the use of fossil fuels. The concentration of carbon dioxide and methane in the atmosphere is exceeding by far the natural range seen in the last 650,000 years. We need to cut down on the green house gas emissions on a global scale right now, and even using the most optimistic scenarios still points to an increase in global temperature.

A global increase of 1.5-2.5 degrees Centigrade would endanger 20-30% of the species assessed of global extinction. Most scenarios in the summary suggests a much higher increase in temperature...

If all future investments in infrastructure and energy plants are shifted to get the lowest possible CO2 emissions, the additional investment costs would be around 5-10% higher. That's not much at all, and simply increasing efficiency of energy supply and industrial processes would do a lot to stabilize GHG emissions on a global scale. It's good to see that UK is helping China to get started on this.

Maybe we have no choice in lowering our oil consumption. A recent article in Wired states that most likely we will be unable to maintain the current consumption because we just can't pump the oil up fast enough. Some says 10 years more is all we have.

My personal opinion is that oil based fuels are way too cheap. If prices were at least doubled, maybe driving around in a petrol car won't be the cheapest way to travel medium distances any more. Electric or hydrogen fuel cell cars, although still very expensive, would become a more viable option. Flying is also cheaper than it should be, and even though it's nice to be able to afford to fly away for vacation, I wish there was a less polluting option for long trips. I really do.