All of lore.kernel.org
 help / color / mirror / Atom feed
From: p.wilczek@samsung.com (Piotr Wilczek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] device tree blob must be 4-bytes alingned
Date: Wed, 11 Dec 2013 14:07:34 +0100	[thread overview]
Message-ID: <1386767259-15693-4-git-send-email-p.wilczek@samsung.com> (raw)
In-Reply-To: <1386767259-15693-1-git-send-email-p.wilczek@samsung.com>

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 <t.figa@samsung.com>
Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 append_dtbs.sh |   11 +++++++++++
 dtbs.c         |    4 ++++
 2 files changed, 15 insertions(+)

diff --git a/append_dtbs.sh b/append_dtbs.sh
index 82bb463..a8a7cda 100755
--- a/append_dtbs.sh
+++ b/append_dtbs.sh
@@ -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
diff --git a/dtbs.c b/dtbs.c
index 812c2ef..26e3b83 100644
--- a/dtbs.c
+++ b/dtbs.c
@@ -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;
-- 
1.7.9.5

  parent reply	other threads:[~2013-12-11 13:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 13:07 [PATCH 0/8] Impedance matcher for Samsung boards Piotr Wilczek
2013-12-11 13:07 ` [PATCH 1/8] registers: add write u8 type Piotr Wilczek
2013-12-11 13:07 ` [PATCH 2/8] string: fix strncmp function Piotr Wilczek
2013-12-11 13:07 ` Piotr Wilczek [this message]
2013-12-11 13:07 ` [PATCH 4/8] Makefile: disable generating Thumb code Piotr Wilczek
2013-12-11 13:07 ` [PATCH 5/8] add memory operations Piotr Wilczek
2013-12-11 13:07 ` [PATCH 7/8] serial: add Exynos specific serial driver Piotr Wilczek
2013-12-11 13:07 ` [PATCH 8/8] board: add Samsung specific board support Piotr Wilczek
2013-12-11 13:16 ` [PATCH 0/8] Impedance matcher for Samsung boards Daniel Mack
2013-12-11 14:03   ` Piotr Wilczek
2013-12-11 14:10     ` Daniel Mack
2013-12-11 14:28       ` Tomasz Figa
2013-12-11 15:19         ` Daniel Mack
2013-12-11 15:48           ` Nicolas Pitre
2013-12-11 19:06           ` Jason Cooper
     [not found] ` <1386767259-15693-7-git-send-email-p.wilczek@samsung.com>
2013-12-11 19:00   ` [PATCH 6/8] add support to supplement atags to device tree Jason Cooper
2013-12-12 12:09     ` Piotr Wilczek
2013-12-12 12:36       ` Jason Cooper
2013-12-18 12:09 ` [PATCH V2 0/8] Impedance matcher for Samsung boards Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 1/8] registers: add write u8 type Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 2/8] string: fix strncmp function Piotr Wilczek
2013-12-18 12:15     ` Russell King - ARM Linux
2013-12-18 12:23       ` Daniel Mack
2013-12-18 12:52         ` Russell King - ARM Linux
2013-12-18 16:01           ` Jason Cooper
2013-12-18 18:50             ` Jason Cooper
2013-12-18 18:56             ` Jason Cooper
2013-12-18 16:03         ` Jason Cooper
2013-12-18 16:04           ` Daniel Mack
2013-12-18 12:50       ` Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 3/8] device tree blob must be 4-bytes alingned Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 4/8] Makefile: disable generating Thumb code Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 5/8] add memory operations Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 7/8] serial: add Exynos specific serial driver Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 8/8] board: add Samsung specific board support Piotr Wilczek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386767259-15693-4-git-send-email-p.wilczek@samsung.com \
    --to=p.wilczek@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.