Skip to contentSkip to conversation

Attempt to improve support for Altera SoC FPGA boards

PATCH New Jan Viktorin 5 participants 38 messages Oct 19, 2015 – Mar 23, 2016

lore
Share & tools
lore
#0 lore raw

cover Attempt to improve support for Altera SoC FPGA boards

Hello Buildroot community,

the following patch series attempts to improve support for building for Altera SoC FPGA boards. I mean, I'd like to have it ready out-of-the-box.

The readme says that it is necessary to "sign" (it is now signing, just CRC by the way) the SPL image in order to boot. I cannot ack this because my SoC Development Kit (not the Arrow one!) boots normally with the generated SPL. How is it possible then? Is it fixed in U-Boot? I doubt, didn't find it there... I am confused about it.

I don't have the second board (Arrow SoCKit) to prove it boots without it.

Anyway, this series contains updates to the readme.txt and also adds mkpimage package to support the "signing" of the SPL images. Those patches are not very coherent and I do not expect to merge them at this stage.

Can somebody check whether the generated SPL boots on Arrow SoCKit?

If it does not, I would like to add the mkpimage package to Buildroot (however, it requires a Go compiler).

If there is no issue, I would just leave the readme updates (an improve them a bit).

Regards
Jan Viktorin

Jan Viktorin (4):
mkpimage: new host package
boot/uboot: compute CRC on SPLs for Altera SoC FPGA
socfpga: update readme for sockit/socdk boards
socfpga: note about unnecessary mkpimage of SPL

 board/altera/readme.txt      | 31 +++++++++++++++++--------------
 boot/uboot/Config.in         | 10 ++++++++++
 boot/uboot/uboot.mk          |  9 +++++++++
 package/mkpimage/mkpimage.mk | 28 ++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 14 deletions(-)
 create mode 100644 package/mkpimage/mkpimage.mk
Signature · 1 line
2.6.1
#1 lore raw

PATCH 1/4 mkpimage: new host package

The tool helps to create a working SPL to boot Altera SoC FPGA boards.

---
 package/mkpimage/mkpimage.mk | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 package/mkpimage/mkpimage.mk
package/mkpimage/mkpimage.mk new file +28 -0
new file mode 100644
index 0000000..e21faf4
@@ -0,0 +1,28 @@
+################################################################################
+#
+# mkpimage
+#
+################################################################################
+
+MKPIMAGE_VERSION = d64752876a6185853400498d3a43a5e18681cab7
+MKPIMAGE_SITE = $(call github,maximeh,mkpimage,$(MKPIMAGE_VERSION))
+MKPIMAGE_LICENSE = MIT
+
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif
+
+define HOST_MKPIMAGE_CONFIGURE_CMDS
+	$(MAKE) -C $(@D) GOPATH="$(dir $(HOSTGO))" deps
+endef
+
+define HOST_MKPIMAGE_BUILD_CMDS
+	$(MAKE) -C $(@D) GOPATH="$(dir $(HOSTGO))"
+endef
+
+define HOST_MKPIMAGE_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/bin/mkpimage $(HOST_DIR)/usr/bin/mkpimage
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.6.1
#2 lore raw

PATCH 1/4 mkpimage: new host package

Hello Jan, all

Quoted 47 lines · Jan Viktorin

The tool helps to create a working SPL to boot Altera SoC FPGA boards.

---
 package/mkpimage/mkpimage.mk | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 package/mkpimage/mkpimage.mk
package/mkpimage/mkpimage.mk new file +25 -0
new file mode 100644
index 0000000..e21faf4
@@ -0,0 +1,28 @@
 
+################################################################################
+#
+# mkpimage
+#
 
+################################################################################
+
+MKPIMAGE_VERSION = d64752876a6185853400498d3a43a5e18681cab7
+MKPIMAGE_SITE = $(call github,maximeh,mkpimage,$(MKPIMAGE_VERSION))
+MKPIMAGE_LICENSE = MIT
+
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif
+
+define HOST_MKPIMAGE_CONFIGURE_CMDS
+       $(MAKE) -C $(@D) GOPATH="$(dir $(HOSTGO))" deps
+endef
+
+define HOST_MKPIMAGE_BUILD_CMDS
+       $(MAKE) -C $(@D) GOPATH="$(dir $(HOSTGO))"
+endef
+
+define HOST_MKPIMAGE_INSTALL_CMDS
+       $(INSTALL) -D -m 0755 $(@D)/bin/mkpimage

$(HOST_DIR)/usr/bin/mkpimage

package/mkpimage/mkpimage.mk new file +3 -1
+endef
+
+$(eval $(host-generic-package))
--
Quoted 2 lines

2.6.1

Thanks a lot for your patch.

It's a bit weird reviewing your patch as I'm the author of the package you want to add, but here goes:

Even I don't use this tool anymore, after I reversed the code from Altera's own tool, they released the documentation for the SPL signing and the fine people at Barebox, created a small program (in C) that does exactly the same, which you can find there:
http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD

However, I don't know how you would integrate such a tool, having a special package ? Making U-Boot depends on Barebox sounds a bit crazy. But it would be lighter than having to grab the go compiler for such a simple program.

Let's wait on what others have to say in the matter.
But anyway, thank you to push this, as it's a real problem that I am currently solving by having a short mkpimage package with the source of this scripts included into it.
If you want, I can send it as a patch so you may take it and rework it.

Quoted 5 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151019/e7b34375/attachment-0001.html>

#3 lore raw

PATCH 1/4 mkpimage: new host package

Maxime, Jan,

Quoted 4 lines · Maxime Hadjinlian

package/mkpimage/mkpimage.mk line 14

Quoted 4 lines
package/mkpimage/mkpimage.mk new file +4 -0
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif

Ouch, having to depend on Go for such a simple tool is indeed not very nice :-/

Quoted 9 lines

Even I don't use this tool anymore, after I reversed the code from Altera's own tool, they released the documentation for the SPL signing and the fine people at Barebox, created a small program (in C) that does exactly the same, which you can find there:
http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD

However, I don't know how you would integrate such a tool, having a special package ? Making U-Boot depends on Barebox sounds a bit crazy. But it would be lighter than having to grab the go compiler for such a simple program.

I agree. Unfortunately, downloading directly
http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD
doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself inside Buildroot, in package/mkpimage/.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/4 mkpimage: new host package

Thomas, All,

On 2015-10-19 22:53 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines · Maxime Hadjinlian
Quoted 4 lines

package/mkpimage/mkpimage.mk line 14

Quoted 4 lines
package/mkpimage/mkpimage.mk new file +4 -0
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif

Ouch, having to depend on Go for such a simple tool is indeed not very nice :-/

Or we can eventually look at the Go package that was submitted a while back, and to which I contributed:

    https://patchwork.ozlabs.org/patch/502222/

;-)

Quoted 10 lines
Quoted 9 lines

Even I don't use this tool anymore, after I reversed the code from Altera's own tool, they released the documentation for the SPL signing and the fine people at Barebox, created a small program (in C) that does exactly the same, which you can find there:
http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD

However, I don't know how you would integrate such a tool, having a special package ? Making U-Boot depends on Barebox sounds a bit crazy. But it would be lighter than having to grab the go compiler for such a simple program.

Quoted 8 lines

I agree. Unfortunately, downloading directly
http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD
doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself inside Buildroot, in package/mkpimage/.

Yup, agreed.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/4 mkpimage: new host package

Quoted 37 lines · Yann E. MORIN

Thomas, All,

On 2015-10-19 22:53 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines · Maxime Hadjinlian
Quoted 4 lines

package/mkpimage/mkpimage.mk line 14

Quoted 4 lines
package/mkpimage/mkpimage.mk new file +4 -0
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif

Ouch, having to depend on Go for such a simple tool is indeed not very nice :-/

Or we can eventually look at the Go package that was submitted a while back, and to which I contributed:

    https://patchwork.ozlabs.org/patch/502222/

;-)

Quoted 1 line
Quoted 1 line

Even I don't use this tool anymore, after I reversed the code from

Altera's

Quoted 1 line
Quoted 1 line

own tool, they released the documentation for the SPL signing and the

fine

Quoted 3 lines
Quoted 3 lines

people at Barebox, created a small program (in C) that does exactly the same, which you can find there:

http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD

Quoted 2 lines
Quoted 2 lines

However, I don't know how you would integrate such a tool, having a

special

Quoted 1 line
Quoted 1 line

package ? Making U-Boot depends on Barebox sounds a bit crazy. But it

would

Quoted 1 line
Quoted 1 line

be lighter than having to grab the go compiler for such a simple

program.

Quoted 3 lines

I agree. Unfortunately, downloading directly

http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD

Quoted 9 lines
Quoted 6 lines

doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself inside Buildroot, in package/mkpimage/.

Yup, agreed.

Agreed too, I'll send the current package that I have that does just that.
Jan: I'll put you in CC so if you want to work with it/on it, feel free !

Quoted 16 lines

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There
is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |
Quoted 2 lines

'------------------------------^-------^------------------^--------------------'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151019/b688f0d6/attachment.html>

#6 lore raw

PATCH 1/4 mkpimage: new host package

Hello all,

thank you for your interest...

Quoted 40 lines · On Mon, 19 Oct 2015 23:12:21 +0200 Maxime Hadjinlian…
Quoted 37 lines · Yann E. MORIN

Thomas, All,

On 2015-10-19 22:53 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines · Maxime Hadjinlian
Quoted 4 lines

package/mkpimage/mkpimage.mk line 14

Quoted 4 lines
package/mkpimage/mkpimage.mk new file +4 -0
+ifndef HOSTGO
+HOSTGO := go
+HOSTGO := $(shell which $(HOSTGO) || type -p $(HOSTGO) || echo go)
+endif  

Ouch, having to depend on Go for such a simple tool is indeed not very nice :-/

Or we can eventually look at the Go package that was submitted a while back, and to which I contributed:

    https://patchwork.ozlabs.org/patch/502222/

;-)

Quoted 1 line
Quoted 1 line

Even I don't use this tool anymore, after I reversed the code from

Altera's

Quoted 1 line
Quoted 1 line

own tool, they released the documentation for the SPL signing and the

fine

Quoted 3 lines
Quoted 3 lines

people at Barebox, created a small program (in C) that does exactly the same, which you can find there:

http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD

Quoted 2 lines
Quoted 2 lines

However, I don't know how you would integrate such a tool, having a

special

Quoted 1 line
Quoted 1 line

package ? Making U-Boot depends on Barebox sounds a bit crazy. But it

would

Quoted 1 line
Quoted 1 line

be lighter than having to grab the go compiler for such a simple

program.

Quoted 3 lines

I agree. Unfortunately, downloading directly

http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself inside Buildroot, in package/mkpimage/.

Yup, agreed.

Agreed. my intention was more like to tell the user: "install your own Go compiler to use this".

Quoted 3 lines
Quoted 1 line

Agreed too, I'll send the current package that I have that does just that.
Jan: I'll put you in CC so if you want to work with it/on it, feel free !

Great!

By the way, there is still the fundamental question. Is the mkpimage really necessary? I can boot the Altera SoC Development Kit without running it. What is the value of doing that? Does it support the secure boot sequence? Does it depend on some DIP switch on the board?

Jan

Quoted 19 lines
Quoted 19 lines

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There
is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |

'------------------------------^-------^------------------^--------------------'

Signature · 4 lines
  Jan Viktorin                E-mail: Viktorin at RehiveTech.com
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#7 lore raw

PATCH 1/4 mkpimage: new host package

Jan, all

Quoted 30 lines · Jan Viktorin

Hello all,

thank you for your interest...

On Mon, 19 Oct 2015 23:12:21 +0200
Maxime Hadjinlian <[email protected]> wrote:

[-SNIP-]

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I agree. Unfortunately, downloading directly

http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself

inside

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Buildroot, in package/mkpimage/.

Yup, agreed.

Agreed. my intention was more like to tell the user: "install your own Go compiler to use this".

Quoted 2 lines
Quoted 1 line

Agreed too, I'll send the current package that I have that does just

that.

Quoted 9 lines
Quoted 1 line

Jan: I'll put you in CC so if you want to work with it/on it, feel free !

Great!

By the way, there is still the fundamental question. Is the mkpimage really necessary? I can boot the Altera SoC Development Kit without running it. What is the value of doing that? Does it support the secure boot sequence? Does it depend on some DIP switch on the board?

As far I can remember you can't boot the SoCFPGA without the SPL being "signed" (which is really a simple header with a CRC and some padding so it fits a precise size).
I'm curious how you made one boot without this as per Altera's documentation the Boot ROM needs it. Note that in Qsys, it's already done in their various scripts, so if you build U-Boot that way, it's done for you.
There's no real added value as far as I could tell, the SoC needs it, that's all. And there's no DIP switch which helps you configure that on the dev kit. I don't think you can configure it. You have to do it and that's pretty much it.

Quoted 1 line

Jan

Quoted 26 lines
Quoted 9 lines
Quoted 9 lines

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

Quoted 5 lines
Quoted 5 lines
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/

There

Quoted 5 lines
Quoted 5 lines

is no |

| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |

'------------------------------^-------^------------------^--------------------'

Quoted 1 line
Quoted 1 line
Quoted 6 lines

--
Jan Viktorin E-mail: Viktorin at RehiveTech.com
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151019/2fd82c56/attachment-0001.html>

#8 lore raw

PATCH 1/4 mkpimage: new host package

Quoted 5 lines · On Mon, 19 Oct 2015 23:36:23 +0200 Maxime Hadjinlian…
Quoted 5 lines

By the way, there is still the fundamental question. Is the mkpimage really necessary? I can boot the Altera SoC Development Kit without running it. What is the value of doing that? Does it support the secure boot sequence? Does it depend on some DIP switch on the board?

Quoted 11 lines

As far I can remember you can't boot the SoCFPGA without the SPL being "signed" (which is really a simple header with a CRC and some padding so it fits a precise size).
I'm curious how you made one boot without this as per Altera's documentation the Boot ROM needs it. Note that in Qsys, it's already done in their various scripts, so if you build U-Boot that way, it's done for you.
There's no real added value as far as I could tell, the SoC needs it, that's all. And there's no DIP switch which helps you configure that on the dev kit. I don't think you can configure it. You have to do it and that's pretty much it.

That's strange. I tried it twice today. I am using files generated directly by Buildroot. No other customizations. It builds the SPL image of size ~43K. The size of the image with CRC is ~64K. Probably, I am doing something in a wrong way(?). By the way, this was the reason why I tried to update the readme.txt. I've created the SD card contents from scratch to avoid any previous working version there... I'll recheck it (hopefully) tomorrow with a different SD card.

Jan

Signature · 4 lines
  Jan Viktorin                E-mail: Viktorin at RehiveTech.com
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#9 lore raw

PATCH 1/4 mkpimage: new host package

Quoted 18 lines · Jan Viktorin
Quoted 7 lines · On Mon, 19 Oct 2015 23:36:23 +0200 Maxime Hadjinlian…
Quoted 5 lines

By the way, there is still the fundamental question. Is the mkpimage really necessary? I can boot the Altera SoC Development Kit without running it. What is the value of doing that? Does it support the secure boot sequence? Does it depend on some DIP switch on the board?

As far I can remember you can't boot the SoCFPGA without the SPL being "signed" (which is really a simple header with a CRC and some padding so

it

Quoted 7 lines

fits a precise size).
I'm curious how you made one boot without this as per Altera's documentation the Boot ROM needs it. Note that in Qsys, it's already done in their various scripts, so if you build U-Boot that way, it's done for you.
There's no real added value as far as I could tell, the SoC needs it, that's all. And there's no DIP switch which helps you configure that on

Quoted 7 lines

the

Quoted 2 lines

dev kit. I don't think you can configure it. You have to do it and that's pretty much it.

That's strange. I tried it twice today. I am using files generated directly by Buildroot. No other customizations. It builds the SPL image of size ~43K. The size of the image with CRC is ~64K.

64K is the precise minimal size for an accepted SPL for the SoC FPGA, which means that you have "signed" it. That's why it's working for you.

Quoted 6 lines

Probably, I am
doing something in a wrong way(?). By the way, this was the reason why I tried to update the readme.txt. I've created the SD card contents from scratch to avoid any previous working version there... I'll recheck it (hopefully) tomorrow with a different SD card.

Quoted 8 lines

Jan

--
Jan Viktorin E-mail: Viktorin at RehiveTech.com
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151020/45193f67/attachment.html>

#10 lore raw

PATCH 1/4 mkpimage: new host package

Quoted 25 lines · On Tue, 20 Oct 2015 00:12:45 +0200 Maxime Hadjinlian…
Quoted 22 lines · Jan Viktorin
Quoted 7 lines · On Mon, 19 Oct 2015 23:36:23 +0200 Maxime Hadjinlian…
Quoted 5 lines

