Sunday, June 23, 2013

Fun with Yocto: Defining Tier 3 Requirements for my Embedded OS

I've been working on the CarHUD for quite some time now, essentially taking my own pace ensuring I get everything just the way I want it to be.  It's nice not having a deadline for a project.

A while back, I was testing out an initial version of HUD code with my old Chevy Malibu.  Needless to say, the car got hit in one of the snow storms we had out here in Iowa this past winter and I got a used Subaru Outback Wagon.  The code had an interesting effect in the Malibu, after three minutes of driving with the code grabbing OBD data from the car, the script (I'm using Python) would hang.  I never figured out what happened before I got the Subaru* so I went to test it one day since I had to run to Sears to get something.

Just imagine a slew of wires all over the car, I pulled the power cord for the Panasonic DVD player we got for our van to power my 3.5in monitor.  That had to get plugged into the rear of the vehicle since I needed the front port for the Raspberry Pi.  The ELM-327 dongle cord was routed over the steering column.

I was pretty excited, I got to Sears without the script crashing.  Ran into the store, got what I needed, and came back out.  Turned the car on to get everything setup again, plugged the monitor and the Raspberry Pi into their respective power sources and nothing.

The first thought was to the discussions on proper shutdown of the Raspberry Pi and how if you pull power, you can corrupt the SD Card.  I didn't want to believe those reports, but sure enough, I wasn't getting the Pi to boot.

After getting home, severely disappointed, I had two things to do:
  1. Check to see if I pulled the lasted running/working code to my Ubuntu 12.04 machine
  2. Re-flash the SD Card with the Raspbian image I had downloaded
Needless to say, I had developed the code on the Ubuntu machine, so it was there.  I couldn't determine if what I had was the latest, but it would work.

The SD Card was another story.  I spent a long time trying to re-partition and fix the card, but to no avail.  Nothing I did would allow me to flash Raspbian.


What was I left with?  A crappy 8GB SD Card that was unusable.  Did the power pull in the car finally kill it or did the card itself have an issue?  The world may never know, but I went an got a SanDisk and vowed to figure out how to make a read only root filesystem for my Pi.

Are we ever going to get to Yocto?  Yep, right now.

I first heard of Yocto following the UDOO computer on Kickstarter.  In the previous post, I mentioned my uncles 55 Chevy project.  I'm helping him develop a cruise control module that will interface with a MegaSquirt ECU and MegaSquirt GPIO (for transmission control).  These modules talk over CAN and the cruise control system would need to also in order to obtain current vehicle speed.  I mentioned my HUD project to him and how I was using a Raspberry Pi, and he stated he had an Arduino that he was messing with to deal with actual control of this cruise control system.  He also needed a way to display dashboard and had thought about using a Raspberry Pi.

I found the UDOO for him since it does both general computing and microcontrolling at once, and we could probably run Android and get a decent dashboard GUI setup for him.  As one of the UDOO's project updates, they decided to support Yocto since there was a ton of interest in the computer.

Ok, back to how this relates to the Pi.

I will say that Yocto is daunting since the documentation is a little confusing in places.  It's supposed to corral the Open Embedded system, so that must be more of a mess.

I'll eventually get into how I am actually using the Yocto build system, but for the time being, I'll show the Tier 3 requirements that are flowed down from the Tier 2 Requirement "The HUD Controller shall be programmed with an embedded version of Linux."

Tier 3 Embedded OS Requirements:

  1. The Hud Controller OS shall support a read-only root file system
  2. The Hud Controller OS shall be able to run existing Python code developed on an Ubuntu 12.04 machine
  3. The Hud Controller OS shall use pgame to display the information to the HUD
  4. The Hud Controller OS shall use the framebuffer to display the graphics
  5. The Hud Controller OS shall support the Raspberry Pi's GPIO, single pin, I2C, and UART.
You're thinking "Great, he went back to requirements."  Don't leave the blog yet, these requirements tell us what we need to put into our Yocto build.

These requirements place constraints on the OS and tell me that I have to put essentially all of Python (I use version 2.7, haven't bothered migrating to 3.x yet) on the system and I have to install pygame and it's associated requirements (some of these aren't part of Yocto).  I also have to install the Raspberry Pi specific GPIO libraries that are available.  It also means that I can't use X11, not that I would want the latency of it starting up anyway.

As it stands now, I'm essentially done with the OS configuring.  All I need to do now is get my all of my code into the system so it gets installed during the build and to enable the read-only root filesystem. I haven't turned it on yet since I've needed to copy stuff to the SD Card for testing.

Definitely more later, the series on Yocto is far from over.

* I did end up figuring out what was wrong, the OBD device had issues talking to the car as fast as I wanted it to.  I ended up blaming the OBD library I was using and wrote my own.  This is a topic for a later post.

No comments:

Post a Comment