view sh/c139-gen-fc-ffs-tree @ 20:aa2fd60a44fb

new shell scripts c11x-gen-fc-{ffs-img,script}
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 10 Jun 2023 23:53:15 +0000
parents 2299f1ebbfd2
children
line wrap: on
line source

#!/bin/sh

# This shell script is officially intended to be C139-specific, but it is
# currently used for all C1xx models.  This script uses aud-c139 audio mode
# config files, but we don't have a different set of these files for other
# C1xx models, and this aspect of the hw is likely to be the same anyway.

if [ $# != 3 ]
then
	echo "usage: $0 rfbin-dir imei-file output-dir" 1>&2
	exit 1
fi

set -e

# Figure out RF bands

rfbin="$1"

if [ ! -d "$rfbin/rx" -o ! -d "$rfbin/tx" ]
then
	echo "Error: no RF calibration records in $1" 1>&2
	exit 1
fi

if [ -f "$rfbin/tx/levels.850" ]
then
	have850=y
else
	have850=n
fi

if [ -f "$rfbin/tx/levels.900" ]
then
	have900=y
else
	have900=n
fi

if [ -f "$rfbin/tx/levels.1800" ]
then
	have1800=y
else
	have1800=n
fi

if [ -f "$rfbin/tx/levels.1900" ]
then
	have1900=y
else
	have1900=n
fi

case $have850$have900$have1800$have1900 in
  nyyn)
	rfcap=dual-eu
	;;
  ynny)
	rfcap=dual-us
	;;
  *)
	echo "Error: RF files in $1 match neither dual-eu nor dual-us" 1>&2
	exit 1
esac

# Figure out IMEI and IMEISV
# SV digits are set per FreeCalypso convention

IMEI=`cat "$2"`
SV=98
IMEISV=`make-imeisv $IMEI $SV`

# Now create and populate our file system output

destdir="$3"

rm -rf "$destdir"
mkdir "$destdir"

# create the same directories as fc-fsio mk-std-dirs

mkdir "$destdir/gsm"
mkdir "$destdir/gsm/com"
mkdir "$destdir/pcm"
mkdir "$destdir/sys"
mkdir "$destdir/mmi"
mkdir "$destdir/var"
mkdir "$destdir/var/dbg"
mkdir "$destdir/etc"

# populate subtrees

cp -r "$rfbin" "$destdir/gsm/rf"
cp -r /opt/freecalypso/aud-c139 "$destdir/aud"

# populate individual files

tiffs-mkfile "$destdir/gsm/com/rfcap" rfcap $rfcap
tiffs-mkfile "$destdir/etc/IMEISV" imeisv $IMEISV
compile-fc-chg /opt/freecalypso/charging/c1xx/standard "$destdir/etc/charging"