mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* handoff data
@ 2025-07-22 11:08 Renaud Barbier
  2025-07-22 12:16 ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Renaud Barbier @ 2025-07-22 11:08 UTC (permalink / raw)
  To: Barebox List

On our LS1046A based board (v2022.03) we used to pass the results of memory tests in the PBL  through the OCRAM to the barebox load.
I see there is handoff data support.

In my board lowlevel.c code, I have added the call:

handoff_add_arm_machine(0x12345678);


And then try to read it back from device_initcall:

 machine = handoff_data_get_entry(HANDOFF_DATA_ARM_MACHINE, &hsize);
printf("machine = %ld, %p\n", hsize, machine);

However, both the machine pointer and size are set to 0.

Am I missing something in the process?

Cheers,
Renaud
 


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

* Re: handoff data
  2025-07-22 11:08 handoff data Renaud Barbier
@ 2025-07-22 12:16 ` Ahmad Fatoum
  2025-07-22 15:46   ` Renaud Barbier
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2025-07-22 12:16 UTC (permalink / raw)
  To: Renaud Barbier, Barebox List

Hello Renaud,

On 7/22/25 13:08, Renaud Barbier wrote:
> On our LS1046A based board (v2022.03) we used to pass the results of memory tests in the PBL  through the OCRAM to the barebox load.
> I see there is handoff data support.
> 
> In my board lowlevel.c code, I have added the call:
> 
> handoff_add_arm_machine(0x12345678);

You should define a new handoff type for your custom info, e.g.:

#define HANDOFF_DATA_MEMTEST   HANDOFF_DATA_BOARD(0)

instead of overloading the (legacy) ARM machine id for something else.

> And then try to read it back from device_initcall:
> 
>  machine = handoff_data_get_entry(HANDOFF_DATA_ARM_MACHINE, &hsize);
> printf("machine = %ld, %p\n", hsize, machine);
> 
> However, both the machine pointer and size are set to 0.
> 
> Am I missing something in the process?

Handoff data is used for DT as well, so if you get to a functional
barebox, handoff is working...

As a sanity check, what happens if you move your handoff_add_arm_machine
behind handoff_data_add_dt() in barebox_pbl_start?

If that works, but your handoff_add_arm_machine in lowlevel.c doesn't,
can you share your code?

Cheers,
Ahmad

> 
> Cheers,
> Renaud
>  
> 

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




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

* RE: handoff data
  2025-07-22 12:16 ` Ahmad Fatoum
@ 2025-07-22 15:46   ` Renaud Barbier
  2025-07-22 16:05     ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Renaud Barbier @ 2025-07-22 15:46 UTC (permalink / raw)
  To: Ahmad Fatoum, Barebox List


> 
> Hello Renaud,
> 
> On 7/22/25 13:08, Renaud Barbier wrote:
> > On our LS1046A based board (v2022.03) we used to pass the results of
> memory tests in the PBL  through the OCRAM to the barebox load.
> > I see there is handoff data support.
> >
> > In my board lowlevel.c code, I have added the call:
> >
> > handoff_add_arm_machine(0x12345678);
> 
> You should define a new handoff type for your custom info, e.g.:
> 
> #define HANDOFF_DATA_MEMTEST   HANDOFF_DATA_BOARD(0)
> 
> instead of overloading the (legacy) ARM machine id for something else.
> 
> > And then try to read it back from device_initcall:
> >
> >  machine = handoff_data_get_entry(HANDOFF_DATA_ARM_MACHINE,
> &hsize);
> > printf("machine = %ld, %p\n", hsize, machine);
> >
> > However, both the machine pointer and size are set to 0.
> >
> > Am I missing something in the process?
> 
> Handoff data is used for DT as well, so if you get to a functional barebox,
> handoff is working...
> 
> As a sanity check, what happens if you move your handoff_add_arm_machine
> behind handoff_data_add_dt() in barebox_pbl_start?
Doing so I can now get the machine value back 0x12345678
machine = 4, 00000000fbf031a0, 0x12345678

> 
> If that works, but your handoff_add_arm_machine in lowlevel.c doesn't, can
> you share your code?

So in my lowlevel code:
static noinline __noreturn void owc_swex50s_r_entry(unsigned long memsize)
{
          Uint32_t baudrate;
...
          /* Data goes to OCRAM. In this example we pass the baudrate*/
          puts("ADD BOARD DATA\n");
          handoff_data_add(HANDOFF_BAUDRATE, &baudrate, sizeof(uint32_t));

          /* Only use 2G */
          if (IS_ENABLED(CONFIG_MACH_OWCSWE550S))
                  memsize = memsize >> 1;
          ls1046a_xload_start_image(&dram_info);

          pr_err("Booting failed\n");

          while (1);
  }

  void owc_swex50s_entry(unsigned long r0, unsigned long r1, unsigned long r2);

  __noreturn void owc_swex50s_entry(unsigned long r0, unsigned long r1, unsigned long r2)
  {
          relocate_to_current_adr();
          setup_c();

          owc_swex50s_r_entry(r0);
  }

I get the following debug output:
ADD BOARD DATA
handoff_data_add_entry hd = 0x00000000100143e8  ==> My data added from lowlevel.c to the OCRAM

Then, from barebox_pbl_start:
~         if (boarddata) {
+                 puts("ADD DT\n");
                  handoff_data_add_dt(boarddata);
+                 puts("ADD MACHINE\n");
+                 handoff_add_arm_machine(0x12345678);
+         }

ADD DT
handoff_data_add_entry hd = 0x00000000800143e8 ====> DT added to DDR  memory
ADD MACHINE
handoff_data_add_entry hd = 0x00000000800143e8 ====> Machine  added to DDR memory
uncompress.c: uncompressing barebox binary at 0x0000000080015370 (size 0x000853fc) to 0xfbd00000 (uncompressed size: 0x000fc5c8)
 handoff_data_move hd = 0x00000000800143e8, dest = 0x00000000fbefc5c8 =====> Handoff data moved to new location
 handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x28061971

Board: owc-swe550s
RENAUD: handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x28061971
...
handoff 0x28061971 at 0x00000000fbefc600 (size 27560)
handoff 0x28061974 at 0x00000000fbf031d0 (size 4)

From device_initcall:
 handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x951726fb
 baudrate = 0, 0000000000000000 =====> 			Obviously, no copied from OCRAM
 handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x28061974
 machine = 4, 00000000fbf031d0, 0x12345678 ==> MACHINE data is correct

So, there is a need to copy the data from OCRAM to when the memory is available.

> 
> Cheers,
> Ahmad
> 
> >
> > Cheers,
> > Renaud
> >
> >
> 
> --
> Pengutronix e.K.                  |                             |
> Steuerwalder Str. 21              |
> https://urldefense.com/v3/__http://www.pengutronix.de/__;!!HKOSU0g!HR
> UHvAKHu8BujxVw_027NrNyWR1gCzuOAqRxHitCLcKK7_3GAlFYC1T3Ybcg07
> WVj9r_PsvGrn9utecIX6xw5yiaxC4$   |
> 31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |


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

* Re: handoff data
  2025-07-22 15:46   ` Renaud Barbier
@ 2025-07-22 16:05     ` Ahmad Fatoum
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-07-22 16:05 UTC (permalink / raw)
  To: Renaud Barbier, Barebox List

Hi,

On 7/22/25 17:46, Renaud Barbier wrote:
> Board: owc-swe550s
> RENAUD: handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x28061971
> ...
> handoff 0x28061971 at 0x00000000fbefc600 (size 27560)
> handoff 0x28061974 at 0x00000000fbf031d0 (size 4)
> 
> From device_initcall:
>  handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x951726fb
>  baudrate = 0, 0000000000000000 =====> 			Obviously, no copied from OCRAM
>  handoff_data_get_entry hd = 0x00000000fbefc5c8, cookie = 0x28061974
>  machine = 4, 00000000fbf031d0, 0x12345678 ==> MACHINE data is correct
> 
> So, there is a need to copy the data from OCRAM to when the memory is available.

Yes. You can see how it's done for i.MX8M by grepping for
handoff_data_move().

What we do there is passing handoff_data_move() an address in DRAM and
then we memcpy the active PBL at the start of the chainloaded image.

The active PBL has set the handoff data base pointer in the data section
and thus it just works.

Cheers,
Ahmad

> 
>>
>> Cheers,
>> Ahmad
>>
>>>
>>> Cheers,
>>> Renaud
>>>
>>>
>>
>> --
>> Pengutronix e.K.                  |                             |
>> Steuerwalder Str. 21              |
>> https://urldefense.com/v3/__http://www.pengutronix.de/__;!!HKOSU0g!HR
>> UHvAKHu8BujxVw_027NrNyWR1gCzuOAqRxHitCLcKK7_3GAlFYC1T3Ybcg07
>> WVj9r_PsvGrn9utecIX6xw5yiaxC4$   |
>> 31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
>> Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |
> 

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




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

end of thread, other threads:[~2025-07-22 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-22 11:08 handoff data Renaud Barbier
2025-07-22 12:16 ` Ahmad Fatoum
2025-07-22 15:46   ` Renaud Barbier
2025-07-22 16:05     ` Ahmad Fatoum

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