Aug 31

In the case of sshfs a folder from my development PC is mapped on top of a folder of the FB. Since this does not work, another option to use is NFS (Network File System). In this case a folder on the development PC is setup so it can be shared over the network and the FB will create a local mapping of the folder, similar like the share function in Windows.

First thing to do is setting up the development PC as an NFS server. In order to do so edit /etc/exports as a minimum. To build in more security, also /etc/hosts.allow and /etc/hosts.deny can be edited, but for testing if it works I only work with /etc/exports.

In a terminal give the command sudo gedit /etc/exports, after entering your password add the following statement at the end of the file:

/home/jan/FOXBoard 10.0.0.151(rw) 10.0.0.180(rw)

This will give my second development PC (at 10.0.0.151) and the FB (at 10.0.0.180) read and write access to the folder /home/jan/FOXBoard on my main development PC (10.0.0.157). Save and close the file, than for nfsd to re-read the file using the exportfs -ra command.

On the second development PC (10.0.0.151) I want to map the remote folder in /mnt/Remote. For this the folder Remote needs to be created using the command sudo mkdit /mnt/Remote

The mapping of the remote folder is done using the sudo mount 10.0.0.157:/home/jan/FOXBoard /mnt/Remote command. Indeed, when listing the content of the /mnt/Remote folder I see the different hello world applications.

To unmount the folder, first leave the Remote folder and type the command umount /mnt/Remote (it is indeed umount and not unmount).

Now let’s see if this also works on the FB. Using ssh a sesion is started, in the folder /mnt there are already several folders (0, 1, 2, 3 and flash). They are all read-only except the flash folder, so create the folder in the flash location using the mkdir /mnt/flash/Remote command. Next the mapping command mount 10.0.0.157:/home/jan/FOXBoard /mnt/flash/Remote is entered. Several errors are listed, the most important one is mount: 10.0.0.157:/home/jan/FOXBoard failed, reason given by server: Permission denied

Some Googleing shows a command to verify if nfs is available by viewing filesystems file in the folder /proc (cat /proc/filesystems). This should contain a line with nfs in it. On the development PC this is the case (nfs and nfs4). On the FB however there is no nfs entry.

Damm.

Aug 26

In order to have easier access to the file system of the FB I want to map the internal flash drive to a folder on my Ubuntu PC. Some Googleing later I found the command sshfs which is basically nothing else than mapping a remote folder to a local folder using ssh as the underlying channel.

The internal flash of the FB is available in the folder /mnt/flash, this folder should be mapped on /home/jan/FOXBoard. In order to do so the command should be:

sshfs root@10.0.0.180:/mnt/flash /home/jan/FOXBoard

After pressing enter the password for root access on the FOXBoard is requested, typing pass and enter results in a second delay after which the message remote host has disconnected is displayed. Tripple checking the command does not show any error, it might be that the FB does not support the command.

In order to verify if the command is indeed 100% correct I will take some drastic measures: install Ubuntu on my Windows XP machine. Not by replacing Windows but installing it next to Windows as a dual boot system. This sounds complex but it is fully taken care of by the installation CD of Ubuntu. After inserting the CD and restarting this is one of the options in the installation menu. After installing and restarting the PC option 1 is Windows XP and option 2 is Ubuntu. Ubuntu is selected and all packages are installed so that in theory I have a same setup as on the mini ITX system that only holds Ubuntu.

The second Ubuntu PC is available at 10.0.0.151, after creating a folder /home/jan/Remote on this PC below command is executed:

sshfs jan@10.0.0.151:/home/jan/Remote /home/jan/FOXBoard

Also here the password is requested and after providing it no message is displayed other than the normal prompt. Copying the hello_host application on the ITX to the /home/jan/FOXBoard folder works, switching to the second Ubuntu PC indeed shows the file is available in /home/jan/Remote. It can be executed and deleted, after deleting the ITX indeed shows its gone aswell. Closing the mapping is done using the fusermount -u /home/jan/Remote.

So apparently the command was correct and the FB does not support sshfs.

Aug 21

In order to compile a program for the FB perhaps the best thing to do is going back to the basics and use command line tools to compile, execute and debug a small program. This will help to learn more about the tools used before setting up the environment in Anjuta.

Start a terminal and create a folder in the user folder, in my case /home/jan/ type the command mkdir FOXBoard, cd FOXBoard, mkdir HelloWorld and cd HelloWorld. Type the command gedit main.c in order to create the program, this will lauch a simple text editor in which below program can be copied.

#include <stdio.h>
int main()
{
printf(“Hello world\n”);
return (0);
}

Press the save button and close gedit, this will get you back to the terminal window. In order to compile this for the host (your computer) type gcc -o hello_host main.c, the executable created can be executed using the ./hello_host command.

In order to make sure gcc-cris is installed, type  /usr/local/cris/bin/gcc-cris –version (so minus minus version), this should respond something like cris-axis-elf-gcc (GCC) 3.2.1 Axis release R64/1.64. In order to prevent typing the whole path everytime you want to compile something the location can be added to the PATH variable of Linux. In order to do so navigate to the /usr folder and execute the command sudo gedit profile. Check if in this file if the PATH variable is already set. If so, add the paths /usr/local/cris:usr/local/gdb-cris to the PATH decleration. If not, add at the end of the file below two lines of code:

PATH=$PATH:/usr/local/cris:usr/local/gdb-cris
export PATH

Safe the file and reboot Linux to set the new PATH variable. In order to verify if indeed the path has changed run the command echo $PATH. Both folders should now be added. A second check is to execute the command gcc-cris –version in the folder of the source code. It should respond with the version of the compiler like explained above.

To compile the program for the FB, type the command gcc-cris -mlinux -o hello_target main.c, this will generate the executable hello_target. In order to copy this to the FB type the scp hello_target root@10.0.0.180:/mnt/flash command, after providing the password pass the file is securly copied. Start a secure shell to the FB using ssh -l root 10.0.0.180 and typing the password pass. Navigate to the folder /mnt/flash and verify if the hello_target program is indeed copied with the ls command. When available, execute the program using ./hello_target.

Perfect, the first program is running on the FOXBoard.

Aug 15

After a discussion with the experts at work and the comments of my brother it seems there is a better way to communicate with the FB than Telnet as advised by ACME. This is called ssh which stands for Secure Shell, in short an encrypted version of Telnet. As found by the port scan port 22 is open for the ssh connection.

Since I did not power off the FB the IP address is still at 10.0.0.180, the ping 10.0.0.180 command in a terminal verifies that the FB is still alive. In that same terminal window, type the command ssh 10.0.0.180. A warning will follow that “The authenticity of host ‘10.0.0.180 (10.0.0.180)’ can’t be established.” and you will be prompted to type yes or no. Please take this literally, a simple y will be rewarded with “Please type ‘yes’ or ‘no'”. Next enter the password which should be pass, the FB responds with “Permission denied, please try again.”. Nice.

Some googeling later it seems that on some board the pass word can be acme. Also this try results in “Permission denied, please try again.”. Nice again.

In the comment of my brother he states it should be ssh @10.0.0.180, sorry brother, this also does not work but it reveals the help text of how to use ssh. One parameters is -l that allows you to provide a login name. Watching the prompt more closely it states “jan@10.0.0.180’s password:”. Since I’m pretty sure I did not tell the FB my name yet this looks suspicious. I’m logged on to the Ubuntu PC as jan, I guess that is were the FB got my name from.

On the FB there is only one account: root. Typing the command ssh -l root 10.0.0.180 prompts for the password of root, typing pass now indeed gives me access. I’m in, now using the front door…

In the folder /etc/conf.d the file net.eth0 is available, the less command is not available on the FB to list the contents of the file. The less advanced command cat is so cat net.eth0 shows the contents. The last lines indeed state that the IP address after reboot is 192.168.0.96, so this must be changed.

Pressing the TAB key twice in a terminal window normally lists all available commands. On the FB however this lists all files in the current directory. In order to find out which kind of editor is available on the FB type the command ls /bin /sbin. There is a tool available called easyedit,in order to edit the file net.eth0 type the command easyedit net.eth0. This is a very nice small editor,in order to popup the menu press the ESC key and type the letter of your menu choice.

The last 4 lines are changed into:

IP=”10.0.0.180″
NETMASK=”255.255.255.0″
BROADCAST=”10.0.0.255″
GATEWAY=”10.0.0.138″

This will fix the IP address to 10.0.0.180, another option is to make use of the DHCP server in order to assign an IP address based on it’s MAC address. In order to do this, change the line BOOTPROTO=”none” into BOOTPROTO=”dhcp”. It does not hurt to assign the static IP address as well, when the DHCP server is down it uses these IP addresses than by default.

After saving the file and exiting easyedit type the command ifconfig eth0, this will list all ethernet settings inclusing the MAC address of the FB, in my case 00:40:8C:CD:00:00. In the DHCP server this MAC address needs to be used for assigning the IP address 10.0.0.180. My DHCP server also has a DNS (Dynamic Name Server) allowing me to assign the name FOXBoard to 10.0.0.180. In this case I don’t have to remember the IP addresses of all my other devices but I can simply use logical names in stead of the IP addresses.

Type the command reboot command to reboot the FB. Since the serial interface is still connected to my Windows PC I can see all boot messages that are send by the FB. Indeed, the IP address listed matches the one I just entered. After about 5 seconds the messages stop, typing the ping 10.0.0.180 (or in my case ping FOXBoard) command in the Ubuntu terminal shows a proper response; the FB is now part of my network.

Aug 14

The FOX board LX832 (hereafter FB) from ACME requires a 5V power supply capable of providing at least 280mA. There are several ways to connect the 5V, I’m using a 4 wire power cable from a floppy drive were only the outer 2 wires need to be connected to a power supply (the red and black wire closes to the red).

The Ethernet port is connected to my 100 Mbit LAN using a normal network cable. The documentation indicates that the default IP address is 192.168.0.90 or 192.168.0.96, this will be a problem since my whole network uses 10.0.0.xxx as addresses. In order to change the IP address of the FB a small network is setup using a 4 port switch that connects to the FB and a Windows PC (sorry). On the PC the IP address is made static and set to 192.168.0.94, after accepting the change and starting a DOS prompt window a PING 192.168.0.90 command does not show any response. Trying the second address using a PING 192.168.0.96 indeed gives a reply and the orange LED on the FB lights during this process.

Using the Telnet server that is available on the FB the command TELNET 192.168.0.96 should start a session, however the response is: Could not open the connection to the host on port 23: connect failed. Since the PING command works I’m sure all wiring is OK. Another way to access the FB is using the build in web-server. Using Internet Explorer and typing http://192.168.0.96 indeed shows the pre-loaded website on the FB.

The third option to get access is using the ftp 192.168.0.96 command in the DOS prompt. This prompts for an user name (type root) and than for a password (type pass). Also here access is granted and the ftp prompt appears. In order to exit, type quit and it returns to the DOS prompt.

As a last resort the FB has a serial port, when ordering the board I included the 3.3V to RS232 serial converter which will be needed in order to connect it to a PC. There is no header soldered on the FB in order to connect the converter but this is easily done using a 6 pins 0.1″ header strip to it. The converter needs to be placed up-side-down on the header strip; the components of the converter board face the components of the FB. A standard 9 pins female-to-mail serial cable can be used to connect the converter to a COM-port of the PC.

Using the Serial Port Terminal application that can be installed in Ubuntu by selecting it in the Applications | Add/Remove… menu a new connection is started using the /dev/ttyS0 serial port, 115200bps, no parity, 8 databits, 1 stopbit and no flow control. After pressing enter a # prompt appears. Typing the ls command shows the current location and content. I’m in…

In order to change the IP address temporally, type the command ifconfig eth0 10.0.0.180. The FB is disconnected from the local network setup and connected back the my LAN. In a terminal in Ubuntu type the command ping 10.0.0.180 and indeed the FB now responds.Ubuntu has a nice tools called Port Scan that is part of the program System | Administration | Network Tools. Executing the port scan on IP address 10.0.0.180 reveals that there are 4 ports open on the FB:

  • Port 21 for ftp
  • Port 22 for ssh
  • Port 80 for www
  • Port 443 for https

So this explains why the Telnet connection will not work, port 23 is not open.

Aug 13

After being able to compile, debug and execute a C-program for Ubuntu now it is time to repeat this process for the FOX board from ACME. The development environment (compiler/debugger) is already installed so let’s follow the instructions on the developer site from AXIS.

Open a terminal window and navigate to the folder containing the main.c file of the foobar-sample program. In order to compile the program and create an executable called hello_host type the command:

gcc -o hello_host main.c

This compiles the program using the GCC that generates executable for the processor of the computer currently used. In order to execute the program type ./hello_host and press enter.

Next step is to compile is for the target platform. The gcc-cris compiler has been installed, in order to call it from a different location that it is installed in the path to the compiler must be added to the PATH environment variable from Linux. Typing the ECHO $PATH command shows the current PATH variable, at this moment it might contain the path to /usr/local/cris but after a reboot this might be gone.

In order to add this permanent to the PATH variable, enter the command sudo gedit /etc/profile and check if the PATH variable is somewere set in this file. If so, add :/usr/local/cris at the end of the path definition. If it does not exists, add below two lines at the end of the file:

  • PATH=$PATH:/usr/local/cris
  • export PATH

A reboot is required to make this effective, you can also type the two commands in a terminal windows to set them for the current session if you don’t want to reboot now.

Navigate again to the folder containing the main.c file of the foobar-sample program and type gcc-cris –version followed by enter. Indeed, the compiler states:

cris-axis-elf-gcc (GCC) 3.2.1 Axis release R64/1.64

Perfect. Next statements on the developer site are how to compile the program. Something about various libraries that can be used. In order to see which library needs to be used the FOX board needs to be connected. Since this is not the case yet, let’s try the dumb method:

gcc-cris -o hello_target main.c

A lot of warnings are displayed, apparently this is not the way to go. Time to connect the FOX board.

Aug 12

It has been a while since my last post, there were some commercial projects I had to work on. The good news is that it gave me time to think about the work done so far and how to proceed. Some of the conclusions are:

  • First make a simple snake model that uses wheels and moves in 2D only
  • Use standard servo’s and add a small micro controller to each servo to make it digital. As an interface between them and the brains use an existing industrial interface, for example a CAN interface.

The first point to learn step by step and prevent that half way the development it becomes some complex that I loose interest. The second one in order to standardize as much as possible so that parts of the design can be used for other robots as well.

But first the basics, I was able to compile a small program in Anjuta, compile and execute it. Next step is to see if a breakpoint can be set and debugging can start from that point onwards.

Start Anjuta and reload the Hello Word application (foobar sample) and modify the code as listed below:

#include <stdio.h>
int main()
{
printf(“Hello world\n”);
printf(“And again\n”);
return (0);
}

Place the cursor on the second printf statement and place a breakpoint on this line using the Debug | Add breakpoint… option in Anjuta; this places a red stop sign in front of the line. Use the Debug | Run target… option to start execution of the program. A program parameters dialog appears, you can check off the Stop at beginning option so that the program executes until the breakpoint just set.

After pressing the execute button and showing the terminal window only Hello world appears and the program finishes with a message that the reason “exited-normally”. This is not what I had in mind, but I realized (the break did me good) that since the second printf command is not executed it might be that the new program is not build automatically. Pressing F11 (or use the Build | Build menu option) takes care of this, now indeed the debugger stops at the second printf command and continuous to the next statement by pressing F6 (or use the Debug | Step over menu option).

Chapter 5 in the user manual (Help | User’s manual menu option) explains in great detail the options available during a debug session. It does not explain how to automatically build the program when the debug session is started. A quick search on the internet also does not give me the answer.

Anyone?