Archive | Arduino IDE RSS for this section

I Installed Something Called “Debian Unstable”

So, after weeks of procrastinating, the day finally came; it was time to upgrade Ubuntu. As many of you likely know, Ubuntu has a 6 month release cycle. New versions come out in November and April. The release of Saucy Salamander marked the first time I’ve had to deal with a Linux distro upgrade since I was running Fedora 8 back in 2008 (Not counting a brief encounter with Debian Squeeze just prior to using Ubuntu). As I recall, my attempt to upgrade to Fedora 9 was a disaster. Nothing worked, and it was a huge amount of effort. It was so bad that I decided to cut my losses and just go back to Windows Vista.

Needless to say, I wasn’t terribly excited about upgrading to Saucy. Finally, about a week ago I decided to stop being lazy and just do it. While it wasn’t quite the disaster that Fedora 9 was, I wouldn’t call the upgrade “smooth”. The first thing that I noticed was the fact that I could no longer lock the display. Since my cat likes to perform unauthorized refactoring of my code if I leave the display unlocked, this would not do. I did some googling, and it turns out that Gnome removed gnome-screensaver in Gnome 3.8. Gnome-screensaver controlled, among other things, locking the screen. All of the functionality was rolled into GDM. Ubuntu uses LightDM, so in order to protect my precious codebase I have to either switch it out for GDM, or use a Gnome shell plugin. First, I tried to install GDM, but every time I logged in I would get a popup saying that GDM crashed. I switched back to LightDM and installed the plugin. Everything seemed to be going fine, but things were just a bit more wonky. Every so often, when I’d go to unlock, the screen would freeze. I could just hope it was working and type my password and press enter to unlock it, but I like things to work right.

Not a huge deal though, I thought. I decided that I’d just grin and bear it. However, things continued to come apart. I went about re-compiling DMP Photo Booth and its modules to make sure everything was working correctly with the updated software versions. For the most part it was, but my working splash screen was broken. When shown, the window would pop, but the image on the window would not show. It seemed my call to while (gtk_events_pending()) gtk_main_iteration(); was returning early. In the course of my investigation I decided to open the Glade UI file to make sure everything was right. The only problem? The version of Glade shipped with Saucy has a major bug that causes it to crash when you open a file with a dialog in it. You can read the bug report here.

For me, this was the straw that broke the camel’s back. It was time to try a new distro.

Let’s Meet Our Contestants!

Ubuntu GNOME

I’ve been running Ubuntu for a while now, and have been mostly satisfied with it. I do have some concerns about their direction, but I’m not quite ready to break out the torches and pitch forks. However, I much prefer Gnome 3 to Unity, so I figured it was time to switch to a Gnome-centric distro. Luckily, there is a Ubuntu distro that focuses on Gnome: Ubuntu GNOME. My concern with this is that they seem to have manpower issues. I don’t feel like getting attached, just to have the rug pulled out from under me, so I won’t be using Ubuntu GNOME.

Fedora 20

I feel that it is fair to say that Fedora is to Red Hat as Ubuntu is to Debian. Fedora is an old, mainstream Linux distro that has the financial backing of a large company behind it. It is likely to be around for years to come. Better yet; Fedora is a Gnome distro. Fedora 20 ships with Gnome 3.10, the current latest and greatest.

Back in 2008, I tried to run Ubuntu. Back then, it didn’t “just work”. Fedora did. Maybe it was time to don my Fedora and come home to my first Linux distro. I downloaded the live DVD for Fedora 20, and booted it up. Everything seemed great; Gnome 3.10’s fancy new UI elements were incredibly profound. Mozart and Da Vinci would surely be reduced to tears at the sight of their magnificence. I was sold. I started the installer and got to work. I set my language, hostname, and then went to configure my partitions. …aaaaaaand no hard drives detected. Crud. After some googling around, this seems to be a known issue. The Googler told me that I could disable SELinux and it would work, but no luck. I was told that I could use the non-live image and it would work, but no luck. Well, so much for that idea. I filed my Fedora installation media in the round file and decided what to do next.

Debian Sid

It seems that the cool kids are running Debian these days. I’ve used Debian before, and had good experiences with it (uptime on my Debian Squeeze home server shows 102 days). The one sticking point is how old the software is. That is, old in the stable release; Debian Unstable has up-to-date software. The cool kids assure me that Sid is still more stable than Ubuntu or Fedora, so I decided to give it a shot.

The Installation

Installing Sid is slightly more tricky than Ubuntu or Fedora. Here’s the installation blurb on the Debian Wiki:

Use the stable installer to install a minimal stable system and then change your /etc/apt/sources.list file to testing and do an update and a dist-upgrade, and then again change your /etc/apt/sources.list file to unstable and again do an update and a dist-upgrade. ... If this seems too complicated you should probably not be using unstable.

With those words of encouragement, I set off to work. I downloaded the Debian 7 net install media, and installed. I followed the wizard, setting up the usual things. For partitioning, I formatted my /boot and / partitions, and preserved my /home partition. I spoke about this before in a previous post, but the short answer is that this keeps you from having to back up your data and settings. You should probably still do that stuff in case you do something stupid, but if all goes well you won’t need to.

When the time came to select additional software, I deselected everything. I finished the install and rebooted. The system booted up to the command line, and I logged in and su‘d to root. Now that my Wheezy install was complete, it was time to upgrade to Jessie. This is accomplished by editing /etc/apt/sources.list and changing every instance of the word wheezy to testing. While I was at it, I added contrib and non-free so I could get things like my wifi driver and flash. Next order of business was to install apt-listbugs and apt-listchanges. These two packages change apt-get to warn you of bugs in software, so you don’t blindly install some software that will light your computer on fire. After that:

apt-get update apt-get dist-upgrade

…then I ate lunch. This process will upgrade my system to testing, and it takes a while. After it’s done, I repeated the steps above, replacing all instances of testing with unstable in my sources.list. Additionally I had to delete the lines:

deb http://URL/ testing/updates main deb-src http://URL/ testing/updates main deb http://URL/debian/ testing-updates main deb-src http://URL/debian/ testing-updates main

…these don’t exist in Unstable.

While the apt-get dist-upgrade was running, it was time to watch some TV.

Finally, when apt-get dist-upgrade completed, I had a Debian Sid system. One problem: it was command line only.

A Few More Things

First things first, I needed to set up sudo:

adduser [username] sudo init 6

After the reboot, my user is set up to use sudo.

I had to install some software. First up is Gnome:

sudo apt-get install gnome

This is starts a 1.3 GB download, so I watched some more TV. When that finished, I needed to install my wifi driver so that I could disconnect my temporary cat-5 cable:

sudo apt-get install firmware-iwlwifi

Next up is the Debian laptop applications. This package installs the software that would be installed by selecting the laptop task in tasksel:

sudo apt-get install task-laptop

I rebooted into Gnome. I logged in and connected to my wifi. Since I preserved my /home partition, all my settings are still set up from Ubuntu, so there is very little asthetic configuration to be done.

The gnome package in Debian installs some other things besides Gnome. Among those things is LibreOffice, so I don’t have to worry about that. However, there are a few usability packages to install:

sudo apt-get install flashplugin-nonfree sudo apt-get install synaptic sudo apt-get install pkg-config

At this point I had a basic system set up. Now it is time to make sure DMP Photo Booth still works. Since I preserved my /home, NetBeans is still installed. However, there is no JDK installed. This was an easy fix:

sudo apt-get install openjdk-7-jdk

Now it is time to install the dependencies for DMP Photo Booth:

sudo apt-get install libmagickwand-dev sudo apt-get install libglib2.0 sudo apt-get install libgtk-3-dev sudo apt-get install cups libcups2-dev

Some of the development tools I need still aren’t installed. GCC is installed, but for some reason gdb isn’t. Also, to do work on the trigger, I’ll need avr-gcc:

sudo apt-get install gdb arduino sudo adduser [username] dialout sudo init 6

Finally, I need to install Glade to modify DMP Photo Booth’s UI:

sudo apt-get instal glade

And that’s it!


It took me a good half of a day to get it all working, but so far so good. Iceweasel is still a thing, but thinks it’s the latest version of firefox, and my addons still work so I’m not going to worry about it. Plus, weasels rule and foxes drool.

Glade is working now, but DMP Photo Booth’s working screen is still broken. However, I’m beginning to think it never was really working right in the first place.

All in all, it’s been a successful load. 1 week in, and I still don’t miss Ubuntu. Hopefully Sid is good to me, and I’ve found my salvation from getting a new Distro version every 6 months.

The Case of the Missing Tip

For the past 10 years or so of my career, I’ve mostly been employed as a sysadmin. During this time, I spend a great deal of time working with Solaris 10. Solaris 10 has a command called tip. Tip can be used for basic serial communications. You basically just pass it a baud rate, and a serial device, and it connects the STDIN and STDOUT.

Working with Arduino, sometimes you want to connect to the serial port and communicate with it. There is a whole Serial library for reading from and writing to Arduino via the usb cable. The Arduino IDE also comes with a serial monitor for use. However, using NetBeans, I find it kind of silly opening Arduino IDE just to use the serial monitor. Unfortunately, tip seems to be a Solaris-only utility. At a loss, I turned to google.

