How a Juicing diet works (+recipes)

My own background story with Juicing

This story begins before I left Israel, around October 2009. I was working comfortably in the hi-tech industry, eating regular meals every day with my colleagues. The sad truth is that I somehow let myself go, and eventually weighed around 105kg (that’s almost 210 pounds for those on the imperial system). For a person who used to being very slim and athletic, it was a horrible shock to look at a photo of myself one day, and realizing what I have done to myself without noticing.

Fast forward to the winter of 2010. I was living in Russia with two flat mates (It was cheaper to rent a room than to rent an apartment, plus I was lonely at the time and I figured I could use the company).

The two women in the apartment used a steamer to cook their foods. I remembered my mom using a steamer, way back in my childhood, but it was only used rarely, for some very specific types of food; definitely not as the main cooking apparatus.

Moscow is notoriously expensive, and since I was trying to save money, buying meat was reserved for special occasions. I basically bought a lot of Broccoli, Cabbage, Carrots, Onions, Beet, Corn, and a LOT of Buckwheat (As the Russians call it: “Grétchka”). And so, for a period of 3 months this is mostly what I ate. This, and the occasional whole wheat Subway sandwich with imitation crab meat and tons of vegetables. Needless to say, I did not drink sugary drinks, and instead drank water with lemon juice.

Old dog learns new tricks

About 1.5 years ago, my friend Golan Ben-Oni introduced me to Dr. Fuhrman, the book “Eat To Live” (which has since made it to the New York Times’ best selling book in the “self help” category), to the China Study, and to Dr. Novick, the funny and witty nutritionist with the warm, charming smile and the always-awesome presentations. He also told me about the movie “Fat, Sick & Nearly Dead” by Joe Cross (which has since become a sensation). That movie, along with the rich information provided by the nutritionists I mentioned, has really opened my eyes about nutrition.

In the space of a few months, I realized what I had been doing wrong my entire life, and why when I was eating only vegetables and raw grain back in Russia, I was losing weight fast, and feeling extremely healthy. In fact it almost got scary to see myself losing so much weight so quickly – I lost 20kg in 3 month.

And yet, it’s one thing to know what to do, and to actually do it. Just like many smokers know smoking kills and causes cancer, but never actually quit smoking. But what if they actually got cancer, suffered through treatment, died, and were suddenly given another chance to jump back in time to the moment they started smoking? How many of them would actually decide to never start smoking?

I feel that what happened to me by chance, has inadvertently shown me two things: 1) It is actually possible to go back to your BMI, and in just a few months. 2) The feeling of being healthy and looking great again, is totally worth the effort.

So can an old dog learn new tricks, and change his ways? Well, mostly. I don’t believe in going to the extreme – I think you sometimes need to have your comfort foods, so that you feel you aren’t completely giving up on your old lifestyle. A slice of Pizza every 2 ~ 3 months? That’s totally acceptable to me.

The basic idea behind juicing

The idea here is that our bodies no longer get the nutrition they need, because we eat a relatively very narrow diet. A study of bones found from before and after the agricultural revolution clearly shows that before the agricultural revolution, people were taller, healthier, and better fed, compared to people who lived after the agricultural revolution.

The simple explanation is that before the agricultural revolution, we were “hunters / gatherers” which meant that we relied on a large variety of foods (whatever we could find that day). After the agricultural revolution, we started eating only one or two types of grain, instead of 50. What this essentially means is that we significantly narrowed our spectrum of nutrients, vitamins and minerals. Suddenly our bodies were not getting all the minerals and vitamins they were used to getting.

The same problem exists with dietary supplements. Rates of cancer have actually gone up since dietary supplements were introduced. The simple truth is that you can’t replace a tomato, which has hundreds of types of vitamins and minerals, with a pill that contains just vitamins A, B and C. Our nutrition is more than just those 3 vitamins. We actually do need those hundreds of vitamins and minerals that a Fresh tomato has, and no pill can give us those nutrients, no matter how good it is.

So why juice? Why not just eat vegetables and fruits?

You could certainly just eat vegetables and fruits, but when you are trying to recover and heal your body, either from some trauma, chronic disease, malnutrition, diabetes, or major weight gain, and you are out of time (literally), you have to take drastic measures. Once you get to the point where you are healthy again, then you can move to “maintenance mode”, and you can start juicing just once a week, of course while eating a balanced diet consisting of vegetables, legumes, fruits, nuts and seeds, leafy greens, berries, etc.

How does juicing work? What’s special about juicing?

