mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: gianluca <gianlucarenzi@eurek.it>, barebox@lists.infradead.org
Subject: Re: Barebox as first and second stage bootloader
Date: Wed, 26 Feb 2020 16:08:40 +0100	[thread overview]
Message-ID: <5d328910-2009-b83f-014a-75a4847ea235@pengutronix.de> (raw)
In-Reply-To: <88405b89-494c-f510-ecb4-810f8b6e0b91@eurek.it>

Hello,

On 2/26/20 3:46 PM, gianluca wrote:
>> Not sure how this relates to booting over USB? You shouldn't need any
>> fuses burnt (but you can probably burn some to stop fallback to DFU)
>>
> 
> I was trying to say that I didn't know how the fallback is managed DFU via serial, usb or whatever or it is managed by some OTP fuses.

For development use, you can use the BOOT pins to configure DFU:
https://www.barebox.org/doc/latest/boards/stm32mp.html#boot-source-selection

>>> I suppose they are TF-A for first stage bootloader and SPL for the second one.
>>>
>>> The images built by Barebox (start_stm32mp157c_dk2.pblb[.stm32] and barebox-stm32mp157c-dk2.img) are suitable to be used as first stage bootloader running from internal SRAM and the .img as the second stage bootloader running from external SDRAM DDR???
>>
>> No, they aren't. The current barebox implementation doesn't set up SDRAM and doesn't install
>> a secure monitor.
>>
> 
> So I need a simple implementation of a SDRAM setup, a secure monitor (TF-A). What do you are using at the moment?

I am using TF-A v2.2. I thought about having a simple SDRAM setup in barebox
for flashing purposes, but got talked out of it, because that was code that's
untested unless you are doing a initial bring up and would be prone to bit rot.

Either go all the way, or don't.

> My goals are to setup the SDRAM and the secure monitor via USB (with DFU STM32 Cube Programmer), then loading via usb (using the same STM32 Cube Programmer) the barebox-stm32mp157c-dk2.img in the external SDRAM addresses.

I haven't tested this, but it should work. barebox doesn't need anything
special to be flashed by the DFU.

> When barebox is done, it will download from a TFTP server the production stuff (SDRAM setup, secure monitor, barebox-stm32mp157c-dk2-PRODUCTION.img) and write those stuff into eMMC partitions.

Doesn't the STM32 Cube Programmer already come with the necessary infrastructure
to partition the eMMC and write the images over USB?

>> USB on the STM32MP1 is not yet complete. I posted some basic patches for the PHY, but we still
>> need host USB driver adjustments and a gadget driver for the DWC2.
>>
> 
> Using the above procedure the USB support is given only by ROM Code written by ST, not by Barebox.

Not exactly, you communicate with the ROM Code to get TF-A into On-Chip RAM. Then you talk with
TF-A to get SSBL into SDRAM. Then you talk with SSBL to flash the rest. That's how the
STM32 Cube Programmer does it.

See below[0].

>>> Is there somebody who is working with STM32 Cube Programmer or DFU-Utils to obtain this boot??
>>
>> I don't think so. We will want to have a solution for this eventually though. Probably some
>> wrapper script that uses DFU to talk to BootROM, then to vendor TF-A, then to barebox.
>>
> 
> Having this wrapper script will be great. I will be grateful for the rest of my (working) life. ;-P

I'll take a look, once we have USB gadget support on the STM32.
Can't say for sure when this will be though. There are means[1] to
accelerate this however. ;-)

>> As I understood, that's what the STM32CubeProgrammer is doing and it's shipped with
>> a FSBL and SSBL already for bootstrapping a system. Have you tried using that to
>> flash barebox?
>>
> 
> Not really. I will check asap. In that way I could run barebox from a bootstrapped system using STM32CubeProgrammer FSBL and SSBL and hooking at the procedure as explained above.

AN5275[0] says that it's really a three stage process like I described.

If you manage to flash barebox with it, a Documentation patch about how to use the CLI version
of the tool would be very much appreciated.


[0]: https://www.st.com/content/ccc/resource/technical/document/application_note/group1/63/b3/70/f6/82/33/4e/5e/DM00589815/files/DM00589815.pdf/jcr:content/translations/en.DM00589815.pd
[1]: https://www.pengutronix.de/en/services/integration_testing.html

Cheers
Ahmad


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  reply	other threads:[~2020-02-26 15:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 11:57 gianluca
2020-02-26 14:28 ` Ahmad Fatoum
2020-02-26 14:46   ` gianluca
2020-02-26 15:08     ` Ahmad Fatoum [this message]
2020-02-26 15:30       ` gianluca
2020-02-26 15:46         ` Ahmad Fatoum
     [not found]           ` <2b5d2afe-c71e-34b9-efa5-57aaa5f28445@eurek.it>
2020-02-27 11:51             ` Ahmad Fatoum
2020-02-28  7:50               ` gianluca
2020-02-28  8:28                 ` gianluca
2020-03-03  6:58                   ` Ahmad Fatoum
     [not found]           ` <fb81fdd3-b674-ce0b-e472-ec8e606e4131@eurek.it>
2020-03-03  7:03             ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d328910-2009-b83f-014a-75a4847ea235@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=gianlucarenzi@eurek.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox