Adriana Kobylak | 5bd157c | 2017-05-25 15:48:27 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Get the pnor mtd device number |
| 4 | pnor=`grep pnor /proc/mtd |cut -c 4` |
| 5 | |
| 6 | # Attach the pnor mtd device to ubi |
| 7 | ubiattach /dev/ubi_ctrl -m $pnor |
| 8 | if [ $? -ne 0 ] |
| 9 | then |
| 10 | # Check the pnor mtd device is formatted as ubi by reading the first 3 byes, |
| 11 | # which should be the ascii chars 'UBI' |
| 12 | magic=`hexdump -C -n 3 /dev/mtd$pnor` |
| 13 | if [[ $magic == *"UBI"* ]] |
| 14 | then |
| 15 | # Device already formatted as ubi, ubiattach failed for some other reason |
| 16 | exit -1 |
| 17 | else |
| 18 | # Format device as ubi |
| 19 | bios-ubiformat |
| 20 | # Retry the ubiattach |
| 21 | ubiattach /dev/ubi_ctrl -m $pnor |
| 22 | fi |
| 23 | fi |