<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rtime.felk.cvut.cz/hw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spinkao</id>
	<title>HW wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://rtime.felk.cvut.cz/hw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spinkao"/>
	<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php/Special:Contributions/Spinkao"/>
	<updated>2026-05-23T01:32:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3721</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3721"/>
		<updated>2010-02-11T09:03:54Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Linux kernel */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Now you can choose the kernel revision you want to compile:&lt;br /&gt;
&lt;br /&gt;
 git branch -r # there you can see all branches available&lt;br /&gt;
 git checkout origin/shark/2.6.28.8 # choose the one you desire&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
The compiled image can be found in linux/_build/midam/arch/powerpc/boot&lt;br /&gt;
It is the file uImage. Copy it to your tftpboot directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3720</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3720"/>
		<updated>2010-02-11T09:03:18Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Linux kernel */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Now you can choose the kernel revision you want to compile:&lt;br /&gt;
&lt;br /&gt;
 git branch -r // there you can see all branches available&lt;br /&gt;
 git checkout origin/shark/2.6.28.8 // choose the one you desire&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
The compiled image can be found in linux/_build/midam/arch/powerpc/boot&lt;br /&gt;
It is the file uImage. Copy it to your tftpboot directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3719</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3719"/>
		<updated>2010-02-11T09:01:02Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Linux kernel */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Now you can choose the kernel revision you want to compile:&lt;br /&gt;
&lt;br /&gt;
 git branch -r // there you can see all branches available&lt;br /&gt;
 git checkout origin/shark/2.6.28.8 // choose the one you desire&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3718</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3718"/>
		<updated>2010-02-11T08:52:48Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* From U-Boot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3717</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3717"/>
		<updated>2010-02-11T08:50:23Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* SocketCan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
==== From U-Boot ====&lt;br /&gt;
&lt;br /&gt;
FIXME: This section needs some tuning. It works, but there are some problems.&lt;br /&gt;
&lt;br /&gt;
Note: There seem to be no problems, if you use correct erase block size, when creating the FS image, i.e. use -e 0x20000 instead of -e 0x10000 (Martin Zidek)&lt;br /&gt;
&lt;br /&gt;
Prepare filesystem image in a development machine and create the filesystem image:&lt;br /&gt;
 cd shark-root&lt;br /&gt;
 mkfs.jffs2 -o ../shark-jffs2.img -b -e 0x10000&lt;br /&gt;
 cp ../shark-jffs2.img /var/lib/tftpboot/ryu/&lt;br /&gt;
&lt;br /&gt;
Then flash the image using the following uboot commands:&lt;br /&gt;
 set fs_image ryu/shark-jffs2.img&lt;br /&gt;
 set update_filesystem &#039;dhcp; tftp 800000 ${fs_image}; erase fc400000 ffffffff; cp.b 800000 fc400000 ${filesize}&#039;&lt;br /&gt;
 run update_filesystem&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3716</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3716"/>
		<updated>2010-02-11T08:49:08Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* SocketCan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
 * Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
 * Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
 * CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
 * Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
 * Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
 * Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
==== From U-Boot ====&lt;br /&gt;
&lt;br /&gt;
FIXME: This section needs some tuning. It works, but there are some problems.&lt;br /&gt;
&lt;br /&gt;
Note: There seem to be no problems, if you use correct erase block size, when creating the FS image, i.e. use -e 0x20000 instead of -e 0x10000 (Martin Zidek)&lt;br /&gt;
&lt;br /&gt;
Prepare filesystem image in a development machine and create the filesystem image:&lt;br /&gt;
 cd shark-root&lt;br /&gt;
 mkfs.jffs2 -o ../shark-jffs2.img -b -e 0x10000&lt;br /&gt;
 cp ../shark-jffs2.img /var/lib/tftpboot/ryu/&lt;br /&gt;
&lt;br /&gt;
Then flash the image using the following uboot commands:&lt;br /&gt;
 set fs_image ryu/shark-jffs2.img&lt;br /&gt;
 set update_filesystem &#039;dhcp; tftp 800000 ${fs_image}; erase fc400000 ffffffff; cp.b 800000 fc400000 ${filesize}&#039;&lt;br /&gt;
 run update_filesystem&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3715</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3715"/>
		<updated>2010-02-11T08:48:31Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* SocketCan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
SocketCan is currently tested only with kernels 2.6.28 or lower. If you want to use Socket Can, it is currently recommended to use kernel 2.6.28. To enable SocketCan support, it is neccesary to run&lt;br /&gt;
&lt;br /&gt;
make menuconfig&lt;br /&gt;
&lt;br /&gt;
before building the kernel and set the following:&lt;br /&gt;
&lt;br /&gt;
Networking Support / CAN bus subsystem support (yes)&lt;br /&gt;
Raw CAN Protocol (raw access with CAN-ID filtering) (yes)&lt;br /&gt;
CAN Device Drivers / Virtual Local CAN Interface (vcan) (yes)&lt;br /&gt;
Prompt for platform CAN drivers with sysfs support (yes)&lt;br /&gt;
Support for a Freescale MSCAN based chips (yes)&lt;br /&gt;
Freescale MPC5200 onboard CAN controller (yes)&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Warning - the ip tool is not working properly yet!&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
==== From U-Boot ====&lt;br /&gt;
&lt;br /&gt;
FIXME: This section needs some tuning. It works, but there are some problems.&lt;br /&gt;
&lt;br /&gt;
Note: There seem to be no problems, if you use correct erase block size, when creating the FS image, i.e. use -e 0x20000 instead of -e 0x10000 (Martin Zidek)&lt;br /&gt;
&lt;br /&gt;
Prepare filesystem image in a development machine and create the filesystem image:&lt;br /&gt;
 cd shark-root&lt;br /&gt;
 mkfs.jffs2 -o ../shark-jffs2.img -b -e 0x10000&lt;br /&gt;
 cp ../shark-jffs2.img /var/lib/tftpboot/ryu/&lt;br /&gt;
&lt;br /&gt;
Then flash the image using the following uboot commands:&lt;br /&gt;
 set fs_image ryu/shark-jffs2.img&lt;br /&gt;
 set update_filesystem &#039;dhcp; tftp 800000 ${fs_image}; erase fc400000 ffffffff; cp.b 800000 fc400000 ${filesize}&#039;&lt;br /&gt;
 run update_filesystem&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3714</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3714"/>
		<updated>2010-02-11T08:43:23Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Boot loader */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to have u-Boot 1.3.2 or later, which is able to hand over flat device tree to the kernel. When older revision is present, it is necessary to upgrade. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
If the above commands fail, you have a new version of socketcan and you need to use ip tool to set bitrate. See bellow.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
=== Using ip tool ===&lt;br /&gt;
&lt;br /&gt;
TODO: How to compile IP tool for PowerPC&lt;br /&gt;
&lt;br /&gt;
 ip link set can0 type can bitrate 1000000&lt;br /&gt;
 ip link set can1 type can bitrate 1000000&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
==== From U-Boot ====&lt;br /&gt;
&lt;br /&gt;
FIXME: This section needs some tuning. It works, but there are some problems.&lt;br /&gt;
&lt;br /&gt;
Note: There seem to be no problems, if you use correct erase block size, when creating the FS image, i.e. use -e 0x20000 instead of -e 0x10000 (Martin Zidek)&lt;br /&gt;
&lt;br /&gt;
Prepare filesystem image in a development machine and create the filesystem image:&lt;br /&gt;
 cd shark-root&lt;br /&gt;
 mkfs.jffs2 -o ../shark-jffs2.img -b -e 0x10000&lt;br /&gt;
 cp ../shark-jffs2.img /var/lib/tftpboot/ryu/&lt;br /&gt;
&lt;br /&gt;
Then flash the image using the following uboot commands:&lt;br /&gt;
 set fs_image ryu/shark-jffs2.img&lt;br /&gt;
 set update_filesystem &#039;dhcp; tftp 800000 ${fs_image}; erase fc400000 ffffffff; cp.b 800000 fc400000 ${filesize}&#039;&lt;br /&gt;
 run update_filesystem&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3712</id>
		<title>MIDAM MPC5200 DB1</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=MIDAM_MPC5200_DB1&amp;diff=3712"/>
		<updated>2010-02-09T14:04:11Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Kernel from flash and root filesystem over NFS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:&lt;br /&gt;
&lt;br /&gt;
* Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),&lt;br /&gt;
* MPC5200 v1.1 2008/02 carrier board.&lt;br /&gt;
&lt;br /&gt;
Set #1 has s/n: &#039;&#039;&#039;008770&#039;&#039;&#039; and set #2 has s/n: &#039;&#039;&#039;008771&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* [[Media:SHARK_V1_1_DOC_CZ.pdf|SHARK_V1_1_DOC_CZ.pdf‎]]&lt;br /&gt;
* [[Media:SHARK_V1_0_linux_DOC_CZ.pdf|SHARK_V1_0_linux_DOC_CZ.pdf]]&lt;br /&gt;
&lt;br /&gt;
==Board overview==&lt;br /&gt;
&lt;br /&gt;
[[Image:Board overview.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Serial line (system console)==&lt;br /&gt;
&lt;br /&gt;
* Loader system console is attached to the ttyPSC0 port.&lt;br /&gt;
* The &#039;&#039;&#039;ttyPSC0 port is done in the LVTTL 3.3V logic&#039;&#039;&#039;, so appropriate 3.3V to RS-232 converter (e.g. [http://pdfserv.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232]) is required for the serial console.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Communication parameters:&#039;&#039;&#039;&lt;br /&gt;
* baud rate: 115200 bps&lt;br /&gt;
* bits: 8 bit&lt;br /&gt;
* stop bits: 1 bit&lt;br /&gt;
* Parity: none&lt;br /&gt;
* Flow control: none&lt;br /&gt;
&lt;br /&gt;
==Module memory map==&lt;br /&gt;
The MPC5200B is 32 bit CPU, so it has a 32 bit address space. It is able to address up to 4 294 967 295 B (0xFFFFFFFF) - 4096 MB. The Shark module has been equipped with &#039;&#039;&#039;128 MB&#039;&#039;&#039; DDR RAM and &#039;&#039;&#039;64 MB&#039;&#039;&#039; NOR flash memory.&lt;br /&gt;
* RAM chips: Samsung K4S511632D-UC(L)75, order: 32M x 16&lt;br /&gt;
* Address space &#039;&#039;&#039;BASE address&#039;&#039;&#039; is 0x00000000&lt;br /&gt;
* RAM is from 0x00000000 to 0x08000000 (128 MB)&lt;br /&gt;
&lt;br /&gt;
Flash memory is being mapped at the and of address space (from 3.9375 GB).&lt;br /&gt;
* &#039;&#039;&#039;Flash BASE address&#039;&#039;&#039; is 0xFC000000 (last address is 0xFFFFFFFF)&lt;br /&gt;
* Flash memory size is 0x04000000 (64 MB)&lt;br /&gt;
&lt;br /&gt;
There are three MTD partitions in the flash (defined in shark.dts). The flat device tree file syntax uses first address and length of the partition for its definition.&lt;br /&gt;
* u-Boot (1 MB) from 0x00000000 to 0x00100000, length 0x00100000&lt;br /&gt;
* kernel (3 MB) from 0x00100000 to 0x00400000, length 0x00300000&lt;br /&gt;
* &#039;&#039;&#039;file-system&#039;&#039;&#039; (56 MB) from 0x00400000 to 0x04000000, length 0x03C00000&lt;br /&gt;
All these addresses are offsets against Flash BASE.&lt;br /&gt;
&lt;br /&gt;
==Boot loader==&lt;br /&gt;
These boards are preinstalled with [http://www.denx.de/wiki/DULG/Manual Das u-Boot] boot loader.&lt;br /&gt;
Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;printenv [variable]&#039;&#039;&#039; - prints complete environment or only given variable.&lt;br /&gt;
*&#039;&#039;&#039;saveenv&#039;&#039;&#039; - commits whole environment in flash memory&lt;br /&gt;
&lt;br /&gt;
For running linux kernel &amp;gt;2.6.25 it&#039;s necessary to upgrade u-Boot to newer version, which is able to hand over flat device tree to the kernel. Binary of u-Boot can be downloaded here: [ftp://rtime.felk.cvut.cz/shark-mpc5200/u-boot.bin u-boot.bin].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;U-Boot upgrade howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the upgrade procedure it is necessary to proceed with utmost precaution, because &#039;&#039;&#039;there is no backup image&#039;&#039;&#039; of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn&#039;t possible without JTAG interface. So, you have been warned. In future builds of the u-Boot there should be a support for recovery image. Follow this commands to upgrade U-Boot&#039;s image in flash memory:&lt;br /&gt;
&lt;br /&gt;
 dhcp&lt;br /&gt;
 tftp 800000 u-boot.bin&lt;br /&gt;
 protect off fc000000 fc09ffff&lt;br /&gt;
 erase fc000000 fc09ffff&lt;br /&gt;
 cp.b 800000 fc000000 ${filesize}&lt;br /&gt;
 protect on fc000000 fc09ffff&lt;br /&gt;
&lt;br /&gt;
Now reboot and than commit new default environment:&lt;br /&gt;
&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
===How to access U-Boot environment variables from Linux ?===&lt;br /&gt;
The U-Boot environment variables is possible to read and write trough utilities ... TO DO&lt;br /&gt;
&lt;br /&gt;
==Cross-tool chain==&lt;br /&gt;
Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:&lt;br /&gt;
&lt;br /&gt;
 emerge -av crossdev&lt;br /&gt;
&lt;br /&gt;
Some dependencies may go before. Building of tool chain itself will take some time, so let&#039;s go to take some coffee.&lt;br /&gt;
&lt;br /&gt;
 crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
For Debian, you can use a [[Cross compilers|packages]] prepared by Pavel Píša.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
It is necessary to use patched Linux sources. We maintain them in our [[Git]] [http://rtime.felk.cvut.cz/gitweb/shark/linux.git repository]. You can clone it by:&lt;br /&gt;
 git clone git://rtime.felk.cvut.cz/shark/linux.git&lt;br /&gt;
&lt;br /&gt;
Note: See [[Linux sources]] for the description of the repository and patch management techniques we use.&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s begin with the kernel configuration and compilation. The following recipe can be used to compile the kernel out of source directory, which is helpful if you want to compile a single kernel version with several configurations.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;mkdir -p _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd _build/midam&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Copy the following code to GNUmakefile file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
VERSION = 2&lt;br /&gt;
PATCHLEVEL = 6&lt;br /&gt;
&lt;br /&gt;
KERNELSRC    := $(shell cd ../..; pwd)&lt;br /&gt;
KERNELOUTPUT := $(patsubst $(KERNELSRC)/%,%,$(shell pwd))&lt;br /&gt;
&lt;br /&gt;
KERNELRELEASE = $(shell cat include/config/kernel.release 2&amp;gt; /dev/null)&lt;br /&gt;
&lt;br /&gt;
MAKEFLAGS += --no-print-directory&lt;br /&gt;
&lt;br /&gt;
ARCH=powerpc&lt;br /&gt;
CROSS_COMPILE=powerpc-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
TFTPBOOT=/var/lib/tftpboot/ryu&lt;br /&gt;
&lt;br /&gt;
export INSTALL_MOD_PATH=$(KERNELSRC)/../MPC5200_root&lt;br /&gt;
&lt;br /&gt;
.PHONY: install all $(MAKECMDGOALS)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT)&lt;br /&gt;
&lt;br /&gt;
Makefile:;&lt;br /&gt;
&lt;br /&gt;
$(filter-out all Makefile,$(MAKECMDGOALS)) %/:&lt;br /&gt;
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make 52xx/midam_defconfig&amp;lt;/tt&amp;gt; # or use &amp;lt;tt&amp;gt;52xx/ryu_defconfig&amp;lt;/tt&amp;gt; for RYU board&lt;br /&gt;
* &amp;lt;tt&amp;gt;make menuconfig&amp;lt;/tt&amp;gt;    # if you need additional configuration&lt;br /&gt;
* &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; # start compilation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How to build the Flat Device Tree file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since kernel version 2.6.25 is description of the platform hardware provided trough the Flat Device Tree. Necessary sources are now part of the kernel sources. Appropriate image could be build with this command:&lt;br /&gt;
&lt;br /&gt;
 make ARCH=powerpc shark.dtb DTS_FLAGS=&amp;quot;-S65536&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If DTS_FLAGS parameter omitted than following error will occur, because there is not enough space in the file, where the u-Boot can store some additional data about buses timing, etc.:&lt;br /&gt;
&lt;br /&gt;
 WARNING: could not create /chosen FDT_ERR_NOSPACE.&lt;br /&gt;
 ERROR: /chosen node create failed - must RESET the board to recover.&lt;br /&gt;
&lt;br /&gt;
==Root file system==&lt;br /&gt;
&lt;br /&gt;
New root file system has been built for MIDAM MPC5200 board. It&#039;s based on:&lt;br /&gt;
* Vanilla linux kernel v2.6.26.5&lt;br /&gt;
* Busybox v1.12.1&lt;br /&gt;
* Dropbear v0.51&lt;br /&gt;
* thttpd v2.25b&lt;br /&gt;
&lt;br /&gt;
TODO: How to build a new root file system&lt;br /&gt;
&lt;br /&gt;
== TO DO - UnionFS for root FS in flash ==&lt;br /&gt;
&lt;br /&gt;
For long term usage is not really good to repeatedly overwrite block in the NOR flash chip, because memory cells are being punished. So it would be better to use jffs2 root FS only as RO file system and create RW tmpfs of same size. UnionFS than could be used to merge these two file systems and provide one RW file system. Changes in FS as a lock and log files can be made without permanent effect.&lt;br /&gt;
&lt;br /&gt;
==SocketCan==&lt;br /&gt;
&lt;br /&gt;
 make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m&lt;br /&gt;
&lt;br /&gt;
CAN subsystem init script:&lt;br /&gt;
&lt;br /&gt;
 modprobe can&lt;br /&gt;
 modprobe mscan-mpc52xx&lt;br /&gt;
 modprobe can-raw&lt;br /&gt;
&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can0/can_bittiming/bitrate&lt;br /&gt;
 echo 1000000 &amp;gt; /sys/class/net/can1/can_bittiming/bitrate&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
Test the setup:&lt;br /&gt;
&lt;br /&gt;
 cansend can0 123#4567&lt;br /&gt;
&lt;br /&gt;
== GPIO how set pin value ==&lt;br /&gt;
In MPC5200 have two kind of GPIO. The first one have wakeup capability, the second one is standard GPIO pins. Each of this sets have its own register sets, so some PSC ports are splitted in to two parts. See MOC5200B documentation section 7.3.2.1 and 7.3.2.2. The availability GPIO of PSC depends on GPS Port Configuration Register settings. For RYU boards is available all GPIO in PSC3 port (HW notation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO: kernel still fails to initialise GPIO drivers on our boards !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 cat /sys/class/gpio/gpiochip248/label    //todo&lt;br /&gt;
&lt;br /&gt;
=== Setting GPIO with wakeup capability ===&lt;br /&gt;
GPIO with wakeup using &lt;br /&gt;
 /sys/class/gpio/gpiochip248/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
  0 -&amp;gt; GPIO_WKUP_7&lt;br /&gt;
  1 -&amp;gt; GPIO_WKUP_6&lt;br /&gt;
  2 -&amp;gt; PSC6_1&lt;br /&gt;
  3 -&amp;gt; PSC6_0&lt;br /&gt;
  4 -&amp;gt; ETH_17&lt;br /&gt;
  5 -&amp;gt; PSC3_9&lt;br /&gt;
  6 -&amp;gt; PSC2_4&lt;br /&gt;
  7 -&amp;gt; PSC1_4&lt;br /&gt;
&lt;br /&gt;
Final value is 248 + requested pin  (example for PSC2_4 248+6 =&amp;gt; 254)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting standard GPIO  not tested ===&lt;br /&gt;
Standard GPIO using &lt;br /&gt;
 /sys/class/gpio/gpiochip216/&lt;br /&gt;
&lt;br /&gt;
Pin notation:&lt;br /&gt;
 0..1  &amp;gt; reserved&lt;br /&gt;
 2..3  &amp;gt; IRDA&lt;br /&gt;
 4..7  &amp;gt; ETHR&lt;br /&gt;
 8..11 &amp;gt; reserved&lt;br /&gt;
 12..15 &amp;gt; USB&lt;br /&gt;
 16..17 &amp;gt; reserved&lt;br /&gt;
 18..23 &amp;gt; PSC3&lt;br /&gt;
 24..27 &amp;gt; PSC2&lt;br /&gt;
 28..31 &amp;gt; PSC1 &lt;br /&gt;
&lt;br /&gt;
Final value is 216 + requested pin  (example for PSC3_3 216+20 =&amp;gt; 236)&lt;br /&gt;
&lt;br /&gt;
Enable PIN for GPIO:&lt;br /&gt;
 echo 236 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
Set GPIO as output or input&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
 echo in &amp;gt;/sys/class/gpio/gpio236/direction&lt;br /&gt;
Set GPIO to 0 or 1 if configured as output pin&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio236/value&lt;br /&gt;
&lt;br /&gt;
== RS485/RS422 selection on PSC1 ==&lt;br /&gt;
&lt;br /&gt;
In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.&lt;br /&gt;
 &lt;br /&gt;
Pin configuration:&lt;br /&gt;
 echo 254 &amp;gt;/sys/class/gpio/export&lt;br /&gt;
 echo out &amp;gt;/sys/class/gpio/gpio254/direction&lt;br /&gt;
 &lt;br /&gt;
Run for RS485:&lt;br /&gt;
 echo 1 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
Run for RS422:&lt;br /&gt;
 echo 0 &amp;gt;/sys/class/gpio/gpio254/value&lt;br /&gt;
&lt;br /&gt;
== Linux boot possibilities ==&lt;br /&gt;
=== PIN configuration ===&lt;br /&gt;
Bootloader is responsible for pin configuration. This is done by writing to &#039;&#039;&#039;GPS Port Configuration Register&#039;&#039;&#039;. The value written there is set by:&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
&lt;br /&gt;
GPS Port Configuration Register values for our boards:&lt;br /&gt;
* original Midam board: 0x90552444&lt;br /&gt;
* RYU_EDU_midam v1.B: 0x91551044&lt;br /&gt;
&lt;br /&gt;
=== Kernel and root filesystem from flash ===&lt;br /&gt;
&lt;br /&gt;
This is the default boot command. If you want to quickly switch several boot combinations, you can store these commands to a variable and use run command to boot linux from flash quickly.&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_linux &#039;set bootargs ${linux_console} ${bootargs_flash}; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_linux&#039;&lt;br /&gt;
=== Kernel from flash and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set bootcmd_nfsroot &#039;set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000&#039;&lt;br /&gt;
 set bootargs_nfs &#039;root=/dev/nfs nfsroot=/midam rw ip=dhcp&#039;&lt;br /&gt;
 run bootcmd_nfsroot&lt;br /&gt;
&lt;br /&gt;
=== Kernel from TFTP and root filesystem over NFS===&lt;br /&gt;
&lt;br /&gt;
 set serverip 147.32.86.30&lt;br /&gt;
 set nfspath &amp;quot;/home/wsh/ppc/MPC5200/root-shark&amp;quot;&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 set bootcmd_tftpnfs &#039;dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000&#039;&lt;br /&gt;
 run bootcmd_tftpnfs&lt;br /&gt;
&lt;br /&gt;
=== Updating kernel image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
 set serverip 10.1.1.3&lt;br /&gt;
 set imagefile ryu/uImage&lt;br /&gt;
 set devicetreefile ryu/shark-ryu.dtb&lt;br /&gt;
 run update_kernel&lt;br /&gt;
&lt;br /&gt;
It is supposed that update_kernel is set to the following value&lt;br /&gt;
 set update_kernel &#039;dhcp; tftp 800000 ${imagefile}; erase fc100000 fc3fffff; cp.b 800000 fc120000 ${filesize}; tftp 800000 ${devicetreefile}; cp.b 800000 fc100000 ${filesize};&#039;&lt;br /&gt;
&lt;br /&gt;
=== Updating root filesystem image in flash memory ===&lt;br /&gt;
&lt;br /&gt;
==== From Linux with NFS root ====&lt;br /&gt;
Erase flash in U-Boot:&lt;br /&gt;
 erase fc400000 ffffffff&lt;br /&gt;
&lt;br /&gt;
Boot Linux with NFS root and run:&lt;br /&gt;
 mount -t jffs2 /dev/mtdblock2 /mnt&lt;br /&gt;
 cd /&lt;br /&gt;
 cp -a `ls | grep -v &#039;\(mnt\|proc\|sys\|tmp\)&#039;` /mnt&lt;br /&gt;
 cd /mnt; mkdir mnt proc sys tmp&lt;br /&gt;
&lt;br /&gt;
==== From U-Boot ====&lt;br /&gt;
&lt;br /&gt;
FIXME: This section needs some tuning. It works, but there are some problems.&lt;br /&gt;
&lt;br /&gt;
Note: There seem to be no problems, if you use correct erase block size, when creating the FS image, i.e. use -e 0x20000 instead of -e 0x10000 (Martin Zidek)&lt;br /&gt;
&lt;br /&gt;
Prepare filesystem image in a development machine and create the filesystem image:&lt;br /&gt;
 cd shark-root&lt;br /&gt;
 mkfs.jffs2 -o ../shark-jffs2.img -b -e 0x10000&lt;br /&gt;
 cp ../shark-jffs2.img /var/lib/tftpboot/ryu/&lt;br /&gt;
&lt;br /&gt;
Then flash the image using the following uboot commands:&lt;br /&gt;
 set fs_image ryu/shark-jffs2.img&lt;br /&gt;
 set update_filesystem &#039;dhcp; tftp 800000 ${fs_image}; erase fc400000 ffffffff; cp.b 800000 fc400000 ${filesize}&#039;&lt;br /&gt;
 run update_filesystem&lt;br /&gt;
&lt;br /&gt;
== Running RT kernel ==&lt;br /&gt;
&lt;br /&gt;
 cyclictest -p 80 -t5 -n&lt;br /&gt;
 0.93 0.68 0.28 1/51 562&lt;br /&gt;
&lt;br /&gt;
 T: 0 (  544) P:80 I:1000 C: 354314 Min:     16 Act:   76 Avg:   69 Max:     190&lt;br /&gt;
 T: 1 (  545) P:79 I:1500 C: 236209 Min:     17 Act:   35 Avg:   53 Max:     131&lt;br /&gt;
 T: 2 (  546) P:78 I:2000 C: 177157 Min:     21 Act:   46 Avg:   56 Max:     123&lt;br /&gt;
 T: 3 (  547) P:77 I:2500 C: 141726 Min:     21 Act:   41 Avg:   53 Max:     155&lt;br /&gt;
 T: 4 (  548) P:76 I:3000 C: 118105 Min:     23 Act:   30 Avg:   56 Max:     126&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Booting VxWorks ==&lt;br /&gt;
&lt;br /&gt;
 set ethaddr 00:04:9f:00:27:xx&lt;br /&gt;
 set psc_cfg 91551044&lt;br /&gt;
 set bootcmd_vxworks &#039;set serverip 147.32.87.33; dhcp; mw f0000b00 ${psc_cfg}; tftp 0x100000 vxworks/vxWorks-midam.bin; go 0x100000&#039;&lt;br /&gt;
 set bootcmd &#039;run bootcmd_vxworks&#039;&lt;br /&gt;
 saveenv&lt;br /&gt;
&lt;br /&gt;
Older tests:&lt;br /&gt;
 dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000&lt;br /&gt;
&lt;br /&gt;
=== Compiling VxWorks ===&lt;br /&gt;
&lt;br /&gt;
It is assumed that VxWorks in installed under &amp;lt;tt&amp;gt;/opt/WindRiver&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 /opt/WindRiver/wrenv.sh -p vxworks-6.6&lt;br /&gt;
 cd &amp;lt;bsp_project&amp;gt;&lt;br /&gt;
 make&lt;br /&gt;
 ... TODO ...&lt;br /&gt;
&lt;br /&gt;
== RTEMS Support ==&lt;br /&gt;
&lt;br /&gt;
MIDAM MPC5200 board is compatible with [http://www.rtems.org/ RTEMS] [http://www.rtems.org/wiki/index.php/Gen5200#IceCube IceCube] BSP.&lt;br /&gt;
&lt;br /&gt;
The PowerPC [[Cross compilers| cross-compiler]] tool-chain for RTEMS-4.9 branch for Debian Intel 32 and 64-bit hosts&lt;br /&gt;
can be installed from Rtime local DEB repository [ftp://rtime.felk.cvut.cz/debian/pool/rtems-4.9/].&lt;br /&gt;
&lt;br /&gt;
* Add APT source:&lt;br /&gt;
 echo deb ftp://rtime.felk.cvut.cz/debian unstable main  &amp;gt;/etc/apt/sources.list.d/rtime-debs.list&lt;br /&gt;
* Update list of available packages&lt;br /&gt;
 apt-get update&lt;br /&gt;
&lt;br /&gt;
Next packages can be installed from cross-dev section (e.g. using apt-get, aptitude or synaptic)&lt;br /&gt;
* binutils-powerpc-rtems4.9&lt;br /&gt;
* gcc-powerpc-rtems4.9&lt;br /&gt;
* rtems4.9-common&lt;br /&gt;
* rtems4.9-icecube&lt;br /&gt;
&lt;br /&gt;
The configurations used for above binutils, GCC and RTEMS BSP packages build are stored&lt;br /&gt;
in [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git local RTEMS development GIT repository]&lt;br /&gt;
in a [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-build/powerpc-rtems build directory for PowerPC architecture].&lt;br /&gt;
&lt;br /&gt;
The short cross-tools build recipe:&lt;br /&gt;
  git clone git://rtime.felk.cvut.cz/rtems-devel.git&lt;br /&gt;
  cd rtems-devel&lt;br /&gt;
  mkdir src&lt;br /&gt;
  cd src&lt;br /&gt;
  tar -xjf path-to/gcc-4.3.4.tar.bz2&lt;br /&gt;
  ln -s gcc-4.3.4 gcc&lt;br /&gt;
  tar -xjf path-to/binutils-2.20&lt;br /&gt;
  ln -s binutils-2.20 binutils&lt;br /&gt;
  tar -xzf path-to/newlib-1.16.0.tar.gz&lt;br /&gt;
  ln -s newlib-1.16.0 newlib&lt;br /&gt;
  cd gcc&lt;br /&gt;
  ln -s ../newlib/newlib .&lt;br /&gt;
  ln -s ../../gcc-patches/4.3.4 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../newlib&lt;br /&gt;
  ln -s ../../newlib-patches/newlib-1.16.0 patches&lt;br /&gt;
  quilt push -a&lt;br /&gt;
  cd ../..&lt;br /&gt;
  ln -s src/gcc src/binutils src/rtems .&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/binutils &amp;amp;&amp;amp; ./binutils-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/gcc &amp;amp;&amp;amp; ./gcc-powerpc-rtems.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
  ( cd rtems-build/powerpc-rtems/rtems-icecube &amp;amp;&amp;amp; ./rtems-mpc5200-sys.cfg &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install )&lt;br /&gt;
&lt;br /&gt;
Applications can be easily build by starting from&lt;br /&gt;
[http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/tree/HEAD:/rtems-omk-template RTEMS application template]&lt;br /&gt;
based on [http://rtime.felk.cvut.cz/omk OMK] rules: &lt;br /&gt;
  cd rtems-omk-template&lt;br /&gt;
  echo &amp;quot;RTEMS_MAKEFILE_PATH=/opt/rtems4.9/powerpc-rtems4.9/icecube&amp;quot; &amp;gt;config.target&lt;br /&gt;
  make default-config all&lt;br /&gt;
&lt;br /&gt;
Compiled application ELF images are located in _compiled/icecube/bin directory. The ELF file needs to be&lt;br /&gt;
be converted into U-boot image to be transferred and started on target board &lt;br /&gt;
 powerpc-rtems4.9-objcopy -R -S -O binary appfoo appfoo.bin&lt;br /&gt;
 cat appfoo.bin | gzip -9 &amp;gt;appfoo.gz&lt;br /&gt;
 mkimage -A ppc -O rtems -T kernel -a 0x00010000 -e 0x00010000 -n RTEMS -d appfoo.gz appfoo.img&lt;br /&gt;
&lt;br /&gt;
The image tranfer and boot sequence can be initiated from target board U-boot prompt &lt;br /&gt;
 mw f0000b00 ${psc_cfg}&lt;br /&gt;
 dhcp&lt;br /&gt;
 #set serverip 192.168.202.251&lt;br /&gt;
 tftp 1000000 appfoo.img&lt;br /&gt;
 bootm&lt;br /&gt;
&lt;br /&gt;
The [http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/HEAD:/rtems-build/powerpc-rtems/rtems-icecube/rtems-mpc5200-mkimg script rtems-mpc5200-mkimg]&lt;br /&gt;
to pack ELF file to U-boot image is part of development repository as well.&lt;br /&gt;
&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:MPC5200]]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=Boa5200_HOWTO&amp;diff=3364</id>
		<title>Boa5200 HOWTO</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=Boa5200_HOWTO&amp;diff=3364"/>
		<updated>2008-10-30T13:51:09Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Socketcan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
This document describes how to install and setup Linux and development environment for BOA5200  board. &lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Serial line setting==&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
Baud Rate – 38400&lt;br /&gt;
&lt;br /&gt;
Bits - 8&lt;br /&gt;
&lt;br /&gt;
Parity – N&lt;br /&gt;
&lt;br /&gt;
Stop Bits - 1&lt;br /&gt;
&lt;br /&gt;
Hardware Flow Control:- No&lt;br /&gt;
&lt;br /&gt;
Software Flow Control:- No&lt;br /&gt;
&lt;br /&gt;
After the setup you will see Redboot&amp;gt; command prompt. Here you can enter Redboot`s commands.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==DHCP server setup==&lt;br /&gt;
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:&lt;br /&gt;
 # I have two ethernet interfaces: &lt;br /&gt;
 # eth0 - Internet&lt;br /&gt;
 # eth1 - connection to BOA5200 (IP= 192.168.10.1)&lt;br /&gt;
 # I do not want to progate infos to 147.32.0.0 subnetwork&lt;br /&gt;
 subnet 147.32.0.0 netmask 255.255.0.0 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # private subnetwork&lt;br /&gt;
 subnet 192.168.10.0 netmask 255.255.255.0 {&lt;br /&gt;
  option broadcast-address 192.168.10.255;&lt;br /&gt;
  option routers 192.168.10.1;&lt;br /&gt;
  option subnet-mask 255.255.255.0;&lt;br /&gt;
  default-lease-time 600;&lt;br /&gt;
  max-lease-time 7200;&lt;br /&gt;
 &lt;br /&gt;
 # settings for BOA5200&lt;br /&gt;
  host BOA5200 {&lt;br /&gt;
   hardware ethernet 00:08:f1:11:22:33;&lt;br /&gt;
   fixed-address 192.168.10.2;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start dhcp server and reboot the board. After booting it has assigned IP, netmask and gateway address:&lt;br /&gt;
 +PHY0: AMD AM79C874&lt;br /&gt;
 FEC eth0: 100Mb/Full Duplex&lt;br /&gt;
 Ethernet eth0: MAC address 00:08:f1:11:22:33&lt;br /&gt;
 IP: 192.168.10.2/255.255.255.0, Gateway: 192.168.10.1&lt;br /&gt;
 Default server: 192.168.10.1&lt;br /&gt;
&lt;br /&gt;
==TFTP server setup==&lt;br /&gt;
Redboot is able to load file from remote tftp server into memory. Tftp server is lanuched by inetd daemon when a new &lt;br /&gt;
connection comes. &lt;br /&gt;
Therefore add the following line into /etc/inetd.conf :&lt;br /&gt;
 tftp            dgram   udp     wait    nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd&lt;br /&gt;
&lt;br /&gt;
Default tftp root directory is /tftpboot. You can change it by calling in.tftpd with specified directory as a parameter.&lt;br /&gt;
&lt;br /&gt;
===Alternative way for Ubuntu based distro===&lt;br /&gt;
&lt;br /&gt;
1. Install tftpd and related packages.&lt;br /&gt;
 sudo apt-get install xinetd tftpd tftp&lt;br /&gt;
&lt;br /&gt;
2. Create /etc/xinetd.d/tftp and put this entry:&lt;br /&gt;
&lt;br /&gt;
 service tftp&lt;br /&gt;
 {&lt;br /&gt;
 protocol        = udp&lt;br /&gt;
 port            = 69&lt;br /&gt;
 socket_type     = dgram&lt;br /&gt;
 wait            = yes&lt;br /&gt;
 user            = nobody&lt;br /&gt;
 server          = /usr/sbin/in.tftpd&lt;br /&gt;
 server_args     = /tftpboot&lt;br /&gt;
 disable         = no&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Make /tftpboot directory&lt;br /&gt;
&lt;br /&gt;
 sudo mkdir /tftpboot&lt;br /&gt;
 sudo chmod -R 777 /tftpboot&lt;br /&gt;
 sudo chown -R nobody /tftpboot&lt;br /&gt;
&lt;br /&gt;
4. Start tftpd through xinetd&lt;br /&gt;
&lt;br /&gt;
 sudo /etc/init.d/xinetd start&lt;br /&gt;
&lt;br /&gt;
see [[http://www.example.com Installing and setting TFTPD in Ubuntu]]&lt;br /&gt;
&lt;br /&gt;
==Tool chain==&lt;br /&gt;
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&lt;br /&gt;
Unpack the archive:&lt;br /&gt;
&lt;br /&gt;
 cd /&lt;br /&gt;
 tar xvzf gcc-powerpc-603e-linux-gnu-4.1.1-bin.tar.gz&lt;br /&gt;
&lt;br /&gt;
You can also create a debian package from archive and then install the package:&lt;br /&gt;
 alien --to-deb gcc-powerpc-603e-linux-gnu-4.1.1-bin.tar.gz&lt;br /&gt;
Note: If you are not root, use fakeroot to run the command.&lt;br /&gt;
&lt;br /&gt;
==Getting the kernel==&lt;br /&gt;
&#039;&#039;&#039;2.4 kernel sources&#039;&#039;&#039; for MPC5200 can be found in &#039;&#039;eCos_Linux_boa5200/tgz&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2.6 Kernel sources from A&amp;amp;M&#039;&#039;&#039; for MPC5200 can be downloaded from ftp://rtime.felk.cvut.cz/MPC5200/linuxppc-2.6.18-1_AM.tar.gz.&lt;br /&gt;
Default kernel configuration file is ftp://rtime.felk.cvut.cz/MPC5200/config-2.6.18-1_AM.&lt;br /&gt;
&lt;br /&gt;
We recommend the vanilla 2.6.18 patched by patches from A&amp;amp;M and us. Patches can be downloaded from our [http://rtime.felk.cvut.cz/darcs/boa5200-linux Darcs repository] by&lt;br /&gt;
  darcs get http://rtime.felk.cvut.cz/repos/boa5200-linux/&lt;br /&gt;
Follow the next section to apply the downloaded patches.&lt;br /&gt;
&lt;br /&gt;
==Applying kernel patches==&lt;br /&gt;
It is recommended to use [http://linux.die.net/man/1/quilt quilt] tool to manage series of patches.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mini-Howto:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Assuming kernel sources are in directory /usr/src/linux.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;tt&amp;gt;cd /usr/src/linux&amp;lt;/tt&amp;gt;&lt;br /&gt;
# &amp;lt;tt&amp;gt;mkdir patches&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Copy all patches you want to apply to &#039;&#039;patches&#039;&#039; subdirectory&lt;br /&gt;
# Create &#039;&#039;series&#039;&#039; file in &#039;&#039;patches&#039;&#039; 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.&lt;br /&gt;
# &amp;lt;tt&amp;gt;quilt push&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;quilt pop&amp;lt;/tt&amp;gt;)  - applies (unapplies) one patch from &#039;&#039;series&#039;&#039; file.&amp;lt;br&amp;gt;To (un)apply all patches use &amp;lt;tt&amp;gt;quilt push -a&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;quilt pop -a&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
==Building kernel==&lt;br /&gt;
&lt;br /&gt;
Do not forget to set ARCH and CROSS_COMPILE variables to this values in Makefile:&lt;br /&gt;
 export ARCH=ppc&lt;br /&gt;
 export CROSS_COMPILE=powerpc-603e-linux-gnu-&lt;br /&gt;
&lt;br /&gt;
After compilation a built image is placed into arch/ppc/boot/image directory.&lt;br /&gt;
&lt;br /&gt;
The following commnad will install modules into &#039;&#039;&amp;lt;directory&amp;gt;&#039;&#039;/lib/modules/...&lt;br /&gt;
 make INSTALL_MOD_PATH=&#039;&#039;&amp;lt;directory&amp;gt;&#039;&#039; modules_install   &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Recommendation:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
 mkdir linuxppc-2.6.18-1_AM_build&lt;br /&gt;
&lt;br /&gt;
2. &lt;br /&gt;
 cd linuxppc-2.6.18-1_AM &lt;br /&gt;
linuxppc-2.6.18-1_AM directory must be clean i.e. no make, make menuconfig executed from this directory&lt;br /&gt;
before!&lt;br /&gt;
&lt;br /&gt;
3. &lt;br /&gt;
 make O=../linuxppc-2.6.18-1_AM_build menuconfig  &lt;br /&gt;
kernel config file (.config) will be created in   linuxppc-2.6.18-1_AM_build&lt;br /&gt;
&lt;br /&gt;
Next time, always run make menuconfig always from the building directory, i.e. linuxppc-2.6.18-1_AM_build&lt;br /&gt;
&lt;br /&gt;
4. &lt;br /&gt;
 cd linuxppc-2.6.18-1_AM_build&lt;br /&gt;
&lt;br /&gt;
5. &lt;br /&gt;
Download ftp://rtime.felk.cvut.cz/MPC5200/GNUmakefile&lt;br /&gt;
&lt;br /&gt;
6. &lt;br /&gt;
Edit GNUmakefile and change paths in KERNELSRC and KERNELOUTPUT variables&lt;br /&gt;
&lt;br /&gt;
7. &lt;br /&gt;
 make &amp;amp;&amp;amp; make modules_install&lt;br /&gt;
&lt;br /&gt;
If you often forget to switch to the build directory and run make in the source directory, put the following GNUmakefile into your source directory:&lt;br /&gt;
 ifeq ($(O),)&lt;br /&gt;
 $(error Please, run make in a different build directory (or use O= option))&lt;br /&gt;
 else&lt;br /&gt;
 include Makefile&lt;br /&gt;
 endif&lt;br /&gt;
&lt;br /&gt;
== Loading kernel ==&lt;br /&gt;
&lt;br /&gt;
You can test your new image on the board as follows:&lt;br /&gt;
 # load kernel image from tftp server into memory&lt;br /&gt;
   RedBoot&amp;gt; load zImage.elf&lt;br /&gt;
 &lt;br /&gt;
 # execute image; root directory (/) is on flash memory&lt;br /&gt;
   RedBoot&amp;gt; exec&lt;br /&gt;
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:&lt;br /&gt;
   RedBoot&amp;gt; ip_address -h 147.32.86.&amp;lt;xxx&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAUTION:&#039;&#039;&#039; 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  &lt;br /&gt;
the next section) and after then you can execute kernel image.&lt;br /&gt;
&lt;br /&gt;
To write the loaded kernel to FLASH memory, execute:&lt;br /&gt;
    RedBoot&amp;gt; fi cr Linux&lt;br /&gt;
&lt;br /&gt;
==Updating RedBoot==&lt;br /&gt;
&lt;br /&gt;
You need to update RedBoot in order to boot Linux 2.6 kernel.&lt;br /&gt;
&lt;br /&gt;
Download ftp://rtime.felk.cvut.cz/MPC5200/MPC5200-2007.02.01-redbootROMRAM.srec &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;!!! Warning: File names are case-sensitive !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 # load RedBoot image from tftp server into memory at the address 0x100000&lt;br /&gt;
 RedBoot&amp;gt;lo -b 0x100000 MPC5200-2007.02.01-redbootROMRAM.srec&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;!!! Warning: File names are case-sensitive !!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 # write image in flash memory&lt;br /&gt;
 RedBoot&amp;gt;fi cr RedBoot&lt;br /&gt;
 RedBoot&amp;gt;reset&lt;br /&gt;
&lt;br /&gt;
If upgrade fails you can fallback to ROM Redboot image by typing &#039;A&amp;amp;M:&#039;&lt;br /&gt;
&lt;br /&gt;
If image of ROMRAM version of RedBoot with name &amp;quot;RedBoot&amp;quot; (case sensitive!!) is not found in FLASH minimal version of ROM RedBoot is started. This version does not support many services like TFTP protocol and FLASH management. To download ROMRAM version of RedBoot to FLASH it is necessary to follow these steps:&lt;br /&gt;
&lt;br /&gt;
Load RAM version of RedBoot to BOA using xmodem (the image file MPC5200-2006.05.10-redbootRAM.srec is placed on BOA original CD):&lt;br /&gt;
 RedBoot&amp;gt; lo -m xmodem&lt;br /&gt;
&lt;br /&gt;
When finished RedBoot should answer with something like that:&lt;br /&gt;
&lt;br /&gt;
 CEntry point: 0x00080100, address range: 0x00080000-0x000bea04&lt;br /&gt;
 xyzModem - CRC mode, 5763(SOH)/0(STX)/0(CAN) packets, 1 retries&lt;br /&gt;
&lt;br /&gt;
Then start the RedBoot:&lt;br /&gt;
 RedBoot&amp;gt; go&lt;br /&gt;
&lt;br /&gt;
RAM RedBoot should start now. Download the new version of ROMRAM RedBoot to FLASH according to the steps above.&lt;br /&gt;
&lt;br /&gt;
==NFS-root setup==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
You can download already prepared root directory from ftp://rtime.felk.cvut.cz/MPC5200/MPC5200_root_070321.tar.gz&lt;br /&gt;
&lt;br /&gt;
To export /var/MPC5200_root directory on your PC via NFS add the following line to &#039;&#039;&#039;/etc/exports&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 /var/MPC5200_root 192.168.10.0/255.255.255.0(rw,sync,no_root_squash)&lt;br /&gt;
&lt;br /&gt;
Then run command &amp;quot;&#039;&#039;&#039;exportfs -ra&#039;&#039;&#039;&amp;quot; so that the change take an effect.&lt;br /&gt;
&lt;br /&gt;
If you want MPC5200 to be mount as root directory instead of that one in flash memory:&lt;br /&gt;
 # load kernel image from tftp server into memory&lt;br /&gt;
  RedBoot&amp;gt; load zImage.elf&lt;br /&gt;
 # execute kernel image with information where to &lt;br /&gt;
 # find root directory in parameter string&lt;br /&gt;
  RedBoot&amp;gt; ex -c &amp;quot;root=/dev/nfs rw nfsroot=192.168.10.1:/var/MPC5200_root ip=dhcp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To mount another directory from Boa use this command:&lt;br /&gt;
 mount -t nfs &amp;lt;ip&amp;gt;:/path/to/exported/dir /path/on/boa&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; exportfs is a part of knfs (Ubuntu) or nfs-kernel-server (Debian) package.&lt;br /&gt;
&lt;br /&gt;
== Login with telnet ==&lt;br /&gt;
 telnet &amp;lt;ip address of boa&amp;gt;&lt;br /&gt;
Log in as root, ask me for the password. --[[User:Sojka|Sojka]] 20:42, 21 March 2007 (CET)&lt;br /&gt;
==Setting up BOA5200==&lt;br /&gt;
&lt;br /&gt;
Use &#039;fconfig&#039; command (see http://ecos.sourceware.org/ecos/docs-latest/redboot/persistent-state-flash.html manual) to set up BOA5200 configuration. Recommended configuration:&lt;br /&gt;
&lt;br /&gt;
 Run script at boot: true&lt;br /&gt;
 Boot script:&lt;br /&gt;
  load zImage.elf&lt;br /&gt;
  ex -c &amp;quot;root=/dev/nfs rw nfsroot=192.168.123.254:/var/MPC5200_root ip=dhcp&amp;quot;&lt;br /&gt;
 Boot script timeout (1000ms resolution): 10 &lt;br /&gt;
 Use BOOTP for network configuration: true&lt;br /&gt;
 Default server IP address: IP address of your computer&lt;br /&gt;
 FEC Network hardware address [MAC]: choose MAC address of the unit (example: 0x00:0x00:0x00:0x00:0x00:0x02)&lt;br /&gt;
 GDB connection port: 9000&lt;br /&gt;
 Force console for special debug messages: false&lt;br /&gt;
 Network debug at boot time: false&lt;br /&gt;
 Update RedBoot non-volatile configuration - continue (y/n)? y&lt;br /&gt;
&lt;br /&gt;
==Socketcan==&lt;br /&gt;
&lt;br /&gt;
Prior to compiling linux kernel with socketcan driver, it is necessary to [http://rtime.felk.cvut.cz/hw/index.php/HOWTO#Applying_kernel_patches  apply kernel patches] , which can be found in [http://rtime.felk.cvut.cz/repos/boa5200-linux/patches/ DARCS repository]&lt;br /&gt;
&lt;br /&gt;
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 @ 1Mbit):&lt;br /&gt;
&lt;br /&gt;
 echo 660000 &amp;gt;/sys/class/net/can0/can_baudrate&lt;br /&gt;
&lt;br /&gt;
The constant 660000 for 1Mbit speed 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.&lt;br /&gt;
&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
&lt;br /&gt;
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 &#039;can&#039;, for example)&lt;br /&gt;
&lt;br /&gt;
 echo 660000 &amp;gt;/sys/class/net/can0/can_baudrate&lt;br /&gt;
 echo 660000 &amp;gt;/sys/class/net/can1/can_baudrate&lt;br /&gt;
 ifconfig can0 up&lt;br /&gt;
 ifconfig can1 up&lt;br /&gt;
&lt;br /&gt;
==CanFestival==&lt;br /&gt;
&lt;br /&gt;
===Obtaining and building CanFestival===&lt;br /&gt;
&lt;br /&gt;
CanFestival driver source can be downloaded from. The primary way how to do it is to check out the source directory from CanFestival CVS by these steps:&lt;br /&gt;
 cvs -d:pserver:anonymous@lolitech.dyndns.org:/canfestival login&lt;br /&gt;
 (type return, without entering a password)&lt;br /&gt;
The system will respond:&lt;br /&gt;
 Logging in to :pserver:anonymous@lolitech.dyndns.org:2401/canfestival&lt;br /&gt;
Then, enter:&lt;br /&gt;
 cvs -z3 -d:pserver:anonymous@lolitech.dyndns.org:/canfestival co -P CanFestival-3&lt;br /&gt;
Then insert CanFestival folder and run this commands:&lt;br /&gt;
 ./configure --timers=unix --can=socket --cc=powerpc-603e-linux-gnu-gcc --arch=ppc --os=linux --target=unix &lt;br /&gt;
 make&lt;br /&gt;
 make install&lt;br /&gt;
Building of CanFestival will produce some libraries and copy them to /usr/powerpc-603e-linux-gnu/lib folder.&lt;br /&gt;
&lt;br /&gt;
===Setting up local CANopen node===&lt;br /&gt;
&lt;br /&gt;
CanFestival source includes tool called &#039;&#039;objdictedit&#039;&#039;. This program has graphical user interface and serves to creating configuration of the CANopen node of application we develop. It is started by command &#039;&#039;objdictedit&#039;&#039;. Using this program you can create the object dictionary for the CanFestival. Mainly it is necessary to set up all SDO and PDO, the node has to send and receive. To each PDO you have to define more things - PDO receive or transmit, variable to be mapped and variable mapping. The variable will then be used in application code to exchange data between CanFestival driver and application. If you set up PDOs here they will be sent and received automatically and the values will be stored into mapped variable. Setting up SDO means that you can use it in your application, but if you want to send it, it has to be done in code.&lt;br /&gt;
After creating this basic configuration you have to build the dictionary which results into to files with extensions .h and .c. You have to link these files with your application.&lt;br /&gt;
&lt;br /&gt;
===Initializing and starting CanFestival===&lt;br /&gt;
&lt;br /&gt;
To explain how to use CanFestival I include some code examples. It supposes node configuration generated by &#039;&#039;objdictedit&#039;&#039; which name is &#039;&#039;canopen&#039;&#039;. It is then used as prefix of automatically generated functions and variables (&#039;&#039;canopen_Data&#039;&#039; is for example object dictionary used by CanFestival). &lt;br /&gt;
Header &#039;&#039;canfestival.h&#039;&#039; has to be included. For start using CanFestival it is necessary to load dynamic library with CAN bus driver API created while compiling CanFestival source. In the example SocketCan driver is used to access CAN bus. &lt;br /&gt;
 if(!LoadCanDriver(&amp;quot;libcanfestival_can_socket.so&amp;quot;)) {&lt;br /&gt;
 	exit -1;&lt;br /&gt;
 }&lt;br /&gt;
Then you have to open CAN device. Parameters of the communication have to be prepared in structure of type &#039;&#039;s_Board&#039;&#039;. In this case CAN is set to use device &#039;&#039;can1&#039;&#039; and baudrate 1Mbps. Handler of the bus is then stored to variable of type &#039;&#039;CAN_HANDLE&#039;&#039;.&lt;br /&gt;
 /**&lt;br /&gt;
  * CAN board definition.&lt;br /&gt;
  * Device name can1, baudrate 1M&lt;br /&gt;
  */&lt;br /&gt;
 s_BOARD canopen_board = {&amp;quot;1&amp;quot;, &amp;quot;1000&amp;quot;};&lt;br /&gt;
&lt;br /&gt;
 CAN_HANDLE canopen_handle;&lt;br /&gt;
 &lt;br /&gt;
 if(!(canopen_handle = canOpen(&amp;amp;canopen_board, &amp;amp;canopen_Data))) {&lt;br /&gt;
 	exit -1;&lt;br /&gt;
 }&lt;br /&gt;
CanFestival implements callbacks to some events like change of state or message reception. There are pointers to callback functions in &#039;&#039;canopen_Data&#039;&#039; structure. You can assign your own functions to these pointers or leave them unused.&lt;br /&gt;
 canopen_Data.initialisation = canopen_initialisation;&lt;br /&gt;
 canopen_Data.preOperational = canopen_preOperational; &lt;br /&gt;
 canopen_Data.operational = canopen_operational; &lt;br /&gt;
 canopen_Data.post_sync = canopen_post_sync; &lt;br /&gt;
 canopen_Data.post_TPDO = canopen_post_TPDO; &lt;br /&gt;
 canopen_Data.stopped = canopen_stopped; &lt;br /&gt;
After setting up these few things you have to call function &#039;&#039;StartTimerLoop&#039;&#039; which initializes CanFestival timers. As an argument you have to insert pointer to the first function you want to proceed after starting the timers. &lt;br /&gt;
 StartTimerLoop(&amp;amp;initNode); &lt;br /&gt;
Here is an example of such a function. It sets local node ID to 1 and bring the node to operation state. Callback functions are called after changing state if used.&lt;br /&gt;
 void initNode(CO_Data * d, UNS32 id)&lt;br /&gt;
 {&lt;br /&gt;
 	setNodeId(&amp;amp;canopen_Data, 0x01);&lt;br /&gt;
	setState(&amp;amp;canopen_Data, Initialisation);&lt;br /&gt;
	setState(&amp;amp;canopen_Data, Operational);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Stopping CanFestival===&lt;br /&gt;
&lt;br /&gt;
After finishing work with CANopen it is good to stop the communication and timers and close the device. It is done by these few functions.&lt;br /&gt;
 setState(&amp;amp;canopen_Data, Stopped);&lt;br /&gt;
 StopTimerLoop();&lt;br /&gt;
 canClose(&amp;amp;canopen_Data);&lt;br /&gt;
 canopen_handle = NULL;&lt;br /&gt;
&lt;br /&gt;
===Writing to Object dictionary===&lt;br /&gt;
&lt;br /&gt;
CANopen devices and all network services of each node are configured by writing to device object dictionary (OD). It is different while writing to local OD or OD of some network device.&lt;br /&gt;
====Writing to local OD====&lt;br /&gt;
Function &#039;&#039;WriteLocalDict&#039;&#039; is used for writing to OD of local node managed by CanFestival.&lt;br /&gt;
 UNS32 writeLocalDict( CO_Data* d, &lt;br /&gt;
 UNS16 wIndex, &lt;br /&gt;
 UNS8 bSubindex, &lt;br /&gt;
 void * pSourceData, &lt;br /&gt;
 UNS8 * pExpectedSize, &lt;br /&gt;
 UNS8 checkAccess);&lt;br /&gt;
Meaning of function arguments:&lt;br /&gt;
 &#039;&#039;&#039;d&#039;&#039;&#039; - pointer to local object dictionary structure&lt;br /&gt;
 &#039;&#039;&#039;wIndex&#039;&#039;&#039; - the index in the object dictionary where you want to write an entry&lt;br /&gt;
 &#039;&#039;&#039;bSubindex&#039;&#039;&#039; - the subindex of the Index. e.g. mostly subindex 0 is used to tell you how many valid entries you can find in this   index. Look at the canopen standard for further information&lt;br /&gt;
 &#039;&#039;&#039;pbSourceData&#039;&#039;&#039; - pointer to the variable that holds the value that should be copied into the object dictionary&lt;br /&gt;
 &#039;&#039;&#039;pExpectedSize&#039;&#039;&#039; - pointer to variable with size of the data to be written&lt;br /&gt;
 &#039;&#039;&#039;CheckAccess&#039;&#039;&#039; - if other than 0, do not read if the data is Read Only or Constant&lt;br /&gt;
&lt;br /&gt;
====Writing to network OD====&lt;br /&gt;
&lt;br /&gt;
It is necessary to use SDO service for writing data to OD of some network device. Each CANopen device has at least one SDO server. It means that it is able to receive SDOs with one ID and answer by SDOs with another ID. It is usual that the server listen for SDOs with ID 0x600 + ID of the node and transmits SDOs of ID 0x580 + node ID. Each SDO we want to use has to be defined while creating node configuration by &#039;&#039;objdictedit&#039;&#039;. Then the SDO is sent by calling appropriate function. The best is to use function &#039;&#039;writeNetworkDictCallBack&#039;&#039; which syntax is shown below.&lt;br /&gt;
 UNS8 writeNetworkDictCallBack (CO_Data* d, &lt;br /&gt;
 UNS8 nodeId, &lt;br /&gt;
 UNS16 index,&lt;br /&gt;
 UNS8 subIndex, &lt;br /&gt;
 UNS8 count, &lt;br /&gt;
 UNS8 dataType, &lt;br /&gt;
 void *data, &lt;br /&gt;
 SDOCallback_t Callback);&lt;br /&gt;
Meaning of function arguments:&lt;br /&gt;
 &#039;&#039;&#039;d&#039;&#039;&#039; - pointer to local object dictionary structure&lt;br /&gt;
 &#039;&#039;&#039;nodeId&#039;&#039;&#039; - ID of the device we want to send SDO&lt;br /&gt;
 &#039;&#039;&#039;index&#039;&#039;&#039; - the index in the object dictionary where you want to write an entry&lt;br /&gt;
 &#039;&#039;&#039;subIndex&#039;&#039;&#039; - the subindex of the Index. e.g. mostly subindex 0 is used to tell you how many valid entries you can find in this index. Look at the canopen standard for further information&lt;br /&gt;
 &#039;&#039;&#039;count&#039;&#039;&#039; - number of bytes to be written&lt;br /&gt;
 &#039;&#039;&#039;dataType&#039;&#039;&#039; - type of the data, use 0 for integers, real numbers and other values&lt;br /&gt;
 &#039;&#039;&#039;data&#039;&#039;&#039; - pointer to the data&lt;br /&gt;
 &#039;&#039;&#039;Callback&#039;&#039;&#039; - pointer to a function which is called after finishing the transfer&lt;br /&gt;
The SDO service is by definition confirmed. It means that SDO server sends response with result of the transfer after each SDO reception. This response has to be read by client to be sure that the data were written correctly. The result should be read in your function which pointer is given to the function &#039;&#039;writeNetworkDictCallBack&#039;&#039; as parameter &#039;&#039;callback&#039;&#039;. The result of SDO transfer in such a function is read by CanFestival function &#039;&#039;getWriteResultNetworkDict&#039;&#039;. This function has to be called after each SDO transmission because it releases line used to transfer. Header of this function is:&lt;br /&gt;
 UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode);&lt;br /&gt;
And meaning of function arguments is:&lt;br /&gt;
 &#039;&#039;&#039;d&#039;&#039;&#039; - pointer to local object dictionary structure&lt;br /&gt;
 &#039;&#039;&#039;nodeId&#039;&#039;&#039; - ID of the device we have sent SDO&lt;br /&gt;
 &#039;&#039;&#039;abortCode&#039;&#039;&#039; - pointer to the variable where error code is written in case of error&lt;br /&gt;
The function can return one of these values according to the SDO transfer state:&lt;br /&gt;
 &#039;&#039;&#039;SDO_FINISHED&#039;&#039;&#039; - data is available&lt;br /&gt;
 &#039;&#039;&#039;SDO_ABORTED_RCV&#039;&#039;&#039; - Transfer failed. (abort SDO received)&lt;br /&gt;
 &#039;&#039;&#039;SDO_ABORTED_INTERNAL&#039;&#039;&#039; - Transfer failed. Internal abort.&lt;br /&gt;
 &#039;&#039;&#039;SDO_DOWNLOAD_IN_PROGRESS&#039;&#039;&#039; - Data not yet available&lt;br /&gt;
The function can be used in cycle waiting while return value is &#039;&#039;SDO_DOWNLOAD_IN_PROGRESS&#039;&#039;. But the better solution is calling it in callback function from &#039;&#039;writeNetworkDictCallBack&#039;&#039;. The callback is call after finishing the transfer.&lt;br /&gt;
&lt;br /&gt;
===Using PDO service===&lt;br /&gt;
&lt;br /&gt;
Using PDO service for data exchange is very easy in CanFestival. The most usual transmission type of PDOs is that they are transmitted after SYNC message. In this case it just has to be set up in objdictedit configuration and then it works, reads and stores values into mapped variables. After each PDO reception or transmission &#039;&#039;post_TPDO&#039;&#039; callback is called if used. &lt;br /&gt;
Sometimes it is necessary to send PDO from code without SYNC message reception. This is done by calling the function &#039;&#039;sendPDOevent&#039;&#039; with this syntax:&lt;br /&gt;
 UNS8 sendPDOevent(CO_Data* d);&lt;br /&gt;
where &#039;&#039;d&#039;&#039; is the pointer to local object dictionary structure. This function sends all PDOs defined by &#039;&#039;objdictedit&#039;&#039; and transmission type &#039;&#039;after event&#039;&#039; (0x255).&lt;br /&gt;
&lt;br /&gt;
===Generating SYNC message===&lt;br /&gt;
&lt;br /&gt;
If you want to set up local node to become the SYNC server you have to write some information to local OD. Here is an example of function which set up the SYNC messages generation:&lt;br /&gt;
 /**&lt;br /&gt;
  * This function initializes local canopen node to send SYNC message&lt;br /&gt;
  * with given period. &lt;br /&gt;
  * @param d - local object dictionary&lt;br /&gt;
  * @param period - period of the SYNC message in us&lt;br /&gt;
  */&lt;br /&gt;
 void synchro_setup(CO_Data *d, unsigned long period)&lt;br /&gt;
 {&lt;br /&gt;
 	UNS32 SYNC_COBID = 0x40000080;&lt;br /&gt;
 	UNS32 SYNC_INTER = period;&lt;br /&gt;
 	UNS8 size = sizeof(UNS32); &lt;br /&gt;
 	writeLocalDict(d, 0x1006, 0x0, &amp;amp;SYNC_INTER, &amp;amp;size, RW);&lt;br /&gt;
 	writeLocalDict(d, 0x1005, 0x0, &amp;amp;SYNC_COBID, &amp;amp;size, RW);&lt;br /&gt;
 }&lt;br /&gt;
According to CANopen specification ID of the SYNC message is 0x80.&lt;br /&gt;
After the setup it can be started by command &#039;&#039;startSYNC(CO_Data *d)&#039;&#039; and stopped by command &#039;&#039;stopSYNC(CO_Data *d)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===SDO and PDO example===&lt;br /&gt;
&lt;br /&gt;
At the end I attach example of a function (&#039;&#039;cpd_start()&#039;&#039;) which starts some device communicating by CANopen. The ID of the device is given by the parameter. The other function (&#039;&#039;cpd_checkSDO_start()&#039;&#039;) is callback used to handle SDO transfer result. It is necessary to wait until one SDO transfer is finished before starting some other. Global variable &#039;&#039;cpd_init_step&#039;&#039; is used for counting actual step of SDO transfer. If some SDO transfer fails it is set to -1 and the startup process is terminated. &lt;br /&gt;
 /**&lt;br /&gt;
  * This function is given to the writeNetworkDict function as a callback.&lt;br /&gt;
  * It checks the result of SDO transmition and after finishing the transmition&lt;br /&gt;
  * it closes the transfer.&lt;br /&gt;
  * @param d - local object disctionary&lt;br /&gt;
  * @param nodeID - ID of the node which the local node is communicating with&lt;br /&gt;
  */ &lt;br /&gt;
 void cpd_checkSDO_start(CO_Data* d, UNS8 nodeId)&lt;br /&gt;
 {&lt;br /&gt;
 	UNS32 abortCode;	&lt;br /&gt;
 	if(getWriteResultNetworkDict (d, nodeId, &amp;amp;abortCode) != SDO_FINISHED) {&lt;br /&gt;
 		cpd_init_step = -1;&lt;br /&gt;
 	}&lt;br /&gt;
 	closeSDOtransfer(&amp;amp;canopen_Data, nodeId, SDO_CLIENT);&lt;br /&gt;
 	cpd_start(&amp;amp;canopen_Data, nodeId);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  * This function switch canopen device into operational state. &lt;br /&gt;
  * @param d - local object dictionary&lt;br /&gt;
  * @param nodeId - ID of the device&lt;br /&gt;
  * return 0 - ok, -1 - failed&lt;br /&gt;
  */&lt;br /&gt;
 int cpd_start(CO_Data *d, UNS8 nodeId)&lt;br /&gt;
 {&lt;br /&gt;
 	UNS8 data8;&lt;br /&gt;
 	UNS16 data16;&lt;br /&gt;
 	UNS32 data32;&lt;br /&gt;
 	switch(cpd_init_step++) {&lt;br /&gt;
 		case 0:&lt;br /&gt;
 			masterSendNMTstateChange(d, nodeId, NMT_Start_Node);&lt;br /&gt;
 			cpd_controlword = 0;&lt;br /&gt;
                        sendPDOevent(d);&lt;br /&gt;
 			cpd_controlword = 6;&lt;br /&gt;
                        sendPDOevent(d);&lt;br /&gt;
 			cpd_controlword = 0x0F;&lt;br /&gt;
                        sendPDOevent(d);&lt;br /&gt;
 &lt;br /&gt;
 			// Start operational mode&lt;br /&gt;
 			data8 = 0xFC;&lt;br /&gt;
 			writeNetworkDictCallBack(d, nodeId, 0x6060, 0x00, 1, 0, &amp;amp;data8, cpd_checkSDO_start);&lt;br /&gt;
 			break;&lt;br /&gt;
 		case 1:&lt;br /&gt;
 			// Check operation status&lt;br /&gt;
 			readNetworkDictCallback(d, nodeId, 0x6061, 0x00, 0, cpd_checkSDO_start);&lt;br /&gt;
 			break;&lt;br /&gt;
 		case 2:&lt;br /&gt;
 			// Setpoint specification&lt;br /&gt;
 			data16 = 0x0002;&lt;br /&gt;
 			writeNetworkDictCallBack(d, nodeId, 0x301B, 0x11, 2, 0, &amp;amp;data16, cpd_checkSDO_start);&lt;br /&gt;
 			break;&lt;br /&gt;
 		case 3:&lt;br /&gt;
 			canopen_init_result = 0;&lt;br /&gt;
 			cpd_init_step = 0;&lt;br /&gt;
 			break;&lt;br /&gt;
 		case -1:&lt;br /&gt;
 			canopen_init_result = -1;&lt;br /&gt;
 			cpd_init_step = 0;&lt;br /&gt;
 			break;&lt;br /&gt;
 	}&lt;br /&gt;
 	return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Emergency message===&lt;br /&gt;
&lt;br /&gt;
New version of CanFestival is extended by EMCY messages support. There is callback added which can be set to point to your own EMCY message handler.This handler has to be a function with three parameters defined in this way:&lt;br /&gt;
 void my_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg)&lt;br /&gt;
After reception of an EMCY message this callback is called. The parameters keep information about node ID of the EMCY producer, error code and content of the error register.&lt;br /&gt;
To register your handler you have to set the callback in CanFestival initialization.&lt;br /&gt;
 my_Data.post_emcy = my_post_emcy;&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
	<entry>
		<id>https://rtime.felk.cvut.cz/hw/index.php?title=H8300-boot&amp;diff=2503</id>
		<title>H8300-boot</title>
		<link rel="alternate" type="text/html" href="https://rtime.felk.cvut.cz/hw/index.php?title=H8300-boot&amp;diff=2503"/>
		<updated>2007-01-22T10:20:18Z</updated>

		<summary type="html">&lt;p&gt;Spinkao: /* Bootstrapping the processor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting the software ==&lt;br /&gt;
&lt;br /&gt;
Actual source code can be downloaded using a [[Darcs]] tool:&lt;br /&gt;
&lt;br /&gt;
  darcs get http://rtime.felk.cvut.cz/repos/h8300-boot&lt;br /&gt;
&lt;br /&gt;
This will create a copy of the repository on your computer. You can upgrade your repository using the command:&lt;br /&gt;
&lt;br /&gt;
  darcs pull&lt;br /&gt;
&lt;br /&gt;
If you have an acount on the &#039;&#039;rtime&#039;&#039; server, you can use &#039;&#039;ssh&#039;&#039;-based access to the repository. If an administrater gave you the right for writing to the repository, you can not only read (pull) repository but also write (push) changes to the repository.&lt;br /&gt;
&lt;br /&gt;
The syntax for getting the repo is:&lt;br /&gt;
&lt;br /&gt;
  darcs get &amp;lt;login&amp;gt;@rtime.felk.cvut.cz:/var/repos/h8300-boot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Browsing of project sources is also possible via [http://rtime.felk.cvut.cz/darcs/darcsweb.cgi?r=h8300-boot;a=summary Darcs web interface].&lt;br /&gt;
&lt;br /&gt;
If you plan to record some changes and push them back to the server, it is recomended to add the following lines to &amp;lt;tt&amp;gt;_darcs/prefs/boring&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 ^TAGS$&lt;br /&gt;
 ^config\.omk&lt;br /&gt;
 ^_build&lt;br /&gt;
 ^_compiled&lt;br /&gt;
&lt;br /&gt;
== Compiling ==&lt;br /&gt;
&lt;br /&gt;
First, you have to configure the make-system for a board you plan to use. For &#039;&#039;h8canusb&#039;&#039; execute the following command from h8300-boot directory:&lt;br /&gt;
 ln -s board/h8canusb/config.h8canusb config.omk&lt;br /&gt;
 make default-config&lt;br /&gt;
Then, you can change default configuration of what is compiled by copying &amp;lt;tt&amp;gt;config.omk-default&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;config.omk&amp;lt;/tt&amp;gt;. In the copied file change default configuration as you want and delete other lines you want to have default value.&lt;br /&gt;
&lt;br /&gt;
After typing&lt;br /&gt;
 make&lt;br /&gt;
everithing is goning to compile and if the compilation is completed without errors, you can use this &#039;&#039;build environment&#039;&#039; for building your own applications.&lt;br /&gt;
&lt;br /&gt;
=== Compiling one application only ===&lt;br /&gt;
&lt;br /&gt;
To compile only a part of sources (e.g. your own application), change the directory to where your applications resides and run&lt;br /&gt;
 make&lt;br /&gt;
This will (re)compile everithing in current directory and all subdirectories. The result of compilation can be found under the &amp;lt;tt&amp;gt;_compiled&amp;lt;/tt&amp;gt; direcotry (located at root of h8300-boot directory structure). The structure of &amp;lt;tt&amp;gt;_compiled&amp;lt;/tt&amp;gt; directory is as follows:&lt;br /&gt;
&lt;br /&gt;
; bin : binary programs for target system&lt;br /&gt;
; bin-utils : binary programs for host system (PC) (note: This will probably change in future)&lt;br /&gt;
; include : header files which are used when compiling for target&lt;br /&gt;
; libs : compiled libraries for target&lt;br /&gt;
&lt;br /&gt;
There is another directory called &amp;lt;tt&amp;gt;_build&amp;lt;/tt&amp;gt; where intermediate products of compilation such as object files, linker maps and dependency descriptions are stored. You can delete files in &amp;lt;tt&amp;gt;_build&amp;lt;/tt&amp;gt; corresponding to your application by issuing&lt;br /&gt;
 make clean&lt;br /&gt;
If you want to delete both &amp;lt;tt&amp;gt;_compiled&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_build&amp;lt;/tt&amp;gt; directories, run&lt;br /&gt;
 make distclean&lt;br /&gt;
&lt;br /&gt;
==== Using non-default link variant ====&lt;br /&gt;
&lt;br /&gt;
If your board has it&#039;s default link variant set for example to &#039;&#039;ram&#039;&#039; and you want to link your application for flash memory, you can use the following command to compile another variant of your program:&lt;br /&gt;
&lt;br /&gt;
 make links_VARIANTS=flash&lt;br /&gt;
&lt;br /&gt;
You can use more variant at once by&lt;br /&gt;
&lt;br /&gt;
 make links_VARIANTS=&amp;quot;flash ram&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Loading and running an application ===&lt;br /&gt;
&lt;br /&gt;
To load an application to the target processor, run&lt;br /&gt;
&lt;br /&gt;
 make load&lt;br /&gt;
&lt;br /&gt;
This load the application from current directory to either RAM or FLASH memory. Which one is selected depends on a value of &amp;lt;tt&amp;gt;DEFAULT_LD_SCRIPT_VARIANT&amp;lt;/tt&amp;gt; variable. This variable can be set globaly in &amp;lt;tt&amp;gt;config.target&amp;lt;/tt&amp;gt; or locally in &amp;lt;tt&amp;gt;Makefile.omk&amp;lt;/tt&amp;gt; and the first word of the value of this variable determines the default memory location for loading (and running). &lt;br /&gt;
&lt;br /&gt;
If you want to load an application to different memory location, use one of&lt;br /&gt;
 make load-flash&lt;br /&gt;
 make load-ram&lt;br /&gt;
&lt;br /&gt;
If there are more programs to load in the current directory, and you want to load a non-default one, you have to run&lt;br /&gt;
 make load-&amp;lt;progname&amp;gt;-ram&lt;br /&gt;
 make load-&amp;lt;progname&amp;gt;-flash&lt;br /&gt;
&lt;br /&gt;
After loading your application, you can run it by running one of the following&lt;br /&gt;
 make run&lt;br /&gt;
 make run-ram&lt;br /&gt;
 make run-flash&lt;br /&gt;
&lt;br /&gt;
You can also combine loading and running to one step and use&lt;br /&gt;
 make load run&lt;br /&gt;
&lt;br /&gt;
=== Bootstrapping the processor ===&lt;br /&gt;
&lt;br /&gt;
In order to be able to load applications to the target system, there have to be a boot loader program in processor&#039;s FLASH memory. It has to be loaded through serial channel 1 (pins TxD1, RxD1). The loader program is located at &amp;lt;tt&amp;gt;app/bloader&amp;lt;/tt&amp;gt; directory and you can load it to the processor by&lt;br /&gt;
 sh bootstrap&lt;br /&gt;
from &amp;lt;tt&amp;gt;bloader&amp;lt;/tt&amp;gt; direcotry.&lt;br /&gt;
&lt;br /&gt;
== Using KDevelop for development ==&lt;br /&gt;
&lt;br /&gt;
[http://www.kdevelop.org/ KDevelop] is very good IDE for developing various kind of applications. It can be easily used to develop software for H8300 processors and can be well integrated with OMK make-system.&lt;br /&gt;
&lt;br /&gt;
If you want to use KDevelop for development, follow theese points:&lt;br /&gt;
&lt;br /&gt;
# Import project to KDevelop (from menu choose Project -&amp;gt; Import existing project). Select the type of project to &#039;&#039;Generic C Application (Custom Makefile)&#039;&#039;&amp;lt;br/&amp;gt;[[Image:Kdevelop1.png]]&lt;br /&gt;
# (Optional) Populate your project with source files by anwering &#039;&#039;&#039;yes&#039;&#039;&#039; to the dialog.&amp;lt;br/&amp;gt;[[Image:Kdevelop2.png]]&lt;br /&gt;
# Open &#039;&#039;Project Options&#039;&#039; dialog (menu Project -&amp;gt; Project Options) and choose &#039;&#039;Run Options&#039;&#039;. Select &#039;&#039;&#039;Run from the BUILD directory&#039;&#039;&#039;, to Main Program editbox write &#039;&#039;&#039;/usr/local/bin/make&#039;&#039;&#039; (you may have your &#039;&#039;make&#039;&#039; in a different directory) and as &#039;&#039;Program Arguments&#039;&#039; write &#039;&#039;&#039;load run&#039;&#039;&#039;.&amp;lt;br/&amp;gt;[[Image:Kdevelop3.png]]&lt;br /&gt;
# Now you can compile your application by pressing &#039;&#039;F8&#039;&#039; and if there are some errors, you can quickly jump the place in source whre the error is by pressing &#039;&#039;F4&#039;&#039;.&amp;lt;br/&amp;gt;[[Image:Kdevelop4.png]]&lt;br /&gt;
# After successfull compilation you can run your application by clicking &#039;&#039;Execute program&#039;&#039; icon. I recomend you to create shortcut key &#039;&#039;F9&#039;&#039; for this action. If you change your sources, you can booth recompile and execute your application by simply pressing &#039;&#039;F9&#039;&#039;.&amp;lt;br/&amp;gt;[[Image:Kdevelop5.png]]&lt;br /&gt;
&lt;br /&gt;
== Using TAGS for navigation in files ==&lt;br /&gt;
&lt;br /&gt;
If you run&lt;br /&gt;
 make TAGS&lt;br /&gt;
in any direcotry, the file TAGS in the toplevel directory of the project will be created. This file can be used by various editors (such as [[wikipedia:Emacs|Emacs]]) for quick searching of symbols in source files.&lt;br /&gt;
&lt;br /&gt;
== Writing your own application ==&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
=== Interrupts ===&lt;br /&gt;
&lt;br /&gt;
Interrupts are disabled by default. If you wand to use interrupts in your application you have to enable them explicitly by&lt;br /&gt;
 sti();&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Interrupts handling mechanisms&#039;&#039; are initialized by calling &amp;lt;tt&amp;gt;excptvec_initfill&amp;lt;/tt&amp;gt; and particular interrupts are setup by calling &amp;lt;tt&amp;gt;excptvec_set&amp;lt;/tt&amp;gt;. For example see the code bellow.&lt;br /&gt;
&lt;br /&gt;
 void  no_isr(void) __attribute__ ((interrupt_handler));&lt;br /&gt;
 void  no_isr(void) {};&lt;br /&gt;
 &lt;br /&gt;
 void my_isr(void)&lt;br /&gt;
 {&lt;br /&gt;
     /* some code */&lt;br /&gt;
 }    &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     // all the interrupts will run no_isr&lt;br /&gt;
     excptvec_initfill(no_isr, 0);&lt;br /&gt;
  &lt;br /&gt;
     // set the interrupt handler my_isr to the interrupt vector&lt;br /&gt;
     // number 42&lt;br /&gt;
     excptvec_set(42, my_isr); &lt;br /&gt;
 &lt;br /&gt;
     /* Enable interrupts which are disabled by default. */&lt;br /&gt;
     sti();&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
When linking your program you need to link it with library &amp;lt;tt&amp;gt;excptvec&amp;lt;/tt&amp;gt;. So in your Makefile.omk you will need a line similar to&lt;br /&gt;
 yourprogram_LIBS = excptvec&lt;br /&gt;
&lt;br /&gt;
=== Serial Communication ===&lt;br /&gt;
&lt;br /&gt;
You have to include&lt;br /&gt;
    #include &amp;lt;periph/sci_rs232.h&amp;gt;&lt;br /&gt;
then initialize the needed serial ports:&lt;br /&gt;
    /* Initialize SCI channels 0 and 1 */&lt;br /&gt;
    sci_rs232_setmode(19200, 0, 0, 0);&lt;br /&gt;
    sci_rs232_setmode(19200, 0, 0, 1);&lt;br /&gt;
Then you can use:&lt;br /&gt;
        sci_rs232_sendch(&#039;H&#039;, 0);&lt;br /&gt;
to send characters.&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;lt;tt&amp;gt;printf()&amp;lt;/tt&amp;gt; and similar functions. The output of theese will go to the serial port specified by &amp;lt;tt&amp;gt;sci_rs232_chan_default&amp;lt;/tt&amp;gt; variable. Its default value is selected in &amp;lt;tt&amp;gt;system_def.h&amp;lt;/tt&amp;gt; and can be different for every board.&lt;br /&gt;
&lt;br /&gt;
For examples see [http://rtime.felk.cvut.cz/darcs/darcsweb.cgi?r=h8300-boot;a=tree;f=/app/rs_test app/rs_test/*.c]&lt;/div&gt;</summary>
		<author><name>Spinkao</name></author>
	</entry>
</feed>