By the way, there is still the fundamental question. Is the mkpimage really necessary? I can boot the Altera SoC Development Kit without running it. What is the value of doing that? Does it support the secure boot sequence? Does it depend on some DIP switch on the board?

As far I can remember you can't boot the SoCFPGA without the SPL being "signed" (which is really a simple header with a CRC and some padding so

it

Quoted 7 lines

fits a precise size).
I'm curious how you made one boot without this as per Altera's documentation the Boot ROM needs it. Note that in Qsys, it's already done in their various scripts, so if you build U-Boot that way, it's done for you.
There's no real added value as far as I could tell, the SoC needs it, that's all. And there's no DIP switch which helps you configure that on

the

Quoted 2 lines

dev kit. I don't think you can configure it. You have to do it and that's pretty much it.

Quoted 6 lines
Quoted 3 lines

That's strange. I tried it twice today. I am using files generated directly by Buildroot. No other customizations. It builds the SPL image of size ~43K. The size of the image with CRC is ~64K.

64K is the precise minimal size for an accepted SPL for the SoC FPGA, which means that you have "signed" it. That's why it's working for you.

OK, confirmed with a different SD card. It really does not boot. I think that the problem was that I wrote only the 43K, however, the rest was already written on the SD card :). We need the tool.

Jan

Quoted 15 lines
Quoted 15 lines

Probably, I am
doing something in a wrong way(?). By the way, this was the reason why I tried to update the readme.txt. I've created the SD card contents from scratch to avoid any previous working version there... I'll recheck it (hopefully) tomorrow with a different SD card.

Jan

--
Jan Viktorin E-mail: Viktorin at RehiveTech.com
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic

Signature · 4 lines
   Jan Viktorin                  E-mail: Viktorin at RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#11 lore raw

PATCH 1/4 mkpimage: new host package

In reply to Yann E. MORIN

Hello,

Quoted 5 lines · Yann E. MORIN

Or we can eventually look at the Go package that was submitted a while back, and to which I contributed:

    https://patchwork.ozlabs.org/patch/502222/

;-)

Well, if we can avoid building a compiler just to build a 300 lines Go program, it'd be great :)

Quoted 10 lines
Quoted 8 lines

I agree. Unfortunately, downloading directly
http://git.pengutronix.de/?p=barebox.git;a=blob_plain;f=scripts/socfpga_mkimage.c;h=$(MKPIMAGE_VERSION);hb=HEAD
doesn't work because this URL contains ';' which our download infrastructure doesn't like much.

However, this program is so simple that I would advocate taking the makedevs route: simply integrate the program source code itself inside Buildroot, in package/mkpimage/.

Yup, agreed.

So Jan, can you rework your submission in this direction?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

PATCH 2/4 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

In reply to Jan Viktorin
---
 boot/uboot/Config.in | 10 ++++++++++
 boot/uboot/uboot.mk  |  9 +++++++++
 2 files changed, 19 insertions(+)
boot/uboot/Config.in +10 -0
index 8643dab..b2a69f3 100644
@@ -338,6 +338,16 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE
 	 for u-boot-dtb.img file so this U-Boot format is required
 	 to be set.
 
+config BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC
+	bool "CRC SPL image for SoC FPGA"
+	depends on BR2_arm
+	depends on BR2_TARGET_UBOOT_SPL
+	help
+	  Generate SPL image fixed by the mkpimage tool to enable
+	  booting on the SoC FPGA based platforms. The tool is
+	  available at https://github.com/maximeh/mkpimage.
+	  It requires a Go language compiler installed on your host.
+
 menuconfig BR2_TARGET_UBOOT_ENVIMAGE
 	bool "Environment image"
 	help
boot/uboot/uboot.mk +9 -0
index 66e728f..8b32154 100644
@@ -215,6 +215,15 @@ UBOOT_DEPENDENCIES += host-zynq-boot-bin
 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
 endif
 
+ifeq ($(BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC),y)
+define UBOOT_CRC_SOCFPGA_IMAGE
+	$(HOST_DIR)/usr/bin/mkpimage -o $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))).crc \
+		$(@D)/$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))
+endef
+UBOOT_DEPENDENCIES += host-mkpimage
+UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_SOCFPGA_IMAGE
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y)
 ifeq ($(BR_BUILDING),y)
 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)),)
Signature · 1 line
2.6.1
#13 lore raw

PATCH 3/4 socfpga: update readme for sockit/socdk boards

In reply to Jan Viktorin

The readme uses mmcblk0 which is quite unusual on host PC. Moreover, the referred website uses /dev/sdx convention.

The fdisk rules didn't work for me this way. there is a little mistake when setting type of partition 2. The numbers are for bigger SD card. This is to be considered...

Should I break it to smaller commits?

---
 board/altera/readme.txt | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
board/altera/readme.txt +15 -14
index 8d5b891..882f54d 100644
@@ -101,29 +101,30 @@ Determine the device associated to the SD card :
 
   $ cat /proc/partitions
 
-let's assume it is /dev/mmcblk0 :
+let's assume it is /dev/sdc :
 
-  $ sudo fdisk /dev/mmcblk0
+  $ sudo fdisk /dev/sdc
 
 Delete all previous partitions with 'd' then create the new partition table,
-using these options, pressing enter after each one:
+using these options, pressing enter after each one (you may need to use different
+values if your SD card is smaller/bigger then 4G):
 
-  * n p 1 9000000 +20480K t 1 b
-  * n p 2 4096 +4496384K t 83
-  * n p 3 2048 +1024K t 3 a2
+  * n p 1 7000000 7774207 t b
+  * n p 2 4096 6999999 t 2 83
+  * n p 3 2048 4095 t 3 a2
 
 Using the 'p' option, the SD card's partition must look like this :
 
-Device         Boot     Start       End  Blocks  Id System
-/dev/mmcblk0p1        9000000   9041919   20960   b W95 FAT32
-/dev/mmcblk0p2           4096   8996863 4496384  83 Linux
-/dev/mmcblk0p3           2048      4095    1024  a2 Unknown
+Device     Boot   Start     End Sectors  Size Id Type
+/dev/sdc1       7000000 7774207  774208  378M  b W95 FAT32
+/dev/sdc2          4096 6999999 6995904  3.3G 83 Linux
+/dev/sdc3          2048    4095    2048    1M a2 unknown
 
 Then write the partition table using 'w' and exit.
 
 Make partition one a DOS partition :
 
-  $ sudo mkdosfs /dev/mmcblk0p1
+  $ sudo mkdosfs /dev/sdc1
 
 Install the binaries to the SDcard
 ----------------------------------
@@ -136,13 +137,13 @@ The partition with type a2 is the partition scan by the first bootloader stage
 in the SoCkit ROM to find the next bootloader stage so we must write the signed
 preloader and the u-boot binaries in that partition :
 
-  $ sudo dd if=u-boot-spl-signed.bin of=/dev/mmcblk0p3 bs=64k seek=0
-  $ sudo dd if=u-boot.img of=/dev/mmcblk0p3 bs=64k seek=4
+  $ sudo dd if=u-boot-spl-signed.bin of=/dev/sdc3 bs=64k seek=0
+  $ sudo dd if=u-boot.img of=/dev/sdc3 bs=64k seek=4
 
 Copy the Linux kernel and its Device tree :
 
   $ sudo mkdir /mnt/sdcard
-  $ sudo mount /dev/mmcblk0p1 /mnt/sdcard
+  $ sudo mount /dev/sdc1 /mnt/sdcard
   $ sudo cp socfpga.dtb uImage /mnt/sdcard
   $ sudo umount /mnt/sdcard
 
Signature · 1 line
2.6.1
#14 lore raw

PATCH 4/4 socfpga: note about unnecessary mkpimage of SPL

In reply to Jan Viktorin
---
 board/altera/readme.txt | 2 ++
 1 file changed, 2 insertions(+)
board/altera/readme.txt +2 -0
index 882f54d..82c2dcd 100644
@@ -88,6 +88,8 @@ Remember that without signing the u-boot-spl.bin, the board will not boot !!!
 
   $ mkpimage u-boot-spl.bin -o u-boot-spl-signed.bin
 
+This seems to be not true at least for the socdk board.
+
 Prepare your SDcard
 ===================
 
Signature · 1 line
2.6.1
#15 lore raw

cover Attempt to improve support for Altera SoC FPGA boards

In reply to Jan Viktorin

I am sorry, the text may be a little bit confusing, so I am adding some clarifications...

Quoted 6 lines · On Mon, 19 Oct 2015 18:24:50 +0200 Jan Viktorin <[email protected]> wrote:

Hello Buildroot community,

the following patch series attempts to improve support for building for Altera SoC FPGA boards. I mean, I'd like to have it ready out-of-the-box.

The readme says that it is necessary to "sign" (it is now signing, just CRC

"not signing"

Quoted 6 lines

by the way) the SPL image in order to boot. I cannot ack this because my SoC Development Kit (not the Arrow one!) boots normally with the generated SPL. How is it possible then? Is it fixed in U-Boot? I doubt, didn't find it there... I am confused about it.

I don't have the second board (Arrow SoCKit) to prove it boots without it.

*it boots without "signing"

Quoted 4 lines

Anyway, this series contains updates to the readme.txt and also adds mkpimage package to support the "signing" of the SPL images. Those patches are not very coherent and I do not expect to merge them at this stage.

The readme should be updated that it is not necessary to sign anything. Or the mkpimage package should be included in Buildroot.

Quoted 25 lines

Can somebody check whether the generated SPL boots on Arrow SoCKit?

If it does not, I would like to add the mkpimage package to Buildroot (however, it requires a Go compiler).

If there is no issue, I would just leave the readme updates (an improve them a bit).

Regards
Jan Viktorin

Jan Viktorin (4):
mkpimage: new host package
boot/uboot: compute CRC on SPLs for Altera SoC FPGA
socfpga: update readme for sockit/socdk boards
socfpga: note about unnecessary mkpimage of SPL

 board/altera/readme.txt      | 31 +++++++++++++++++--------------
 boot/uboot/Config.in         | 10 ++++++++++
 boot/uboot/uboot.mk          |  9 +++++++++
 package/mkpimage/mkpimage.mk | 28 ++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 14 deletions(-)
 create mode 100644 package/mkpimage/mkpimage.mk
Signature · 4 lines
   Jan Viktorin                  E-mail: Viktorin at RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#16 lore raw

v2 cover Attempt to improve support for Altera SoC FPGA boards

In reply to Jan Viktorin

Hello all,

I've integrated the changes by Maxime into my patch series. I've also reworked the readme changes.

First, the readme is a little bit more verbose about the support of the SoC DK board (and not just the SoCkit). Second, I've updated the notes about mkpimage and "signing" of the SPL.

The last three patches related to that readme are less important. They just improve the text a little bit.

Regards
Jan

Jan Viktorin (7):
mkpimage: new host package
boot/uboot: compute CRC on SPLs for Altera SoC FPGA
altera: improve readme to cover both supported boards
altera: update text about the mkpimage
altera: change mmcblk0 to sdc
altera: improve fdisk instructions
altera: remove whitespace before colon

 board/altera/readme.txt      |  80 ++++++------
 boot/uboot/Config.in         |  10 ++
 boot/uboot/uboot.mk          |   9 ++
 package/mkpimage/mkpimage.c  | 287 +++++++++++++++++++++++++++++++++++++++++++
 package/mkpimage/mkpimage.mk |  22 ++++
 5 files changed, 371 insertions(+), 37 deletions(-)
 create mode 100644 package/mkpimage/mkpimage.c
 create mode 100644 package/mkpimage/mkpimage.mk
Signature · 1 line
2.6.1
#17 lore raw

PATCH v2 1/7 mkpimage: new host package

The tool helps to create a working SPL to boot Altera SoC FPGA boards.

The code of mkpimage is integrated directly from the Barebox repository as stated in the 'mkpimage.mk' file.

This tool is *NOT* necessary for any other boards so far.

---
v1 -> v2: dropped Go implementation, included mkpimage.c from Barebox
because of a wierd URL that cannot be hanled by Buildroot

---
 package/mkpimage/mkpimage.c  | 287 +++++++++++++++++++++++++++++++++++++++++++
 package/mkpimage/mkpimage.mk |  22 ++++
 2 files changed, 309 insertions(+)
 create mode 100644 package/mkpimage/mkpimage.c
 create mode 100644 package/mkpimage/mkpimage.mk
package/mkpimage/mkpimage.c new file +287 -0
new file mode 100644
index 0000000..1a7a66d
@@ -0,0 +1,287 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <endian.h>
+
+#define VALIDATION_WORD 0x31305341
+
+#define MAX_IMAGE_SIZE (60 * 1024 - 4)
+
+static int add_barebox_header;
+
+struct socfpga_header {
+	uint8_t validation_word[4];
+	uint8_t version;
+	uint8_t flags;
+	uint8_t program_length[2];
+	uint8_t spare[2];
+	uint8_t checksum[2];
+};
+
+static uint32_t bb_header[] = {
+	0xea00007e,	/* b 0x200  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0xeafffffe,	/* 1: b 1b  */
+	0x65726162,	/* 'bare'   */
+	0x00786f62,	/* 'box\0'  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* padding  */
+	0x00000000,	/* socfpga header */
+	0x00000000,	/* socfpga header */
+	0x00000000,	/* socfpga header */
+	0xea00006b,	/* entry. b 0x200  */
+};
+
+static int read_full(int fd, void *buf, size_t size)
+{
+	size_t insize = size;
+	int now;
+	int total = 0;
+
+	while (size) {
+		now = read(fd, buf, size);
+		if (now == 0)
+			return total;
+		if (now < 0)
+			return now;
+		total += now;
+		size -= now;
+		buf += now;
+	}
+
+	return insize;
+}
+
+static int write_full(int fd, void *buf, size_t size)
+{
+	size_t insize = size;
+	int now;
+
+	while (size) {
+		now = write(fd, buf, size);
+		if (now <= 0)
+			return now;
+		size -= now;
+		buf += now;
+	}
+
+	return insize;
+}
+
+static uint32_t crc_table[256] = {
+	0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
+	0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
+	0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
+	0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
+	0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
+	0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
+	0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
+	0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
+	0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
+	0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
+	0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
+	0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
+	0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4,
+	0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
+	0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
+	0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
+	0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
+	0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
+	0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
+	0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
+	0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
+	0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
+	0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
+	0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
+	0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
+	0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
+	0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
+	0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
+	0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
+	0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
+	0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
+	0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
+	0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
+	0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
+	0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
+	0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
+	0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
+	0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
+	0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
+	0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
+	0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
+	0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
+	0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
+};
+
+uint32_t crc32(uint32_t crc, void *_buf, int length)
+{
+	uint8_t *buf = _buf;
+
+	while (length--)
+		crc = crc << 8 ^ crc_table[(crc >> 24 ^ *(buf++)) & 0xff];
+
+	return crc;
+}
+
+static int add_socfpga_header(void *buf, int size)
+{
+	struct socfpga_header *header = buf + 0x40;
+	uint8_t *buf_header = buf + 0x40;
+	uint32_t *crc;
+	unsigned checksum;
+	int length = size >> 2;
+	int i;
+
+	if (size & 0x3) {
+		fprintf(stderr, "%s: size must be multiple of 4\n", __func__);
+		return -EINVAL;
+	}
+
+	header->validation_word[0] = VALIDATION_WORD & 0xff;
+	header->validation_word[1] = (VALIDATION_WORD >> 8) & 0xff;
+	header->validation_word[2] = (VALIDATION_WORD >> 16) & 0xff;
+	header->validation_word[3] = (VALIDATION_WORD >> 24) & 0xff;
+	header->version = 0;
+	header->flags = 0;
+	header->program_length[0] = length & 0xff;
+	header->program_length[1] = (length >> 8) & 0xff;
+	header->spare[0] = 0;
+	header->spare[1] = 0;
+
+	checksum = 0;
+	for (i = 0; i < sizeof(*header) - 2; i++)
+		checksum += buf_header[i];
+
+	header->checksum[0] = checksum & 0xff;;
+	header->checksum[1] = (checksum >> 8) & 0xff;;
+
+	crc = buf + size - sizeof(uint32_t);
+
+	*crc = crc32(0xffffffff, buf, size - sizeof(uint32_t));
+	*crc ^= 0xffffffff;
+
+	return 0;
+}
+
+static void usage(const char *prgname)
+{
+	fprintf(stderr, "usage: %s [OPTIONS] <infile>\n", prgname);
+}
+
+int main(int argc, char *argv[])
+{
+	int opt, ret;
+	const char *outfile = NULL, *infile;
+	struct stat s;
+	void *buf;
+	int fd;
+	int min_image_size = 80;
+	int max_image_size = MAX_IMAGE_SIZE;
+	int addsize = 0, pad;
+
+	while ((opt = getopt(argc, argv, "o:hb")) != -1) {
+		switch (opt) {
+		case 'b':
+			add_barebox_header = 1;
+			min_image_size = 0;
+			max_image_size = MAX_IMAGE_SIZE - 512;
+			addsize = 512;
+			break;
+		case 'h':
+			usage(argv[0]);
+			exit(0);
+		case 'o':
+			outfile = optarg;
+			break;
+		default:
+			exit(1);
+		}
+	}
+
+	if (optind == argc) {
+		usage(argv[0]);
+		exit(1);
+	}
+
+	infile = argv[optind];
+
+	ret = stat(infile, &s);
+	if (ret) {
+		perror("stat");
+		exit(1);
+	}
+
+	if (s.st_size < min_image_size) {
+		fprintf(stderr, "input image too small. Minimum is 80 bytes\n");
+		exit(1);
+	}
+
+	if (s.st_size > max_image_size) {
+		fprintf(stderr, "input image too big. Maximum is %d bytes, got %ld bytes\n",
+				max_image_size, s.st_size);
+		exit(1);
+	}
+
+	fd = open(infile, O_RDONLY);
+	if (fd < 0) {
+		perror("open infile");
+		exit(1);
+	}
+
+	pad = s.st_size & 0x3;
+	if (pad)
+		pad = 4 - pad;
+
+	buf = calloc(s.st_size + 4 + addsize + pad, 1);
+	if (!buf) {
+		perror("malloc");
+		exit(1);
+	}
+
+	ret = read_full(fd, buf + addsize, s.st_size);
+	if (ret < 0) {
+		perror("read infile");
+		exit(1);
+	}
+
+	close(fd);
+
+	if (add_barebox_header) {
+		memcpy(buf, bb_header, sizeof(bb_header));
+	}
+
+	ret = add_socfpga_header(buf, s.st_size + 4 + addsize + pad);
+	if (ret)
+		exit(1);
+
+	fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+	if (fd < 0) {
+		perror("open outfile");
+		exit(1);
+	}
+
+	ret = write_full(fd, buf, s.st_size + 4 + addsize + pad);
+	if (ret < 0) {
+		perror("write outfile");
+		exit(1);
+	}
+
+	exit(0);
+}
package/mkpimage/mkpimage.mk new file +22 -0
new file mode 100644
index 0000000..6360902
@@ -0,0 +1,22 @@
+################################################################################
+#
+# mkpimage
+#
+################################################################################
+
+# source included in the package
+# came from barebox's repository:
+# http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD
+HOST_MKPIMAGE_SOURCE =
+HOST_MKPIMAGE_LICENSE = GPLv2
+
+define HOST_MKPIMAGE_BUILD_CMDS
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+		package/mkpimage/mkpimage.c -o $(@D)/mkpimage
+endef
+
+define HOST_MKPIMAGE_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/mkpimage $(HOST_DIR)/usr/bin/mkpimage
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.6.1
#18 lore raw