In order to heal, your body needs to rebuild its reserves of vitamins and minerals. The problem is that if you tried to obtain the amounts you actually need, you would have to consume 5 whole leafs of kale, 5 stalks of celery, 1 beet, 1 bunch of spinach, 5 large carrots, 2 apples, 2 tomatoes, 1 lemon, and repeat all this 3 times a day.

Thing is, you can’t possibly eat all of that in a day, simply because of the large volume of space this food would require in your stomach. To overcome this limitation, we juice those vegetables and fruits. Luckily, modern juicers separate the juice (containing all the good stuff) from the pulp (which is just empty cellulose). By getting rid of the cellulose, you get a juice that contains all the vitamins and minerals from all those vegetables and fruits that you can drink easily.

Recipes

The “Everything” Juice

  • One bunch of Kale (Around 8 ~ 10 leafs)
  • Two carrots
  • Two small beets or one large beet
  • Two celery stalks
  • One Green Apple
  • One Red Apple
  • Ginger (5 slices)

Just Green

  • One bunch of Kale (Around 8 ~ 10 leafs)
  • One bunch Spinach
  • Two celery stalks
  • Two Green Apples

And here are some external links:

 

Why #OpIsrael is good for Israel

First, let me say a few words about what Anonymous actually is: An idea. A man is fragile, so are a group of people, but an idea, that can’t be killed.

But it can be hijacked by anyone. Anyone can claim they are Anonymous. I can say I am Anonymous and you won’t be able to prove it one way or another. The problem is that the group has this reputation of avenging the weak and oppressed, of exacting justice where justice is lacking.

I am not going to go into the actual issue of whether or not an injustice is being committed against Palestinians or Israelis. I believe both have suffered more than enough, and are hostages of political movements with radical ideas.

Here is what I believe #OpIsrael will actually achieve (and has already achieved, even before it happened):

  1. Increase world awareness to the Israeli / Palestinian problem. Except the world is already very much aware of this problem (and sick of it, quite frankly), so this is kinda pointless and will achieve nothing.
  2. Improve security systems in Israel – I know that IT engineers in Israel have been preparing for a few weeks now, backing up data, securing servers, reconfiguring networking equipment, purchasing new equipment, etc.
  3. With the Israeli mind hard at work on creating security solutions for the silly hacking attempts by “Anonymous” operatives, new security products will come out of the Israeli hi-tech sector, with existing products significantly improved to deal with such situations in the future.
  4. It will increase security awareness at ISP’s and other large companies in Israel, and convince executives to increase budget for security equipment and personnel. The situation, and the media coverage, will surely give them a great excuse to do just that.
  5. It will teach network operators in Israel and Europe to deal with such attacks, and nudge them to better organize and coordinate their efforts.
  6. Show to the world that “Anonymous” is just a group of anonymous people – they could be terrorists fighting for an evil cause, or they can be good guys fighting for a good cause. The point is that you don’t know, which is the essence of the Anon movement. But one thing is for sure: If Anonymous was a “good” group in the past in the eyes of public opinion, it will now show its “sinister” face due to its association with a terrorist organization, and will eventually harm peace activists everywhere because the tracking tools will improve, and punishment for participating in such an attack will become more severe.

And this is why I see the whole thing in a pretty positive light for Israel. Whatever short term damage might be caused by a bunch of script kiddies, will yield amazing long term benefits for the state of Israel and for the world.

 

On Desktop Wars, and why we are all losing

One of the reasons Macromedia Flash is so problematic and on its way “out” is that it was always a plugin. It does not have direct access to the browser’s DOM, nor do scripts on the page have access to the internal DOM within the Flash object. They are two separate entities, running in two separate threads. Flash, being somewhat “dangerous” because of the kind of functions it can potentially expose, is executed in a “sandbox” which is supposed to keep it from doing any damage to the system. If Flash was properly designed, it would simply be an “engine” that offered accelerated rendering, advanced animation functionality, and new DOM object types, and it would have exposed those functions and types to the DOM. Developers could then script using those advanced functions using JavaScript instead of ActionScript, and they would be able to utilize the new Object types. In addition, since all Flash objects are actually within the browser’s DOM, the Flash functions could potentially work on ANY HTML Element, be they tables, div’s, span’s, etc. Imagine the possibilities, the richness of the documents we would get. The “Web” would be so much nicer and more advanced. We could have had Web 3.0 back in 2001. And I argue that the VIDEO element, out of lack of necessity  would probably not have been invented if Flash had just done this one simple thing, of exposing their functionality as functions and object types within a browser’s DOM, instead of keeping them separate in their own proprietary container that nobody can touch.

