MIDAM MPC5200 DB1: Difference between revisions
No edit summary |
|||
| Line 117: | Line 117: | ||
echo out >/sys/class/gpio/gpio254/direction | echo out >/sys/class/gpio/gpio254/direction | ||
echo 0 >/sys/class/gpio/gpio254/value | echo 0 >/sys/class/gpio/gpio254/value | ||
echo 1 >/sys/class/gpio/gpio254/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 | echo 1 >/sys/class/gpio/gpio254/value | ||
Revision as of 21:36, 30 January 2009
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.
- export ARCH=powerpc
- make 52xx/midam_defconfig (or use 52xx/ryu_defconfig for RYU board)
- 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
cat /sys/class/gpio/gpiochip248/label echo 254 >/sys/class/gpio/export echo out >/sys/class/gpio/gpio254/direction echo 0 >/sys/class/gpio/gpio254/value echo 1 >/sys/class/gpio/gpio254/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 ...
