56 | | === Laguna Product families |
57 | | The Laguna boards have a primary NOR FLASH device and a smaller SPI FLASH device for an **alternate boot device**. Because of the differences in the FLASH types you need to have a different bootloader on each device. |
58 | | |
59 | | ==== Step 1. Bootloader |
60 | | The alternate boot device and the primary boot device require different bootloaders **(SPI vs NOR FLASH)**. Only the primary boot device is programmed with a bootable image by Gateworks. In order to program the alternate boot device you will need to do so from Linux (as u-boot-nor.bin on the primary boot device without modification can only access NOR flash). |
61 | | |
62 | | **REQUIRED: You will also need to modify your Linux kernel to allow writing to the u-boot partition of SPI flash by commenting out the '.mask_flags = MTD_WRITEABLE' in the laguna_spi_partitions structure in:** |
63 | | {{{ |
64 | | /gateworks-openwrt/trunk$ vi build_dir/target-arm_v6k_uClibc-0.9.33.2_eabi/linux-cns3xxx/linux-3.8.6/arch/arm/mach-cns3xxx/laguna.c |
65 | | }}} |
66 | | |
67 | | Once modified, recompile the BSP. Then flash this to the NOR flash on your board. |
68 | | |
69 | | Once booted to NOR flash with this modified kernel you can write the laguna u-boot-spi.bin to /dev/mtd5 via mtd: |
70 | | {{{#!bash |
71 | | root@OpenWrt:/# mtd write u-boot_spi.bin /dev/mtd5 |
72 | | Unlocking /dev/mtd5 ... |
73 | | |
74 | | Writing from u-boot_spi.bin to /dev/mtd5 ... |
75 | | root@OpenWrt:/# |
76 | | }}} |
77 | | |
78 | | Now you can follow the instructions above to boot off the **Alternate Boot Device** (SPI Flash) and setup your kernel/rootfs using the instructions for an SPI FLASH device such as the GW2380 found here here |
79 | | |
80 | | ==== Step 2. Kernel / Root Filesystem |
81 | | Depending on the size of the SPI FLASH you will likely **need to prune features from your kernel/filesystem**. A good starting point may be the Laguna test_config file which uses a ramdisk and a minimal set of utilities used by Gateworks to test boards. As this OpenWrt config file specifies an INTRAMFS ramdisk, you only need to flash the kernel which includes the root filesystem. |
82 | | |
83 | | 1. Use the instructions above to boot from the **Alternate Boot Device** (SPI FLASH) and break out into the bootloader. You can determine that you are booted to the **Alternate Boot Device** by seeing a smaller FLASH size in the boot header or by looking at the output of 'printenv bootcmd' and seeing that it boots a kernel from 0x60080000 (SPI FLASH) instead of 0x10080000 (NOR FLASH) |
84 | | {{{#!bash |
85 | | ... |
86 | | Hit any key to stop autoboot: 0 |
87 | | Laguna> printenv bootcmd |
88 | | bootcmd=bootm 0x60080000 |
89 | | }}} |
90 | | 1. set R1.7 (SWITCH_BOOT_CLEAR) so that you have plenty of time to write the kernel to the SPI Flash: |
91 | | {{{#!bash |
92 | | Laguna > imw 0x20 1 0xc0 1 # set SWITCH_BOOT_CLEAR (R1.7) |
93 | | }}} |
94 | | 1. set ipaddr/serverip according to your network. For example if your server is at 192.168.1.14 and your target is to be 192.168.1.211: |
95 | | {{{#!bash |
96 | | Laguna> sete ipaddr 192.168.1.211 |
97 | | Laguna> sete serverip 192.168.1.14 |
98 | | }}} |
99 | | 1. Erase what is currently in the SPI FLASH: (This is a range, start and end for a specific flash size. Example 16MB SPI below) |
100 | | {{{#!bash |
101 | | Laguna> erase 0x60080000 0x60ffffff |
102 | | }}} |
103 | | 1. Copy Kernel+Root-filesystem to the Board |
104 | | {{{#!bash |
105 | | Laguna> tftpboot 0x00800000 laguna/openwrt-cns3xxx-uImage_ramdisk |
106 | | Laguna> cp.b 0x00800000 0x60080000 $(filesize) |
107 | | }}} |
108 | | 1. Set kernel commandline for booting a ramdisk: |
109 | | {{{#!bash |
110 | | setenv bootargs 'console=ttyS0,115200 root=/dev/ram0 rootfstype=ramfs' |
111 | | saveenv |
112 | | }}} |
113 | | 1. Boot into Linux |
114 | | {{{#!bash |
115 | | Laguna> bootm |
116 | | }}} |
117 | | |
118 | | Notes: |
119 | | * when using the SPI FLASH device you can erase the u-boot env flash section and restore factory defaults with: |
120 | | {{{#!bash |
121 | | Laguna> protect off 0x60040000 +0x40000 |
122 | | Laguna> erase 0x60040000 +0x40000 |
123 | | Laguna> reset |
124 | | }}} |
125 | | |
126 | | ==== Using u-boot-2014.10-cns3xxx bootloader |
127 | | If using the [https://github.com/Gateworks/u-boot-cns3xxx u-boot-2014.10-cns3xxx] which supports both the 16MB and 4MB SPI flash devices used on Laguna products, you will need to use the 'sf' commands within uboot to access flash. |
128 | | |
129 | | Update kernel: |
130 | | {{{#!bash |
131 | | setenv serverip 192.168.1.146 |
132 | | setenv ipaddr 192.168.1.1 |
133 | | setenv spi_koffset 0x80000 |
134 | | setenv spi_klen 0x180000 |
135 | | setenv spi_roffset 0x200000 |
136 | | # update kernel |
137 | | tftp ${loadaddr} laguna/openwrt-cns3xxx-uImage && sf probe && sf update ${loadaddr} ${spi_koffset} ${filesize} |
138 | | }}} |
139 | | |
140 | | Update SPI uboot: |
141 | | {{{#!bash |
142 | | # update SPI uboot |
143 | | setenv serverip 192.168.1.146 |
144 | | setenv ipaddr 192.168.1.1 |
145 | | tftp ${loadaddr} laguna/u-boot_spi.bin && sf probe && sf update ${loadaddr} 0 ${filesize} |
146 | | }}} |
147 | | |
148 | | Enable Alternate Boot timer: |
149 | | {{{#!bash |
150 | | i2c mw 0x20 1 0x40 1 # set R1.6 SWITCH_BOOT_ENABLE |
151 | | }}} |
152 | | |
153 | | Clear Alternate Boot timer: |
154 | | {{{#!bash |
155 | | i2c mw 0x20 1 0xc0 1 # set R1.7 SWITCH_BOOT_CLEAR |
156 | | }}} |