source: rtems/bsps/arm/beagle/simscripts/sdcard.sh @ e99847bf

5
Last change on this file since e99847bf was 68a5f751, checked in by Pierre-Louis Garnier <garnie_a@…>, on 02/25/19 at 22:30:11

arm/beagle: Fix sdcard.sh tool

  • Property mode set to 100644
File size: 2.2 KB
Line 
1# we store all generated files here.
2TMPDIR=tmp_sdcard_dir.$$
3
4FATIMG=$TMPDIR/bbxm_boot_fat.img
5SIZE=65536
6OFFSET=2048
7FATSIZE=`expr $SIZE - $OFFSET`
8UENV=uEnv.txt
9
10rm -rf $TMPDIR
11mkdir -p $TMPDIR
12trap 'rm -rf $TMPDIR' EXIT
13
14if [ $# -ne 3 ]
15then    echo "Usage: $0 <RTEMS prefix> <RTEMS executable> <Device Tree Blob>"
16        exit 1
17fi
18
19PREFIX=$1
20
21if [ ! -d "$PREFIX" ]
22then    echo "This script needs the RTEMS tools bindir as the first argument."
23        exit 1
24fi
25
26executable=$2
27
28case "$2" in
29        *beagleboard*)
30                ubootcfg=omap3_beagle
31                imgtype=bb
32                ;;
33        *beaglebone*)
34                ubootcfg=am335x_evm
35                imgtype=bone
36                ;;
37        *)
38                echo "Can't guess which uboot to use - please specify full path to executable."
39                exit 1
40                ;;
41esac
42
43dtb="$3"
44
45app=rtems-app.img
46
47if [ ! -f "$executable" ]
48then    echo "Expecting RTEMS executable as arg; $executable not found."
49        exit 1
50fi
51
52set -e
53
54IMG=${imgtype}_`basename $2`-sdcard.img
55
56# Make an empty image
57dd if=/dev/zero of=$IMG bs=512 seek=`expr $SIZE - 1` count=1
58dd if=/dev/zero of=$FATIMG bs=512 seek=`expr $FATSIZE - 1` count=1
59
60# Make an ms-dos FS on it
61$PREFIX/bin/newfs_msdos -r 1 -m 0xf8 -c 4 -F16  -h 64 -u 32 -S 512 -s $FATSIZE -o 0 ./$FATIMG
62
63# Prepare the executable.
64base=`basename $executable`
65$PREFIX/bin/arm-rtems5-objcopy $executable -O binary $TMPDIR/$base.bin
66gzip -9 $TMPDIR/$base.bin
67$PREFIX/bin/mkimage -A arm -O rtems -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d $TMPDIR/$base.bin.gz $TMPDIR/$app
68echo "setenv bootdelay 5
69uenvcmd=run boot
70boot=fatload mmc 0 0x80800000 $app ; fatload mmc 0 0x88000000 $(basename "$dtb") ; bootm 0x80800000 - 0x88000000" >$TMPDIR/$UENV
71
72# Copy the uboot and app image onto the FAT image
73$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/MLO ::MLO
74$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/u-boot.img ::u-boot.img
75$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$app ::$app
76$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$UENV ::$UENV
77# Copy DTB
78$PREFIX/bin/mcopy -bsp -i $FATIMG "$dtb" ::"$(basename "$dtb")"
79
80# Just a single FAT partition (type C) that uses all of the image
81$PREFIX/bin/partition -m $IMG $OFFSET c:${FATSIZE}\*
82
83# Put the FAT image into the SD image
84dd if=$FATIMG of=$IMG seek=$OFFSET
85
86echo "Result is in $IMG."
Note: See TracBrowser for help on using the repository browser.