RTEMS-BBB(五):SD卡

用到bengras大神的源码下的一个simscripts脚本,可以一步完成 
% cd $HOME/development/rtems/rtems-src/c/src/lib/libbsp/arm/beagle/simscripts
 % sh sdcard.sh $HOME/development/rtems/4.11 $HOME/development/rtems/b-beagle/arm-rtems4.11/c/beagleboneblack/testsuites/samples/hello/hello.exe
查看一下sdcard.sh脚本内容
# 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."
用到了工具链安装时用到的u-boot工具,生成MLO和u-boot.img,注意uEnv.txt的内容脚本中也写好,将hello.exe通过mkimage工具打包成rtems-app.img然后再将整个四个文件
一起打包成img,还用到了partition分区工具
我们可以把hello.exe替换成rki.elf
然后生成bone_rki.elf-sdcard.img
再烧入SD卡中启动,在console口可以看到



下一篇讲解如何不用这个脚本做SD卡
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值