29
1070_0_Product_Manual - October 28, 2010 8:52 AM
C programs can be compiled on the PhidgetSBC itself, via the SSH interface, or off-board using a cross compiler.
Use of a cross compiler is not strictly documented here, but it is possible to build one from the buildroot distribution
available on our web site. When developing C applications on the PhidgetSBC, it is recommended that you log in
using the ‘user’ account instead of ‘root’.
If you need to log data from a custom application, you can either log directly to the application directory with the
size limits of the userspace in mind, or to /tmp if the data should be erased on reboot. Alternatively, you can use a
flash drive, which are mounted automatically at /media/usb(0-9) when plugged in.
Note that custom applications should not try to get user input, as stdin is closed before the application gets run.
GCC
The PhidgetSBC contains full GCC and associated build tools, as well as make and gdb for compiling C source. Use of
these is the same as on full linux, just keep in mind that there is no swap space and userspace is limited. Compiling
will also be slow for complicated programs. Simple programs are ideal for this environment.
The C library used is uClibc. For most uses this should be similar to full libc, just much smaller.Also, when compiling
a program that links with libphidget21.so, you need to add ‘-lphidget21 -ldl -lpthread -lm’ to the command line.
Otherwise, you will get segfaults.
Phidget Dictionary
Communication between a custom application on the PhidgetSBC and the outside world can be facilitated by using
the dictionary interface of the Phidget Webservice. The dictionary lets you set and listen for key/value pairs over
the network, and take action accordingly. This could be used to post data or listen for commands over the network,
while maintaining reliability and ultimate control on the PhidgetSBC itself in case of network failure.
See the Phidget Programming manual for its use in your language of choice.
SSH
The built-in SSH Server can be enabled to allow console access to the PhidgetSBC. By default, this server is disabled.
SSH access to the PhidgetSBC is enabled in the Network: Network configuration page on the PhidgetSBC. Projects
on the PhidgetSBC should be stored in the user home directory (/home/user). Enabling the server for the first time
can take several minutes as the encryption keys are generated.
Once SSH is enabled, connect to the PhidgetSBC using its hostname or IP address (e.g. ‘ssh user@phidgetsbc.
local’). You should login using the restricted ‘user’ account using the initial password set for the ‘root’ account. The
password for the user account can be changed any time either through the unrestricted root account or directly
through the user account. Files can be sent to the board using scp or by uploading through the web interface in
Userspace: Userspace Browser. The SSH server does not support sftp.
Text files (source code, etc.) can be edited using vi or with the web interface.
On Windows, we recommend Putty for an SSH client. You can get this at http://www.chiark.greenend.org.
uk/~sgtatham/putty/download.html.
Customization
If you wish to customize the root filesystem, you have two options: customize locally on the board, or build a
custom kernel and filesystem from source. If you mess up the firmware while customizing, you can always perform a
board reset and start again.
You may also want to to add new libraries or kernel extensions, add new Unix tools, update certain aspects, delete
others, change the boot process, etc. All of this is possible, but it is also completely unsupported by Phidgets.
In order to customize the root file system of a running PhidgetSBC, you will need to remount the filesystem as read-
write with the command: ‘mount -o remount,rw /’. At this point you can change any files in /, just keep in mind the
amount of free space. Once the SBC is rebooted, / will again be mounted as read-only.