h1

Here’s how you can’t do it too!

August 7, 2014

I just cross compiled an application for Raspberry Pi: camcv combines the Pi’s camera program raspivid with OpenCV.

It took hours and hours. Not just to build the cross compilers (though that did hours) and figure out cmake and figure out what code I needed, it took hours of tweaking and fiddling to make it work.

I suppose now I’m supposed to write up how I accomplished it, so you can reproduce it, glossing over the tricky bits and making it sound like a walk in the park.

First, I must give credit to

Well, and to be fair, I’m still at Step 3 of OpenCV and Pi Camera’s instructions (of 7 (and a half)). I finally got the program to compile but I have a new Raspberry Pi board and haven’t even powered it on. Oh heck, if I’m reading step 4 correctly, I haven’t actually managed to pull in OpenCV.

I had this neat plan for what to do with the Pi, a camera (two maybe!), and a small display. But I’ve been so battered by compiling something that already existed and isn’t even really what I meant to compile anyway.

I find that many Linux projects have this exponentially expanding scope. My initial initial plan was to play with the camera in python using the actually pretty simple SimpleCV computer vision tools. But it was horrifically slow (a known issue to people who have tried the python and camera but a new issue to a newbie like me).

Worse, I don’t know cross-compiling has been truly worth it. Is multiple hours of setup worth many times two minutes of recompile time? Also, the RPi Compute doesn’t have an Ethernet port so it isn’t as easy to set up a tftp that would all my device access to the cross compiled executables without even a scp copy.

So I’m not going to give you the “here’s how I did it”… I’m not even sure how to post my trees. And I went through so many strange turns, I’m not sure my results will be useful (“and then at step 1123, spin in your chair, clockwise three times, the next cmake .; make instruction will then work”).

 

h1

Wandering Silicon Valley looking for techy fun

August 2, 2014

A podcast listener, Brian, asked an interesting question- he’s been traveling to San Jose and San Francisco for work, he enjoyed stopping by HSC/Halted. If you’ve never been there, it is very amusing. It is a warehouse where electronics go after they’ve been bought, resold, taken apart, and then resold again. It is a fun to visit, looking at power supplies from the 60s, radio cabinets from the 40s, and disk drives from the 80s. He planned to visit Weird Stuff in Sunnyvale, a similar sort of store. He asked if there were other places I could recommend checking out. My response:

***

Have you been to Hacker Dojo in Mountain View? People go there to hang out, get together at meetups, and sometimes to work. You can walk in for free and walk around asking people what they are working on. People apparently don’t mind. (I’ve only worked there once and we had a pretty strong don’t-bug-us vibe.) Being a member lets you schedule rooms and get a key to use the site in off hours. You don’t have to be a member to grab a table and have folks come by to talk to you.

There are a few hacker spaces, many of them are very friendly. I’d search for you goal zip code and “hacker space”.

There is also the Tech Shop. There is one in downtown SJ (also SF and a couple others). Tours are free, classes can get expensive. You don’t have to be a member to take classes and while you are there for the class, they usually let you roam. (You can just go in to use tools you are rated on for ~$10 or the monthly/annual fee.)  The Tech Museum is more for kids but can be amusing (and is downtown SJ so you can do that and the Tech Shop in one day).

More in the HSC/Weird stuff range, have you been to Saturday De Anza Electronics swap meet? Imagine you got to wander every electronics hoarder’s garage. Some say the people are very nice (it is one of those “if you are social, they are social” things that I tend to fail at).

It seems like there is a conference every week at Santa Clara, San Jose, and SF’s Moscone convention centers. (Seriously? The World Flash Memory Summit? Why?) These sometimes cost money but you may be surprised how quickly they’ll give you a pass if you say “I have a blog” or “I want to see what it is about so I can let my boss know”.

Is this what you were looking for? There is also meetup.com which has a ton of meetups: robots, auto hacking, ham radio, etc.

Oh, right, don’t forget to hit HRO when you are near HSC.

I’ve also found wandering the Google campus on the weekends to be nice, they have a strange set of buildings (and I like architecture). The Computer History is in Mountain View too. Make sure you see the Babbage Engine go, it makes calculation stunningly beautiful.

I don’t know as much in SF, I usually go that way for culture more than tech. But there is a ton of tech there (and meetup.com will help with finding that).

***

From his happy response, I went into more detail than expected. And, of course, he’ll be in town for the Flash Memory Summit.

 

h1

Elementary school programming

July 30, 2014

An embedded.fm listener (Mike) is working on starting a program for a local elementary school that introduces Engineering with a main focus on programming and electronics. He wanted to know if I had any suggestions.

For programming for almost any age, Scratch is awesome. It can be web based or on a Raspberry Pi. It is very well design to introduce programming concepts (and it is fun to make little movies of avatars). I’ve used it for 2nd graders (and 11th graders).

For 3rd-6th grade, Minecraft is a good way to get some kids interested in programming, they end up wanting to run their own servers and create worlds. (Though it tends to be a bit boy-centric. My godsons have adored it since they were in 2nd and 4th grade (now they are 5th and 7th)).

For electronics, the LightUp system is pretty intuitive and very neat to play with. They have kindergarten stories. The kits are a bit expensive and they are only from MakerShed (big kits aren’t available yet).

