mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: AM3xxx: Add support for building AM33xx spi images
@ 2014-05-15  9:43 Sascha Hauer
  2014-06-02 11:41 ` Rolf Evers-Fischer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2014-05-15  9:43 UTC (permalink / raw)
  To: barebox

From: Jan Luebbe <jlu@pengutronix.de>

mk-am35xx-spi-image can only build AM35xx images. Rename
the tool to mk-am3xxx-spi-image and add support for the AM33xx.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/Makefile                                  |  7 ++-
 scripts/Makefile                                   |  2 +-
 ...mk-am35xx-spi-image.c => mk-am3xxx-spi-image.c} | 52 ++++++++++++++++++----
 3 files changed, 50 insertions(+), 11 deletions(-)
 rename scripts/{mk-am35xx-spi-image.c => mk-am3xxx-spi-image.c} (77%)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 3312a49..c576999 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -167,13 +167,16 @@ KBUILD_IMAGE := barebox.ubl
 endif
 
 quiet_cmd_am35xx_spi_image = SPI-IMG $@
-      cmd_am35xx_spi_image = scripts/mk-am35xx-spi-image -a $(TEXT_BASE) $< > $@
+      cmd_am35xx_spi_image = scripts/mk-am3xxx-spi-image -s am35xx -a $(TEXT_BASE) $< > $@
 
 barebox.spi: $(KBUILD_BINARY) FORCE
 	$(call if_changed,am35xx_spi_image)
 
+MLO.spi: MLO FORCE
+	$(call if_changed,am35xx_spi_image)
+
 ifeq ($(CONFIG_OMAP_BUILD_SPI),y)
-KBUILD_IMAGE := barebox.spi
+KBUILD_IMAGE := MLO.spi
 endif
 
 quiet_cmd_zynq_image = ZYNQ-IMG $@
diff --git a/scripts/Makefile b/scripts/Makefile
index 3908c1d..d8925da 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -13,7 +13,7 @@ hostprogs-y                      += kernel-install
 hostprogs-$(CONFIG_KALLSYMS)     += kallsyms
 hostprogs-$(CONFIG_ARCH_MVEBU)   += kwbimage kwboot
 hostprogs-$(CONFIG_ARCH_NETX)    += gen_netx_image
-hostprogs-$(CONFIG_ARCH_OMAP)    += omap_signGP mk-am35xx-spi-image
+hostprogs-$(CONFIG_ARCH_OMAP)    += omap_signGP mk-am3xxx-spi-image
 hostprogs-$(CONFIG_ARCH_S5PCxx)  += s5p_cksum
 hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
 hostprogs-$(CONFIG_ARCH_ZYNQ)	 += zynq_mkimage
diff --git a/scripts/mk-am35xx-spi-image.c b/scripts/mk-am3xxx-spi-image.c
similarity index 77%
rename from scripts/mk-am35xx-spi-image.c
rename to scripts/mk-am3xxx-spi-image.c
index 74e79db..dcb7060 100644
--- a/scripts/mk-am35xx-spi-image.c
+++ b/scripts/mk-am3xxx-spi-image.c
@@ -48,32 +48,66 @@
 #include <getopt.h>
 #include <endian.h>
 
+enum soc {
+	SOC_AM33XX,
+	SOC_AM35XX,
+	SOC_UNKNOWN,
+};
+
+static char *soc_names[] = {
+	[SOC_AM33XX] = "am33xx",
+	[SOC_AM35XX] = "am35xx",
+};
+
 void usage(char *prgname)
 {
 	printf("usage: %s [OPTION] FILE > IMAGE\n"
 	       "\n"
 	       "options:\n"
-	       "  -a <address> memory address for the loaded image in SRAM\n",
+	       "  -a <address> memory address for the loaded image in SRAM\n"
+	       "  -s <soc>     SoC to use (am33xx, am35xx)\n",
 	       prgname);
 }
 
 int main(int argc, char *argv[])
 {
 	FILE *input;
-	int opt;
+	int opt, i;
 	off_t pos;
 	size_t size;
 	uint32_t addr = 0x40200000;
 	uint32_t temp;
+	enum soc soc = SOC_UNKNOWN;
+	char *socname = NULL;
 
-	while((opt = getopt(argc, argv, "a:")) != -1) {
+	while((opt = getopt(argc, argv, "a:s:")) != -1) {
 		switch (opt) {
 		case 'a':
 			addr = strtoul(optarg, NULL, 0);
 			break;
+		case 's':
+			socname = optarg;
+			break;
+		}
+	}
+
+	if (!socname) {
+		fprintf(stderr, "SoC not specified. Use -s <soc>\n");
+		exit(EXIT_FAILURE);
+	}
+
+	for (i = 0; i < 2; i++) {
+		if (!strcmp(socname, soc_names[i])) {
+			soc = i;
+			break;
 		}
 	}
 
+	if (soc == SOC_UNKNOWN) {
+		fprintf(stderr, "SoC %s unknown\n", socname);
+		exit(EXIT_FAILURE);
+	}
+
 	if (optind >= argc) {
 		usage(argv[0]);
 		exit(1);
@@ -108,12 +142,14 @@ int main(int argc, char *argv[])
 	pos = (pos + 3) & ~3;
 
 	/* image size */
-	temp = htobe32((uint32_t)pos);
-	fwrite(&temp, sizeof(uint32_t), 1, stdout);
+	if (soc == SOC_AM35XX) {
+		temp = htobe32((uint32_t)pos);
+		fwrite(&temp, sizeof(uint32_t), 1, stdout);
 
-	/* memory address */
-	temp = htobe32(addr);
-	fwrite(&temp, sizeof(uint32_t), 1, stdout);
+		/* memory address */
+		temp = htobe32(addr);
+		fwrite(&temp, sizeof(uint32_t), 1, stdout);
+	}
 
 	for (;;) {
 		size = fread(&temp, 1, sizeof(uint32_t), input);
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: AM3xxx: Add support for building AM33xx spi images
  2014-05-15  9:43 [PATCH] ARM: AM3xxx: Add support for building AM33xx spi images Sascha Hauer
@ 2014-06-02 11:41 ` Rolf Evers-Fischer
  0 siblings, 0 replies; 2+ messages in thread
