* [Buildroot] Patch: new board Socrates Cyclone 5 @ 2017-07-30 12:51 Michał Łyszczek 2017-07-30 13:15 ` Thomas Petazzoni 0 siblings, 1 reply; 10+ messages in thread From: Michał Łyszczek @ 2017-07-30 12:51 UTC (permalink / raw) To: buildroot Hi, This is my first contribution so please correct me if I did something wrong. I attach patch with new board support - EVB SoCrates based on Altera's Cyclone 5. I had to add a single binary file - preloader.bin. This is uboot based SPL from Altera. Problem with altera is that boot images must be signed with mkpimage tool, that is bundled with Quartus and it is not possible to sign SPL from buildroot. Yes, supposedly there is option in config to create signed SPL, but it doesn't work for none of my Altera's board, hence this binary SPL. Good side is that this SPL loads uboot that is made during compilation, so there is still place for customization and patching if someone needs it. -- Best Regards ?yszczek Micha? -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Added-new-board-EVB-SoCrates-based-on-Altera-Cyclone.patch Type: text/x-patch Size: 47132 bytes Desc: not available URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170730/da0e1e48/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170730/da0e1e48/attachment.asc> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-07-30 12:51 [Buildroot] Patch: new board Socrates Cyclone 5 Michał Łyszczek @ 2017-07-30 13:15 ` Thomas Petazzoni 2017-08-01 7:54 ` Lionel Flandrin 0 siblings, 1 reply; 10+ messages in thread From: Thomas Petazzoni @ 2017-07-30 13:15 UTC (permalink / raw) To: buildroot Hello, (Lionel, Jan: see below, there is a question for you.) On Sun, 30 Jul 2017 14:51:25 +0200, Micha? ?yszczek wrote: > This is my first contribution so please correct me if I did something wrong. Could you please resend your patch with "git send-email" so that it is sent as the e-mail body and not as attachment? This will make reviewing the patch a lot easier. > I attach patch with new board support - EVB SoCrates based on Altera's > Cyclone 5. I had to add a single binary file - preloader.bin. This is > uboot based SPL from Altera. Problem with altera is that boot images > must be signed with mkpimage tool, that is bundled with Quartus and it > is not possible to sign SPL from buildroot. Yes, supposedly there is > option in config to create signed SPL, but it doesn't work for none of > my Altera's board, hence this binary SPL. Good side is that this SPL > loads uboot that is made during compilation, so there is still place for > customization and patching if someone needs it. I've added in Cc: Jan and Lionel who added and improved the BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC. Hopefully they will have some ideas. Best regards, Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-07-30 13:15 ` Thomas Petazzoni @ 2017-08-01 7:54 ` Lionel Flandrin 2017-08-01 8:53 ` Thomas Petazzoni 0 siblings, 1 reply; 10+ messages in thread From: Lionel Flandrin @ 2017-08-01 7:54 UTC (permalink / raw) To: buildroot On Sun, Jul 30, 2017 at 03:15:02PM +0200, Thomas Petazzoni wrote: > Hello, Hi! > (Lionel, Jan: see below, there is a question for you.) > > On Sun, 30 Jul 2017 14:51:25 +0200, Micha? ?yszczek wrote: > > > This is my first contribution so please correct me if I did something wrong. > > Could you please resend your patch with "git send-email" so that it is > sent as the e-mail body and not as attachment? This will make reviewing > the patch a lot easier. > > > I attach patch with new board support - EVB SoCrates based on Altera's > > Cyclone 5. I had to add a single binary file - preloader.bin. This is > > uboot based SPL from Altera. Problem with altera is that boot images > > must be signed with mkpimage tool, that is bundled with Quartus and it > > is not possible to sign SPL from buildroot. Yes, supposedly there is > > option in config to create signed SPL, but it doesn't work for none of > > my Altera's board, hence this binary SPL. Good side is that this SPL > > loads uboot that is made during compilation, so there is still place for > > customization and patching if someone needs it. What do you mean by "signed" with mkpimage? As far as I know mkpimage can't sign anything, it just puts a simple header before the BIN file and then adds a CRC at the end. Simply looking at the help message of Altera's own mkpimage: > mkpimage version 16.0 (build 211) > > Description: This tool creates an Altera BootROM-compatible image of Second > Stage Boot Loader (SSBL). The input and output files are in binary format. > It can also decode and check the validity of previously generated image. > > Usage: > Create quad image: > mkpimage [options] -hv <num> -o <outfile> <infile> <infile> <infile> <infile> > Create single image: > mkpimage [options] -hv <num> -o <outfile> <infile> > Decode single/quad image: > mkpimage -d [-a <num>] <infile> > > Options: > -a (--alignment) <num> : Address alignment in kilobytes for output image > (64, 128, 256, etc.), default to 64 for header > version 0 and 256 for header version 1, > override if the NAND flash has a different > block size. If outputting a single image, value > of '0' is permitted to specify no flash block > padding (needed for SSBL image encryption). > -d (--decode) : Flag to decode the header information from > input file and display it > -f (--force) : Flag to force decoding even if the input file > is an unpadded image > -h (--help) : Display this help message and exit > -hv (--header-version) <num> : Header version to be created (Arria/Cyclone V = > 0, Arria 10 = 1) > -o (--output) <outfile> : Output file, relative and absolute path > supported > -off (--offset) <num> : Program entry offset relative to start of > header (0x40), default to 0x14. Used for header > version 1 only Buildroot uses barebox's reimplementation in package/mkpimage to have the same functionality. They should generate a valid image for Altera bootloaders (both Arria/Cyclone V and 10). Now on top of that I know that the Arria 10 supports booting signed and even encrypted images, however I'm not sure if the Cyclone V has this functionality. If it does and your board is configured only to accept signed code maybe that's your problem? Can I access this preloader.bin somewhere? I could check if there's anything obviously special about it. > I've added in Cc: Jan and Lionel who added and improved the > BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC. Hopefully they will have > some ideas. > > Best regards, > > Thomas > -- > Thomas Petazzoni, CTO, Free Electrons > Embedded Linux and Kernel engineering > http://free-electrons.com -- Lionel Flandrin -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170801/68f68ca7/attachment.asc> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 7:54 ` Lionel Flandrin @ 2017-08-01 8:53 ` Thomas Petazzoni 2017-08-01 10:02 ` Lionel Flandrin 0 siblings, 1 reply; 10+ messages in thread From: Thomas Petazzoni @ 2017-08-01 8:53 UTC (permalink / raw) To: buildroot Hello, On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: > Can I access this preloader.bin somewhere? I could check if there's > anything obviously special about it. The preloader.bin is part of the patch that Micha? sent: https://patchwork.ozlabs.org/patch/795350/ And the very reason why I opened up this thread is because it's not great to have pre-built bootloader images in the Buildroot tree. Best regards, Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 8:53 ` Thomas Petazzoni @ 2017-08-01 10:02 ` Lionel Flandrin 2017-08-01 11:07 ` Jan Viktorin 0 siblings, 1 reply; 10+ messages in thread From: Lionel Flandrin @ 2017-08-01 10:02 UTC (permalink / raw) To: buildroot On Tue, Aug 01, 2017 at 10:53:03AM +0200, Thomas Petazzoni wrote: > Hello, > > On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: > > > Can I access this preloader.bin somewhere? I could check if there's > > anything obviously special about it. > > The preloader.bin is part of the patch that Micha? sent: > > https://patchwork.ozlabs.org/patch/795350/ Ah, I missed that, thank you for pointing it out. It's definitely a mkpimage file. A simple way to validate that is to check offset 0x40: @0x40: [41 53 30 31] Magic ("AS01") @0x44: [00] Version (v0 for Cyclone V) @0x45: [00] Flags @0x46: [48 25] Program length in words, so 38176B @0x48: [00 00] Not used ("spare") @0x4a: [62 01] Header checksum Then at the end of the file you have a 4 byte CRC which I haven't bothered to validate. So nothing out of the ordinary as far as I can tell. In particular I can't see anything ressembling a cryptographic signature at the beginning or end of the file. Looks like a regular u-boot SPL to me. I can't really say more about it, I don't have a Cyclone V board at the moment. My advice would be to validate that the SPL generated by u-boot does contain a valid mkpimage header. Since there are no standard extensions (Altera uses ".bin" for everything) it's easy to use the wrong file by mistake. I think buildroot's file should end in ".crc" (the ".bin" generated by u-boot is the raw u-boot binary and can't be used as-is). There's also the possibility of an error during flashing (truncated file or something similar). If the mkpimage CRC is invalid the ROM will bail out. So make sure you give the correct file size to your flasher. If everything else fails it should be possible to debug the boot sequence with the JTAG, see if the CPU jumps into the SPL code at some point. If it does then clearly it's the SPL that's bogus, otherwise it's the boot ROM refusing to load it for some reason. Here are some docs regarding "bare metal" debugging: https://rocketboards.org/foswiki/view/Documentation/UsingDS5HeadlessDebuggerWithAlteraSoCs > And the very reason why I opened up this thread is because it's not > great to have pre-built bootloader images in the Buildroot tree. I agree completely. > Best regards, > > Thomas -- Lionel Flandrin -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170801/97ffc01a/attachment.asc> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 10:02 ` Lionel Flandrin @ 2017-08-01 11:07 ` Jan Viktorin 2017-08-01 11:21 ` Thomas Petazzoni 0 siblings, 1 reply; 10+ messages in thread From: Jan Viktorin @ 2017-08-01 11:07 UTC (permalink / raw) To: buildroot On Tue, 1 Aug 2017 12:02:48 +0200 Lionel Flandrin <lionel@svkt.org> wrote: > On Tue, Aug 01, 2017 at 10:53:03AM +0200, Thomas Petazzoni wrote: > > Hello, > > > > On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: > > > > > Can I access this preloader.bin somewhere? I could check if there's > > > anything obviously special about it. > > > > The preloader.bin is part of the patch that Micha? sent: > > > > https://patchwork.ozlabs.org/patch/795350/ > > Ah, I missed that, thank you for pointing it out. > > It's definitely a mkpimage file. A simple way to validate that is to > check offset 0x40: > > @0x40: [41 53 30 31] Magic ("AS01") > @0x44: [00] Version (v0 for Cyclone V) > @0x45: [00] Flags > @0x46: [48 25] Program length in words, so 38176B > @0x48: [00 00] Not used ("spare") > @0x4a: [62 01] Header checksum > > Then at the end of the file you have a 4 byte CRC which I haven't > bothered to validate. > > So nothing out of the ordinary as far as I can tell. In particular I > can't see anything ressembling a cryptographic signature at the > beginning or end of the file. Looks like a regular u-boot SPL to me. > > I can't really say more about it, I don't have a Cyclone V board at > the moment. My advice would be to validate that the SPL generated by Hi, I've got a Socrates Cyclone V available and so I am able to test. If there are any patches to test, I can probably help. Regards Jan [...] > > > And the very reason why I opened up this thread is because it's not > > great to have pre-built bootloader images in the Buildroot tree. > > I agree completely. > > > Best regards, > > > > Thomas > -- Jan Viktorin E-mail: Viktorin at RehiveTech.com System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 11:07 ` Jan Viktorin @ 2017-08-01 11:21 ` Thomas Petazzoni 2017-08-01 18:08 ` Michał Łyszczek 0 siblings, 1 reply; 10+ messages in thread From: Thomas Petazzoni @ 2017-08-01 11:21 UTC (permalink / raw) To: buildroot Hello, On Tue, 1 Aug 2017 13:07:11 +0200, Jan Viktorin wrote: > > On Tue, Aug 01, 2017 at 10:53:03AM +0200, Thomas Petazzoni wrote: > > > Hello, > > > > > > On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: > > > > > > > Can I access this preloader.bin somewhere? I could check if there's > > > > anything obviously special about it. > > > > > > The preloader.bin is part of the patch that Micha? sent: > > > > > > https://patchwork.ozlabs.org/patch/795350/ > > > > Ah, I missed that, thank you for pointing it out. > > > > It's definitely a mkpimage file. A simple way to validate that is to > > check offset 0x40: > > > > @0x40: [41 53 30 31] Magic ("AS01") > > @0x44: [00] Version (v0 for Cyclone V) > > @0x45: [00] Flags > > @0x46: [48 25] Program length in words, so 38176B > > @0x48: [00 00] Not used ("spare") > > @0x4a: [62 01] Header checksum > > > > Then at the end of the file you have a 4 byte CRC which I haven't > > bothered to validate. > > > > So nothing out of the ordinary as far as I can tell. In particular I > > can't see anything ressembling a cryptographic signature at the > > beginning or end of the file. Looks like a regular u-boot SPL to me. > > > > I can't really say more about it, I don't have a Cyclone V board at > > the moment. My advice would be to validate that the SPL generated by > > Hi, I've got a Socrates Cyclone V available and so I am able to test. > If there are any patches to test, I can probably help. Micha? original patch is at https://patchwork.ozlabs.org/patch/795350/, but I dislike having the prebuilt preloader.bin in the Buildroot tree. So if you can get that to work without having a pre-built binary in U-Boot, that'd be great. Thanks! Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 11:21 ` Thomas Petazzoni @ 2017-08-01 18:08 ` Michał Łyszczek 2017-08-01 18:45 ` Michał Łyszczek 0 siblings, 1 reply; 10+ messages in thread From: Michał Łyszczek @ 2017-08-01 18:08 UTC (permalink / raw) To: buildroot W dniu 01.08.2017 o 13:21, Thomas Petazzoni pisze: > Hello, > > On Tue, 1 Aug 2017 13:07:11 +0200, Jan Viktorin wrote: > >>> On Tue, Aug 01, 2017 at 10:53:03AM +0200, Thomas Petazzoni wrote: >>>> Hello, >>>> >>>> On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: >>>> >>>>> Can I access this preloader.bin somewhere? I could check if there's >>>>> anything obviously special about it. >>>> >>>> The preloader.bin is part of the patch that Micha? sent: >>>> >>>> https://patchwork.ozlabs.org/patch/795350/ >>> >>> Ah, I missed that, thank you for pointing it out. >>> >>> It's definitely a mkpimage file. A simple way to validate that is to >>> check offset 0x40: >>> >>> @0x40: [41 53 30 31] Magic ("AS01") >>> @0x44: [00] Version (v0 for Cyclone V) >>> @0x45: [00] Flags >>> @0x46: [48 25] Program length in words, so 38176B >>> @0x48: [00 00] Not used ("spare") >>> @0x4a: [62 01] Header checksum >>> >>> Then at the end of the file you have a 4 byte CRC which I haven't >>> bothered to validate. >>> >>> So nothing out of the ordinary as far as I can tell. In particular I >>> can't see anything ressembling a cryptographic signature at the >>> beginning or end of the file. Looks like a regular u-boot SPL to me. >>> >>> I can't really say more about it, I don't have a Cyclone V board at >>> the moment. My advice would be to validate that the SPL generated by >> >> Hi, I've got a Socrates Cyclone V available and so I am able to test. >> If there are any patches to test, I can probably help. > > Micha? original patch is at > https://patchwork.ozlabs.org/patch/795350/, but I dislike having the > prebuilt preloader.bin in the Buildroot tree. So if you can get that to > work without having a pre-built binary in U-Boot, that'd be great. > > Thanks! > > Thomas > Hi, Sorry for confusion, by "signing" I meant using mkpimage to generate header and CRC - no crypto magic here. I tried flashing with genereted spl.crc but it didn't work, and it looks like board never reaches SPL code - it hangs in boot rom (never reaches code from sd card). I have investigated it more and tried to compile uboot from altera's git (https://github.com/altera-opensource/u-boot-socfpga ; tag v2017.07) And I did: make socfpga_cyclone5_config make I've also created valid mkpimage (using official one from altera), when verifying mkpimage tool reports 4 valid images (all the same). In this scenario cyclone still didn't boot up and hangs in boot rom and never reaches spl code. Jan Viktorin, you said you have socrates board, did you ever compile spl manually for this board? It looks like I must be missing something. Any ideas? -- Best Regards ?yszczek Micha? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170801/fbd561ae/attachment.asc> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 18:08 ` Michał Łyszczek @ 2017-08-01 18:45 ` Michał Łyszczek 2017-08-01 19:32 ` Thomas Petazzoni 0 siblings, 1 reply; 10+ messages in thread From: Michał Łyszczek @ 2017-08-01 18:45 UTC (permalink / raw) To: buildroot W dniu 01.08.2017 o 20:08, Micha? ?yszczek pisze: > W dniu 01.08.2017 o 13:21, Thomas Petazzoni pisze: >> Hello, >> >> On Tue, 1 Aug 2017 13:07:11 +0200, Jan Viktorin wrote: >> >>>> On Tue, Aug 01, 2017 at 10:53:03AM +0200, Thomas Petazzoni wrote: >>>>> Hello, >>>>> >>>>> On Tue, 1 Aug 2017 09:54:56 +0200, Lionel Flandrin wrote: >>>>> >>>>>> Can I access this preloader.bin somewhere? I could check if there's >>>>>> anything obviously special about it. >>>>> >>>>> The preloader.bin is part of the patch that Micha? sent: >>>>> >>>>> https://patchwork.ozlabs.org/patch/795350/ >>>> >>>> Ah, I missed that, thank you for pointing it out. >>>> >>>> It's definitely a mkpimage file. A simple way to validate that is to >>>> check offset 0x40: >>>> >>>> @0x40: [41 53 30 31] Magic ("AS01") >>>> @0x44: [00] Version (v0 for Cyclone V) >>>> @0x45: [00] Flags >>>> @0x46: [48 25] Program length in words, so 38176B >>>> @0x48: [00 00] Not used ("spare") >>>> @0x4a: [62 01] Header checksum >>>> >>>> Then at the end of the file you have a 4 byte CRC which I haven't >>>> bothered to validate. >>>> >>>> So nothing out of the ordinary as far as I can tell. In particular I >>>> can't see anything ressembling a cryptographic signature at the >>>> beginning or end of the file. Looks like a regular u-boot SPL to me. >>>> >>>> I can't really say more about it, I don't have a Cyclone V board at >>>> the moment. My advice would be to validate that the SPL generated by >>> >>> Hi, I've got a Socrates Cyclone V available and so I am able to test. >>> If there are any patches to test, I can probably help. >> >> Micha? original patch is at >> https://patchwork.ozlabs.org/patch/795350/, but I dislike having the >> prebuilt preloader.bin in the Buildroot tree. So if you can get that to >> work without having a pre-built binary in U-Boot, that'd be great. >> >> Thanks! >> >> Thomas >> > > Hi, > > Sorry for confusion, by "signing" I meant using mkpimage to generate > header and CRC - no crypto magic here. > > I tried flashing with genereted spl.crc but it didn't work, and it looks > like board never reaches SPL code - it hangs in boot rom (never reaches > code from sd card). > > I have investigated it more and tried to compile uboot from altera's git > (https://github.com/altera-opensource/u-boot-socfpga ; tag v2017.07) > > And I did: > > make socfpga_cyclone5_config > make > > I've also created valid mkpimage (using official one from altera), when > verifying mkpimage tool reports 4 valid images (all the same). In this > scenario cyclone still didn't boot up and hangs in boot rom and never > reaches spl code. > > Jan Viktorin, you said you have socrates board, did you ever compile spl > manually for this board? It looks like I must be missing something. > > Any ideas? > Ok, I know what I was missing. My brain. I used socfpga_cyclone5 config while I should have used socfpga_cyclone. So it looks like I can actually post a patch without any binary stuff. Now question arises. Should I post completly new patch, or somehow modify previous one? -- Z wyrazami szacunku ?yszczek Micha? +48-727-564-419 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170801/c0e335e7/attachment.asc> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] Patch: new board Socrates Cyclone 5 2017-08-01 18:45 ` Michał Łyszczek @ 2017-08-01 19:32 ` Thomas Petazzoni 0 siblings, 0 replies; 10+ messages in thread From: Thomas Petazzoni @ 2017-08-01 19:32 UTC (permalink / raw) To: buildroot Hello, On Tue, 1 Aug 2017 20:45:13 +0200, Micha? ?yszczek wrote: > Ok, I know what I was missing. My brain. I used socfpga_cyclone5 config > while I should have used socfpga_cyclone. So it looks like I can > actually post a patch without any binary stuff. Great! > Now question arises. Should I post completly new patch, or somehow > modify previous one? Post a completely new patch. Thanks! Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-08-01 19:32 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-30 12:51 [Buildroot] Patch: new board Socrates Cyclone 5 Michał Łyszczek 2017-07-30 13:15 ` Thomas Petazzoni 2017-08-01 7:54 ` Lionel Flandrin 2017-08-01 8:53 ` Thomas Petazzoni 2017-08-01 10:02 ` Lionel Flandrin 2017-08-01 11:07 ` Jan Viktorin 2017-08-01 11:21 ` Thomas Petazzoni 2017-08-01 18:08 ` Michał Łyszczek 2017-08-01 18:45 ` Michał Łyszczek 2017-08-01 19:32 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox