Skip to content

Commit

Permalink
device tree blob must be 4-bytes alingned
Browse files Browse the repository at this point in the history
Each appended device tree blob must be 4-bytes aligned.
This patch modifies append_dtbs script to append bytes to each device tree
file so the size is multiple of 4.
When finding dtb the addres of next dtb is also aligned to 4-bytes.

Signed-off-by: Tomasz Figa <[email protected]>
Signed-off-by: Piotr Wilczek <[email protected]>
Signed-off-by: Kyungmin Park <[email protected]>
  • Loading branch information
Piotr Wilczek authored and zonque committed Dec 18, 2013
1 parent 1e29caa commit ec09d8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions append_dtbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@ OUT="$1"
shift
DTBS="$*"

while [ -n "$*" ]
do
SIZE=`stat $1 -c %s`
MOD=`expr $SIZE % 4`
if [ $MOD -ne 0 ]; then
PADDING=`expr 4 - $MOD`
dd if=/dev/zero count=$PADDING bs=1 >> $1 2> /dev/null
fi
shift
done

cat $DTBS >>$OUT
dd if=/dev/zero of=$OUT oflag=append conv=notrunc bs=1 count=8 #sentinel
4 changes: 4 additions & 0 deletions dtbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ void *find_dtb(void *dtbs, const char *compat)
return d;

d = (struct fdt_header *)((char *)d + be_to_cpu(d->totalsize));

/* align to 4-bytes */
d = (struct fdt_header *)((((unsigned int)d + 0x3) & ~0x3));

}

return NULL;
Expand Down

0 comments on commit ec09d8a

Please sign in to comment.