Permalink
Browse files

Intial commit of sd card building utility.

Creates Verification Test images, Bootloader flash images and
Memory test / burn-in images. Will create cards that work on
Elpida or Micron based boards (Micron is the default)
  • Loading branch information...
0 parents commit fef29885f095bc43d392b636dc53c882f16708cd mgrundy committed Oct 12, 2010
@@ -0,0 +1,62 @@
+echo ============================================================
+echo Running initial setup
+echo ============================================================
+echo running mmcinit
+mmc init
+
+echo setting nand ecc hw
+nandecc hw
+
+echo erasing 0x0 0x80000
+nand erase 0x0 0x80000
+
+echo reading x-loader (x-load.bin.ift)
+fatload mmc 0:1 0x82000000 x-load.bin.ift
+
+echo writing x-loader to nand
+nand write 0x82000000 0x0 0x80000
+
+echo setting nand ecc sw
+nandecc sw
+
+echo erasing 0x80000 0x160000
+nand erase 0x80000 0x160000
+
+echo reading u-boot (pu-boot.bin)
+fatload mmc 0:1 0x82000000 pu-boot.bin
+
+echo writing u-boot to nand
+nand write 0x82000000 0x80000 0x160000
+
+echo setting boot sequence and args
+setenv mmcargs 'setenv bootargs smsc95xx.mac=${ethaddr} console=${console} root=/dev/mmcblk0p1 rw rootwait rootdelay=1 kgdboc=${console} usbcore.autosuspend=-1'
+setenv mmcboot 'mmc init;ext2load mmc 0:1 0x80000000 /boot/uImage;run mmcargs;bootm 0x80000000'
+setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p1 rw rootwait rootdelay=1 kgdboc=ttyS2,115200n8 usbcore.autosuspend=-1 8250.nr_uarts=6 printk.time=1'
+setenv shutdown 'i2c mw 4b 46 41 1'
+setenv bootcmd 'run mmcboot; run confcmd; run shutdown'
+setenv confcmd 'mmc init; mw.b 0x81600000 0xff 0x100; fatload mmc 0:1 0x81600000 config.img; source 0x81600000;'
+setenv bootdelay '3'
+setenv console 'ttyS2,115200n8'
+setenv preboot ''
+setenv stderr 'serial'
+setenv stdin 'serial'
+setenv stdout 'serial'
+setenv loadaddr
+setenv usbtty
+setenv vram
+setenv dvimode
+setenv defaultdisplay
+setenv mmcroot
+setenv mmcrootfstype
+setenv nandroot
+setenv nandrootfstype
+setenv nandargs
+setenv loadbootscript
+setenv bootscript
+setenv loaduimage
+setenv nandboot
+setenv bootkernel
+setenv bootkernel_1
+echo Saving Normal Configuration
+saveenv
+run shutdown
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,33 @@
+echo ============================================================
+echo Running the Ram and Nand tests
+echo ============================================================
+setenv red 'imw 4A EE 11 1'
+setenv grn 'imw 4A EE 22 1'
+setenv off 'imw 4A EE 00 1'
+run grn
+if diagnose memory nand; then
+ if diag memory RAMtest; then
+ echo loading test kernel
+ fatload mmc 0:1 0x80000000 uImage
+ echo loading initrd
+ fatload mmc 0:1 0x81600000 ramdisk.gz
+ # Now booting correctly with ramdisk and initrd:
+ setenv bootargs 'console=ttyS2,115200n8 ramdisk_size=10240 mem=256M root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,4M rw rootwait rootdelay=1 kgdboc=ttyS2,115200n8 usbcore.autosuspend=-1 8250.nr_uarts=6 printk.time=1'
+
+ echo booting test kernel
+ bootm 0x80000000
+ # Ram Test Failed
+ else
+ while echo; do
+ run off
+ sleep 1
+ run red
+ sleep 1
+ done
+ fi
+#Nand test Failed
+else
+ run off
+ run red
+fi
+
Binary file not shown.
235 sdbuild
@@ -0,0 +1,235 @@
+#!/bin/bash
+# Licensed under terms of GPLv2
+# (c) 2010 BugLabs Mike Grundy <Michael.Grundy@buglabs.net>
+#
+# mkcard() from mkcard.sh v0.5
+# (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
+#
+# Parts of the procudure base on the work of Denys Dmytriyenko
+# http://wiki.omap.com/index.php/MMC_Boot_Format
+
+prompt()
+{
+ tvar=L
+ while [ "$tvar" != "y" ] &&
+ [ "$tvar" != "Y" ] &&
+ [ "$tvar" != "n" ] &&
+ [ "$tvar" != "N" ] &&
+ [ "$tvar" != "r" ] &&
+ [ "$tvar" != "R" ]; do
+
+ read -n1 tvar
+
+ done
+ export $1=$tvar
+}
+
+micron-loader () {
+ cp ./x-loader/MLO-micron $1/MLO
+ cp ./x-loader/x-load.bin.ift-micron $1/x-load.bin.ift
+}
+
+elpida-loader () {
+ cp ./x-loader/MLO-elpida $1/MLO
+ cp ./x-loader/x-load.bin.ift-elpida $1/x-load.bin.ift
+}
+
+mtest-build () {
+ cp ./u-boot/u-boot.gold-bin $1/u-boot.bin
+ cp ./uImage/uImage $1
+ cp ./memtest/ramdisk.gz $1
+ cp ./memtest/__setenv.img $1
+}
+
+flash-build () {
+ cp ./u-boot/u-boot-force-env $1/u-boot.bin
+ cp ./u-boot/pu-boot.bin $1
+ cp ./flash/config.img $1
+}
+
+vtest-build() {
+ cp ./u-boot/u-boot.gold-bin $1
+ cp ./uImage/uImage $1
+ cp ./vtest/ramdisk.gz $1
+}
+
+vtest-vars () {
+ echo wlan_ip=192.168.1.10$1 > $2/testvars
+ echo test_ip=192.168.1.1 >>$2/testvars
+ echo source_addr=192.168.1.10$1 >>$2/testvars
+ echo dest_addr=192.168.1.1 >>$2/testvars
+ echo wlan_name=bugbasetesting >>$2/testvars
+}
+
+mkcard(){
+ export LC_ALL=C
+
+ DRIVE=$1
+ PARTNAME=$2
+ if [ -e $PARTNAME ]; then
+ PARTNAME="BUGCARD"
+ fi
+
+ sleep 5
+ umount ${DRIVE}*
+
+ dd if=/dev/zero of=$DRIVE bs=1024 count=1024
+ if [ $? != "0" ];then
+ echo "Partition table wipe (dd) failed"
+ exit
+ fi
+
+ SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
+ CYLINDERS=`echo $SIZE/255/63/512 | bc`
+ # echo DISK SIZE: $SIZE bytes CYLINDERS: $CYLINDERS
+
+ {
+ echo ,9,0x0C,*
+ echo ,,0x0C,-
+ } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
+ if [ $? != "0" ];then
+ echo sfdisk failed, exiting
+ exit
+ fi
+
+ sleep 1
+
+ if [ -b ${DRIVE}1 ]; then
+ umount ${DRIVE}1
+ mkfs.vfat -F 32 -n "${PARTNAME}" ${DRIVE}1
+ if [ $? != "0" ];then
+ echo mkfs failed, exiting
+ exit
+ fi
+ elif [ -b ${DRIVE}p1 ]; then
+ umount ${DRIVE}p1 2&>1 > /dev/null
+ mkfs.vfat -F 32 -n "${PARTNAME}" ${DRIVE}p1
+ if [ $? != "0" ];then
+ echo mkfs failed, exiting
+ exit
+ fi
+ else
+ echo "Cant find boot partition in /dev"
+ exit
+ fi
+
+ if [ -b ${DRIVE}2 ]; then
+ umount ${DRIVE}2
+ mkfs.vfat -F 32 -n "${PARTNAME}-2" ${DRIVE}2
+ if [ $? != "0" ];then
+ echo mkfs failed, exiting
+ exit
+ fi
+ elif [ -b ${DRIVE}p2 ]; then
+ umount ${DRIVE}p2
+ mkfs.vfat -F 32 -n "${PARTNAME}-2" ${DRIVE}p2
+ if [ $? != "0" ];then
+ echo mkfs failed, exiting
+ exit
+ fi
+ else
+ echo "Cant find 2nd partition in /dev"
+ exit
+ fi
+}
+
+help () {
+ echo sdbuild - Designed to keep Rao and the fine folks at CircuitCo happy
+ echo " -d Device name of the sd card you are building"
+ echo " -e Configure for prototype boards with Elpida memory"
+ echo -e " (Micron is the defaut. It's in all the production bases)"
+ echo " -f Create bootloader flash card"
+ echo " -m Create memory test / burn-in card"
+ echo " -n Test Fixture ID (only used with -v)"
+ echo " -v Create verification test card"
+}
+memtype=micron
+if [ $# -eq 0 ]; then
+ help
+ exit -1
+fi
+
+while [ $# -gt 0 ]; do
+ # -d Device name
+ if [ "$1" == "-d" ]; then
+ shift
+ if [ -b $1 ]; then
+ devname=$1
+ mountpoint=/media/$(echo $devname | sed 's:/dev/::')1
+ else
+ echo $1 is not a valid block device
+ exit -1
+ fi
+ # -e Elpida memory (micron is the default)
+ elif [ "$1" == "-e" ]; then
+ memtype=elpida
+ # -f Create bootloader flash disk
+ elif [ "$1" == "-f" ]; then
+ buildtype=flash
+ # -m Create memory test
+ elif [ "$1" == "-m" ]; then
+ buildtype=mtest
+ # -n Test Fixture ID (only used with -v)
+ elif [ "$1" == "-n" ]; then
+ shift
+ fixid=$1
+ # -v Create verification test
+ elif [ "$1" == "-v" ]; then
+ buildtype=vtest
+ # Create a better informed user
+ elif [ "$1" == "--help" ]; then
+ help
+ else
+ echo $1 is not a valid option. Try one of these instead:
+ help
+ exit
+ fi
+ shift
+done
+
+while [ 1 ]; do
+
+
+ if [ "$buildtype" == "vtest" ]; then
+ volid=TESTRIG${fixid}
+ elif [ "$buildtype" == "mtest" ]; then
+ volid=MEMTEST
+ elif [ "$buildtype" == "flash" ]; then
+ volid=FLASH-${memtype}
+ else
+ echo Internal Error, sorry
+ exit
+ fi
+
+ echo partitioning and formatting card
+ mkcard $devname $volid
+ echo mounting partition
+ pmount ${devname}1
+ if [ ! -d $mountpoint ]; then
+ echo mount failed
+ exit
+ fi
+ echo Writing x-loader for ${memtype}
+ ${memtype}-loader ${mountpoint}
+ echo Writing files to disk
+ ${buildtype}-build ${mountpoint}
+
+ pumount ${devname}1
+ clear
+ echo
+ echo
+ echo
+ echo
+ echo "********************************************************************"
+ echo "SD Card build complete. Would you like to create another copy? (y/n)"
+ echo "********************************************************************"
+
+ prompt finished
+
+ if [ $finished == "n" ]; then
+ break
+ else
+ continue
+ fi
+done
+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit fef2988

Please sign in to comment.