view sh/c11x-gen-fc-script @ 23:2df287f4722c

doc/C1xx-flashing: article written
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Jun 2023 09:55:27 +0000
parents aa2fd60a44fb
children
line wrap: on
line source

#!/bin/sh

# This shell script generates the set of files needed for reflashing a Motorola
# C11x/12x phone to FreeCalypso: it invokes c11x-gen-fc-ffs-img to generate
# fc-ffs.bin (customized FFS image containing IMEI and extracted factory RF
# calibration values specific to your particular phone), and the present script
# then generates a command script for fc-loadtool that flashes everything
# in one go.

if [ $# != 1 ]
then
	echo "usage: $0 fwimage.bin" 1>&2
	exit 1
fi

if [ ! -f "$1" ]
then
	echo "Error: $1 does not exist or is not a regular file" 1>&2
	exit 1
fi

flashimg=flashdump.bin

if [ ! -f $flashimg ]
then
	echo "Error: $flashimg is missing" 1>&2
	exit 1
fi

if [ ! -d rfbin ]
then
	echo "Error: rfbin directory is missing" 1>&2
	exit 1
fi

if [ ! -f IMEI ]
then
	echo "Error: IMEI file is missing" 1>&2
	exit 1
fi

set -e

length=`wc -c $flashimg | cut -d ' ' -f 1`

case "$length" in
	2097152)
		flash=2m
		ffs_addr=0x1C0000
		;;
	4194304)
		flash=4m
		ffs_addr=0x300000
		;;
	*)
		echo "Error: file length of $flashimg is not understood" 1>&2
		exit 1
esac

c11x-gen-fc-ffs-img rfbin IMEI $flash

echo 'flash erase-program-boot /opt/freecalypso/target-bin/compal-flash-boot-for-fc.bin' > fc-flash-script
echo "flash e-program-bin 0x10000 $1" >> fc-flash-script
echo "flash e-program-bin $ffs_addr fc-ffs.bin" >> fc-flash-script

echo 'Generated fc-loadtool command script in fc-flash-script'