Google Proves Unhelpful

Shocking, I know. The number one solution to this is “Well, just write something in C!” I know what you’re thinking, and yes it did occur to me that this would be right up my alley. However, I know there is a utility that exists that does exactly what I want. In the interest of not re-inventing the wheel, I search on. The number two solution to the problem is a program called Minicom. Minicom is a fairly heavy menu-driven program that does serial comms. From what I can tell, it seems to be more like Microsoft’s Hyper Terminal than tip. Since I’m just looking for a simple command line utility, I move on.

Finally, after much searching, I come across my solution. There is a program called cu that seems to function exactly like tip. It even share the same disconnect code: ~. to hang up a connection. Even better: it’s in the repositories!

On an Ubuntu system, all you need to do is:

sudo apt-get install cu

…and you’re good to go. To connect is simple, just enter:

cu -l /dev/ttyWHATEVER -s BAUD_RATE

…and you’ll connect to your Arduino. To hang up, just enter ~. and it will disconnect (Ctrl+C and Ctrl+D have no effect).

Configuring Netbeans for Arduino Development

After spending some time using Eclipse and Arduino IDE for Arduino development, I’ve decided enough is enough! No longer will I put up with the unbearable hardship of using some other IDE. It’s NetBeans or bust! Well, it was a long road, but I’ve made it. If you’d like to make it too, then I can help.

Arduino IDE

First, we need to install the Arduino IDE. On Ubuntu, this is a simple apt-get:

sudo apt-get install arduino arduino-core gdb-avr

When that is finished, run the Arduino IDE.

Click Add when prompted about Dialout permissions

Enter your password

Before we can continue, we must logout, then log back in for the updated permissions to take effect.

Verify it works

Open Arduino IDE

Click File -> Examples -> 01.Basics -> Blink

A new window should launch with code for the basic blink program.

Plug your Arduino Uno into your computer via usb port. Click Tools -> Serial Port and select the correct Serial port

Click the Upload button on the toolbar. If all is well, your Pin 13 LED should start blinking.

Netbeans configuration

Launch Netbeans

Click Tools -> Options

Click on the C/C++ tab

In the bottom left corner, click Add…

In the Base Directory: field, enter the location of your AVR tool collection. apt-get put mine at /usr/bin

In the Tool Collection Family: dropdown, select GNU

In the Tool Collection Name: field, enter Arduino. Click OK when done

The various commands will be populated with the standard GNU toolkit commands. This is not what we want. Change them all to their avr equivalents: avr-gcc, avr-g++, avr-as, and avr-gdb. There is no avr-make, so leave it as the standard make. Feel free to clear the QMake Command: field.

Click the Code Assistance tab. Ensure the Tool Collection: dropdown has your Arduino toolchain selected and that the C Compiler tab is selected

Add arduino libraries. These are:

/usr/share/arduino/hardware/arduino/cores/arduino /usr/share/arduino/hardware/arduino/variants/[VARIANT] /usr/share/arduino/libraries

Click C++ Compiler. Add the same libraries as above

Click OK

The Plugin

For our plugin, we’ll be using arduino-netbeans by Jaques Claudino

Click the above link, and navigate to Downloads. Download the latest Linux plugin.

When the download is completed, return to NetBeans.

Click Tools -> Plugins and click the Downloaded tab

Click Add Plugins…

Browse to the location of the downloaded plugin, select it, and click OK

Click Install

Follow the wizard.

When prompted about an untrusted certificate, we might as well click Continue. After all, we are downloading software made by Some Guy, it’s not going to be signed by VeriSign or somesuch.

Click Finish when done.

Click Close.

Verify it works

Click File -> New Project…

Select Arduino and click Next >

Give your project a name, and click Finish.

First, open up the Makefile for your project, we have some changes to make

As the comments at the top of the Makefile say, we need to make some changes. First set COM_PORT to be the correct serial port.

Next Set ARDUINO_BASE_DIR to the correct installation path. For me, that is /usr/share/arduino

Next, uncomment the correct configuration. Since I am using an Uno, there is no change for me. However, if you have a different board, comment the Uno section and uncomment the correct board.

We should officially be set. In your main.cpp, implement the blink program. I recommend copying and pasting the one provided by Arduino IDE that we used previously. Be sure you don’t delete the #include and extern HardwareSerial Serial; lines.

When you are ready, click Clean and Build. Then click Run. If all is well, your onboard Pin 13 LED should blink.

%d bloggers like this: