how to: develop c/c++ on the beagleboard directly

1,426 views
Skip to first unread message

Brice Rebsamen

unread,
Feb 23, 2009, 3:02:09 AM2/23/09
to Beagle Board
It took me several days to get started with the beagleboard so I'm
posting here my findings. Hope it will be useful to somebody.

What I want is to use the beagleboard as a main board on my robot. And
I want to directly develop on the beagleboard not build an image using
open embedded. If you follow this guide, at the end you should be able
to connect via ssh to the beagleboard and remotely edit files, then
use a remote shell to compile and run them.


--------------------------------
Basic hardware setup
--------------------------------

This page has some nice information.
http://code.google.com/p/beagleboard/wiki/HowToGetAngstromRunning

Basically:
- power the board using 5V power supply or AC-DC converter, or from a
USB to barel converter and plug it to a computer.
- We want to use it as a mother board, so the USB-OTG socket must be
used as a host socket. For this, either plug in a mini-A type
connector (could not get one), or connect together pin 4 and 5 of the
socket and plug a regular mini USB cable (mini-B). Either solder them
together, add a jumper, or simply manually connect them using a
metallic pointer while the kernel is booting.
- Plug a USB hub in the OTG socket, and there plug in mouse and
keyboards and ethernet converter and everything you want. The hub
needs to be powered!



-----------------------------
Installing Angstrom
-----------------------------
Angstrom is a Linux based OS designed for embedded system and supports
ARM processors, including the one on the BeagleBoard.
The SD card must be formated in a special way (number of heads and
sectors, ...). Two partitions are required: one FAT32 which serves as
a boot partition, and an EXT3 partition which holds the linux root
file system (rootfs). This is because the boot loader in the NAND does
not support loading the kernel from and EXT3 partition.

Demo image from Koen
----------------------------------

Follow this tutorial:
http://code.google.com/p/beagleboard/wiki/HowToGetAngstromRunning
It includes where to find the files required, how to format the SD
card and place required files on it, how to update the boot loader and
how to configure it to automatically boot Angstrom (need to be done
only once).
This works fine and yields an OS with a nice GUI, and plenty of
applications: browsers (firefox and epiphany) games, multimedia
players...


Minimum system
--------------------------

The goal here is to get the minimum packages required to get the card
running with a command line OS with a working ethernet connection and
SSH server.

1) Get a base image from Narcissus
Narcissus is an online tool to build an Angstrom image from a selected
list of packages:
http://amethyst.openembedded.net/~koen/narcissus/
It produces 2 files: a .tar.bz2 archive containing the rootfs and
a .img.gz compressed image to be written to the SD card with dd. It
create the FAT and EXT3 partition and copy the necessary files in the
FAT partition. (however, the EXT3 partition needs to be recreated to
accomodate the size of the SD card.)
- In Narcissus: build a start image with the following packages: task-
base, “busybox replacement” (task-proper-tools) and “all
modules” (this adds support for the USB-Ethernet device).
- Download and install the images.
- boot and login as root. By default there is no password. You can set
one using command passwd.

2) Networking
Run udhcpc to setup the interface with DHCP (simply type udhcpc).
In order to ease development, and for situations when it's not
convenient to connect a monitor and a keyboard to the board, we want
to be able to connect to the beagleboard via SSH from the console and
alsa from the linux explorer (Nautilus, Konqueror, ...) and editors.
This allow to work on the files on the beagleboard from a linux
desktop.
I found that this does not work with the lightweight ssh server
installed by default (dropbear). So we will remove it and install
openssh instead. This is easily done using opkg, the package manager.
opkg update
opkg -force-removal-of-dependent-packages dropbear
opkg install openssh openssh-sftp-server
The first command get the list of packages from the repository. The
second command removes dropbear and the task-base metapackage that
depends on it. The third command installs openssh, openssh-scp,
libcrypto, openssh-ssh, openssh-sshd, ssh-keygen and openssh-sftp-
server.
It seems to be necessary to set a root password (use command passwd).
You might also want to configure your network / router so that the
board always get the same IP or so that you can find it by its
hostname.
Last but not least, we want the board to automatically set up and
configure the Ethernet interface at boot up. This is normally done in /
etc/network/interfaces by setting interface eth0 as auto and dhcp.
However it does not work in this case, most likely because the usb
driver + host mode setting seems to take too long and the /etc/init.d/
networking start script will fail with an unknown interface. So one
way is to create a boot up script that gets executed last:
- Create a /etc/init.d/run_udhcpc file and make it executable (chmod
+x run_udhcpc). It contains only one line: “udhcpc”.
- Type update-rc.d run_udhcpc defaults
- Reboot to test. After reboot, when you type ifconfig you should see
interface eth0 with an IP address.