PATCH v2 1/7 mkpimage: new host package

Hello,

Quoted 12 lines · Jan Viktorin

The tool helps to create a working SPL to boot Altera SoC FPGA boards.

The code of mkpimage is integrated directly from the Barebox repository as stated in the 'mkpimage.mk' file.

This tool is *NOT* necessary for any other boards so far.

---
v1 -> v2: dropped Go implementation, included mkpimage.c from Barebox
because of a wierd URL that cannot be hanled by Buildroot

Quoted 6 lines
---
 package/mkpimage/mkpimage.c  | 287 +++++++++++++++++++++++++++++++++++++++++++
 package/mkpimage/mkpimage.mk |  22 ++++
 2 files changed, 309 insertions(+)
 create mode 100644 package/mkpimage/mkpimage.c
 create mode 100644 package/mkpimage/mkpimage.mk

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#19 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

In reply to Jan Viktorin
---
 boot/uboot/Config.in | 10 ++++++++++
 boot/uboot/uboot.mk  |  9 +++++++++
 2 files changed, 19 insertions(+)
boot/uboot/Config.in +10 -0
index 8643dab..b2a69f3 100644
@@ -338,6 +338,16 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE
 	 for u-boot-dtb.img file so this U-Boot format is required
 	 to be set.
 
+config BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC
+	bool "CRC SPL image for SoC FPGA"
+	depends on BR2_arm
+	depends on BR2_TARGET_UBOOT_SPL
+	help
+	  Generate SPL image fixed by the mkpimage tool to enable
+	  booting on the SoC FPGA based platforms. The tool is
+	  available at https://github.com/maximeh/mkpimage.
+	  It requires a Go language compiler installed on your host.
+
 menuconfig BR2_TARGET_UBOOT_ENVIMAGE
 	bool "Environment image"
 	help
boot/uboot/uboot.mk +9 -0
index 66e728f..8b32154 100644
@@ -215,6 +215,15 @@ UBOOT_DEPENDENCIES += host-zynq-boot-bin
 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
 endif
 
+ifeq ($(BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC),y)
+define UBOOT_CRC_SOCFPGA_IMAGE
+	$(HOST_DIR)/usr/bin/mkpimage -o $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))).crc \
+		$(@D)/$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))
+endef
+UBOOT_DEPENDENCIES += host-mkpimage
+UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_SOCFPGA_IMAGE
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y)
 ifeq ($(BR_BUILDING),y)
 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)),)
Signature · 1 line
2.6.1
#20 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

A small mistake here...

Quoted 13 lines · On Tue, 20 Oct 2015 13:32:20 +0200 Jan Viktorin <[email protected]> wrote:
---
 boot/uboot/Config.in | 10 ++++++++++
 boot/uboot/uboot.mk  |  9 +++++++++
 2 files changed, 19 insertions(+)
boot/uboot/Config.in +0 -0
index 8643dab..b2a69f3 100644
@@ -338,6 +338,16 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE
 	 for u-boot-dtb.img file so this U-Boot format is required
 	 to be set.

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 349

Quoted 10 lines
boot/uboot/Config.in +9 -0
 
+config BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC
+	bool "CRC SPL image for SoC FPGA"
+	depends on BR2_arm
+	depends on BR2_TARGET_UBOOT_SPL
+	help
+	  Generate SPL image fixed by the mkpimage tool to enable
+	  booting on the SoC FPGA based platforms. The tool is
+	  available at https://github.com/maximeh/mkpimage.
+	  It requires a Go language compiler installed on your host.

The last 2 and half lines about mkpimage are obsolete for v2 ^^^^

Quoted 24 lines
boot/uboot/Config.in +1 -0
+
 menuconfig BR2_TARGET_UBOOT_ENVIMAGE
 	bool "Environment image"
 	help
boot/uboot/uboot.mk +9 -0
index 66e728f..8b32154 100644
@@ -215,6 +215,15 @@ UBOOT_DEPENDENCIES += host-zynq-boot-bin
 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
 endif
 
+ifeq ($(BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC),y)
+define UBOOT_CRC_SOCFPGA_IMAGE
+	$(HOST_DIR)/usr/bin/mkpimage -o $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))).crc \
+		$(@D)/$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))
+endef
+UBOOT_DEPENDENCIES += host-mkpimage
+UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_SOCFPGA_IMAGE
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y)
 ifeq ($(BR_BUILDING),y)
 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)),)
Signature · 4 lines
   Jan Viktorin                  E-mail: Viktorin at RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#21 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

In reply to Jan Viktorin

Hello,

Quoted 11 lines · Jan Viktorin
---
 boot/uboot/Config.in | 10 ++++++++++
 boot/uboot/uboot.mk  |  9 +++++++++
 2 files changed, 19 insertions(+)
boot/uboot/Config.in +0 -0
index 8643dab..b2a69f3 100644

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 341

Quoted 4 lines
boot/uboot/Config.in +1 -0
@@ -338,6 +338,16 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE
 	 for u-boot-dtb.img file so this U-Boot format is required
 	 to be set.
 
+config BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC

I've added ALTERA in the option name.

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 342

Quoted 1 line
boot/uboot/Config.in +1 -0
+	bool "CRC SPL image for SoC FPGA"

In the prompt.

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 349

