#!/bin/bash # unless otherwise noted, EVERY NUMBER IS IN HEX base_dir=$(dirname $0) scriptfile=autoscript.scr imgfile=autoscript.bin kernel_file=uImage for i in $base_dir/omap5912osk/uImage* ; do cp -f $i $base_dir/$kernel_file done if [ ! -f $base_dir/$kernel_file ] ; then echo "Could not find kernel image $base_dir/$kernel_file." exit 1 fi kernel_size_10=`du -b $base_dir/$kernel_file | cut -f 1` kernel_size=$( printf "0x%08X" $kernel_size_10 ) rootfs_file=rootfs.jffs2 #cp -f $base_dir/omap5912osk/gpe-image-omap5912osk.jffs2 $base_dir/$rootfs_file cp -f $base_dir/omap5912osk/pd-osk-gpe-image-omap5912osk.jffs2 $base_dir/$rootfs_file if [ ! -f $base_dir/$rootfs_file ] ; then echo "Could not find root filesystem image $base_dir/$rootfs_file." exit 1 fi rootfs_size_10=`du -b $base_dir/$rootfs_file | cut -f 1` rootfs_size=$( printf "0x%08X" $rootfs_size_10 ) # the osk doesn't have enough RAM to copy the whole rfs with tftp # thus we must split it # this makes files named rootfs.jffs2.00, rootfs.jffs2.01, ... max_file_size=0x00C00000 # 12 MiB split --bytes $(($max_file_size)) --numeric-suffixes $rootfs_file ${rootfs_file}. # because this may get confusing, here is a description of interpolation rules # here documents work basically like double quoted strings w.r.t. variable expansion # $var is local to this script, and will be expanded before catting # \${var} is not expanded here, but will be expanded when the generated script is run in u-boot # like in a double quoted string, single quotes don't have any special meaning (w.r.t. this script) # in u-boot, single quote do not expand variables, so # setenv bar blah # setenv foo '${bar}' # setenv fu ${bar} # means that foo is literally "${bar}" and fu is literally "blah" # variables are expanded only once, so "setenv baz ${foo}" means baz = "${bar}" # basically, # $var is a literal in u-boot # \${var} is "${var}" in u-boot # "setenv foo \${var}" or "setenv foo '${var}'" makes foo the unexpanded ${var} in u-boot # almost everything except constants (addresses and such) should be of the form \${var} # so they get expanded when they're used. # use this regex to check: [^\\][$] # isn't quoting fun? bonus points if you can quine this script # note about bootargs # it seems that bootargs is not expanded before being passed to the kernel, # so we must not have any unexpanded variables in it # 0x00000000-0x00020000 : "bootloader" # 0x00020000-0x00040000 : "params" # 0x00040000-0x00240000 : "kernel" # 0x00240000-0x02000000 : "filesystem" (cat < $base_dir/$scriptfile mkimage -A arm -O linux -T script -C none -a 0 -e 0 \ -n "kernel/fs loader script" \ -d $base_dir/$scriptfile $base_dir/$imgfile chmod 644 $base_dir/$imgfile chmod 644 $base_dir/$kernel_file chmod 644 $base_dir/$rootfs_file