Jump to content

MIDAM MPC5200 DB1

From HW wiki

Description

Two sets of the MIDAM MPC5200 was delivered by the Mikroklima s.r.o. for our purposes. Each set consist of the:

  • Shark MPC52000 CPU module (pin compatible with TQ Components TQM5200 module),
  • MPC5200 v1.1 2008/02 carrier board.

Set #1 has s/n: 008770 and set #2 has s/n: 008771.


Board overview

Serial line (system console)

  • Loader system console is attached to the ttyPSC0 port.
  • The ttyPSC0 port is done in the LVTTL 3.3V logic, so appropriate 3.3V to RS-232 converter (e.g. MAX3232) is required for the serial console.

Communication parameters:

  • baud rate: 115200 bps
  • bits: 8 bit
  • stop bits: 1 bit
  • Parity: none
  • Flow control: none

Boot loader

These boards are preinstalled with Das u-Boot boot loader. Behaviour of the u-Boot can be handled by its environment variables. Here are some useful commands:

  • printenv [variable] - prints complete environment or only given variable.
  • saveenv - commits whole environment in flash memory

For running linux kernel >2.6.25 it'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: u-boot.bin.

U-Boot upgrade howto:

During the upgrade procedure it is necessary to proceed with utmost precaution, because there is no backup image of the u-Boot in the flash for recovery purposes. Fail-flash recovery isn'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's image in flash memory:

dhcp
tftp 800000 u-boot.bin
protect off fc000000 fc09ffff
erase fc000000 fc09ffff
cp.b 800000 fc000000 ${filesize}
protect on fc000000 fc09ffff

Now reboot and than commit new default environment:

saveenv

Cross-tool chain

Necessary cross-tool chain for PowerPC platform can be build using Crossdev tool. You can install Crossdev on your Gentoo distro very simply:

emerge -av crossdev

Some dependencies may go before. Building of tool chain itself will take some time, so let's go to take some coffee.

crossdev --b 2.18-r3 --k 2.6.23-r3 --g 4.1.2 --without-headers -t powerpc-unknown-linux-gnu

For Debian, you can use a package prepared by Pavel Píša.

Linux kernel

It is necessary to use patched Linux sources. We maintain them in our Git repository. You can clone it by:

git clone git://rtime.felk.cvut.cz/shark/linux.git

Note: See Linux sources for the description of the repository and patch management techniques we use.

Now let's begin with the kernel configuration. First of all set target platform as Power PC and generate default config for MPC5200 platform.

  1. export ARCH=powerpc
  2. make 52xx/midam_defconfig (or use 52xx/ryu_defconfig for RYU board)
  3. make menuconfig

How to build the Flat Device Tree file

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:

make ARCH=powerpc shark.dtb DTS_FLAGS="-S65536"

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.:

WARNING: could not create /chosen FDT_ERR_NOSPACE.
ERROR: /chosen node create failed - must RESET the board to recover.

Root filesystem

New root filesystem has been built for MIDAM MPC5200 board. It's based on:

  • Vanilla linux kernel v2.6.26.5
  • Busybox v1.12.1
  • Dropbear v0.51
  • thttpd v2.25b

SocketCan

make KERNELDIR=/home/marsark/src/linux-2.6.26.5/_build/mpc5200_ryu/ CONFIG_CAN_MPC52XX=m CONFIG_CAN_MSCAN=m

CAN subsystem init script:

modprobe can
modprobe mscan-mpc52xx
modprobe can-raw
echo 660000 > /sys/class/net/can0/can_bittiming/bitrate
echo 660000 > /sys/class/net/can1/can_bittiming/bitrate
ifconfig can0 up
ifconfig can1 up

Test the setup:

cansend can0 123#4567

GPIO how set pin value

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).


cat /sys/class/gpio/gpiochip248/label    //todo

Setting GPIO with wakeup capability

GPIO with wakeup using

/sys/class/gpio/gpiochip248/

Pin notation:

 0 -> GPIO_WKUP_7
 1 -> GPIO_WKUP_6
 2 -> PSC6_1
 3 -> PSC6_0
 4 -> ETH_17
 5 -> PSC3_9
 6 -> PSC2_4
 7 -> PSC1_4

Final value is 248 + requested pin (example for PSC2_4 248+6 => 254)

Enable PIN for GPIO:

echo 254 >/sys/class/gpio/export

Set GPIO as output or input

echo out >/sys/class/gpio/gpio254/direction
echo in >/sys/class/gpio/gpio254/direction

Set GPIO to 0 or 1 if configured as output pin

echo 0 >/sys/class/gpio/gpio254/value
echo 1 >/sys/class/gpio/gpio254/value


Setting standard GPIO not tested

Standard GPIO using

/sys/class/gpio/gpiochip216/

Pin notation:

0..1  > reserved
2..3  > IRDA
4..7  > ETHR
8..11 > reserved
12..15 > USB
16..17 > reserved
18..23 > PSC3
24..27 > PSC2
28..31 > PSC1 

Final value is 216 + requested pin (example for PSC3_3 216+20 => 236)

Enable PIN for GPIO:

echo 236 >/sys/class/gpio/export

Set GPIO as output or input

echo out >/sys/class/gpio/gpio236/direction
echo in >/sys/class/gpio/gpio236/direction

Set GPIO to 0 or 1 if configured as output pin

echo 0 >/sys/class/gpio/gpio236/value
echo 1 >/sys/class/gpio/gpio236/value

RS485/RS422 selection on PSC1

In MPC5200 or schematic it is PSC2. In linux is PSC numbered from 0 so it is PSC1.

Pin configuration:

echo 254 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio254/direction

Run for RS485:

echo 0 >/sys/class/gpio/gpio254/value

Run for RS422:

echo 1 >/sys/class/gpio/gpio254/value

Linux boot possibilities

PIN configuration

Bootloader is responsible for pin configuration. This is done by writing to GPS Port Configuration Register. The value written there is set by:

set psc_cfg 91551044


Kernel from flash and root filesystem over NFS

bootcmd_nfsroot=set bootargs ${linux_console} ${bootargs_nfs}; dhcp; mw f0000b00 ${psc_cfg}; bootm fc120000 - fc100000;
bootargs_nfs=root=/dev/nfs nfsroot=/midam rw ip=dhcp
run bootcmd_nfsroot

Kernel from TFTP and root filesystem over NFS

set serverip 147.32.86.187
set nfspath "/home/wsh/ppc/MPC5200/root-shark"
set imagefile ryu/uImage
set devicetreefile ryu/shark-ryu.dtb
set bootargs_nfs 'root=/dev/nfs nfsroot=${serverip}:${nfspath} rw ip=dhcp'
set bootcmd_tftpnfs 'dhcp; tftp 800000 ${imagefile}; tftp 7f0000 ${devicetreefile}; set bootargs ${linux_console} ${bootargs_nfs}; mw f0000b00 ${psc_cfg}; bootm 800000 - 7f0000'
run bootcmd_tftpnfs

Booting VxWorks

dhcp; set serverip 147.32.86.187; set bootfile vxWorks.bin; tftp 0x00100000; go 0x00100000

Compiling VxWorks

It is assumed that VxWorks in installed under /opt/WindRiver

/opt/WindRiver/wrenv.sh -p vxworks-6.6
cd <bsp_project>
make
... TODO ...