Tuesday, April 4, 2017

Make Something That Isn't A Computer A Computer

I asked my girlfriend what I should do for my blog. She suggested that I "make something that isn't a computer a computer." So I looked around for something that I could do that to. I have a router, but that seems too easy with things like OpenWRT and whatnot. How about something a touch more obscure. Why not a drone? I have most of a Parrot Bebop Drone, so we can use different parts of it if we want. I want very much.

This is the board of the drone. There are several main chips on this board. One of them is a Parrot branded CPU. That's the one with the silver rectangle on it in the bottom third of the board. There are also RAM chips. Next to the beeper in the middle is a Broadcom BCM43526. That obviously does all of the networking stuff. The big one on top is a Cypress CY8C34. That controls the motor timings. I also have the battery, but I can't find the charger. So figuring this out has to be quick. It should be fine

I actually have no idea why I have this drone. It was given to me in parts. So any part of this could be broken. Let's see what we can get to run.

I plugged the drone board into the battery and my computer, pressed the button, and hoped it wouldn't short. Sure enough, it booted and started broadcasting a network. I connected and found two FTP servers. They were pretty much useless. There was also an HTTP server on 8080 which was nothing but statistics about its existence. Charming, but no SSH or telnet. Why?

After doing some digging on the internet, pressing the power button 4 times after it turns on starts it in a kind of debug mode. This exposes a telnet server. Now we can find what's powering it. We find a ARMv7 Processor:

Processor       : ARMv7 Processor rev 7 (v7l)
processor       : 0
BogoMIPS        : 1561.76

processor       : 1
BogoMIPS        : 1560.01

Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc09
CPU revision    : 7

Hardware        : Mykonos3 board
Revision        : 000a
Serial          : 0000000000000000

It's also showing 296676 kB of memory. The whole filesystem, however, was read only. You can easily fix that by writing mount -o remount,rw /. We can change the fact that telnet doesn't start when the board starts by adding that line and the line /usr/sbin/telnetd -l /bin/login.sh just before the end of /etc/init.d/rcS. Now you can always connect to 192.168.42.1 and expect a telnet server and a writable filesystem to be waiting for you.

Next, I plugged in the GPS module. I got NMEA data from it by running  cat `cat /etc/parrot/gps/tty`. It started dumping data. Good. Next step is to be able to write software for it.

Unfortunately, the battery died before I could get to that part, so I had to figure out a way to power this thing off of the wall or a USB. I hooked it up to a variable power supply and tested to see the lowest voltage it would turn on at. It turned on at around 6V, but when it tried to turn wireless on it crashed. However, at voltages that I needed to try (like 9V or 12V), it overloaded the power supply. This was odd, as it was only taking about half an amp. So I decided to try a 9V DC power supply to see if it would do the trick. I tried a 9V power supply first and it seemed pretty stable. The battery was 11.1V, so I didn't want to push the board to 12V. I'm glad it worked.

Once I had that permanently affixed to the board I continued my software investigations. Compiling software for it was actually slightly easier than I thought and, while I haven't extensively tested this, it seems as if it works fairly well.

First, we need to know how to compile for this chip. Given the CPU info given above, we know that this is an ARM v7 chip without floating point hardware. So we need to install the ARM ABI for GCC. This is done simply with:

sudo apt-get install gcc-arm-linux-gnueabi

Now, we can compile things using gcc-arm-linux-gnueabi just like normal. It may also be important to use the -static flag just in case some libraries aren't included. A hello world program worked well, as did some more complex stuff. I tried to compile this really simple web server I found and it worked the first try. Compiling for ARM will probably have its pitfalls for more complex stuff in the future, but for now it's kind of a breeze.

Changing the name and SSID of the board was easy. I used the dragon config file to change the name of the network and the hostname with the hostname command. This board is now a Linux terminal. Pretty impressive, no? Linux runs on a ton of things, and this is certainly not the last time I'll be doing this. I firmly believe that anything can run anything, so if it's a general purpose processor, it can probably be turned into a regular terminal. I'll find something else to do this to because this was actually a lot of fun.

No comments:

Post a Comment