Overview
--------------

mx35pdk (known als as mx35_3stack) is a development board by Freescale.
It consists of three pluggable board:
	- CPU module, with CPU, RAM, flash
	- Personality board, with most interfaces (USB, Network,..)
	- Debug board with JTAG header.

The board is usually delivered with redboot. This howto explains how to boot
a linux kernel and how to replace the original bootloader with U-Boot.

The board is delivered with Redboot on the NAND flash. It is possible to
switch the boot device with the switches SW1-SW2 on the Personality board,
and with SW5-SW10 on the Debug board.

Delivered Redboot script to start the kernel
---------------------------------------------------

In redboot the following script is stored:

fis load kernel
exec -c "noinitrd console=ttymxc0,115200 root=/dev/mtdblock8 rw rootfstype=jffs2 ip=dhcp fec_mac=00:04:9F:00:E7:76"

Kernel is taken from flash. The image is in zImage format.

Booting from NET, rootfs on NFS:
-----------------------------------

To change the script in redboot:

load -r -b 0x100000 <path_to_zImage>
exec -c "noinitrd console=ttymxc0,115200 root=/dev/nfsroot rootfstype=nfsroot nfsroot=192.168.1.1:/opt/eldk-4.2-arm/armVFP rw ip=dhcp"

If the ip address is not set, you can set it with :

ip_address -l <board_ip/netmask> -h <server_ip>

Linux partitions:
---------------------------

As default, the board is shipped with these partition tables for NAND
and for NOR:

Creating 5 MTD partitions on "NAND 2GiB 3,3V 8-bit":
0x00000000-0x00100000 : "nand.bootloader"
0x00100000-0x00600000 : "nand.kernel"
0x00600000-0x06600000 : "nand.rootfs"
0x06600000-0x06e00000 : "nand.configure"
0x06e00000-0x80000000 : "nand.userfs"

Creating 6 MTD partitions on "mxc_nor_flash.0":
0x00000000-0x00080000 : "Bootloader"
0x00080000-0x00480000 : "nor.Kernel"
0x00480000-0x02280000 : "nor.userfs"
0x02280000-0x03e80000 : "nor.rootfs"
0x01fe0000-0x01fe3000 : "FIS directory"
0x01fff000-0x04000000 : "Redboot config"

NAND partitions can be recognized enabling in kernel CONFIG_MTD_REDBOOT_PARTS.
For this board, CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK should be set to 2.

However, the setup in redboot is not correct and does not use the whole flash.

Better solution is to use the kernel parameter mtdparts.
Here the resulting script to be defined in RedBoot with fconfig:

load -r -b 0x100000 sbabic/mx35pdk/zImage.2.6.37
exec -c "noinitrd console=ttymxc0,115200 root=/dev/nfsroot rootfstype=nfsroot nfsroot=192.168.1.1:/opt/eldk-4.2-arm/arm rw ip=dhcp mtdparts=mxc_nand:1m(boot),5m(linux),96m(root),8m(cfg),1938m(user);physmap-flash.0:512k(b),4m(k),30m(u),28m(r)"

Flashing U-Boot
--------------------------------

U-Boot should be stored on the NOR flash.

The boot storage can be select using the switches on the personality board
(SW1-SW2) and on the DEBUG board (SW4-SW10).

If something goes wrong flashing the bootloader, it is always possible to
recover the board booting from the other device.

Saving U-Boot in the NOR flash
---------------------------------

Check the partition for boot in the NOR flash. Setting the mtdparts as reported,
the boot partition should be /dev/mtd0.

Creating 6 MTD partitions on "mxc_nor_flash.0":
0x00000000-0x00080000 : "Bootloader"
0x00080000-0x00480000 : "nor.Kernel"
0x00480000-0x02280000 : "nor.userfs"
0x02280000-0x03e80000 : "nor.rootfs"
0x01fe0000-0x01fe3000 : "FIS directory"
0x01fff000-0x04000000 : "Redboot config"

To erase the whole partition:
$ flash_eraseall /dev/mtd0

Writing U-Boot:
dd if=u-boot.bin of=/dev/mtd0

To boot from NOR, you have to select the switches as follows:

Personality board
	SW2	all off
	SW1	all off

Debug Board:
	SW5	0
	SW6	0
	SW7	0
	SW8	1
	SW9	1
	SW10	0
