From patchwork Fri Aug 2 15:51:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 2838022 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C3BEBF535 for ; Fri, 2 Aug 2013 15:54:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1B1520342 for ; Fri, 2 Aug 2013 15:54:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B31B201B8 for ; Fri, 2 Aug 2013 15:54:56 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HfX-0006gO-GV; Fri, 02 Aug 2013 15:53:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5Hf1-0006pq-2v; Fri, 02 Aug 2013 15:52:59 +0000 Received: from mho-03-ewr.mailhop.org ([204.13.248.66] helo=mho-01-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HeK-0006j7-4P for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 15:52:26 +0000 Received: from pool-72-84-113-162.nrflva.fios.verizon.net ([72.84.113.162] helo=titan) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1V5Hdz-000Lw8-Vv; Fri, 02 Aug 2013 15:51:56 +0000 Received: from triton.localdomain (omega.lakedaemon.net [10.16.5.5]) by titan (Postfix) with ESMTP id F23BA47A21A; Fri, 2 Aug 2013 11:51:43 -0400 (EDT) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 72.84.113.162 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19G4WcXj69OaemVH3qQhscoDi1+PQRLNmE= From: Jason Cooper To: zonque@gmail.com, nico@fluxnic.net Subject: [RFC PATCH V2 8/9] make appending images/dtbs optional Date: Fri, 2 Aug 2013 15:51:15 +0000 Message-Id: <4c634732b7e4cda4b56b57039b365af0e3ba4102.1375457714.git.jason@lakedaemon.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: In-Reply-To: References: <51F2A014.7000209@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130802_115217_002722_56423A7C X-CRM114-Status: GOOD ( 11.05 ) X-Spam-Score: -1.9 (-) Cc: stigge@antcom.de, thomas.petazzoni@free-electrons.com, swarren@nvidia.com, Jason Cooper , devicetree@vger.kernel.org, s.neumann@raumfeld.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason Cooper --- .gitignore | 1 - Makefile | 35 ++++++++++++++++------------------- append_dtbs.sh | 8 ++++++++ main.c | 15 +++++++++++++-- matcher.lds | 8 ++++++-- 5 files changed, 43 insertions(+), 24 deletions(-) create mode 100755 append_dtbs.sh diff --git a/.gitignore b/.gitignore index ac4198c..e0ebf62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -*.sh *.o *.bin cscope.* diff --git a/Makefile b/Makefile index 65e9f3b..c9b2381 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,13 @@ -CFLAGS=-Wall -ffreestanding +ifneq ($(origin APPEND_KERNEL), undefined) +INPUT_OBJS=zimage.o +CFLAGS+=-DAPPEND_KERNEL="$(APPEND_KERNEL)" +endif + +ifneq ($(origin APPEND_DTBS), undefined) +CFLAGS+=-DAPPEND_DTBS="$(APPEND_DTBS)" +endif + +CFLAGS+=-Wall -ffreestanding LDFLAGS=-static -nostdlib GCC=$(CROSS_COMPILE)gcc OBJCOPY=$(CROSS_COMPILE)objcopy @@ -21,34 +30,22 @@ COMMON_OBJS = \ register.o \ string.o -INPUT_OBJS = \ - zimage.o \ - dtb-raumfeld-controller-0.o \ - dtb-raumfeld-controller-1.o \ - dtb-raumfeld-controller-2.o \ - dtb-raumfeld-connector-0.o \ - dtb-raumfeld-connector-1.o \ - dtb-raumfeld-connector-2.o \ - dtb-raumfeld-speaker-0.o \ - dtb-raumfeld-speaker-1.o \ - dtb-raumfeld-speaker-2.o - all: uImage -dtb-%.o: input/%.dtb - $(OBJCOPY) -I binary -O $(BINFMT) -B arm $^ $@ - -zimage.o: input/zImage +zimage.o: $(APPEND_KERNEL) $(OBJCOPY) -I binary -O $(BINFMT) -B arm $^ $@ %.o: %.c $(GCC) $(CFLAGS) -c $^ matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(UART_OBJ) $(INPUT_OBJS) - $(LD) $(LDFLAGS) -T matcher.lds -o $@ $^ + $(LD) $(LDFLAGS) -T matcher.lds -Ttext $(LOADADDR) -o $@ $^ matcher.bin: matcher - $(OBJCOPY) -O binary $^ $@ + $(OBJCOPY) -O binary --set-section-flags .bss=alloc,load,contents $^ $@ +ifneq ($(origin APPEND_DTBS), undefined) + ./append_dtbs.sh $@ $(APPEND_DTBS) +endif uImage: matcher.bin mkimage -A arm -O linux -C none -T kernel \ diff --git a/append_dtbs.sh b/append_dtbs.sh new file mode 100755 index 0000000..82bb463 --- /dev/null +++ b/append_dtbs.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +OUT="$1" +shift +DTBS="$*" + +cat $DTBS >>$OUT +dd if=/dev/zero of=$OUT oflag=append conv=notrunc bs=1 count=8 #sentinel diff --git a/main.c b/main.c index ed25842..c64a083 100644 --- a/main.c +++ b/main.c @@ -3,13 +3,21 @@ #include "print.h" #include "board.h" +#ifdef APPEND_KERNEL extern __u32 _binary_input_zImage_start; +#endif + +void main(__u32 dummy, __u32 machid, const struct tag *tags) + __attribute__((section(".text_main"))); void main(__u32 dummy, __u32 machid, const struct tag *tags) { struct board *board; - void (*start_kernel)(__u32 dummy, __u32 machid, void *dtb) = - (void *) &_binary_input_zImage_start; + void (*start_kernel)(__u32 dummy, __u32 machid, void *dtb); + +#ifdef APPEND_KERNEL + start_kernel = (void *) &_binary_input_zImage_start; +#endif putstr("++ Impedance Matcher (3rd stage loader) ++\n"); @@ -26,6 +34,9 @@ void main(__u32 dummy, __u32 machid, const struct tag *tags) putstr("Not given."); putstr("\n"); + if (board->kernel) + start_kernel = board->kernel; + putstr("Booting into Linux kernel ...\n"); start_kernel(0, 0xffffffff, board->dtb); } diff --git a/matcher.lds b/matcher.lds index 96eb16a..7b85010 100644 --- a/matcher.lds +++ b/matcher.lds @@ -1,6 +1,10 @@ SECTIONS { - . = 0x10008000; - .text : { * (.text); } + .text : { * (.text_main); * (.text); } .data : { * (.data); } .rodata : { * (.rodata); } + .bss : + { + * (.bss); + } + PROVIDE (__end_of_image = .) ; }