In the meantime, I have a friend who picks up Snap Circuits at garages sales. His 5 year old is building amazing things (making mods on the existing plans already!). I haven’t played with those but am amused by the pics I’ve seen.

So what would you suggest?

h1

Email: NaNoWriMo

July 27, 2014

Friday at lunch, I mentioned NaNoWriMo (national novel writing month). It isn’t until November but I admit I sketched out my outline starting in August.

http://nanowrimo.org/

They do the “contest” as a fundraiser, raising money for libraries in distant lands. It is free though they ask for donations. They supply support, forums, local meetups, and some prizes if you finish (one was a radio station that would let you read a chapter, another was coupons for getting books printed at a self publishing site).

It was fun. More importantly, it made me confident I could write a book when the time came that I wanted to do a real one.

 

h1

My checklist for debugging insurmountable issues

June 21, 2014

I listen to the Amp Hour podcast. Last week, they were talking about ways engineers fail and about checklists as a way to be more disciplined in avoiding preventable errors.

I try to learn from my mistakes so I do have a checklist of sorts when I reach the “it’s all broken and never, ever going to work again” stage of debugging. Of course, when I get to that point, the symptoms are usually different. Still, some parts of the path are relatively common.

1. Having you tried turning it off and back on again?

It is a joke, a very well seasoned joke. But it is only funny because it is so horribly true. This isn’t a good way to debug a horrible problem but it does provide the circumstances the problem happens under. I often start from scratch to reproduce issues because there is often a clue in the process. So, turning it off and back on again is a way to make sure that I start from a well-understood starting point.

The next questions:

Really? Are you sure?

But these are going to follow most of these checklist questions. As embedded system get more complicated, it is pretty easy to turn a part of the system off but not all of it. I don’t usually go from no-power-to-my-desk, I almost always start with my computer on. But sometimes, turning off all power is necessary (including restarting the debugger).

2. Does it have power?

This is different than the previous in that the “it” refers to all the things that may be broken: the processor, the debugger, the sensor or actuator, the level shifters, everything. This step usually requires a voltmeter (and is related to #5).

3. Is it running the code you think it is?

I sometimes have two or three code bases. If my development environment is pointed to the wrong one, I could easily be compiling over here but loading the image from over there. Or possibly, if the load process is difficult, I may think I’ve loaded the code and somehow missed a step.

I’m working on a big system now, a monitor of another system. When I compile the code, it goes through four machines before it gets to where I can try it out. The possibility that I typed cp instead of scp (or forgot the ending colon!), well, let’s just say it happens more often than I’d like.

This is the reason to have build numbers. But if you are really, really sure it is running the code you think, change something about the output and reload. Make sure you see the change.

4. Did you read the boot and debug output?

I write error logging features and always want a serial debug output. I love power on self tests. However, once the system is working, I stop looking at them. But sometimes, if a cable has loosened or hardware has failed, the system will tell me. But only if I am listening.

5. If it used to work, what changed?

Nothing changed, of course. It just stopped working. My minor code change could not possibly have caused something so catastrophic.

I’ve heard that. I’ve said it. That doesn’t make it true.

If nothing changed, then run the old code. If it fails, well, that’s interesting now, isn’t it? If it succeeds, well then, stop saying nothing changed, something obviously did.

This does require frequent commit to version control, to get back to a last-known-good image. But you were doing that anyway, right? And then you can binary search to determine where the error crept in.

Note that if the code change doesn’t explain it, compare the map files (even the binaries). Realizing that something crossed a boundary may give you inside. Oh, also, the makefile (or project file) may have changed: optimizations can have big ramifications.

6. Is there anything interesting in the map file?

Like many embedded engineers, I find the map file to be a bit of an illegible mess. Happily, I’m not afraid of them anymore. There is an amazing amount of information in the map file. And it provides a different perspective on the code, sometimes it will jog my memory.

7. Can you prove it is hardware?

Of course, at this point, it probably is. But you know hardware engineers, they can be feeble. They need proof. So what kind of proof can you offer? How can you break it down to show it cannot possibly be the software?

Seriously, I have had the privilege of working with some phenomenal hardware engineers. It is seldom hardware (but not never). The process of proving it is hardware is a good part of debugging. Plus, if you can make the difficult error repeatable for the hardware engineer, they’ll probably take you to lunch for making their jobs easier.

8. Can you explain the problem to another engineer?

When I tutored intro to CS, I asked people to explain their problem to a teddy bear outside my office before explaining them to me. I usually listened in. However, at least 50% of the people thanked the bear and left without talking to me. Ok, probably only 20% thanked the bear but most walked away because they never actually needed my help. They needed to get their thoughts in order, to explain it to themselves.

I do that now, talk to myself. Sometimes I try to explain it to a trusted colleague (or a junior engineer) in email, trying to figure out what questions they would ask me so the explanations is really good.  Occasionally, I even send the email after all that, if I still can’t figure out the problem.

9. Did you use the single line if again?

When I saw Apple’s goto Fail bug, I completely understood.  I avoid unbraced if statements because one month, I tallied up my most common coding mistakes and found that unbraced if statements caused a disproportionate number of my bugs. I vowed never to use them again.  Since this is a known failure point on my part, it makes my checklist.