From: Rolf Evers-Fischer @ 2014-06-02 11:41 UTC (permalink / raw)
  To: barebox

Dear Sascha and Jan,

Sascha Hauer <s.hauer@...> writes:

> 
> From: Jan Luebbe <jlu@...>
> 
> mk-am35xx-spi-image can only build AM35xx images. Rename
> the tool to mk-am3xxx-spi-image and add support for the AM33xx.
> 
> Signed-off-by: Sascha Hauer <s.hauer@...>
> ---
>  arch/arm/Makefile                                  |  7 ++-
>  scripts/Makefile                                   |  2 +-
>  ...mk-am35xx-spi-image.c => mk-am3xxx-spi-image.c} | 52


I tried to use the changes from this patch in order to create a SPI image.
But I was not successful.

1.a) When I set the CONFIG_OMAP_BUILD_SPI option to "yes" and the
CONFIG_OMAP_BUILD_IFT option to "no", there is no SPI image built. These are
the last line from barebox_mlo compilation:
" (...)
  CHK     include/generated/compile.h
images built:
finished target barebox_mlo.compile"
It seems to me that the parameter "image-y" is never set.

1.b) When I set both config options to "yes", there is an MLO image built,
but no SPI image.

How do I have to configure my project in order to get an SPI image?

2.) Additionally, I'm not sure if we really need the changes in the
mk-am35xx-spi-image.c file, since especially the am3358/am3359 are
using the same format as the am35xx:
 - 32 bit image size in big-endian
 - 32 bit load address in big-endian
 - binary image converted from little- to big-endian

But it may be different for other am33xx SoCs.


A couple of weeks ago I have been able to create a SPI image in
barebox-2014.03 by modification of the file "images/Makefile.am33xx" only.
Maybe, you can take a look into my patch as well (of course the
"CONFIG_MACH_SPR" option and filenames have to match the name of your board
accordingly):

diff --git a/images/Makefile.am33xx b/images/Makefile.am33xx
index dacc2d1..0a6c019 100644
--- a/images/Makefile.am33xx
+++ b/images/Makefile.am33xx
@@ -7,6 +7,12 @@ quiet_cmd_mlo_image = MLO     $@
 $(obj)/%.mlo: $(obj)/% FORCE
 	$(call if_changed,mlo_image)
 
+quiet_cmd_spi_image = SPI     $@
+      cmd_spi_image = scripts/mk-am35xx-spi-image -a 0x402f0400 $< > $@
+
+$(obj)/%.spi: $(obj)/% FORCE
+	$(call if_changed,spi_image)
+
 pblx-$(CONFIG_MACH_PCM051) += start_am33xx_phytec_phycore_sdram
 FILE_barebox-am33xx-phytec-phycore.img = start_am33xx_phytec_phycore_sdram.pblx
 am33xx-barebox-$(CONFIG_MACH_PCM051) += barebox-am33xx-phytec-phycore.img
@@ -23,8 +29,20 @@ pblx-$(CONFIG_MACH_BEAGLEBONE) +=
start_am33xx_beaglebone_sram
 FILE_barebox-am33xx-beaglebone-mlo.img = start_am33xx_beaglebone_sram.pblx.mlo
 am33xx-mlo-$(CONFIG_MACH_BEAGLEBONE) += barebox-am33xx-beaglebone-mlo.img
 
+pblx-$(CONFIG_MACH_SPR) += start_am33xx_spr_sdram
+FILE_barebox-am33xx-spr.img = start_am33xx_spr_sdram.pblx
+am33xx-barebox-$(CONFIG_MACH_SPR) += barebox-am33xx-spr.img
+
+pblx-$(CONFIG_MACH_SPR) += start_am33xx_spr_sram
+FILE_barebox-am33xx-spr-spi.img = start_am33xx_spr_sram.pblx.spi
+am33xx-spi-$(CONFIG_MACH_SPR) += barebox-am33xx-spr-spi.img
+
 ifdef CONFIG_OMAP_BUILD_IFT
 image-y += $(am33xx-mlo-y)
 else
+ifdef CONFIG_OMAP_BUILD_SPI
+image-y += $(am33xx-spi-y)
+else
 image-y += $(am33xx-barebox-y)
 endif
+endif

Nevertheless I'd like to keep my code as close as possible to the
barebox-mainline. Therefore I'm interested to find a common solution
together with you.


Kind regards,
 Rolf



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-02 11:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15  9:43 [PATCH] ARM: AM3xxx: Add support for building AM33xx spi images Sascha Hauer
2014-06-02 11:41 ` Rolf Evers-Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox