| 329 | [=#SplitMethod] |
| 330 | ==== Updating UBI with low RAM devices: |
| 331 | For some devices, the size of the NAND flash exceeds the size of RAM. In this scenario the instructions from the prior section would fail as you would run out of RAM space before you could finish retrieving the file to program the NAND flash with. |
| 332 | |
| 333 | To work around this limitation Gateworks has created an installable U-Boot script that will apply UBI files containing a single partition image. This can be particularly useful for updating the firmware of a running target. |
| 334 | |
| 335 | To update using a split UBI: |
| 336 | '''1. Split your UBI |
| 337 | In most situations the RAM of your device will be smaller than the image file required to update your system, therefore it is necessary to split the image file and apply the resulting compressed parts in a piece wise update. The below example uses the {{{split}}} command to split the input file into parts that are reasonably smaller than the RAM size of the board which will be consuming the update. |
| 338 | {{{#!bash |
| 339 | FILE=xenial-large.ubi |
| 340 | # Split file every 200M with suffix ".part" and decimal increment |
| 341 | split -d -b 200M ${FILE} ${FILE}.part |
| 342 | for i in $(ls ${FILE}.*); do |
| 343 | mv $i ${FILE}.$(echo $i | cut -d'.' -f3) |
| 344 | done |
| 345 | |
| 346 | # Result will be multiple files such as xenial-large.ubi.partXX that are <= 200M and |
| 347 | # which adhere to the naming convention required by the script (ends with .partXX in sequential order) |
| 348 | }}} |
| 349 | '''2. Install the U-Boot script |
| 350 | On the target machine, source the [http://trac.gateworks.com/raw-attachment/wiki/linux/ubi/nand_split_update.scr nand_split_update.scr] U-Boot script attached to this page (or copy its contents with an editor). For example via tftp: |
| 351 | {{{#!bash |
| 352 | setenv serverip 192.168.1.100 |
| 353 | tftp nand_split_update.scr |
| 354 | source $loadaddr |
| 355 | }}} |
| 356 | '''3. Configure your U-Boot environment |
| 357 | From the script's usage: |
| 358 | {{{ |
| 359 | The following environment variables need to be set in order for this script to run: |
| 360 | |
| 361 | splitfile - full path file name prefix of the splitted files (eg file.ubi for file.ubi.part00) |
| 362 | }}} |
| 363 | An example configuration: |
| 364 | {{{#!bash |
| 365 | setenv splitfile xenial-large.ubi # ubi file from example above |
| 366 | }}} |
| 367 | |
| 368 | '''4. Run the added script with {{{run nand_split_update}}} |
| 369 | |
| 370 | |
| 371 | |