Patch: Automatically run osmoload from osmocon

Christian Vogel vogelchr at vogel.cx
Sun Feb 5 14:50:55 CET 2012


Hi,

I'm getting kind of annoyed by the new >64k firmwares that need
to be loaded via osmoload. Included patch #2 adds a "-a" option
to osmocon that runs an arbitrary script after the main firmware
has been successfully uploaded to the phone.

This script could, for example, then handle upload of a second
stage firmware via osmoload. Also layer23 could be started here
just before uploading layer1.

The script will be given the socket, serial port, loader method
(c123xor...) and main firmware as arguments, those can be used
to distinguish several phones that are connected to the same PC.

Example usage (using attached osmoload.sh script):

osmocon -p /dev/ttyUSB0 -m c155 -a .../osmoload.sh \
	.../board/compal_e99/loader.compalram.bin

Received DOWNLOAD ACK from phone, your code is running now!
OSMOCOM Loader (revision osmocon_v0.0.0-1299-g7c08201)
(---- 2 second delay ----)
[osmoload.sh] Socket is /tmp/osmocom_loader, port is /dev/ttyUSB0.
[osmoload.sh] Loader method was c155.
[osmoload.sh] New firmware will be
osmocom-bb/src/target/firmware/board/compal_e99/rssi.highram.bin.
Received pong.
Loading 75472 bytes of memory to address 0x820000 from file
osmocom-bb/src/target/firmware/board/compal_e99/rssi.highram.bin
..................................................................

	Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-osmocon-array-of-download-method-names.patch
Type: text/x-diff
Size: 2278 bytes
Desc: not available
URL: <http://lists.osmocom.org/pipermail/baseband-devel/attachments/20120205/519a0610/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-osmocon-Option-a-runs-program-script-on-upload.patch
Type: text/x-diff
Size: 4732 bytes
Desc: not available
URL: <http://lists.osmocom.org/pipermail/baseband-devel/attachments/20120205/519a0610/attachment-0001.patch>
-------------- next part --------------
#!/bin/bash

socket="$1"
port="$2"
method="$3"
main_fw="$4"

fw_dir="${main_fw%/*}"
new_fw="${fw_dir}/rssi.highram.bin"
osmoload="$OSMOCOM_ROOT/osmocom-bb/src/host/osmocon/osmoload"

tag="[${0##*/}]"

echo "Environment:"
env


if ! [ -x "$osmoload" ] ; then
	echo "$tag *** $osmoload not found/not executable." >&2
	exit 1
fi

if ! [ -f "$new_fw" ] ; then
	echo "$tag *** $new_fw not found." >&2
	exit 1
fi

echo "$tag Socket is $socket, port is $port." >&2
echo "$tag Loader method was $method." >&2
echo "$tag New firmware will be $new_fw." >&2

MAX_PINGS=5
N=0
while [ "$N" -lt "$MAX_PINGS" ] ; do
	N="$(( $N + 1 ))"
	$osmoload -l $socket ping
	if [ "$?" == 0 ] ; then
		break
	fi
done

if [ "$N" -ge $MAX_PINGS ] ; then
	echo "$tag *** could not ping phone!" >&2
	exit 1
fi

$osmoload -l $socket  memload 0x820000 $new_fw
if [ "$?" != 0 ] ; then
	echo "$tag *** could not upload firmware!" >&2
	exit 1
fi

$osmoload -l $socket jump 0x820000
if [ "$?" != 0 ] ; then
	echo "$tag *** could not run firmware!" >&2
	exit 1
fi


More information about the baseband-devel mailing list