I see this as parallel to the way current Window Managers function alongside X11. Instead of introducing specific behavior into the core window managers, I would instead just expose raw functionality. In other words, Animation functionality, Effects, Shaders, Object Types, etc. And I would then allow scripting it all via Scripting Engines that would plug into the DOM. You could have packages that define the UI/UX language, that are written in either JavaScript or ChaiScript or really any scripting engine. As long as they have access to the “DOM” (In this case being Desktop Object Model), they can manipulate the objects on the desktop, and use the functions exposed into the DOM by the various plugins and by the WM itself. One could easily produce a Metro UI clone, using a bunch of scripts that manipulate the DOM. Or really any other UI, BeOS, Amiga, anything really. It could be 3D, or 2D, or even 4D! It could even be networked into some additional nodes on the cloud where some of your desktop element could live on. Once you have a DOM which can be serialized into JSON objects, the potential is infinite. Imagine how simple it is then, to share an application across networks? Yours looks the way you like, with your graphics and eye candy, but the substance, the “juice” of what you’re viewing, is transferred to someone else’s desktop, and there, his own UI Scripts apply their own animations and eye candy to the same application/content, and they see it the way they like.

I believe this is where Desktops will eventually go. There will be a DOM (Desktop Object Model), there will be “plugins” that introduce eye candy features, shaders, effects, maybe physical modeling effects, plugins that fetch data from the net and inject them into the DOM, etc. And there will be the underlying engine which just lets those plugins access the hardware via some HAL. This is the kind of desktop I would love to have in the future. A desktop where everything can be scripted. Where I can decide myself how windows are maximized, and where I can decide that if some window is maximized, I want to trigger certain specific actions, like lower the priority of all other applications, if the window I just maximized is a Media Player and I want to watch a movie without other apps bothering me or using the CPU too much (Just one example, I’m sure people will come up with amazing things once they have a DOM and plugins that allow scripting the DOM).

 

Goodbye Apple?

I don’t like the way things are going with Mac OS X. My fears that something was slowly getting worse, were validated yesterday while visiting the Apple Store’s Genius Bar. While my laptop was being checked for issues, I told the Genius who was taking care of me that I have not rebooted the laptop in 27 days. He said that not rebooting might cause instability. He recommended I reboot my laptop at least once a week. When I looked at him incredulously, he called another Genius who was standing in the next stall, and that other Genius confirmed it.

Really? An Unix OS with a BSD Core going unstable if not rebooted every week?

The truth is that I look at the system logs, and I don’t like what I’m seeing. There are things going on under the hood that are quite worrying and annoying. There are too many errors and warnings in the logs. For a company that prides itself on producing cleanly designed products, I would expect the same philosophy would be applied under the hood. Unfortunately, this is not the case.

The “rumor” in chat rooms is that in truth, Apple hates us Geeks. That the ideal Apple customer is the typical mindless Zombie user, who buys products because of their aesthetics and because they “just work”. The user who wants simplicity, and who won’t sniff around log files. It feels almost like Apple has become more of an “iOS” company, and is becoming less and less of a “Mac OS X” company.

This caused me to start researching into alternative hardware – a thin & light 15″ laptop that will run Ubuntu Desktop for me, have a quad core i7 processor under the hood, with at least 8Gb RAM, and a very fast GPU with dedicated 1Gb RAM. It is this search that made me realize that Apple’s competition is shooting itself in the foot, and is literally driving consumers away into Apple’s open arms.

However: The non-Apple scene is a mess!

How come? Well, When was the last time you tried to shop for a “PC” Laptop recently? Have you seen how many processor options are available even within a single family of processors? How many Intel i5 and i7 variants are out there? How many GPU Types and Variants are out there? How many types of disk drive standards? Sizes? Speeds? Protocols? Cache sizes? TRIM Support anyone?

The truth is that the moment you step outside of Apple’s realm, you find yourself in a jungle. The “Experts” all have their opinions on what the best laptop/desktop is. Who do you trust? Who do you believe? And for how long will their opinions hold true? Probably not too long…

This reminded me of that research about consumer happiness as a function of choice. It turns out that when consumers have too many options to choose from, they will first be overwhelmed with the selection, and later, they will be unhappy with their selection,  thinking there might have been a better product they could have chosen. But give them just 2 ~ 4 products to choose from, and they will be absolutely happy, believing they selected the best product. Knowing this, let’s look at Apple’s product offerings: You basically get to choose whether you want a light laptop with less features, or heavy laptop with more “pro” features, then the screen size and resolution, and then the amount of RAM and Disk Space, and you’re done!

If only it was so simple with non-Apple hardware, I am pretty certain less people would switch to Apple products.

