* [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl @ 2013-09-14 12:07 Jean-Christophe PLAGNIOL-VILLARD 2013-09-14 12:27 ` [PATCH 1/2] add fix size tools Jean-Christophe PLAGNIOL-VILLARD 2013-09-16 8:56 ` [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Sascha Hauer 0 siblings, 2 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-14 12:07 UTC (permalink / raw) To: barebox Hi, today if we use a relocatable pbl we have 0 at 0x2c on ARM as the linker script can not calculte the size correctly so fix it post zbarebox.bin generation Jean-Christophe PLAGNIOL-VILLARD (2): add fix size tools ARM: PBL: fix binary size arch/arm/pbl/Makefile | 8 ++++++++ scripts/Makefile | 1 + scripts/fix_size.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 scripts/fix_size.c Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] add fix size tools 2013-09-14 12:07 [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-14 12:27 ` Jean-Christophe PLAGNIOL-VILLARD 2013-09-14 12:27 ` [PATCH 2/2] ARM: PBL: fix binary size Jean-Christophe PLAGNIOL-VILLARD 2013-09-16 8:56 ` [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Sascha Hauer 1 sibling, 1 reply; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-14 12:27 UTC (permalink / raw) To: barebox this will allow to write the size of barebox at an offset of the binary this is needed for ARM when using relocated binary Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- scripts/Makefile | 1 + scripts/fix_size.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 scripts/fix_size.c diff --git a/scripts/Makefile b/scripts/Makefile index 307dc3d..61f31db 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -7,6 +7,7 @@ hostprogs-$(CONFIG_KALLSYMS) += kallsyms hostprogs-y += bin2c hostprogs-y += mkimage +hostprogs-y += fix_size hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_MVEBU) += kwbimage kwboot hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image diff --git a/scripts/fix_size.c b/scripts/fix_size.c new file mode 100644 index 0000000..869ae7e --- /dev/null +++ b/scripts/fix_size.c @@ -0,0 +1,81 @@ +#include <stdlib.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <stdint.h> +#include <fcntl.h> +#ifndef _BSD_SOURCE +#define _BSD_SOURCE /* See feature_test_macros(7) */ +#endif +#include <endian.h> + +int main(int argc, char**argv) +{ + struct stat s; + int c; + int fd; + uint64_t offset = 0; + uint32_t size = 0; + char *file = NULL; + int ret = 1; + int is_bigendian = 0; + + while ((c = getopt (argc, argv, "hf:o:b")) != -1) { + switch (c) { + case 'f': + file = optarg; + break; + case 'o': + offset = strtoul(optarg, NULL, 16); + break; + case 'b': + is_bigendian = 1; + break; + } + } + + if (!file) { + fprintf(stderr, "missing file\n"); + return 1; + } + + if (stat(file, &s)) { + perror("stat"); + return 1; + } + + fd = open(file, O_WRONLY); + if (fd < 0) { + perror("open"); + return 1; + } + + ret = lseek(fd, offset, SEEK_SET); + if (ret < 0) { + perror("lseek"); + ret = 1; + goto err; + } + + size = s.st_size; + + if (is_bigendian) + size = htobe32(size); + else + size = htole32(size); + + ret = write(fd, &size, 4); + if (ret != 4) { + perror("write"); + ret = 1; + goto err; + } + + ret = 0; +err: + + close(fd); + + return ret; +} -- 1.8.4.rc1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: PBL: fix binary size 2013-09-14 12:27 ` [PATCH 1/2] add fix size tools Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-14 12:27 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-14 12:27 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/pbl/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index f4b3471..f89c56b 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -13,9 +13,17 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ # Make sure files are removed during clean extra-y += piggy.gzip piggy.lz4 piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map +ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) +FIX_SIZE=-b +else +FIX_SIZE= +endif + $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(call if_changed,objcopy) $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) + $(Q)$(kecho) ' Barebox: fix size' + $(Q)$(objtree)/scripts/fix_size -f $(objtree)/$@ -o 0x2c $(FIX_SIZE) $(Q)$(kecho) ' Barebox: $@ is ready' $(obj)/zbarebox.S: $(obj)/zbarebox FORCE -- 1.8.4.rc1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl 2013-09-14 12:07 [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Jean-Christophe PLAGNIOL-VILLARD 2013-09-14 12:27 ` [PATCH 1/2] add fix size tools Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-16 8:56 ` Sascha Hauer 2013-09-16 14:35 ` Jean-Christophe PLAGNIOL-VILLARD 1 sibling, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2013-09-16 8:56 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Sat, Sep 14, 2013 at 02:07:25PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > Hi, > > today if we use a relocatable pbl we have 0 at 0x2c on ARM > as the linker script can not calculte the size correctly > > so fix it post zbarebox.bin generation > > Jean-Christophe PLAGNIOL-VILLARD (2): > add fix size tools > ARM: PBL: fix binary size Looks good. Should I apply? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl 2013-09-16 8:56 ` [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Sascha Hauer @ 2013-09-16 14:35 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-16 14:35 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On 10:56 Mon 16 Sep , Sascha Hauer wrote: > On Sat, Sep 14, 2013 at 02:07:25PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > > Hi, > > > > today if we use a relocatable pbl we have 0 at 0x2c on ARM > > as the linker script can not calculte the size correctly > > > > so fix it post zbarebox.bin generation > > > > Jean-Christophe PLAGNIOL-VILLARD (2): > > add fix size tools > > ARM: PBL: fix binary size > > Looks good. Should I apply? yes please go a head I'm working on at91bootstrap to detect if it's barebox and load only the right size so this help Best Regards, J. > > Sascha > > -- > Pengutronix e.K. | | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-09-16 14:34 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-09-14 12:07 [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Jean-Christophe PLAGNIOL-VILLARD 2013-09-14 12:27 ` [PATCH 1/2] add fix size tools Jean-Christophe PLAGNIOL-VILLARD 2013-09-14 12:27 ` [PATCH 2/2] ARM: PBL: fix binary size Jean-Christophe PLAGNIOL-VILLARD 2013-09-16 8:56 ` [RFC] [PATCH 0/2] fix barebox size when using a relocated pbl Sascha Hauer 2013-09-16 14:35 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox