Jump to content

Boa5200 HOWTO: Difference between revisions

From HW wiki
Molnam1 (talk | contribs)
Molnam1 (talk | contribs)
Line 235: Line 235:
==Socketcan==
==Socketcan==


Prior to compiling linux kernel with socketcan driver, it is necessary to [[Applying kernel patches apply patches]] , which can be found in [http://rtime.felk.cvut.cz/repos/boa5200-linux/patches/ DARCS repository]
Prior to compiling linux kernel with socketcan driver, it is necessary to [[apply patches]] , which can be found in [http://rtime.felk.cvut.cz/repos/boa5200-linux/patches/ DARCS repository]


To set up can interface, it is necessary to configure the communication speed first and then bring the interface up. Communication speed can be set up using following command (for can0 interface):
To set up can interface, it is necessary to configure the communication speed first and then bring the interface up. Communication speed can be set up using following command (for can0 interface):

Revision as of 10:46, 3 September 2007

Introduction

This document describes how to install and setup Linux and development environment for BOA5200 board. Assume that you have a development machine (your PC) that you use for development and building your applications which you consequently want to get running and test on BOA5200.

Serial line setting

The easiest way to communicate with the board ,when there is no OS and remote shell running on it, is over serial line. Recommended serial communication program is minicom. Setup minicom as follows:

Baud Rate – 38400

Bits - 8

Parity – N

Stop Bits - 1

Hardware Flow Control:- No

Software Flow Control:- No

After the setup you will see Redboot> command prompt. Here you can enter Redboot`s commands. Redboot is a simple boot manager bulit upon eCos real-time OS. For more details , see http://ecos.sourceware.org/ecos/docs-latest/redboot/redboot-guide.html.

DHCP server setup

Redboot supports BOOTP protocol which means that it is able to get network information(IP,netmask,gateway IP address,etc.) from DHCP server(provides BOOTP besides DHCP protocol). Install dhcp server (on debian: apt-get install dhcpd) on your development machine. Example of my dhcp configuration file /etc/dhcpd.conf:

# I have two ethernet interfaces: 
# eth0 - Internet
# eth1 - connection to BOA5200 (IP= 192.168.10.1)
# I do not want to progate infos to 147.32.0.0 subnetwork
subnet 147.32.0.0 netmask 255.255.0.0 {
}

# private subnetwork
subnet 192.168.10.0 netmask 255.255.255.0 {
 option broadcast-address 192.168.10.255;
 option routers 192.168.10.1;
 option subnet-mask 255.255.255.0;
 default-lease-time 600;
 max-lease-time 7200;

# settings for BOA5200
 host BOA5200 {
  hardware ethernet 00:08:f1:11:22:33;
  fixed-address 192.168.10.2;
 }
}


Start dhcp server and reboot the board. After booting it has assigned IP, netmask and gateway address:

+PHY0: AMD AM79C874
FEC eth0: 100Mb/Full Duplex
Ethernet eth0: MAC address 00:08:f1:11:22:33
IP: 192.168.10.2/255.255.255.0, Gateway: 192.168.10.1
Default server: 192.168.10.1

TFTP server setup

Redboot is able to load file from remote tftp server into memory. Tftp server is lanuched by inetd daemon when a new connection comes. Therefore add the following line into /etc/inetd.conf :

tftp            dgram   udp     wait    nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd

Default tftp root directory is /tftpboot. You can change it by calling in.tftpd with specified directory as a parameter.

Alternative way for Ubuntu based distro

1. Install tftpd and related packages.

sudo apt-get install xinetd tftpd tftp

2. Create /etc/xinetd.d/tftp and put this entry:

service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no
}

3. Make /tftpboot directory

sudo mkdir /tftpboot
sudo chmod -R 777 /tftpboot
sudo chown -R nobody /tftpboot

4. Start tftpd through xinetd

sudo /etc/init.d/xinetd start

see [Installing and setting TFTPD in Ubuntu]

Tool chain

Toolchain(gcc, ld, ...) for MPC5200 can be downloaded from ftp://rtime.felk.cvut.cz/MPC5200/gcc-powerpc-603e-linux-gnu-4.1.1-bin.tar.gz Unpack the archive:

cd /
tar xvzf gcc-powerpc-603e-linux-gnu-4.1.1-bin.tar.gz

You can also create a debian package from archive and then install the package:

alien --to-deb gcc-powerpc-603e-linux-gnu-4.1.1-bin.tar.gz

Note: If you are not root, use fakeroot to run the command.

Applying kernel patches

It is recommended to use quilt tool to manage series of patches.

Mini-Howto:

Assuming kernel sources are in directory /usr/src/linux.

1. cd /usr/src/linux

2. mkdir patches

3. Copy all patches you want to apply to patches subdirectory

4. Create series file in patches subdirectory and write names of patch files each on separate line. The order the patches are stated in the file is significant!! The patch on the first line will be applied first followed by others.

4. quilt push (quilt pop) - applies (unapplies) all patches in series file

Building kernel

2.4 kernel sources for MPC5200 can be found in eCos_Linux_boa5200/tgz directory on BOARD DOCUMENTATION CD or from ftp://rtime.felk.cvut.cz/MPC5200/kernel_2.4/linuxppc-2.4-boa5200-release_2006_05_10.tgz.

2.6 Kernel sources for MPC5200 can be downloaded from ftp://rtime.felk.cvut.cz/MPC5200/linuxppc-2.6.18-1_AM.tar.gz. Default kernel configuration file is ftp://rtime.felk.cvut.cz/MPC5200/config-2.6.18-1_AM. Do not forget to set ARCH and CROSS_COMPILE variables to this values in Makefile:

ARCH=ppc
CROSS_COMPILE=powerpc-603e-linux-gnu-

After compilation a built image is placed into arch/ppc/boot/image directory.

The following commnad will install modules into <directory>/lib/modules/...

make INSTALL_MOD_PATH=<directory> modules_install   

Recommendation:

1. Make the building directory linuxppc-2.6.18-1_AM_build, where object files will be placed, outside the origin source directory linuxppc-2.6.18-1_AM

mkdir linuxppc-2.6.18-1_AM_build

2.

cd linuxppc-2.6.18-1_AM 

linuxppc-2.6.18-1_AM directory must be clean i.e. no make, make menuconfig executed from this directory before!

3.

make O=../linuxppc-2.6.18-1_AM_build menuconfig  

kernel config file (.config) will be created in linuxppc-2.6.18-1_AM_build

Next time, always run make menuconfig always from the building directory, i.e. linuxppc-2.6.18-1_AM_build

4.

cd linuxppc-2.6.18-1_AM_build

5. Download ftp://rtime.felk.cvut.cz/MPC5200/GNUmakefile

6. Edit GNUmakefile and change paths in KERNELSRC and KERNELOUTPUT variables

7.

make && make modules_install

Loading kernel

You can test your new image on the board as follows:

# load kernel image from tftp server into memory
  RedBoot> load zImage.elf

# execute image; root directory (/) is on flash memory
  RedBoot> exec

If you want to load the kernel from different TFTP server than the one provided by DHCP, you can use the following command to set the IP address of your server:

  RedBoot> ip_address -h 147.32.86.<xxx>

CAUTION: you must boot the kernel by RedBoot release at least 2007_02_01 otherwise it will not run! So you must load into RAM and then run the appropriate RedBoot image (or replace/update its image on flash with the new one - see the next section) and after then you can execute kernel image.

Updating RedBoot

Download ftp://rtime.felk.cvut.cz/MPC5200/MPC5200-2007.02.01-redbootROMRAM.srec

# load RedBoot image from tftp server into memory at the address 0x100000
RedBoot>lo -b 0x100000 MPC5200-2007.02.01-redbootROMRAM.srec
# write image in flash memory
RedBoot>fi cr RedBoot
RedBoot>reset

If upgrade fails you can fallback to ROM Redboot image by typing 'A&M:'

NFS-root setup

During the development phase of application it must be tested many times. However, it is annoying to copy several application files to flash memory every time. The practical solution is to mount via NFS working directory or whole root directory from the point of OS running on the board.

You can download already prepared root directory from ftp://rtime.felk.cvut.cz/MPC5200/MPC5200_root_070321.tar.gz

To export /var/MPC5200_root directory via NFS add the following line to /etc/exports:

/var/MPC5200_root 192.168.10.0/255.255.255.0(rw,sync,no_root_squash)

Then run command 'exportfs -ra' so that the change take an effect.

If you want MPC5200 to be mount as root directory instead of that one in flash memory:

# load kernel image from tftp server into memory
 RedBoot> load zImage.elf
# execute kernel image with information where to 
# find root directory in parameter string
 RedBoot> ex -c "root=/dev/nfs rw nfsroot=192.168.10.1:/var/MPC5200_root ip=dhcp"

NOTE: exportfs is a part of knfs package for debian systems (ubuntu,...)

Login with telnet

telnet <ip address of boa>

Log in as root, ask me for the password. --Sojka 20:42, 21 March 2007 (CET)

Setting up BOA5200

Use 'fconfig' command (see http://ecos.sourceware.org/ecos/docs-latest/redboot/persistent-state-flash.html manual) to set up BOA5200 configuration. Recommended configuration:

Run script at boot: true
Boot script:
 load zImage.elf
 ex -c "root=/dev/nfs rw nfsroot=192.168.123.254:/var/MPC5200_root ip=dhcp"
Boot script timeout (1000ms resolution): 10 
Use BOOTP for network configuration: true
Default server IP address: IP address of your computer
FEC Network hardware address [MAC]: choose MAC address of the unit (example: 0x00:0x00:0x00:0x00:0x00:0x02)
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
Update RedBoot non-volatile configuration - continue (y/n)? y

Socketcan

Prior to compiling linux kernel with socketcan driver, it is necessary to apply patches , which can be found in DARCS repository

To set up can interface, it is necessary to configure the communication speed first and then bring the interface up. Communication speed can be set up using following command (for can0 interface):

echo 660000 >/sys/class/net/can0/can_baudrate

The constant 660000 was found experimentally, driver seems to calculate the transmission speed improperly. To bring up the can network interface, use the same command as with any other network interface, i.e.

ifconfig can0 up

The most comfortable way of setting up both can interfaces upon startup of system is to place following script to /etc/init.d/ (name it 'can', for example)

echo 660000 >/sys/class/net/can0/can_baudrate
echo 660000 >/sys/class/net/can1/can_baudrate
ifconfig can0 up
ifconfig can1 up