3) Set date, time and time zone
Set the time zone in /etc/profile: find the line TZ=”UTC” and set it
to TZ=”SGT-8”
Then reload the file: source /etc/profile
Finally install packages to automatically get the time from a server:
opkg ntpdate




------------------------------------------------
C/C++ development environment
------------------------------------------------
The following command installs the whole C/C++ toolchain (compiler,
make, autoconf, ...)
opkg install task-native-sdk cpp gccmakedep
Try to compile a hello world example.

Brice Rebsamen

unread,
Feb 26, 2009, 11:13:01 PM2/26/09
to Beagle Board
I received that question. I post it here together with my answers for
future references



Q1:
I want to build a little blimp robot using the board and be able to
program directly on it [...] you were saying that you could program on
the beagle board without keyboard and screen...do you mean you have
the board connected to an other computer and you edit some file and
make them run on the board?

A1:
The board is connected to a LAN and I am developing from the a Linux
desktop connected to the same LAN. So the 2 computers can communicate.
In Linux, you can create a remote connection, which kind of behaves as
a folder, except that the files in that folders are located to another
machine (you can use various protocols..., I use SFTP).

So from that remote folder I can open the files and edit them just
like with regular files, except that it does not work with all
editors. It works with Kate and Gedit, for sure, but I think it does
not work with KDevelop (KDE's awesome IDE), and I don't know if it
works with Eclipse. And I have no idea about windows apps...

So, I can edit those remote files from my desktop. Then I open a
remote shell to the beagleboard, from which I can compile and run my
code. Of course it's only suitable for text programs... Apps with a
GUI won't work!




Q2:
in my case, i would like to be able to debug and see the state of
variable..(like in visual c++)...do you think this could be possible?

A2:
I debug with gdb on the remote shell. meaning that you'll have to
learn how to use it from a text interface. I have heard that there is
something called gdb server, I have no idea how it works, but my guess
is that it would allow you to run the server on the beagleboard, a
client on your desktop and do GUI based debugging. However I have
absolutely no idea, but might be worth investigating


Q3:
or using an image with a C/C++ IDE with a screen would be better?

A3:
Probably easier. In my case it's not easy: connecting a mouse, a
keyboad, a screen, to the robot is a pain because the board is buried
inside.



Brice



On Feb 23, 4:02 pm, Brice Rebsamen <brice.rebsa...@gmail.com> wrote:
> It took me several days to get started with the beagleboard so I'm
> posting here my findings. Hope it will be useful to somebody.
>
> What I want is to use the beagleboard as a main board on my robot. And
> I want to directly develop on the beagleboard not build an image using
> open embedded. If you follow this guide, at the end you should be able
> to connect via ssh to the beagleboard and remotely edit files, then
> use a remote shell to compile and run them.
>
> --------------------------------
> Basic hardware setup
> --------------------------------
>
> This page has some nice information.http://code.google.com/p/beagleboard/wiki/HowToGetAngstromRunning

Koen Kooi

unread,
Feb 27, 2009, 2:13:02 AM2/27/09
to beagl...@googlegroups.com

Op 27 feb 2009, om 05:13 heeft Brice Rebsamen het volgende geschreven:

> I have heard that there is
> something called gdb server, I have no idea how it works, but my guess
> is that it would allow you to run the server on the beagleboard, a
> client on your desktop and do GUI based debugging. However I have
> absolutely no idea, but might be worth investigating

With gdbserver you can use a copy of your rootfs, this time with
debugging symbols on your host to debug a rootfs without debugging
symbols on your target. That means you debug applications on devices
with small flash and low amoounts of ram.

regards,

Koen

PGP.sig

Brian Phelps

unread,
Feb 27, 2009, 11:36:29 AM2/27/09
to beagl...@googlegroups.com
Couldn't one mount the rootfs using sshfs or nfs rather than mount a copy?

Koen Kooi

unread,
Feb 27, 2009, 11:45:59 AM2/27/09
to beagl...@googlegroups.com

You could, but the gdbserver trick is for when your rootfs is too full
to install debugging symbols (e.g. 16MB of flash), or has too few RAM
to load the debuging symbols into RAM.

regards,

Koen

PGP.sig
Reply all
Reply to author
Forward
0 new messages