summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
diff options
context:
space:
mode:
authorBen Gras <beng@shrike-systems.com>2014-11-03 19:53:40 +0100
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-11-03 14:19:47 -0600
commit53dd6d6130c870d12351d8ca75e4ac9dcc834c86 (patch)
tree022804b833f8fdb47a15ab8940743f91726776b5 /c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
parentAdded BeagleBoard BSP (diff)
downloadrtems-53dd6d6130c870d12351d8ca75e4ac9dcc834c86.tar.bz2
BSP for several Beagle products
Specifically the beagleboard, beagleboard xM, beaglebone, beaglebone black. More info on these targets: http://www.beagleboard.org/ This commit forms a basic BSP by combining Claas's work with . new clock and irq code and definitions for beagle targets (beagleboard and beaglebones), mostly reused from the Minix codebase, thus making irqs, ticks and non-polled console mode work too . new timer code for ns timing with high timer resolution, 24MHz on the AM335X and 13MHz on the DM37XX . select the console uart based on target at configure time . removing all the lpc32xx-specific macros and code and other unused code and definitions that the beagle bsp was based on . re-using some standard functions instead of lpc32xx versions . fixed some whitespace problem in preinstall.am . fixed some compile warnings . configure MMU: set 1MB sections directly in the TTBR, just to show the difference between cacheable RAM and non-cacheable device memory and invalid ranges; this lets us turn on caches and not rely on boot loader MMU configuration. Verified to work when MMU is initially either on or off when RTEMS gets control. Thanks for testing, commentary, improvements and fixes to Chris Johns, Brandon Matthews, Matt Carberry, Romain Bornet, AZ technology and others. Signed-Off-By: Ben Gras <beng@shrike-systems.com>
Diffstat (limited to '')
-rw-r--r--c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh b/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
new file mode 100644
index 0000000000..becd2c7720
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
@@ -0,0 +1,84 @@
+# we store all generated files here.
+TMPDIR=tmp_sdcard_dir.$$
+
+FATIMG=$TMPDIR/bbxm_boot_fat.img
+SIZE=65536
+OFFSET=2048
+FATSIZE=`expr $SIZE - $OFFSET`
+UENV=uEnv.txt
+
+rm -rf $TMPDIR
+mkdir -p $TMPDIR
+
+if [ $# -ne 2 ]
+then echo "Usage: $0 <RTEMS prefix> <RTEMS executable>"
+ exit 1
+fi
+
+PREFIX=$1
+
+if [ ! -d "$PREFIX" ]
+then echo "This script needs the RTEMS tools bindir as the first argument."
+ exit 1
+fi
+
+executable=$2
+
+case "$2" in
+ *beagleboard*)
+ ubootcfg=omap3_beagle
+ imgtype=bb
+ ;;
+ *beaglebone*)
+ ubootcfg=am335x_evm
+ imgtype=bone
+ ;;
+ *)
+ echo "Can't guess which uboot to use - please specify full path to executable."
+ exit 1
+ ;;
+esac
+
+app=rtems-app.img
+
+if [ ! -f "$executable" ]
+then echo "Expecting RTEMS executable as arg; $executable not found."
+ exit 1
+fi
+
+set -e
+
+IMG=${imgtype}_`basename $2`-sdcard.img
+
+# Make an empty image
+dd if=/dev/zero of=$IMG bs=512 seek=`expr $SIZE - 1` count=1
+dd if=/dev/zero of=$FATIMG bs=512 seek=`expr $FATSIZE - 1` count=1
+
+# Make an ms-dos FS on it
+$PREFIX/bin/newfs_msdos -r 1 -m 0xf8 -c 4 -F16 -h 64 -u 32 -S 512 -s $FATSIZE -o 0 ./$FATIMG
+
+# Prepare the executable.
+base=`basename $executable`
+$PREFIX/bin/arm-rtems4.11-objcopy $executable -O binary $TMPDIR/$base.bin
+gzip -9 $TMPDIR/$base.bin
+$PREFIX/bin/mkimage -A arm -O rtems -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d $TMPDIR/$base.bin.gz $TMPDIR/$app
+echo "setenv bootdelay 5
+uenvcmd=run boot
+boot=fatload mmc 0 0x80800000 $app ; bootm 0x80800000" >$TMPDIR/$UENV
+
+# Copy the uboot and app image onto the FAT image
+$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/MLO ::MLO
+$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/u-boot.img ::u-boot.img
+$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$app ::$app
+$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$UENV ::$UENV
+
+# Just a single FAT partition (type C) that uses all of the image
+$PREFIX/bin/partition -m $IMG $OFFSET c:${FATSIZE}\*
+
+# Put the FAT image into the SD image
+dd if=$FATIMG of=$IMG seek=$OFFSET
+
+# cleanup
+rm -rf $TMPDIR
+
+echo "Result is in $IMG."