One thing is for sure: Apple is beginning to disappoint me, and I am now on the look out for a great, thin, sturdy laptop with great specs. It will run Linux for me, and will NOT require a weekly reboot just to keep things “stable”.

 

Linux Cheat Sheet

Every once in a while you encounter this edge scenario that requires some specialized knowledge. And let’s face it, it’s always nice to find a quick cheat sheet with “recipes” for common (and sometimes less common) problems, than having to RTFM for hours, trying to find the solution.

So I decided to list the common problems I’ve encountered, and the solutions I found for those problems that have actually worked.

 

Deleting a massive number of files

Sometimes a directory full of old session files (maybe left behind by some php script) can be a real pain, especially when you’re trying to rsync or backup that site. Sometimes there are so many files in that directory, that an rm -rf * will return an error about the argument list being too long. The problem here is the usage of the asterisk (globing), which produces a huge list of files. To understand the effect of * just type this in a directory with some files: echo *

The following command will help you:

find /session/directory/ -type f -delete

Or if you want to erase only sessions that are older than 5 days:

find /session/directory/ -type f -mtime +5 -delete

Note 1: if you add -name sess_* you will stumble into the same globing pitfall mentioned above, so make sure to enclose it with quotes: ‘sess_*’.

Note 2: If you are doing this on a production server, then do this instead with a bash for loop:

 for i in *; do 
 rm -f $i; 
 done

This will take longer, but will keep the server i/o load extremely low and won’t affect your production systems.

 

Converting from ext2 to ext3 and back

Nobody will judge you for choosing to use the ext2 filesystem, a real expert uses the tools for the job. In this case, the expert would make a calculated decision to trade safety for performance. Not having to write a journal could boost performance, but not having a journal could pose a problem during data recovery. However data recovery might not always be a concern.

This conversion process will not result in any data loss, and should be fairly quick even on large drives.

The process for ext2 -> ext3:

  1. Unmount the ext2 partition
  2. tune2fs -j /dev/sdb1
  3. Edit /etc/fstab and change ext2 to ext3 for /dev/sdb1
  4. Remount your ext3 partition

 

Hard Reboot on a semi-dead machine

Yesterday I found myself still logged into a machine that was stuck in a semi dead state, due to data corruption on one of the drives. It was impossible to reboot the machine using the conventional methods, and I had no IPMI or KVM for this old server, which meant I had to rely on a technician to physically press the reset button. But it turns out there is another way, and if you find yourself in a similar situation with root access to a barely functioning machine, you might want to consider the REISUB process, which uses the SysReq kernel feature as described in this wonderful Wikipedia article about the Magic SysRq key.

The short version is this:

echo 1 > /proc/sys/kernel/sysrq  # Enable the SysRq feature (just in case it's disabled)
echo s > /proc/sysrq-trigger     # Sync: Write all buffers to disks
echo b > /proc/sysrq-trigger     # Reboot the machine

 

MySQL Dump with Broken Views

So you decided to dump a database, either as backup, or to transfer it to another machine. But you get one of the below errors:

mysqldump: Couldn't execute 'SHOW FIELDS FROM `funny_table`': View 'silly_db.funny_table' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

mysqldump: Got error: 1449: The user specified as a definer ('silly_db'@'localhost') does not exist when using LOCK TABLES

Fear not, you can dump it with this command:

mysqldump --force -uBob -pSecret --single-transaction silly_db > silly_db.sql

You will still get some warnings or errors but you can probably safely ignore them. What’s happening here is that something or someone left behind some Views that refer to tables that no longer exist, or to tables that exist but with fields that no longer exist. Some wordpress plugins have bad hygiene habits, and do not properly clean up behind them (hey, just like some people!).

Reading BIOS Events

Sometimes there’s a problem with your server harware. But if your machine lacks IPMI or DRAC, how do you know what’s wrong with the hardware?

Luckily, the BIOS will in some cases log some of the hardware faults in its BIOS Event Log. But how do you get to it from the comfort of your couch? dmidecode to the rescut.

In debian / ubuntu, just apt-get install dmidecode and then run:

dmidecode -t 15

This will show you the last few errors in your event log. Maybe an ECC Memory error, which might indicate your memory modules are faulty (as happened to me).

 

WPML: WordPress Plugin gone wrong

A few years ago I decided it’s time to offer one of my WordPress sites in more than one language. After researching a bit, I found the best product was WPML. I found references to it in the WordPress Plugin Directory, googled it, found and visited the website, and decided it was worth the $79. So I purchased it and started the long and painful job of translating my website.

My website was quite technical, and I found it difficult to believe the iCanLocalize translators would do it justice, especially considering the target language was Hebrew, which is a language with many horrible pitfalls when translating technical terms.

