Skip to content

Installing 8192cu module on the B^3 running Arch Linux

I started with Arch Linux for the Beaglebone Black

http://archlinuxarm.org/platforms/armv7/ti/beaglebone-black

(I’ve made an working img file if anyone needs it)

http://www.ubermentis.com/files/Arch-Linux-BBB-%206-20-13.rar

#Update the system

pacman -Syu
pacman -Syy #refreshes package lists; sometimes the local list is out of date.
pacman -S nano #I know how to use VIM, but I like nano.
export EDITOR=nano
#Time to figure out what architecture I’m using and get linux-headers and developmental files
# for building packages and modules.
#Tells you the architecture name.

arch ; uname -a

# pacman -Ss will search for packages

pacman -Ss armv71*

core/linux-armv7 3.9.4-2 (base)
The Linux Kernel and modules – ARMv7 processors
core/linux-headers-armv7 3.9.4-2
Header files and scripts for building modules for linux kernel – ARMv7
processors
#I tried to install the updated kernel, but it seems to require an updated uBoot.img.  I didn’t feel like track that down, so # I skipped updating the kernel and went with adding the headers.

pacman -S linux-headers-armv7
pacman -Syu

#I rebooted
#I then installed aurget, an aur helper (aur is a community supported Arch Linux package library).

wget https://aur.archlinux.org/packages/au/aurget/aurget.tar.gz
tar -xvf aurget.tar.gz 

cd aurget

makepkg # Makes the package locally

pacman -U aurget.pkg.tar.xz # Installs the aurget package we just compiled.

#Now, to get the 8192cu files through aurget.  I used the community repository because the patches to the 8192 driver # are included.  Now, it’ll ask if you want to edit the PKGBUILD file.  I did, and under “arch=” I added armv7l (note for # typers, that last alphanumeric is a L). E.g., arch=(‘i386′ ‘etc’ ‘armv7l’)

aurget -S dkms-8192cu –asroot -Acs

#I then rebooted.

pacman -Syu

