mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Oftree from memory and access to start arguments
@ 2018-06-05 23:07 Pascal Vizeli
  2018-06-07  7:31 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Vizeli @ 2018-06-05 23:07 UTC (permalink / raw)
  To: barebox

Hi,

I'm working on a functionality to load a device tree with oftree from
memory. The use case is like raspberry platform they have his own
device tree for linux kernel. If I known the address (config.txt), I
will load this from memory and read out the dynamic linux args and use
other overlays for states with bootchoiser and boot the kernel
correctly.

On raspberry, I can write the device-tree to a memory address with
config.txt. It would be nice, if I can access to barebox (start.c)
main arguments, while the raspberry pi load barebox like a linux
kernel and give him the device-address on r2.

I'm not sure if the access to the arguments really wanted, so I do
that only with fixed address. In other case, I don't see how I could
access to this arguments.

The idea is to have a function like `oftree -l 0x100`. Extended maybe
a global variable with the memory address, passed from start.

Anyway it work also with config.txt:
device_tree_address=0x100

Greets
Pascal

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

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

* Re: Oftree from memory and access to start arguments
  2018-06-05 23:07 Oftree from memory and access to start arguments Pascal Vizeli
@ 2018-06-07  7:31 ` Sascha Hauer
  2018-06-07 23:03   ` Pascal Vizeli
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2018-06-07  7:31 UTC (permalink / raw)
  To: Pascal Vizeli; +Cc: barebox

Hi Pascal,

On Wed, Jun 06, 2018 at 01:07:27AM +0200, Pascal Vizeli wrote:
> Hi,
> 
> I'm working on a functionality to load a device tree with oftree from
> memory. The use case is like raspberry platform they have his own
> device tree for linux kernel. If I known the address (config.txt), I
> will load this from memory and read out the dynamic linux args and use
> other overlays for states with bootchoiser and boot the kernel
> correctly.
> 
> On raspberry, I can write the device-tree to a memory address with
> config.txt. It would be nice, if I can access to barebox (start.c)
> main arguments, while the raspberry pi load barebox like a linux
> kernel and give him the device-address on r2.

Starting barebox with the devicetree provided in r2 shouldn't be a
problem. See arch/arm/boards/raspberry-pi/lowlevel.c:

ENTRY_FUNCTION(start_raspberry_pi2, r0, r1, r2)
{
        void *fdt = __dtb_bcm2836_rpi_2_start + get_runtime_offset();

        arm_cpu_lowlevel_init();

        barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
}

Just call barebox_arm_entry() with 'r2' instead of 'fdt'.

You could also store the value of r2 in a known memory location
and load the devicetree later in some board specific initcall.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: Oftree from memory and access to start arguments
  2018-06-07  7:31 ` Sascha Hauer
@ 2018-06-07 23:03   ` Pascal Vizeli
  2018-06-11  6:31     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Vizeli @ 2018-06-07 23:03 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

I wrote a patch they do that what you have suggest. It write the dtb
from memory into a file.

My problem is, I don't know how I can share data between PBL and the
main process?
That are not the same binary, so I can't use extern keyword and on
this early boot step I don't know how I can access to memory.
I think with a simple pointer, I can't access to a memory area they
are not my own?

greets
Pascal

2018-06-07 9:31 GMT+02:00 Sascha Hauer <s.hauer@pengutronix.de>:
> Hi Pascal,
>
> On Wed, Jun 06, 2018 at 01:07:27AM +0200, Pascal Vizeli wrote:
>> Hi,
>>
>> I'm working on a functionality to load a device tree with oftree from
>> memory. The use case is like raspberry platform they have his own
>> device tree for linux kernel. If I known the address (config.txt), I
>> will load this from memory and read out the dynamic linux args and use
>> other overlays for states with bootchoiser and boot the kernel
>> correctly.
>>
>> On raspberry, I can write the device-tree to a memory address with
>> config.txt. It would be nice, if I can access to barebox (start.c)
>> main arguments, while the raspberry pi load barebox like a linux
>> kernel and give him the device-address on r2.
>
> Starting barebox with the devicetree provided in r2 shouldn't be a
> problem. See arch/arm/boards/raspberry-pi/lowlevel.c:
>
> ENTRY_FUNCTION(start_raspberry_pi2, r0, r1, r2)
> {
>         void *fdt = __dtb_bcm2836_rpi_2_start + get_runtime_offset();
>
>         arm_cpu_lowlevel_init();
>
>         barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
> }
>
> Just call barebox_arm_entry() with 'r2' instead of 'fdt'.
>
> You could also store the value of r2 in a known memory location
> and load the devicetree later in some board specific initcall.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: Oftree from memory and access to start arguments
  2018-06-07 23:03   ` Pascal Vizeli
@ 2018-06-11  6:31     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-06-11  6:31 UTC (permalink / raw)
  To: Pascal Vizeli; +Cc: barebox

On Fri, Jun 08, 2018 at 01:03:11AM +0200, Pascal Vizeli wrote:
> Hi Sascha,
> 
> I wrote a patch they do that what you have suggest. It write the dtb
> from memory into a file.
> 
> My problem is, I don't know how I can share data between PBL and the
> main process?
> That are not the same binary, so I can't use extern keyword and on
> this early boot step I don't know how I can access to memory.
> I think with a simple pointer, I can't access to a memory area they
> are not my own?

I have a patch in the queue that shall solve this problem, but I never
came to it to make it ready. So far I would recommend some internal SRAM
to store a pointer. Another possibility would be to pass some less
memory to barebox_arm_entry() and pick up the data there. (I would
recommend at least 4k of memory to steal)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

end of thread, other threads:[~2018-06-11  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 23:07 Oftree from memory and access to start arguments Pascal Vizeli
2018-06-07  7:31 ` Sascha Hauer
2018-06-07 23:03   ` Pascal Vizeli
2018-06-11  6:31     ` Sascha Hauer

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