Quoted 7 lines
boot/uboot/Config.in +7 -0
+	depends on BR2_arm
+	depends on BR2_TARGET_UBOOT_SPL
+	help
+	  Generate SPL image fixed by the mkpimage tool to enable
+	  booting on the SoC FPGA based platforms. The tool is
+	  available at https://github.com/maximeh/mkpimage.
+	  It requires a Go language compiler installed on your host.

I've tweaked this description to longer refer to Maxime's tool since you're not using it. I've also s/SoC FPGA/Altera SoC FPGA/. SoC FPGA is really a poor choice from Altera, since it's just two generic terms put next to each other, so we really need to write "Altera SoC FPGA" everywhere, otherwise it's confusing.

Applied with those things fixed.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#22 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

Hello,

I am surprise a bit by applying those quite old patchs. I've forgotten about this patch series entirely. I am afraid, they've fixed this in U-Boot upstream (2016.01?) by generating *.sfp files. I was testing this some time ago with:

BR2_TARGET_UBOOT_FORMAT_DTB_IMG=y BR2_TARGET_UBOOT_SPL=y BR2_TARGET_UBOOT_SPL_NAME="spl/u-boot-spl-dtb.sfp"

and it seems to work. I didn't have time to sync this with Buildroot upstream, sorry.

Regards
Jan

Quoted 44 lines · On Tue, 22 Mar 2016 23:54:28 +0100 Thomas Petazzoni…

Hello,

Quoted 11 lines · Jan Viktorin
---
 boot/uboot/Config.in | 10 ++++++++++
 boot/uboot/uboot.mk  |  9 +++++++++
 2 files changed, 19 insertions(+)
boot/uboot/Config.in +0 -0
index 8643dab..b2a69f3 100644

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 341

Quoted 4 lines
boot/uboot/Config.in +1 -0
@@ -338,6 +338,16 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE
 	 for u-boot-dtb.img file so this U-Boot format is required
 	 to be set.
 
+config BR2_TARGET_UBOOT_SOCFPGA_IMAGE_CRC  

I've added ALTERA in the option name.

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 342

Quoted 1 line
boot/uboot/Config.in +1 -0
+	bool "CRC SPL image for SoC FPGA"  

In the prompt.

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQ_IMAGE · line 349

Quoted 7 lines
boot/uboot/Config.in +7 -0
+	depends on BR2_arm
+	depends on BR2_TARGET_UBOOT_SPL
+	help
+	  Generate SPL image fixed by the mkpimage tool to enable
+	  booting on the SoC FPGA based platforms. The tool is
+	  available at https://github.com/maximeh/mkpimage.
+	  It requires a Go language compiler installed on your host.  

I've tweaked this description to longer refer to Maxime's tool since you're not using it. I've also s/SoC FPGA/Altera SoC FPGA/. SoC FPGA is really a poor choice from Altera, since it's just two generic terms put next to each other, so we really need to write "Altera SoC FPGA" everywhere, otherwise it's confusing.

Applied with those things fixed.

Best regards,

Thomas

Signature · 4 lines
   Jan Viktorin                  E-mail: Viktorin at RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#23 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

Hello,

Quoted 11 lines · Jan Viktorin

I am surprise a bit by applying those quite old patchs. I've forgotten about this patch series entirely. I am afraid, they've fixed this in U-Boot upstream (2016.01?) by generating *.sfp files. I was testing this some time ago with:

BR2_TARGET_UBOOT_FORMAT_DTB_IMG=y BR2_TARGET_UBOOT_SPL=y BR2_TARGET_UBOOT_SPL_NAME="spl/u-boot-spl-dtb.sfp"

and it seems to work. I didn't have time to sync this with Buildroot upstream, sorry.

No problem. Before applying, I looked in U-Boot if there was a tool called mkpimage, and there wasn't, so I assumed it was still needed.

In this case, could you send some follow-up patches that revert the changes that are no longer needed, and that update the two Altera defconfigs to use newer U-Boot versions that have this capability?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#24 lore raw

PATCH v2 2/7 boot/uboot: compute CRC on SPLs for Altera SoC FPGA

Quoted 16 lines · On Wed, 23 Mar 2016 14:06:32 +0100 Thomas Petazzoni…

Hello,

Quoted 11 lines · Jan Viktorin

I am surprise a bit by applying those quite old patchs. I've forgotten about this patch series entirely. I am afraid, they've fixed this in U-Boot upstream (2016.01?) by generating *.sfp files. I was testing this some time ago with:

BR2_TARGET_UBOOT_FORMAT_DTB_IMG=y BR2_TARGET_UBOOT_SPL=y BR2_TARGET_UBOOT_SPL_NAME="spl/u-boot-spl-dtb.sfp"

and it seems to work. I didn't have time to sync this with Buildroot upstream, sorry.

Quoted 6 lines

No problem. Before applying, I looked in U-Boot if there was a tool called mkpimage, and there wasn't, so I assumed it was still needed.

In this case, could you send some follow-up patches that revert the changes that are no longer needed, and that update the two Altera defconfigs to use newer U-Boot versions that have this capability?

I'll be happy to do it if I find some time for this.

Jan

Quoted 4 lines

Thanks!

Thomas

Signature · 4 lines
   Jan Viktorin                  E-mail: Viktorin at RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#25 lore raw

PATCH v2 3/7 altera: improve readme to cover both supported boards

In reply to Jan Viktorin
---
 board/altera/readme.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
board/altera/readme.txt +5 -2
index 8d5b891..ddd9e03 100644
@@ -1,4 +1,4 @@
-SoCkit
+SoCkit, SoC Development Kit
 
 Intro
 =====
@@ -6,9 +6,12 @@ Intro
 This is the buildroot board support for the Arrow SoCkit Evaluation Board
 and the Altera Cyclone 5 Development Board.
 
-A good source of information is :
+A good source of information for Arrow SoCkit:
 http://www.rocketboards.org/foswiki/Documentation/ArrowSoCKitEvaluationBoard
 
+More information about SoC DK:
+https://www.altera.com/products/boards_and_kits/dev-kits/altera/kit-cyclone-v-soc.html
+
 How it works
 ============
 
Signature · 1 line
2.6.1
#26 lore raw

PATCH v2 3/7 altera: improve readme to cover both supported boards

Hello,

Quoted 4 lines · Jan Viktorin
---
 board/altera/readme.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#27 lore raw

PATCH v2 4/7 altera: update text about the mkpimage

In reply to Jan Viktorin

As we've integrated the mkpimage, we just leave some notes about other available tools and give an advice how to enable this feature in Buildroot.

---
 board/altera/readme.txt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
board/altera/readme.txt +9 -7
index ddd9e03..fdd7316 100644
@@ -75,21 +75,23 @@ After building, you should obtain this tree:
     ??? socfpga.dtb
     ??? u-boot.img
     ??? u-boot-spl.bin
+    ??? u-boot-spl.bin.crc
     ??? uImage
 
 
 Signing the Preloader
 ---------------------
 
-*** BEWARE ****
-The u-boot-spl.bin must be signed using the Altera's tool "mkpimage".
-This tool comes as a part of the Altera development environnment (SoC EDS).
-A fork of this tool have been done by Maxime Hadjinlian and can be found here :
-https://github.com/maximeh/mkpimage
+The u-boot-spl.bin needs a checksum computed by the Altera's tool "mkpimage".
+This tool comes as a part of the Altera development environnment (SoC EDS),
+as a standalone tool https://github.com/maximeh/mkpimage and as a part of the
+Barebox project. The boards do not boot without the checksum.
 
-Remember that without signing the u-boot-spl.bin, the board will not boot !!!
+The Buildroot integrates the mkpimage and you can find it in the configuration.
+If you check: "Bootloaders/U-Boot/CRC SPL image for SoC FPGA" the build system
+calls mkpimage on the SPL for you automatically.
 
-  $ mkpimage u-boot-spl.bin -o u-boot-spl-signed.bin
+  $ mkpimage u-boot-spl.bin -o u-boot-spl.bin.crc
 
 Prepare your SDcard
 ===================
Signature · 1 line
2.6.1
#28 lore raw

PATCH v2 4/7 altera: update text about the mkpimage

Hello,

Quoted 31 lines · Jan Viktorin

As we've integrated the mkpimage, we just leave some notes about other available tools and give an advice how to enable this feature in Buildroot.

---
 board/altera/readme.txt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
board/altera/readme.txt +3 -5
index ddd9e03..fdd7316 100644
@@ -75,21 +75,23 @@ After building, you should obtain this tree:
     ??? socfpga.dtb
     ??? u-boot.img
     ??? u-boot-spl.bin
