Stefano Babic | eae4988 | 2011-01-20 08:05:15 +0000 | [diff] [blame] | 1 | Overview |
| 2 | -------------- |
| 3 | |
| 4 | mx35pdk (known als as mx35_3stack) is a development board by Freescale. |
| 5 | It consists of three pluggable board: |
| 6 | - CPU module, with CPU, RAM, flash |
| 7 | - Personality board, with most interfaces (USB, Network,..) |
| 8 | - Debug board with JTAG header. |
| 9 | |
| 10 | The board is usually delivered with redboot. This howto explains how to boot |
| 11 | a linux kernel and how to replace the original bootloader with U-Boot. |
| 12 | |
| 13 | The board is delivered with Redboot on the NAND flash. It is possible to |
| 14 | switch the boot device with the switches SW1-SW2 on the Personality board, |
| 15 | and with SW5-SW10 on the Debug board. |
| 16 | |
| 17 | Delivered Redboot script to start the kernel |
| 18 | --------------------------------------------------- |
| 19 | |
| 20 | In redboot the following script is stored: |
| 21 | |
| 22 | fis load kernel |
| 23 | exec -c "noinitrd console=ttymxc0,115200 root=/dev/mtdblock8 rw rootfstype=jffs2 ip=dhcp fec_mac=00:04:9F:00:E7:76" |
| 24 | |
| 25 | Kernel is taken from flash. The image is in zImage format. |
| 26 | |
| 27 | Booting from NET, rootfs on NFS: |
| 28 | ----------------------------------- |
| 29 | |
| 30 | To change the script in redboot: |
| 31 | |
| 32 | load -r -b 0x100000 <path_to_zImage> |
| 33 | 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" |
| 34 | |
| 35 | If the ip address is not set, you can set it with : |
| 36 | |
| 37 | ip_address -l <board_ip/netmask> -h <server_ip> |
| 38 | |
| 39 | Linux partitions: |
| 40 | --------------------------- |
| 41 | |
| 42 | As default, the board is shipped with these partition tables for NAND |
| 43 | and for NOR: |
| 44 | |
| 45 | Creating 5 MTD partitions on "NAND 2GiB 3,3V 8-bit": |
| 46 | 0x00000000-0x00100000 : "nand.bootloader" |
| 47 | 0x00100000-0x00600000 : "nand.kernel" |
| 48 | 0x00600000-0x06600000 : "nand.rootfs" |
| 49 | 0x06600000-0x06e00000 : "nand.configure" |
| 50 | 0x06e00000-0x80000000 : "nand.userfs" |
| 51 | |
| 52 | Creating 6 MTD partitions on "mxc_nor_flash.0": |
| 53 | 0x00000000-0x00080000 : "Bootloader" |
| 54 | 0x00080000-0x00480000 : "nor.Kernel" |
| 55 | 0x00480000-0x02280000 : "nor.userfs" |
| 56 | 0x02280000-0x03e80000 : "nor.rootfs" |
| 57 | 0x01fe0000-0x01fe3000 : "FIS directory" |
| 58 | 0x01fff000-0x04000000 : "Redboot config" |
| 59 | |
| 60 | NAND partitions can be recognized enabling in kernel CONFIG_MTD_REDBOOT_PARTS. |
| 61 | For this board, CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK should be set to 2. |
| 62 | |
| 63 | However, the setup in redboot is not correct and does not use the whole flash. |
| 64 | |
| 65 | Better solution is to use the kernel parameter mtdparts. |
| 66 | Here the resulting script to be defined in RedBoot with fconfig: |
| 67 | |
| 68 | load -r -b 0x100000 sbabic/mx35pdk/zImage.2.6.37 |
| 69 | 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)" |
| 70 | |
| 71 | Flashing U-Boot |
| 72 | -------------------------------- |
| 73 | |
| 74 | There are two options: the original bootloader in NAND can be replaced with |
| 75 | u-boot, or u-boot can be stored on the NOR flash without erasing |
| 76 | the delivered bootloader. |
| 77 | The boot storage can be select using the switches on the personality board |
| 78 | (SW1-SW2) and on the DEBUG board (SW4-SW10). |
| 79 | |
| 80 | The second option is to be preferred if you have not a JTAG debugger. |
| 81 | If something goes wrong flashing the bootloader, it is always possible to |
| 82 | recover the board booting from the other device. |
| 83 | |
| 84 | Replacing the bootloader on the NAND |
| 85 | -------------------------------------- |
| 86 | To replace RedBoot with U-Boot, the easy way is to do this in linux. |
| 87 | Start the kernel with the suggested options. Make sure to have set the |
| 88 | mtdparts exactly as described, because this matches the layout on the |
| 89 | mx35pdk. |
| 90 | |
| 91 | You should see in your boot log the following entries for the NAND |
| 92 | flash: |
| 93 | |
| 94 | 5 cmdlinepart partitions found on MTD device mxc_nand |
| 95 | Creating 5 MTD partitions on "mxc_nand": |
| 96 | 0x000000000000-0x000000100000 : "boot" |
| 97 | 0x000000100000-0x000000600000 : "linux" |
| 98 | 0x000000600000-0x000006600000 : "root" |
| 99 | 0x000006600000-0x000006e00000 : "cfg" |
| 100 | 0x000006e00000-0x000080000000 : "user" |
| 101 | |
| 102 | You can use the utilities flash_eraseall and nandwrite to put |
| 103 | u-boot on the NAND. The bootloader is marked as "boot", and 1MB is |
| 104 | reserved. If everything is correct, this partition is accessed as |
| 105 | /dev/mtd4. However, check if it is correct with "cat /proc/mtd" and |
| 106 | get the device node from the partition name: |
| 107 | |
| 108 | $ cat /proc/mtd | grep boot |
| 109 | |
| 110 | I suggest you try the utilities on a different partition to be sure |
| 111 | if everything works correctly. If not, and you remove RedBoot, you have to |
| 112 | reinstall it using the ATK tool as suggested by Freescale, or using a |
| 113 | JTAG debugger. |
| 114 | |
| 115 | I report the versions of the utilities I used (they are provided with ELDK): |
| 116 | |
| 117 | -bash-3.2# nandwrite --version |
| 118 | nandwrite $Revision: 1.32 $ |
| 119 | |
| 120 | flash_eraseall --version |
| 121 | flash_eraseall $Revision: 1.22 $ |
| 122 | |
| 123 | nandwrite reports a warning if the file to be saved is not sector aligned. |
| 124 | This should have no consequences, but I preferred to pad u-boot.bin |
| 125 | to get no problem at all. |
| 126 | $ dd if=/dev/zero of=zeros bs=1 count=74800 |
| 127 | $ cat u-boot.bin zeros > u-boot-padded.bin |
| 128 | |
| 129 | To erase the partition: |
| 130 | $ flash_eraseall /dev/mtd4 |
| 131 | |
| 132 | Writing u-boot: |
| 133 | |
| 134 | $ nandwrite /dev/mtd4 u-boot-padded.bin |
| 135 | |
| 136 | Now U-Boot is stored on the booting partition. |
| 137 | |
| 138 | To boot from NAND, you have to select the switches as follows: |
| 139 | |
| 140 | Personality board |
| 141 | SW2 1, 4, 5 on |
| 142 | 2, 3, 6, 7, 8 off |
| 143 | SW1 all off |
| 144 | |
| 145 | Debug Board: |
| 146 | SW5 0 |
| 147 | SW6 0 |
| 148 | SW7 0 |
| 149 | SW8 1 |
| 150 | SW9 1 |
| 151 | SW10 0 |
| 152 | |
| 153 | |
| 154 | Saving U-Boot in the NOR flash |
| 155 | --------------------------------- |
| 156 | |
| 157 | The procedure to save in the NOR flash is quite the same as to write into the NAND. |
| 158 | |
| 159 | Check the partition for boot in the NOR flash. Setting the mtdparts as reported, |
| 160 | the boot partition should be /dev/mtd0. |
| 161 | |
| 162 | Creating 6 MTD partitions on "mxc_nor_flash.0": |
| 163 | 0x00000000-0x00080000 : "Bootloader" |
| 164 | 0x00080000-0x00480000 : "nor.Kernel" |
| 165 | 0x00480000-0x02280000 : "nor.userfs" |
| 166 | 0x02280000-0x03e80000 : "nor.rootfs" |
| 167 | 0x01fe0000-0x01fe3000 : "FIS directory" |
| 168 | 0x01fff000-0x04000000 : "Redboot config" |
| 169 | |
| 170 | To erase the whole partition: |
| 171 | $ flash_eraseall /dev/mtd0 |
| 172 | |
| 173 | Writing u-boot: |
| 174 | dd if=u-boot.bin of=/dev/mtd0 |
| 175 | |
| 176 | To boot from NOR, you have to select the switches as follows: |
| 177 | |
| 178 | Personality board |
| 179 | SW2 all off |
| 180 | SW1 all off |
| 181 | |
| 182 | Debug Board: |
| 183 | SW5 0 |
| 184 | SW6 0 |
| 185 | SW7 0 |
| 186 | SW8 1 |
| 187 | SW9 1 |
| 188 | SW10 0 |