A good example of this is Microsoft Windows 95, which was very poorly translated to Hebrew. So poorly that it was the subject of many jokes when one of the first Hebrew translations appeared back in 1995. Screenshots with funny translations were circulated over Email.

So needless to say, I did not trust their translators and decided to translate it myself. I was of course very happy with the results, because the pages ended up not being a literal translation, while still carrying the same message. In fact I felt the translated pages were better worded than the original English counterpart, if only because I had to think about the meaning and how to say it better in Hebrew, and was quite successful with that.

But I digress. Fast forward two years later, and I find myself in a Mafia situation. The plugin has upgrades, but I can not upgrade my WPML plugin. Apparently I need to pay iCanLocalize some more money before I can upgrade the plugin. I decided to wait with the upgrade, and instead to follow their release notes and wait for a compelling feature that will force me to upgrade. Unfortunately, two bad things happened:

1. The bad: No compelling reason materialized for upgrading. It was all either security fixes, or minor improvements for compatibility with other plugins.

2. The worse: Security fixes were introduced, but I was not allowed to receive those fixes!

This pissed me off. Enough so that I decided to write about it and explain all that is wrong with their practice, and hopefully warn other WordPress site owners about this.

You see, If I can not upgrade the product, at the very least I do not want to be reminded about it. Every time a new version is released, my WordPress Updates Manager alerts me. And because I decided on principle not to pay the “Mafia” for upgrades, It angers me even more to see those warnings all the time. Why do I call them a “Mafia”? Because that’s just how the Mafia works: They throw a brick on your store, smashing your window front. A bit later, while you are still cleaning up the mess, the goons show up and offer you “protection” in exchange for a monthly “retainer” ($$$).

I believe that if you make a plugin, and decide that new features should cost more, that’s fair. Sure. After all, developers need to make a living. However, I also believe you have a responsibility to your previous customers. This is why Auto Manufacturers are forced to keep a stock of replacement parts for their cars for 7 years after the model is introduced into the market.

A bug YOU introduced, is YOUR responsibility, and you need to fix it for me or else the product I purchased is defective by definition. Security updates should also be part of the deal, and should be back-ported into my old version. I should not have to pay you just because you introduced a security flaw into your own product, and won’t fix that security flaw for your old users. That’s just totally irresponsible.

I eventually decided to remove Hebrew from my site and uninstall the plugin, effectively throwing away the original $79. It is the first time I throw away a piece of software I purchased for ethical reasons.

Lessons learned about the A13 OLinuXino with A13-LCD7-TS

I have recently purchased two of those very sweet Olinuxino A13 boards for a new project I’m working on. I bought them directly from Olimex in Bulgaria, only to later discover that I could have ordered them from another website in the US. The prices are a bit higher, but shipping is lower so for small quantities it might work better.

I also bought two LCD Touch screens, two MOD-RS232, and some other boards that I plan to experiment with further down the road (for example to control higher voltage relays).

What this guide contains

In this guide I will show you:

  1. What hardware to purchase for your development kit
  2. How to build your own custom Linux Kernel
  3. How to build a bootable SD Card with Debian Wheezy
  4. How to get X11 working on the A13-LCD7-TS with Debian
  5. How to get the Touch Screen to work with X11
  6. How to start a locked-down, full screen web browser

By the end of this guide, you will hopefully learn how all the components work together, and as an added benefit you will also get a fully working development system that allows you to comfortably start working on your product, based on a very solid platform, with stable, reliable, and reproducible results. I believe learning is more important than doing, and this is why I’m making this guide as detailed as possible.

Another important aspect is the comments to this post, which come from pretty smart people who tried all this out, and had really important feedback. Without this feedback, this guide would certainly be lacking. I would like to thank all of you for taking the time to give feedback so that others may have a better configuration with their systems.

My initial impression

I was initially trying to purchase a Raspberry Pi, but supplies being non-existent I was forced to look for alternatives, and I’m very glad I did because the end result is that I have a more powerful platform to work with. It’s faster, has 3 USB ports with tons of gpio pins, has an on-board nand chip, wifi adapter, sd card reader, audio in/out, and the pretty useful UEXT connector. It runs very cool, and since there are no moving parts or fans it is naturally silent.

In addition to this specific product being quite amazing, feature wise, Olimex has a very talented team of engineers who crank out new boards and designs at a pace rarely seen. They are already working on an A10 board, which packs even more impressive hardware and features. Once in a while they even find the time to write a new guide or how-to, and post it on their blog.