+    ??? u-boot-spl.bin.crc
     ??? uImage
 
 
 Signing the Preloader
 ---------------------
 
-*** BEWARE ****
-The u-boot-spl.bin must be signed using the Altera's tool "mkpimage".
-This tool comes as a part of the Altera development environnment (SoC EDS).
-A fork of this tool have been done by Maxime Hadjinlian and can be found here :
-https://github.com/maximeh/mkpimage
+The u-boot-spl.bin needs a checksum computed by the Altera's tool "mkpimage".
+This tool comes as a part of the Altera development environnment (SoC EDS),

board/altera/readme.txt After building, you should obtain this tree: · line 94

Quoted 10 lines
board/altera/readme.txt +6 -2
+as a standalone tool https://github.com/maximeh/mkpimage and as a part of the
+Barebox project. The boards do not boot without the checksum.
 
-Remember that without signing the u-boot-spl.bin, the board will not boot !!!
+The Buildroot integrates the mkpimage and you can find it in the configuration.
+If you check: "Bootloaders/U-Boot/CRC SPL image for SoC FPGA" the build system
+calls mkpimage on the SPL for you automatically.
 
-  $ mkpimage u-boot-spl.bin -o u-boot-spl-signed.bin
+  $ mkpimage u-boot-spl.bin -o u-boot-spl.bin.crc

This is the wrong change. Instead, you should just modify the two Altera defconfigs we have to use the new feature, and remove all that text since the final bootloader image is now automatically generated by Buildroot. You can leave a note like "The final U-Boot image with the Altera required CRC is automatically generated by Buildroot using mkpimage", but all the rest is useless once the defconfigs are changed.

I'll mark this patch as Changes Requested in our patch tracking system.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#29 lore raw

PATCH v2 5/7 altera: change mmcblk0 to sdc

In reply to Jan Viktorin

It is not very common to have mmcblk0 device on the host PC, the previous text was quite confusing.

---
 board/altera/readme.txt | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
board/altera/readme.txt +10 -10
index fdd7316..62c3670 100644
@@ -106,9 +106,9 @@ Determine the device associated to the SD card :
 
   $ cat /proc/partitions
 
-let's assume it is /dev/mmcblk0 :
+let's assume it is /dev/sdc :
 
-  $ sudo fdisk /dev/mmcblk0
+  $ sudo fdisk /dev/sdc
 
 Delete all previous partitions with 'd' then create the new partition table,
 using these options, pressing enter after each one:
@@ -120,15 +120,15 @@ using these options, pressing enter after each one:
 Using the 'p' option, the SD card's partition must look like this :
 
 Device         Boot     Start       End  Blocks  Id System
-/dev/mmcblk0p1        9000000   9041919   20960   b W95 FAT32
-/dev/mmcblk0p2           4096   8996863 4496384  83 Linux
-/dev/mmcblk0p3           2048      4095    1024  a2 Unknown
+/dev/sdc1             9000000   9041919   20960   b W95 FAT32
+/dev/sdc2                4096   8996863 4496384  83 Linux
+/dev/sdc3                2048      4095    1024  a2 Unknown
 
 Then write the partition table using 'w' and exit.
 
 Make partition one a DOS partition :
 
-  $ sudo mkdosfs /dev/mmcblk0p1
+  $ sudo mkdosfs /dev/sdc1
 
 Install the binaries to the SDcard
 ----------------------------------
@@ -141,19 +141,19 @@ The partition with type a2 is the partition scan by the first bootloader stage
 in the SoCkit ROM to find the next bootloader stage so we must write the signed
 preloader and the u-boot binaries in that partition :
 
-  $ sudo dd if=u-boot-spl-signed.bin of=/dev/mmcblk0p3 bs=64k seek=0
-  $ sudo dd if=u-boot.img of=/dev/mmcblk0p3 bs=64k seek=4
+  $ sudo dd if=u-boot-spl-signed.bin of=/dev/sdc3 bs=64k seek=0
+  $ sudo dd if=u-boot.img of=/dev/sdc3 bs=64k seek=4
 
 Copy the Linux kernel and its Device tree :
 
   $ sudo mkdir /mnt/sdcard
-  $ sudo mount /dev/mmcblk0p1 /mnt/sdcard
+  $ sudo mount /dev/sdc1 /mnt/sdcard
   $ sudo cp socfpga.dtb uImage /mnt/sdcard
   $ sudo umount /mnt/sdcard
 
 Copy the rootfs :
 
-  $ sudo dd if=rootfs.ext2 of=/dev/mmcblk0p2 bs=64k
+  $ sudo dd if=rootfs.ext2 of=/dev/sdc2 bs=64k
   $ sudo sync
 
 It's Done!
Signature · 1 line
2.6.1
#30 lore raw

PATCH v2 5/7 altera: change mmcblk0 to sdc

Hello,

Quoted 4 lines · Jan Viktorin

It is not very common to have mmcblk0 device on the host PC, the previous text was quite confusing.

I think this is not true. On my PC right now:

 179        0    3813376 mmcblk0
 179        1    3813344 mmcblk0p1

So I believe this patch is not really necessary. Just
keep /dev/mmcblk0, the text is clear enough that this device might be different on the user's system.

I've marked this one as Rejected in patchwork.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#31 lore raw

PATCH v2 6/7 altera: improve fdisk instructions

In reply to Jan Viktorin

The 't' command expects the number of the target partition when there are at least 2 of them. Also note about the arbitrary value 9000000.

---
 board/altera/readme.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
board/altera/readme.txt +4 -3
index 62c3670..a30e5a9 100644
@@ -111,10 +111,11 @@ let's assume it is /dev/sdc :
   $ sudo fdisk /dev/sdc
 
 Delete all previous partitions with 'd' then create the new partition table,
-using these options, pressing enter after each one:
+using these options, pressing enter after each one (the value 9000000 depends
+on the size of your SD card):
 
-  * n p 1 9000000 +20480K t 1 b
-  * n p 2 4096 +4496384K t 83
+  * n p 1 9000000 +20480K t b
+  * n p 2 4096 +4496384K t 2 83
   * n p 3 2048 +1024K t 3 a2
 
 Using the 'p' option, the SD card's partition must look like this :
Signature · 1 line
2.6.1
#32 lore raw

PATCH v2 6/7 altera: improve fdisk instructions

Hello,

Quoted 16 lines · Jan Viktorin

The 't' command expects the number of the target partition when there are at least 2 of them. Also note about the arbitrary value 9000000.

---
 board/altera/readme.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
board/altera/readme.txt +0 -0
index 62c3670..a30e5a9 100644
@@ -111,10 +111,11 @@ let's assume it is /dev/sdc :
   $ sudo fdisk /dev/sdc
 

board/altera/readme.txt let's assume it is /dev/sdc : · line 119

Quoted 10 lines
board/altera/readme.txt +4 -3
 Delete all previous partitions with 'd' then create the new partition table,
-using these options, pressing enter after each one:
+using these options, pressing enter after each one (the value 9000000 depends
+on the size of your SD card):
 
-  * n p 1 9000000 +20480K t 1 b
-  * n p 2 4096 +4496384K t 83
+  * n p 1 9000000 +20480K t b
+  * n p 2 4096 +4496384K t 2 83
   * n p 3 2048 +1024K t 3 a2

