GPIO using Fedora 18 on pcDuino

On April 17, 2013 · 0 Comments
pcDuino

A Mini PC with Arduino type Interface powered by ARM Pro Spec

I recently purchased a pcDuino because of it’s plenitude of I/O (5v) GPIO pins. My Raspberry Pi was an interesting board, but it lacked the GPIO and Analog to Digital inputs that make the Arduino so useful. The Arduino, while imminently useful, lacks the power to handle images and other high-bandwith tasks so it’s relegated to motor control and simple I/O.

The pcDuino comes well-outfitted compared to both the Raspberry Pi and the Arduino:

  • CPU: 1GHz ARM Cortex A8
  • GPU: OpenGL ES2.0, OpenVG 1.1 Mali 400 core
  • DRAM: 1GB
  • Onboard Storage: 2GB Flash, SD card slot for up to 32GB
  • Video Output: HDMI
  • OS: Linux + Android
  • Extension Interface: 2.54 mm Headers compatible with Arduino
  • Network interface: RJ45 and USB WiFi Dongle

Once I saw the horrid version of Lubuntu that came pre-installed on the device, I started looking for a Fedora port. Luckily Hans de Goede has published a Fedora port for the Allwinner 10 chip. Loading this was simple and straightforward – just follow the README

Then came the task of accessing the GPIO. The Lubuntu image that came with the device exposed some GPIO pins at /sys/devices/virtual/misc/gpio, but Fedora did not show any pins there. After a couple of days of probing the Internet for the source, I stumbled across the amazing GPIO sysfs capabilities of Linux.

After following the guide on elinux.org, I was still unable to access *any* GPIO. Then I remembered that I chose “cubieboard” when I loaded the port by Hans. More hunting revealed uboot, sunxi-tools and the script.bin file. Following are the rough instructions on how to get access to the GPIO on your pcDunio in Fedora…

  • Start with the Fedora port by Hans de Goede.

    • In step 6 when it asks you to select a board with:
    • sh /select-board.sh
    • Select the cubieboard
  • Clone the linux-sunxi/sunxi-tools on your Linux box (not the pcDunio)
  • Compile by typing make

      Don’t worry if it doesn’t compile everything. The two commands we need – bin2fex and fex2bin will be compiled in that directory
  • Mount your microSD card and grab the script.bin file ( /boot/uboot/script.bin )
  • Convert it to fex format ( bin2fex script.bin > myboard.fex )
  • Grab the pcDuino fex file from linux-sunxi / sunxi-boards
  • Copy the lines from section [gpio_para] into your myboard.fex file at about the same place they were in
    the pcduino.fex file
  • Convert it back to bin format with ( fex2bin myboard.fex > script.bin )
  • Move it back into place as /boot/uboot/script.bin

  • Unmount your sdcard from your Linux box and boot your pcDuino – it’s got new superpowers now.
  • Follow the guide at elinux.org
  • PROFIT

Pic or it didn’t happen

Bash shell script that blinks the LED

Making Fedora 17, Unicorn and nginx work together

On April 5, 2013 · 0 Comments

I had a heck of a time getting a Rails+Unicorn+nginx deployment going on Fedora 17. The problem was, I could get it running using TCP sockets but not using unix sockets. I loosely followed these instructions for deploying a Rails 3.2 app but kept having problems with the unix sockets.

The Solution:

Don’t put the socket file in the /tmp directory.

The Why:

Fedora has this in /etc/systemd/system/multi-user.target.wants/nginx.service

    [Unit]
    Description=The nginx HTTP and reverse proxy server
    After=syslog.target network.target remote-fs.target nss-lookup.target

    [Service]
    Type=forking
    PIDFile=/run/nginx.pid
    ExecStartPre=/usr/sbin/nginx -t
    ExecStart=/usr/sbin/nginx
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target

