blob: accf7d824b7a34886b9fa0ef89c9b8c5b7bb2cef [file] [log] [blame]
Adriana Kobylak5bd157c2017-05-25 15:48:27 -05001#!/bin/sh
2
3# Get the pnor mtd device number
4pnor=`grep pnor /proc/mtd |cut -c 4`
5
6# Attach the pnor mtd device to ubi
7ubiattach /dev/ubi_ctrl -m $pnor
8if [ $? -ne 0 ]
9then
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
23fi