:: Synchronizing package databases…
core is up to date
extra is up to date
community is up to date
alarm is up to date
aur is up to date
:: Starting full system upgrade…
resolving dependencies…
looking for inter-conflicts…
Packages (1): dkms-8192cu-v3.4.4_4749-8 #Huh, so looks like the package is installed.
Total Installed Size:   5.28 MiB
Net Upgrade Size:       0.00 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                                                       [###########################################################] 100%
(1/1) checking package integrity                                                                     [###########################################################] 100%
(1/1) loading package files                                                                          [###########################################################] 100%
(1/1) checking for file conflicts                                                                    [###########################################################] 100%
(1/1) checking available disk space                                                                  [###########################################################] 100%
8192cu, v3.4.4_4749: added #And now added.
——————————
Deleting module version: v3.4.4_4749
completely from the DKMS tree.
——————————
Done.
(1/1) upgrading dkms-8192cu    #Now upgraded.                                 [###########################################################] 100%
Creating symlink /var/lib/dkms/8192cu/v3.4.4_4749/source ->
/usr/src/8192cu-v3.4.4_4749
DKMS: add completed.
Kernel preparation unnecessary for this kernel.  Skipping…
Building module:
cleaning build area…..
make KERNELRELEASE=3.8.13-5-ARCH ARCH=arm CROSS_COMPILE= -C /usr/lib/modules/3.8.13-5-ARCH/build M=/var/lib/dkms/8192cu/v3.4.4_4749/build modules…………………………………………………………………….
cleaning build area…..
DKMS: build completed.
8192cu:
Running module version sanity check.
– Original module
– No original module exists within this kernel
– Installation
– Installing to /usr/lib/modules/3.8.13-5-ARCH/kernel/drivers/net/wireless/ #Added to directory
depmod…… #Setup as a module
DKMS: install completed.

#I threw my connection information into etc/wpa_supplicant.conf and brought up supplicant.
nano /etc/wpa_supplicant.conf

#Home network; allow all valid ciphers
network={
    ssid=”Name_of_network”
    key_mgmt=WPA-PSK
    psk=”put-password-here”
}

 #Now, I played around with some of the wireless tools available.

pacman -S -iw
pacman -S wireless_tools
pacman -S networkmanager
pacman -S dhclient
pacman -S openresolv

But in the end, I used wpa_supplicant and dhclient

I ran
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

After some time, it connected. 

I then pressed Ctrl + Z to send it to the background and ran:
 
dhclient -A wlan0 #The -A option makes it verbose, so you know what’s going on.

I looked to see if I had an IP:

iwconfig wlan0
 
I pulled the card and made an image.

Now, the wifi is still very iffy.  More dropped packets than I’d like, and it has some real weird behavior (e.g., getting stuck, needing to be rebooted, not liking the LAN cable attached, not liking the LAN cable un-attached).  But still, this is further than I ever made it on the damned Angstrom distro.

I don’t suppose the Linux wise could spot some errors I’ve made that would help make the result more stable?

Distcc and RPi

1. Update

sudo apt-get update

2. Install libiberty

wget https://toolbox-of-eric.googlecode.com/files/libiberty.tar.gz

sudo tar -xvf libiberty.tar.gz

cd libiberty

sudo ./configure

sudo make

sudo make install

I had to install libiberty before distcc would make correctly. Then, I couldn’t get distcc to build correctly unless I dropped the —gtk2.0 build parameter. If I dropped that, then it would build.

3. Install distcc

sudo apt-get install subversion autoconf automake python python-dev

svn checkout http://distcc.googlecode.com/svn/trunk/ distcc-read-only

cd distcc-read-only

./autogen.sh

4. Create symbolic links

sudo ln -s /usr/local/bin/distcc /usr/local/bin/gcc

sudo ln -s /usr/local/bin/distcc /usr/local/bin/cc

sudo ln -s /usr/local/bin/distcc /usr/local/bin/g++

sudo ln -s /usr/local/bin/distcc /usr/local/bin/c++

sudo ln -s /usr/local/bin/distcc /usr/local/bin/cpp

At this point, “which gcc” says: /usr/local/bin/gcc

4. Add path variable and distcc information to .bashrc

~$ sudo nano .bashrc

# The remote machines that will build things for you. Don’t put the ip of the Pi unless

# you want the Pi to take part to the build process.

# The syntax is : “IP_ADDRESS/NUMBER_OF_JOBS IP_ADDRESS/NUMBER_OF_JOBS” etc…

# The documentation states that your should set the number of jobs per machine to

# its number of processors. I advise you to set it to twice as much. See why in the test paragraph.

# For example:

export DISTCC_HOSTS=”192.xxx.x.xx/12″

# xx=the ip of my machine doing the processing

# When a job fails, distcc backs off the machine that failed for some time.

# We want distcc to retry immediately

export DISTCC_BACKOFF_PERIOD=0

# Time, in seconds, before distcc throws a DISTCC_IO_TIMEOUT error and tries to build the file

# locally ( default hardcoded to 300 in version prior to 3.2 )

export DISTCC_IO_TIMEOUT=3000

# Don’t try to build the file locally when a remote job failed

export DISTCC_SKIP_LOCAL_RETRY=1

export PATH=/usr/local/bin:$PATH

(Crt+O to save, Ctrl+X to exit—Save=Y)

5. Reboot

6. Update (I’m not good at Linux, I do this often just in case :)

7. I download opencv

sudo git clone –depth=1 git://code.opencv.org/opencv.git

sudo cd opencv

sudo mkdir redist && cd redist

At this point I kick myself for trying to run the cmake command without having installed cmake. So, I install cmake.

sudo apt-get install cmake

sudo cmake -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_JASPER=ON – DBUILD_OPENEXR=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON – DBUILD_TIFF=ON -DBUILD_ZLIB=ON -DBUILD_DOCS=OFF – DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_gpu=OFF – DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DWITH_OPENCL=OFF ..

And here is where I get thrown with the errors I’ve listed, usually a 111. After reading the comments, I’ve played with the PATH variable until I’ve blistered fingers. I’ll remove any double entries, or whatever I feel like messing up. I’ve even gone as far as removing instances of “gcc/c++/g++/cc/cpp,” renaming them xxx.old, just to be sure it wasn’t calling a local compiler because it found it first.

In the end, same result, the errors I listed in the comment, or the 111 error.

I should note, I try something different every time I follow the build, trying to solve for X, so sometimes I’ll actually get a connection to the desktop when I run the “cmake” command, and other times I won’t.

I’m lost. Help.

—Thomas

Python Zombie 1.1

import Tkinter

import time
import threading
import random
import Queue
import serial
import readline
import xbee
import sys

x=””

class GuiPart:
def __init__(self, master, queue, endApplication):
self.sonar = Tkinter.StringVar() # Feeds sonar sensor data to label
self.lm = Tkinter.StringVar() # Feeds left motor speed to label
self.rm = Tkinter.StringVar() # Feeds right motor speed to label

self.queue = queue
# Set up the GUI
frame1 = Tkinter.Frame(master, bd=200) #Setup frame.
frame1.bind(“<Key>”, self.key) # Allow frame to handle keypresses.
frame1.focus_set() #Set focus of frame so that keypresses activate event.
frame1.pack() #Show it.

#Button
console = Tkinter.Button(frame1, text=’Close’, command=endApplication)
console.pack()

# Add more GUI stuff here
self.lm.set(0) # Initializes left motor label
self.rm.set(0) # Initializes right motor label
self.sonar.set(0) # Initializes sonar label

#Sonar label
sonarLbl = Tkinter.Label(frame1, textvariable=self.sonar)
sonarLbl.pack()

#Right motor label
rmLbl = Tkinter.Label(frame1, text=”Left Motor Speed: “, textvariable=self.rm)
rmLbl.pack()

#Left motor label
lmLbl = Tkinter.Label(frame1, textvariable=self.lm)
lmLbl.pack()

def key(self, event):
#print “pressed”, repr(event.char)
#self.sonar = repr(event.char) <—— This should be the line to handle keypresses
global x
x = repr(event.char)

def processIncoming(self):
“””
Handle all the messages currently in the queue (if any).
“””
while self.queue.qsize():
try:
msg = self.queue.get(0)
# Check contents of message and do what it says
# As a test, we simply print it

# Below is where I will parse the “msg” variable, splitting
# it (msg.rsplit) to pull out sensor data and update labels.

lm, rm, sonar, mknt = msg.rsplit(“,”)
lm = “Left Motor Speed: “+lm
rm = “Right Motor Speed: “+rm
sonar = “Sonar: “+sonar+” CMs away”

self.sonar.set(sonar) # Setting the labels with latest sensor info.
self.lm.set(lm) # Setting the labels with latest sensor info.
self.rm.set(rm) # Setting the labels with latest sensor info.

except Queue.Empty:
pass

class ThreadedClient:
“””
Launch the main part of the GUI and the worker thread. periodicCall and
endApplication could reside in the GUI part, but putting them here
means that you have all the thread controls in a single place.
“””
def __init__(self, master):
“””
Start the GUI and the asynchronous threads. We are in the main
(original) thread of the application, which will later be used by
the GUI. We spawn a new thread for the worker.
“””
self.master = master

# Create the queue
self.queue = Queue.Queue()

# Set up the GUI part
self.gui = GuiPart(master, self.queue, self.endApplication)

# Set up the thread to do asynchronous I/O
# More can be made if necessary
self.running = 1

self.thread1 = threading.Thread(target=self.workerThread1)
self.thread1.start()

#Start receiving thread.
self.rx = threading.Thread(target=self.rx)
self.rx.start()

# Start the periodic call in the GUI to check if the queue contains
# anything
self.periodicCall()

def periodicCall(self):
“””
Check every 100 ms if there is something new in the queue.
“””
self.gui.processIncoming()
if not self.running:
# This is the brutal stop of the system. You may want to do
# some cleanup before actually shutting it down.
import sys
sys.exit(1)
self.master.after(100, self.periodicCall)

def workerThread1(self):
“””
This is where we handle the asynchronous I/O. For example, it may be
a ‘select()’.
One important thing to remember is that the thread has to yield
control.
“””
while self.running:
# To simulate asynchronous I/O, we create a random number at
# random intervals. Replace the following 2 lines with the real
# thing.
time.sleep(rand.random() * 0.3)
msg = rand.random()

#self.queue.put(msg)

# Continuously read and print packets
def rx(self):
global x
self.ser = serial.Serial(‘/dev/ttyUSB0′, 9600, timeout=1, bytesize=8, stopbits=1)
self.ser.flush()
while(1):
response = str(self.ser.readline())

# Send movement codes.
if x == “‘a'” or x == “‘A'”: # or “‘A'”: # Turn left.
self.ser.write(‘4′)
elif x == “‘w'” or x == “‘W'”: #Go forward.
self.ser.write(“3″)
elif x == “‘d'” or x == “‘D'”: #Turn right.
self.ser.write(“2″)
elif x == “‘s'” or x == “‘S'”: #Go back.
self.ser.write(“1″)
elif x == “‘x'” or x == “‘X'”: #Stop.
self.ser.write(“5″)
elif x == “‘1′”: #Raise speed.
self.ser.write(“7″)
elif x == “‘2′”: #Lower speed.
self.ser.write(“6″)

x = “”

if len(response) > 10:
self.ser.flushInput() #If you don’t flush the buffer, then it’ll try to read out all
#the sensor readings, so the reaction time will be extrordinary.
time.sleep(.1)# This scales back the CPU usage.
self.queue.put(response)

def endApplication(self):
print “Closing”
self.running = 0
self.ser.close()
sys.exit(1)

rand = random.Random()
root = Tkinter.Tk()

client = ThreadedClient(root)
root.mainloop()

Design a Motor Driver for LSN bot

Image

Well, I should start by saying I knew nothing about electronics when I started this bit.  I simply wanted to learn.  I had pieced together a PC last June for my wife and I had to build a switch for it.  It was a little momentary switch I bought at the Shack.  The moment I hit the switch and the PC came on I was hooked.  I wanted to build a robot.

Well, I soon learned about Arduino and the Open Hardware community.  They were a kin.  So, I started constructing Little Sky Net (hey, cliches are comforting).  I bought an Arduino, ran the blink sketch, learned about PWM, learned about motor controllers; then, I saw how much the Arduino Motor Shield was.

See, I’m cheap–more than that, I’m married.  My wife had given me a budget of $100 a month and it was adding up quick.  I soon found the little H-Bridge IC at SparkFun (https://www.sparkfun.com/products/315?) and I thought $2.35 was a heck of a lot better than $30

.Image

So, I bought them to go with the Inertia labs kit (http://www.robotmarketplace.com/products/IL-ANTKIT2.html).  When they came in I learned that there was much more to the little ICs than just wiring them.

I started by wiring it to a perforated circuit board.

Image

I hooked it to a Lilypad Arduino (don’t ask, I had no clue what I was doing) I noticed there were was a lot of jittering and it had the high-pitch squeal.  So I started reading:

http://arduino.cc/forum/index.php/topic,22406.0.html

http://www.robotroom.com/HBridge.html

I learned I needed smooth capacitors and a voltage regulator, at least to make it a decent motor driver.  Well, while I had been poking around for correct ways to wire up the H-bridge I came across the “Iron Transfer” method of home etching PCBs.  Awesome.  I immediately ran down to the Shack and bought stuff to try it.  When I got back I realized I had no real way to design the board.  Little more poking around and I came across Eagle.  Within a few hours, I had printed out my board design and was eagerly dipping it in Ferric Chloride hoping something great would come out of it.  Image

Then came another problem.  “How do I drill the holes?”  I ended up using my dremel; easy.  Then started the ultimate frustration–soldering the damn thing.  After some time, and ripping through boards, I realized my iron was crap.  It wouldn’t get hot enough and when I tried to pull it away from a soldered pin, it would rip the trace up…and I’d have to etch a new board with much cursing.

Finally, I got a board done and wired it up to the bot.

Image

It freaking worked! Well, sort of.

The Arduino code told it to go forward, turn right, then go forward, repeat.  It would go forward awesome like, but when it tried to turn, it would only turn the right set of tracks and drag the left.  It wasn’t what I hoped.  I had written the code so that the left tracks would go in reverse and the right would go forward, creating a zero-point turn.

But, it worked.  Not bad for someone without a high-school diploma and $25.

Of course, I soon was dissatisfied.  I wanted the zero-point.  Well, after some digging I learned the difference between a full H-Bridge and a half H-Bridge.  I had a half, meaning the bridge could tell both sides to go forward at difference speeds based upon the enable pin, but it couldn’t tell one motor to go forward and the other backwards at the same time.

Heck, that’s no problem.  I had bought two ICs and I still had some copper board and Ferric left, I’d just use one side of two different ICs.  Two halves makes a whole, right?  A little bit later I had this monster:

Image

It worked, but I wasn’t pleased with it.  I had been burning at both ends and I had to etch several boards due to the fact my design sucked and my iron was worse.  But in the end, it worked…well, for a little bit.  My regulators kept overheating and at one point something shorted and I lost that dear little fragile Lilypad.

In the end.  I bought an Arduino Motorshield.  I had learned the hard lesson that a circuit is easy to build, but a good circuit was often esoteric in nature–or at least, them seemed at the time.

Originally, I thought I’d be saving money with the H-Bridge IC.  But when I eventually ended up at the Shack (I’d buy online now) to get my Motor Shield I gladly paid $36.

To try and create my own shield I had spent:

$4.70 Two H-Bridge Ics
$3.00 Four capacitors
$2.50 Two Voltage Regulators
$14.00 Ferric Chloride
$5.26 Copper board
$29.46 Total

Of course, this breakdown does not include the time (16+ hours, hey, I didn’t know what solder was before I started) I put in, nor the Arduino Lilypad I fried ($22.95) or the one H-Bridge I broke the legs off.  I happily gave that smug guy at the Shack my $36, went home, and in 6 minutes (no lies) had my LSN moving.

My schematic:

Image

The board layout:

Image

Links for learnin':

Eagle Circuit Board design software

http://www.cadsoftusa.com/

Better H-Bridge:

http://www.digikey.com/product-detail/en/L298P013TR/497-3624-2-ND/677551

Good info for circuit designers:

http://www.allaboutcircuits.com/

http://letsmakerobots.com/

Follow

Get every new post delivered to your Inbox.