And if you look over on the Unicorn site, you’ll see this as the documentation for the listen method / configuration setting

    Adds an address to the existing listener set. May be specified more than once. address may be an Integer port number for a TCP port, an “IP_ADDRESS:PORT” for TCP listeners or a pathname for UNIX domain sockets.

    listen 3000 # listen to port 3000 on all TCP interfaces
    listen "127.0.0.1:3000"  # listen to port 3000 on the loopback interface
    listen "/tmp/.unicorn.sock" # listen on the given Unix domain socket
    listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
    

Which encourages folks to put the socket in the /tmp directory. This is going to cause trouble for every Fedora user that tries to use Unicorn.

While debugging this I got the infamous “502 Bad Gateway” page from nginx. I checked out the error_log, and this message was there:

2013/04/05 12:25:58 [crit] 2906#0: *29 connect() to unix:/tmp/my_project_name.socket failed 
                    (2: No such file or directory) while connecting to upstream, 
                    client: 192.168.10.234, server: my_project_name.railsit.com, 
                    request: "GET / HTTP/1.1", 
                    upstream: "http://unix:/tmp/my_project_name.socket:/", 
                    host: "my_project_name.railsit.com:8081"

So, after a couple of hours of head scratching and WTF’ing, I remembered that systemd did some crazy shenanigans
to mysql, preventing me from setting the file limit higher. As soon as I saw the PrivateTmp=true line in the
nginx.service file, I knew that systemd was the culprit.

Hope this helps someone.

Disable double click for HTML links

On August 31, 2010 · 0 Comments

I’ve got a bunch of users that constantly double click html links. Also, I’ve had a few users probing my apps trying to expose holes. Those probes have generally included either clicking links multiple times, or automatically submitting URLs via some automated process.

When I added messages to guide users that were re-submitting the same URLs, the double click users showed up as potential offenders. I needed a way to keep the double click users off of my intrusion detection report, but still be alerted to the more nefarious users. The solution to this problem is preventing browser based double clicks

I think my solution is elegant. I didn’t find this solution on the Internet, so I decided to post it here.

Simply make the onclick handler for the <a> tag reset it’s onclick handler to return false:

<a href="#" onclick="this.onclick=function () {return false;};return true;">Click Here</a>

I’ve tested this in Chrome/FF/IE8/IE6 and they all seem to work just fine. Comments and feedback welcomed.

Outliers – the Story of Success

On January 23, 2010 · 0 Comments

outliersI’d heard of Outliers a few months back in some of my geek feed reading. I’m sure the portions of the book that were cited were the portions about Bill Gates and Bill Joy. At least that’s what I remembered when I saw the book last Sunday at Barnes and Nobel.
Continue Reading…

Bike maintenance

On January 20, 2010 · 0 Comments

cleanbikeI’ll have to admit that I’m not the most diligent at bike maintenance. I’ve been known to let a chain go for a couple of months without cleaning, have grime on my wheels and frames from a rain storm a month ago.

After attending the Bike Maintenance 101 class at Cahaba Cycles my son and I cleaned every bike in the house. It felt really good to walk away from a row of clean bikes, knowing that I can jump on and ride anytime without worry of weird failures.

Riding a dirty bike is fun, but riding a clean bike is even better.

Lenovo USB Keyboard

On January 20, 2010 · 0 Comments

keyboardI spend a lot of time on my Thinkpad laptop. Coding, blogging, surfing, etc. I absolutely love the keyboard. The keys are just the right distance apart, well laid out, etc.

I have a couple of desktop machines that perform various services around the house. One is a Windows box, one is an old server that is used for experiments, etc. Using the random keyboards on those boxes was a PITA until I got my Lenovo USB Keyboard.

This keyboard has:

  • UltraNav
  • Keypad
  • Great feel

If you’re going to use this keyboard on Windows XP, make sure you load the drivers from the Lenovo site. Linux seems to have everything built in.

I’m afraid this keyboard isn’t manufactured any more.

