[U-Boot] Socfpga preloader signing patch

Charles Manning cdhmanning at gmail.com
Mon Apr 7 21:51:20 CEST 2014


On Saturday 05 April 2014 09:47:02 Pavel Machek wrote:
> Hi!
>
> > I'm trying to get custom preloader to work (on EBV Socrates)... I
> > tried applying old patch from mail archives, but a) applying patch
> > from mail archives is not fun and b) it did not seem to do the trick.
>
> Just to make sure... right way to use the
> socfpga-signed-preloader.bin is
>
> dd if=socfpga-signed-preloader.bin of=/dev/mmcblk0p1 bs=64k seek=0
> dd if=u-boot.img of=/dev/mmcblk0p1 bs=64K seek=4

Almost right.

It must be partition 3, which must be of type A2.

dd .....of=/dev/mmcblk0p3 ...

I use the following script to set up an sd card with some useful partitions:


#!/bin/bash
# Script to partition an SDCard for the SoCFPGA
# /dev/sdx3 MUST be type A2. It is used for the bootloaders.
#
# We also make /dev/sdx1 -  FAT, then the rest is ext2
#


#set -e -x

DEVICE=$1
THIS_DIR="$( cd "$( dirname "$0" )" && pwd )"
BASE_DIR="${THIS_DIR}/.."

errmsg() {
	echo "Error: $@" 2>&1
}

errdie() {
	errmsg "$@"
	exit 1
}

log() {
	echo '----'
	echo "$@"
	echo '----'
}

usage() {
	echo "Usage: $1 <sd/mmc device file>"
}

if [ $# -ne 1 ]; then
	errmsg "incorrect usage"
	usage $0
	exit 1
fi

DEVICE=$1

# precondition checks

if [ ! -b ${DEVICE} ]; then
	errdie "${DEVICE} is not an accessable block device"
fi

# confirm

read -p "The ${DEVICE} device will be formatted. Continue? [y/n] " answer
if [ "$answer" != "y" ]; then
	exit 0;
fi

# umount if device partitions are mounted

for partition in `mount | grep ${DEVICE} | cut -d ' ' -f 1`; do
	echo "Umounting ${partition} ..."
	umount $partition
	if [ $? -ne 0 ]; then
		errdie "failed to umount ${partition}"
	fi
done

# go

log 'Repartitioning...'


#
# Set up 3 partitions, then set their type.
#  /dev/sdx3 is the bootloader partition and must be type A2
#  We add a small FAT partition, as /dev/sdx1 then the rest is
# an ext2 partition.
#
fdisk $DEVICE << EOF
o
n
p
3
2048
+8M
n
p
1

+20M
n
p
2


t
1
4
t
2
83
t
3
a2
p
w
EOF

if [ $? -ne 0 ]; then
	errdie "repartitioning failed"
fi

log 'Formatting...'

echo "Formatting FAT aprtition..."

mkfs.vfat ${DEVICE}1
if [ $? -ne 0 ]; then
	errdie "formatting failed"
fi

echo "Formatting Linux partition ..."

mkfs.ext2 ${DEVICE}2
if [ $? -ne 0 ]; then
	errdie "formatting failed"
fi


log 'Done'

exit 0
#end of script



More information about the U-Boot mailing list