Apart from the Olimex engineers who are obviously dedicated to their cause, there’s a good number of individuals working on the “ARM Netbook” project. The Olimex and ARM engineers, as well as the community of users, all hang out on the Freenode IRC Network, on channels #olimex and #arm-netbook (If you have an IRC client you can click those links to directly join the rooms). I strongly urge you to join those chat rooms if you have questions, or if you feel you can help others with your skills and knowledge.

And if this is not enough to convince you, consider this: All Olimex products are 100% open source hardware, which includes the CAD files for the boards, routing, etc. You can truly do whatever you want with the designs, and all the designs are fully available and downloadable from their github account. This is not the case with the Raspberry Pi where some parts are closed with strange excuses given by project members.

Important adjustment of expectations

I think that for a short while I was under the illusion that things will just work great out of the box. I was quickly disillusioned however, because the problems piled up and some of them proved quite a challenge initially. Thankfully, the Olimex hardware has quite a following; a mix of hardware enthusiasts as well as commercial entities purchasing the boards to include in their embedded linux projects. They all socialize and help each other on the Olimex forums.

On the other hand, the issues I encountered are all software related, and platform specific. This means that with some reasonable effort and enough reading, they can all be solved. I solved my issues within a week, and I am now very pleased with the results. I am by no means done – As of this moment, I still have a segmentation fault with the touchscreen driver, but I’m sure I will have this issue resolved within the next 24 hours.

So what I learned is something I should have known right from the start: This is not a mass market product. It is a very new product (May 2012!), and this means whoever utilizes this platform is pretty much on the bleeding edge of open source hardware technologies, and this is not without implications. On the other hand, this is what makes it fun. Reading data sheets, really understanding how the board functions, what components are on the board and why they were chosen, what each pin does in the various on-board connectors, and so on and so forth. This is a platform that forces you to take off your shirt and dive into unknown waters, but you get to swim with some pretty cool fish!

Simple challenges during my first order

No Power Supply: While ordering the boards, I needed to purchase power supplies separately. Olimex does not sell power supplies for America. A quick search on Amazon based on the power rating, polarity, and dimensions of the connector, and I found a pretty good power supply on Amazon. It arrived within a few days and I was able to power the boards.

No LCD Cable: This is when I realized the LCD comes without the cable that connects it to the board. Fortunately Olimex support (Tsvetan) replied that the cables are the same as IDE cables. Again Amazon to the rescue, and within 2 days I had two cables and the LCD was hooked up to the board. At this point I was able to boot the system, which comes preloaded with Android.

Wrong Screen Resolution: When Android booted I noticed the entire screen is offset some 20% to the right and some 10% to the bottom. The touch screen however was properly calibrated, so I had to touch the icons in the area where I thought they should be. This is pretty easy to resolve, as I found out later, but not from Linux or Mac. You need to install a program called LiveSuit on Windows. A port of LiveSuite for Linux exists, but it does not recognize the Android IMG file. I tell this to you now, but it took many days of trying and failing and talking to people online until I received a final confirmation that it only works on Windows, because of people at Allwinner, the company that produced the SOC (Systen On Chip).

Bad USB to Serial Strategy: I had a PL2303 at home, so I didn’t buy the USB to Serial cable sold by Olimex. This was a mistake because the one I had did not work very well. I should have just purchased it but I didn’t think I would need it. It ended up being very important, because it helps you login to the console and configure the OS to connect to the network, for example, or to see the output from u-boot while the system is booting. It’s just a good idea to have console access.

Which brings me to the next section for any person considering buying Olimex products, or any products in general since this does not apply only to Olimex but to any hardware project.

What to buy as a starter kit

I feel I have learned quite a lot about the platform because of all the mistakes I made and all the obstacles I encountered, so I am thankful that I made those mistakes. However if you are in a hurry to create a commercial product based on this platform, you will avoid all the mistakes I made by simply buying the correct products for your kit.

This is my recommended list of materials for any person trying to develop on this platform for the first time:

  • From the Olinuxino A13 category:
    • One of the Olinuxino Boards (based on whether you need 1 or 3 usb ports, wifi or no wifi, 512mb RAM or 256mb RAM on the Micro version, etc). I purchased the most expensive one A13-OLinuXino-WIFI
    • One of the LCD products, without the touchscreen A13-LCD7 or with a touchscreen A13-LCD7-TS (that’s the one I have). I like having the LCD because it’s cheap enough and will not take away one of your monitors while you work with your kit. The size is perfect for development purposes and the resolution is high enough (800×480) which makes the fonts quite sharp and readable.
    • One of the SD cards (A13-OLinuXino-MICRO-SD or A13-OLinuXino-SD), it comes preloaded with Debian Linux (Wheezy), and will save you a lot of time and efforts (and most of the mistakes I made).
  • If you are getting an LCD, get this cable: CABLE-IDC40-15cm
  • Get the following cables for sure:
  • If you live in Europe or a country with European power sockets and voltage, definitely get this power supply: SY0612E
  • If you plan on using an off the shelf USB to Serial cable with a DB9 connector, definitely get this UEXT adapter: MOD-RS232