Free Tech Support again

On January 17, 2010 · 0 Comments

geek-squad-demotivational-posterLooks like I’m the free tech support guy again. I’m sure it’s not the quality, it’s the price. I’m going to have a hard time feeding my family on the $0 I get from fixing other peoples computers.

It seems that it’s always Windows XP that shows up at my door. Two weeks ago, this laptop was eaten up with viruses. A quick Internet search (from my Linux box that has never had a virus) yielded the solution. A quick download later and the machine was clean enough to put back on the Internet.

This week, the same computer was going to blue screen before the login page. WTF? How does it get that bad. The product key doesn’t work (It’s a Dell OEM product key), and I’m not sure what was done before I got it. I was able to repair windows, but now XP wants to be activated again.

I’m tired of fooling with this one. I’m going to offer to load Ubuntu (heck, if I’m going to support something, it might as well be something I like using) or just give it back. There’s not much data on it, and all it’s used for is surfing and watching DVDs. Sounds like a great job for Ubuntu.

There’s also the issue of the thank you. Anything will do, thank you note, case of diet coke, anything.

Tour de Cure Just Around the Corner

On January 13, 2010 · 0 Comments

ada

tdcThe Birmingham Alabama Tour de Cure is just 19 weeks away. I’ve started my training mostly by commuting to work (15 mile round trip), but I’ll be doing longer rides as the weather permits. It’s been cold in Alabama lately, and riding outside takes a special kind of resolve.

More importantly, I’ve started my fundraising for this year’s TDC. The training for the ride is important, and serves as a great lead in for asking for donations. Doing time on the bike trainers and home gyms is not the most important part of Tour. The most important part is doing my part to cure this disease, and I can do that best by raising as much money as possible. My goal is $5000.

I’m the rider recruitment chair for the Birmingham Tour de Cure. Don’t be surprised if you get a note or call from me asking you to join the Tour. I’ll ask you first to be a rider. If you don’t feel comfortable being a rider, I’ll gladly accept a donation. If you want to track my progress, just head on over to http://main.diabetes.org/goto/david.wilkins

Looking for a new cell phone

On January 11, 2010 · 0 Comments

products_xp3questI’m currently in the market for a cell phone for my son. Being a geek, I naturally tend toward the new devices with lots of features. The last two phones he’s had were fairly new devices: Blackberry Pearl and Blackberry Pearl Flip. The problem with these devices is that, while snazzy, they weren’t designed for ruggedness. The Pearl Flip only lasted about a month until it got crushed underfoot, and the Pearl lost it’s mind after about 3 months.

I’ve decided to move away from brittle phones to rugged phones. The one I’ve got my eye on is the sonim xp3 quest. Some of the features are:

  • IP-67 rating/ MIL-810F certified
  • 3-Year Unconditional Guarantee
  • Equipped with a turn-by-turn navigation application
  • micro sd Card slot (up to 2 GB)
  • 2MP Camera with Flash
  • Submersible to 1M for 30 minutes in water
  • Withstands 2m drops on concrete

It’s doesn’t have 3G, or a touch screen, but it might last for more than a few months. If he just won’t lose it, I’ll be able to collect on the warranty at least.

Mobile Internet Devices

On January 8, 2010 · 0 Comments

It seems that more and more mobile internet devices (MIDs) are showing up. A friend of mine turned me on to these over at allpmp.com. At just $155, they’re nearly cheap enough to put in every room of the house. I’d like to replace my 70′s era intercom system with some MIDs that could display Jetson’s style information while I get dressed. And the intercom functionality would be great to have too.

These units are a bit small. The 4.3″ screen is about the size to build into a piece of modern furniture. I don’t think that screen would be something that I could read from across a medium sized room.

Amazingly, this device sports WIFI, USB, and 3G. I wonder why the Nexus One costs $530, and this one costs $155? Sure, there are some processor differences, but not $400 worth!