Rather than tweaking this horrible thing, what about using sfdisk instead, or even better, switch to genimage to generate the image ? The latter would really be the ideal solution (but I would accept a patch changing to sfdisk in the mean time, if you don't have the time to look into genimage right now).

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#33 lore raw

PATCH v2 7/7 altera: remove whitespace before colon

In reply to Jan Viktorin
---
 board/altera/readme.txt | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
board/altera/readme.txt +16 -16
index a30e5a9..cda71c9 100644
@@ -15,8 +15,8 @@ https://www.altera.com/products/boards_and_kits/dev-kits/altera/kit-cyclone-v-so
 How it works
 ============
 
-Boot process :
---------------
+Boot process:
+-------------
 
 In summary, the bootloader has multiple stages, an hardcoded boot routine is
 loaded from an on-chip ROM.
@@ -28,15 +28,15 @@ loaded from an on-chip ROM.
     which will load the u-boot image.
   - Then the u-boot image will load the Linux kernel.
 
-A good source of information for the boot process is :
+A good source of information for the boot process is:
 http://xillybus.com/tutorials/u-boot-image-altera-soc
 
-Note for the SPL :
+Note for the SPL:
 The SPL generated by the u-boot from Rocketboards doesn't seems to work,
 therefore we provide a patch for {uboot-PKG}/board/altera/socfpga_cyclone5/*
 based on the files generated with the Altera example design.
 
-For more information about this files please look at :
+For more information about this files please look at:
 http://www.rocketboards.org/foswiki/Documentation/PreloaderUbootCustomization#Common_Source_Code
 
 How to build it
@@ -46,11 +46,11 @@ Configure Buildroot
 -------------------
 
 The altera_sockit_defconfig configuration is a minimal configuration with
-all that is required to bring the SoCkit :
+all that is required to bring the SoCkit:
 
   $ make altera_sockit_defconfig
 
-and for the SoC Development Board :
+and for the SoC Development Board:
 
   $ make altera_sockdk_defconfig
 
@@ -96,17 +96,17 @@ calls mkpimage on the SPL for you automatically.
 Prepare your SDcard
 ===================
 
-A good source of information for the partitioning process is :
+A good source of information for the partitioning process is:
 http://www.rocketboards.org/foswiki/view/Projects/SoCKitLinaroLinuxDesktop#Partition_the_SD_Card
 
 Create the SDcard partition table
 ----------------------------------
 
-Determine the device associated to the SD card :
+Determine the device associated to the SD card:
 
   $ cat /proc/partitions
 
-let's assume it is /dev/sdc :
+let's assume it is /dev/sdc:
 
   $ sudo fdisk /dev/sdc
 
@@ -118,7 +118,7 @@ on the size of your SD card):
   * n p 2 4096 +4496384K t 2 83
   * n p 3 2048 +1024K t 3 a2
 
-Using the 'p' option, the SD card's partition must look like this :
+Using the 'p' option, the SD card's partition must look like this:
 
 Device         Boot     Start       End  Blocks  Id System
 /dev/sdc1             9000000   9041919   20960   b W95 FAT32
@@ -127,32 +127,32 @@ Device         Boot     Start       End  Blocks  Id System
 
 Then write the partition table using 'w' and exit.
 
-Make partition one a DOS partition :
+Make partition one a DOS partition:
 
   $ sudo mkdosfs /dev/sdc1
 
 Install the binaries to the SDcard
 ----------------------------------
 
-Remember your binaries are located in output/images/, go inside that directory :
+Remember your binaries are located in output/images/, go inside that directory:
 
   $ cd output/images
 
 The partition with type a2 is the partition scan by the first bootloader stage
 in the SoCkit ROM to find the next bootloader stage so we must write the signed
-preloader and the u-boot binaries in that partition :
+preloader and the u-boot binaries in that partition:
 
   $ sudo dd if=u-boot-spl-signed.bin of=/dev/sdc3 bs=64k seek=0
   $ sudo dd if=u-boot.img of=/dev/sdc3 bs=64k seek=4
 
-Copy the Linux kernel and its Device tree :
+Copy the Linux kernel and its Device tree:
 
   $ sudo mkdir /mnt/sdcard
   $ sudo mount /dev/sdc1 /mnt/sdcard
   $ sudo cp socfpga.dtb uImage /mnt/sdcard
   $ sudo umount /mnt/sdcard
 
-Copy the rootfs :
+Copy the rootfs:
 
   $ sudo dd if=rootfs.ext2 of=/dev/sdc2 bs=64k
   $ sudo sync
Signature · 1 line
2.6.1
#34 lore raw

PATCH v2 7/7 altera: remove whitespace before colon

Hello,

Quoted 4 lines · Jan Viktorin
---
 board/altera/readme.txt | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

I've applied after fixing the conflicts due to the previous patches not being applied.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#35 lore raw

PATCH 1/1 mpkimage: new package

mkpimage is a necessary tool used to "signed" U-Boot SPL for the Altera SoCFPGA family.

The code of mkpimage is integrated directly from the Barebox repository as stated in the 'mkpimage.mk' file.

This tool is *NOT* necessary for any other boards so far.

Signed-off-by Maxime Hadjinlian <[email protected]>

---
 package/Config.in.host          |   1 +
 package/mkpimage/Config.in.host |   7 +
 package/mkpimage/mkpimage.c     | 287 ++++++++++++++++++++++++++++++++++++++++
 package/mkpimage/mkpimage.mk    |  22 +++
 4 files changed, 317 insertions(+)
 create mode 100644 package/mkpimage/Config.in.host
 create mode 100644 package/mkpimage/mkpimage.c
 create mode 100644 package/mkpimage/mkpimage.mk
package/Config.in.host +1 -0
index 1f69687..a4662d7 100644
@@ -15,6 +15,7 @@ menu "Host utilities"
 	source "package/imx-usb-loader/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/mke2img/Config.in.host"
+	source "package/mkpimage/Config.in.host"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
 	source "package/omap-u-boot-utils/Config.in.host"
package/mkpimage/Config.in.host new file +7 -0
new file mode 100644
index 0000000..3f55568
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_HOST_MKPIMAGE
+	bool "host-mkpimage"
+	help
+	  This packages contains the 'mkpimage' tool from Barebox.
+	  It's used to sign the U-Boot SPL for the Altera's SoCFPGA family.
+
+	  http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c
package/mkpimage/mkpimage.c new file +287 -0

287 lines not on this page · raw message

package/mkpimage/mkpimage.mk new file +22 -0
new file mode 100644
index 0000000..d6dcdd2
@@ -0,0 +1,22 @@
+################################################################################
+#
+# mkpimage
+#
+################################################################################
+
+# source included in the package
+# came from barebox's repository:
+# http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD
+HOST_MKPIMAGE_SOURCE =
+HOST_MKPIMAGE_LICENSE = GPLv2
+
+define HOST_MKPIMAGE_BUILD_CMDS
+    $(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+        package/mkpimage/mkpimage.c -o $(@D)/mkpimage
+endef
+
+define HOST_MKPIMAGE_INSTALL_CMDS
+    $(INSTALL) -D -m 755 $(@D)/mkpimage $(HOST_DIR)/usr/bin/mkpimage
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.6.1
#36 lore raw

PATCH 1/1 mpkimage: new package

Hi Maxime,

package/mkpimage/Config.in.host line 2

Quoted 2 lines · Maxime Hadjinlian
package/mkpimage/Config.in.host new file +2 -0
+config BR2_PACKAGE_HOST_MKPIMAGE
+	bool "host-mkpimage"

All other host packages (except imx-usb-loader) don't have a dash after "host" in the config prompt.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#37 lore raw

PATCH 1/1 mpkimage: new package

In reply to Maxime Hadjinlian

Maxime,

package/Config.in.host menu "Host utilities" · line 18

Quoted 9 lines · Maxime Hadjinlian
package/Config.in.host +1 -0
index 1f69687..a4662d7 100644
@@ -15,6 +15,7 @@ menu "Host utilities"
 	source "package/imx-usb-loader/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/mke2img/Config.in.host"
+	source "package/mkpimage/Config.in.host"

Do we really need a visible Config.in option for this tool? Can't it simply be used as a dependency of U-Boot, as proposed by Jan in his patch series ?

Quoted 11 lines
package/mkpimage/mkpimage.mk new file +5 -0
new file mode 100644
index 0000000..d6dcdd2
@@ -0,0 +1,22 @@
+################################################################################
+#
+# mkpimage
+#
+################################################################################

package/mkpimage/mkpimage.mk line 15

Quoted 10 lines
package/mkpimage/mkpimage.mk new file +10 -0
+
+# source included in the package
+# came from barebox's repository:
+# http://git.pengutronix.de/?p=barebox.git;a=blob;f=scripts/socfpga_mkimage.c;h=1a7a66d98841e9f52c3ea49c651286aa1412c9a5;hb=HEAD
+HOST_MKPIMAGE_SOURCE =
+HOST_MKPIMAGE_LICENSE = GPLv2
+
+define HOST_MKPIMAGE_BUILD_CMDS
+    $(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+        package/mkpimage/mkpimage.c -o $(@D)/mkpimage

Use tabs for indentation.

package/mkpimage/mkpimage.mk line 19

Quoted 4 lines
package/mkpimage/mkpimage.mk new file +4 -0
+endef
+
+define HOST_MKPIMAGE_INSTALL_CMDS
+    $(INSTALL) -D -m 755 $(@D)/mkpimage $(HOST_DIR)/usr/bin/mkpimage

Ditto.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com