Lessons about building and booting a Debian SD Card

The main lesson here is that if you want to be up and running as soon as possible, that you should not even focus on trying to build the Debian image yourself. Olimex sell you the SD Card with the Debian image already pre-built for you.

On the other hand, I do feel it is a great learning experience. And more importantly, I believe that if you are serious about the product you are building, you have to learn how the parts all fit together. Building your own Debian image is a great way to learn about that.

Remember how I said in the beginning that this is all very fresh technology? Some of the options I’m going to show you here, were only just committed into the Github repository of the sunxi-bsp project by techn_ from IRC.

Before we start – Installing Prerequisites

It’s important to have a correct system time, or you will get warnings about some dates being in the future. While we’re at it, let’s also install git, the compilers and other utilities required to build our packages:

# Install compilers and related utilities
apt-get install build-essential git automake autoconf libtool ntpdate pkg-config

# Let's make sure our system time is correct
ntpdate pool.ntp.org

If you connect to your A13 over SSH (Like I do, which is way more convenient than working on the A13 directly), then it is quite possible the network will disconnect after you update the system time. I’m not exactly sure why this happens (I have some theories), but if you find yourself disconnected from your A13 after you update the system time, don’t panic, and don’t reboot your A13. Just connect to the console as root and type:

/etc/init.d/networking restart
/etc/init.d/ssh restart

That’s it, your A13 will now be available again via SSH.

Quick start guide – Building the Kernel

Fortunately for us, this task has been made infinitely simpler by the good guys on #arm-netbook via the sunxi-bsp project, which is an umbrella project, as well as a set of scripts, designed to bring everything you need in order to build the kernel, u-boot, and the script.bin file, as well as tools that help you hack around with the AllWinner hardware.

# Let's fetch the sunxi-bsp project into /usr/src:
cd /usr/src/
git clone git://github.com/linux-sunxi/sunxi-bsp.git

# Now we configure it for the A13 Olinuxino:
cd sunxi-bsp
make
./configure a13_olinuxino

# This time, make will build everything!
make

Once this is done, you’ll have the kernel, as well as the modules and u-boot under the /build/ directory. You now have the latest supported kernel (At the moment 3.0.52).

Important step: Enabling sun4i-gpio

If you own the A13-LCD7-TS hardware, you will notice it doesn’t power on under Debian. It took me a while to figure out the reason behind this. Turns out the backlight is powered by pin 15 of the GPIO port to which the LCD is hooked up. Android has a PWM (Pulse Width Modulation) component that pulses this pin in various frequencies, to give you different levels of brightness.

Since Debian does not have a PWM module, all we can do is power the pin, and the display will always be stuck on maximum brightness. That’s fine by me anyway.

To set that pin to the On mode, we need two things:

  1. Enable GPIO in script.bin, set pin 15 to be On by default, and update that file in your boot partition (same place where uImage is).
  2. When Debian loads, we need to load the sun4i-gpio module, so that the settings will actually be in effect. But first we’ll need to build it with the kernel, since it’s not enabled by default.

Let’s enable the GPIO Kernel modules:

cd /usr/src/sunxi-bsp/
make linux-config

This will get you into the standard “menuconfig” option, except it will edit the correct .config for your setup (in our case: a13_defconfig). Navigate to Device Drivers —> Misc Devices and enable the following features as Module <M>:

<M> An ugly sun4i gpio driver
<M> Sunxi platform register debug driver

Exit back and save the settings, then run make again:

make

This time, make sure you see sun4i-gpio.ko in the list of generated modules. If you see it there, you have enabled the correct modules.

A word of caution about the Paranoid Android…

During my trial and errors with trying to activate the LCD, I experimented with a pre-built kernel that I extracted from the built-in Android OS that came with the A13. The theory was that it might have a PWM module to power the LCD.

It booted the OS just fine, but I discovered that non-root users did not have permission to create Network File Descriptors. Through some more research on google, I discovered this is a Kernel config flag called CONFIG_ANDROID_PARANOID_NETWORK. If enabled, the kernel will require users to be on a group with gid 3003 to be allowed network access, and that’s just one of the restrictions. This broke the xf86-input-tslib module with a segmentation fault.

So my warning to you is: Do not enable CONFIG_ANDROID_PARANOID_NETWORK unless you are prepared to deal with the implications (making code modifications in several modules, and configuring the system very carefully).

Preparing the bootable Debian SD Card

Coming soon. In the mean time, consult this guide on the A13 Olinuxino Wiki Page

In fact, that page contains ready made images, along with various tools that will help you tweak the script.bin file to your hardware configuration (VGA vs. LCD for example).

Building tslib and xf86-input-tslib

In order to support the A13-LCD7-TS we have to use a patched tslib and xf86-input-tslib. The way I understand the patches, they are designed to work around the multi-touch limitation in the hardware.

1. First download the 3 patch files from this github directory and place them in /usr/src/

2. Perform the steps below to patch, compile and install tslib in your system:

cd /usr/src
git clone https://github.com/kergoth/tslib
cd tslib
patch -p1 < ../tslib.patch
autoreconf -vi
./configure --prefix=/usr/local
make
make install
ldconfig

At this stage, tslib will be installed on your system, and by running ldconfig we make sure that the libraries can be accessible immediately. Note that if you installed the libraries into a non-standard location, you should make sure to add that path to /etc/ld.so.conf and then run ldconfig again. To find out the touchscreen device number run “dmesg | grep sun4i-ts“. Sample output below:

root@debian:/usr/src/tslib# dmesg | grep sun4i-ts
[ 15.540000] sun4i-ts.c: sun4i_ts_init: start ...
[ 15.560000] sun4i-ts: tp_screen_size is 5 inch.
[ 15.560000] sun4i-ts: tp_regidity_level is 5.
[ 15.570000] sun4i-ts: tp_press_threshold_enable is 0.
[ 15.580000] sun4i-ts: rtp_sensitive_level is 15.
[ 15.590000] sun4i-ts: rtp_exchange_x_y_flag is 0.
[ 15.600000] sun4i-ts.c: sun4i_ts_probe: start...
[ 15.620000] input: sun4i-ts as /devices/platform/sun4i-ts/input/input1
[ 15.640000] sun4i-ts.c: sun4i_ts_probe: end

As we can see in the output above (on my system), the device number is input 1.

To run ts_test and ts_calibrate, as well as run X11 with tslib support, we need to export the following environment variables:

export TSLIB_TSEVENTTYPE=raw
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts

Note that in the TSLIB_TSDEVICE environment variable, the “event1” part corresponds to the “input1” device that we saw earlier. If your device is on “input4” then you should replace “event1” with “event4“.

I have placed this block of exports in /etc/environment so they are all set on system boot. I also erased /etc/pointercal and reran ts_calibrate to re-generate that file. ts_calibrate will guide you through the calibration process, and when done it will write the new values into /etc/pointercal. You can then run ts_test to make sure you are happy with the calibration. ts_test will allow you to draw on the screen, or drag a small block around, which is great because it gives you a good feel for the accuracy and responsiveness of the touch screen.

By the way, one small “visual bug” I noticed is that ts_calibrate and ts_test do not clear the screen when they exit, but don’t worry about that.

3. Perform the steps below to patch and compile the xf86-xorg-tslib module:

# Let's get some X11 dependencies first
apt-get install xorg-dev xserver-xorg-dev x11proto-core-dev

# Now we fetch the module's source code and unpack it:
cd /usr/src
wget http://ftp.de.debian.org/debian/pool/main/x/xf86-input-tslib/xf86-input-tslib_0.0.6.orig.tar.gz
tar zxfv xf86-input-tslib_0.0.6.orig.tar.gz
cd xf86-input-tslib-0.0.6/

# Apply the patches
patch -p1 < ../1-xf86tslib-sigfault.patch
patch -p1 < ../xf86-input-tslib-port-ABI-12-r48.patch

# Finally, let's get this thing built and installed
./configure –prefix=/usr
make
make install

Now that we have the module compiled and installed, we need to tell X11 about the new device. We’ll do this by creating a new file under /usr/share/X11/xorg.conf.d/. I chose to call this file: 20-touchscreen.conf.

Here’s what my file looks like:

Section "InputClass"
        Identifier "Sun4iTouchscreen"
        Option "Device" "/dev/input/event1"
        Driver "tslib"
	Option "ScreenNumber" "0"
	Option "Rotate" "NONE"
	Option "Width" "800"
	Option "Height" "480"
	Option "SendCoreEvents" "yes"
	Option "Type" "touchscreen"
EndSection

At this point you are ready to start X. Let’s start it with in Verbose mode so you can see the logging on screen:

X -verbose

If you did everything right, you should see a mouse cursor on the screen, and you should be able to properly click on screen items and even drag scroll bars to scroll around. Congratulations!