PowerPC/e500: how is FDT access supposed to work?

Daniel Wohllebe <daniel.wohllebe-5KK72Q/[email protected]> Mon, 01 Jul 2024 13:03:04 +0200
Newsgroups gmane.os.rtems.user
Message-ID <[email protected]>
--===============7968927200423761885==
Content-Type: multipart/alternative;
 boundary=----WCR89VTUQ2T2VZGK2H6IXNWQD8U5GR
Content-Transfer-Encoding: 7bit

------WCR89VTUQ2T2VZGK2H6IXNWQD8U5GR
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello everyone,


I am in need of some friendly advice=2E I am working on getting an applica=
tion running, which I compiled for PowerPC using the qoriq_e500 BSP (https:=
//docs=2Ertems=2Eorg/branches/master/user/bsps/bsps-powerpc=2Ehtml#qoriq-qo=
riq)=2E

Due to the current lack of a physical board, I want to have it run in QEMU=
 on the ppce500 machine (https://www=2Eqemu=2Eorg/docs/master/system/ppc/pp=
ce500=2Ehtml)=2E

I have RTEMS on head 25ba67963aa23dff4fbe87a2e0c56b8c011cdf8a and set ever=
ything up via the source builder at head 423d98d2058a7dac0921f9a13113b02469=
6236b9 (so my state is from early June)=2E

=20

I have created the application image und started it up inside QEMU via the=
 U-Boot bootloader=2E

However, my application runs into a fatal error (QORIQ_FATAL_FDT_NO_BUS_FR=
EQUENCY) early on, and then gets stuck trying to print (what I assume is) a=
n error message (see the following stack trace):

=20

```

(gdb) bt

#0  ns16550_polled_putchar (base=3D0x2001148 <qoriq_uart_context_0>, out=
=3D13 '\r')

    at =2E=2E/=2E=2E/=2E=2E/bsps/shared/dev/serial/ns16550-context=2Ec:535

#1  0x0004f1e0 in rtems_putc (c=3D10 '\n') at =2E=2E/=2E=2E/=2E=2E/cpukit/=
libcsupport/src/rtems_putc=2Ec:49

#2  0x0004d264 in _IO_Vprintf (put_char=3D0x4f1a8 <rtems_put_char>, arg=3D=
arg@entry=3D0x0, fmt=3D0x1004311 "%s\n",

    fmt@entry=3D0x1004310 "\n%s\n", ap=3Dap@entry=3D0x2389e80 <_ISR_Stack_=
area_begin+7872>) at =2E=2E/=2E=2E/=2E=2E/cpukit/dev/iovprintf=2Ec:133

#3  0x00044e44 in vprintk (fmt=3Dfmt@entry=3D0x1004310 "\n%s\n", ap=3Dap@e=
ntry=3D0x2389e80 <_ISR_Stack_area_begin+7872>)

    at =2E=2E/=2E=2E/=2E=2E/cpukit/libcsupport/src/vprintk=2Ec:45

#4  0x00040df4 in printk (fmt=3Dfmt@entry=3D0x1004310 "\n%s\n") at =2E=2E/=
=2E=2E/=2E=2E/cpukit/libcsupport/src/printk=2Ec:41

#5  0x0003d410 in bsp_fatal_extension (source=3DRTEMS_FATAL_SOURCE_BSP, al=
ways_set_to_false=3D<optimized out>, code=3D2561)

    at =2E=2E/=2E=2E/=2E=2E/bsps/shared/start/bspfatal-default=2Ec:66

#6  0x0004cc90 in _User_extensions_Iterate (arg=3Darg@entry=3D0x2389f48 <_=
ISR_Stack_area_begin+8072>,

    visitor=3D0x4cb88 <_User_extensions_Fatal_visitor>, direction=3Ddirect=
ion@entry=3DCHAIN_ITERATOR_FORWARD)

    at =2E=2E/=2E=2E/=2E=2E/cpukit/score/src/userextiterate=2Ec:194

#7  0x0004889c in _User_extensions_Fatal (error=3D2561, source=3DRTEMS_FAT=
AL_SOURCE_BSP)

    at =2E=2E/=2E=2E/=2E=2E/cpukit/include/rtems/score/userextimpl=2Eh:467

#8  _Terminate (the_source=3Dthe_source@entry=3DRTEMS_FATAL_SOURCE_BSP, th=
e_error=3Dthe_error@entry=3D2561)

    at =2E=2E/=2E=2E/=2E=2E/cpukit/score/src/interr=2Ec:55

#9  0x0003d0b8 in rtems_fatal (fatal_code=3D2561, fatal_source=3DRTEMS_FAT=
AL_SOURCE_BSP) at =2E=2E/=2E=2E/=2E=2E/cpukit/include/rtems/fatal=2Eh:160

#10 bsp_fatal (code=3DQORIQ_FATAL_FDT_NO_BUS_FREQUENCY) at =2E=2E/=2E=2E/=
=2E=2E/bsps/include/bsp/fatal=2Eh:222

#11 initialize_frequency_parameters () at =2E=2E/=2E=2E/=2E=2E/bsps/powerp=
c/qoriq/start/bspstart=2Ec:89

#12 bsp_start () at =2E=2E/=2E=2E/=2E=2E/bsps/powerpc/qoriq/start/bspstart=
=2Ec:178

#13 0x00047808 in rtems_initialize_executive () at =2E=2E/=2E=2E/=2E=2E/cp=
ukit/sapi/src/exinit=2Ec:135

#14 0x0003c68c in boot_card (cmdline=3D<optimized out>) at =2E=2E/=2E=2E/=
=2E=2E/bsps/shared/start/bootca

#15 0x0000412c in bsp_section_start_begin () at =2E=2E/=2E=2E/=2E=2E/bsps/=
powerpc/qoriq/start/start=2ES:

```

=20

I suspect that the flattened device tree is not being loaded correctly, wh=
ich also leads to the application not being able to push out characters to =
UART=2E

=20

Further investigation went as follows:

During initialize_frequency_parameters() in bsps/powerpc/qoriq/start/bspst=
art=2Ec (https://gitlab=2Ertems=2Eorg/rtems/rtos/rtems/-/blob/main/bsps/pow=
erpc/qoriq/start/bspstart=2Ec), the first call to fdt_node_offset_by_prop_v=
alue() returns the negative node integer -9, which, if I traced everything =
correctly, means I have run into the error FDT_ERR_BADMAGIC, telling me I d=
on't have a real device tree present at all=2E

I then went a step back and followed the flow of initialize_frequency_para=
meters() from the beginning, ending up in bsp_fdt_get() of bsps/shared/star=
t/bsp-fdt=2Ec (https://gitlab=2Ertems=2Eorg/rtems/rtos/rtems/-/blob/main/bs=
ps/shared/start/bsp-fdt=2Ec)=2E

At this point I found out that BSP_DTB_IS_SUPPORTED is not defined, as onl=
y the array bp_fdt_blob exists and is accessed=2E This array is filled with=
 the pre-initialized `0xdeadbeef` values and does not contain any meaningfu=
l data=2E

=20

My question is:

I fail to see the mechanism by which a real FDT should have been available=
 at this point=2E Is there a detail or some magic that I am missing here th=
at would make this work usually? I could not find any trace of any linker s=
cripts or any routines that are used to add content to the blob/array=2E


Kind Regards,

Daniel
------WCR89VTUQ2T2VZGK2H6IXNWQD8U5GR
Content-Type: text/html;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html><body><div dir=3D"auto">Hello everyone,<br><br><br>I a=
m in need of some friendly advice=2E I am working on getting an application=
 running, which I compiled for PowerPC using the qoriq_e500 BSP (<a href=3D=
"https://docs=2Ertems=2Eorg/branches/master/user/bsps/bsps-powerpc=2Ehtml#q=
oriq-qoriq">https://docs=2Ertems=2Eorg/branches/master/user/bsps/bsps-power=
pc=2Ehtml#qoriq-qoriq</a>)=2E<br><br>Due to the current lack of a physical =
board, I want to have it run in QEMU on the ppce500 machine (<a href=3D"htt=
ps://www=2Eqemu=2Eorg/docs/master/system/ppc/ppce500=2Ehtml">https://www=2E=
qemu=2Eorg/docs/master/system/ppc/ppce500=2Ehtml</a>)=2E<br><br>I have RTEM=
S on head 25ba67963aa23dff4fbe87a2e0c56b8c011cdf8a and set everything up vi=
a the source builder at head 423d98d2058a7dac0921f9a13113b024696236b9 (so m=
y state is from early June)=2E<br><br> <br><br>I have created the applicati=
on image und started it up inside QEMU via the U-Boot bootloader=2E<br><br>=
However, my application runs into a fatal error (QORIQ_FATAL_FDT_NO_BUS_FRE=
QUENCY) early on, and then gets stuck trying to print (what I assume is) an=
 error message (see the following stack trace):<br><br> <br><br>```<br><br>=
(gdb) bt<br><br>#0=C2=A0 ns16550_polled_putchar (base=3D0x2001148 &lt;qoriq=
_uart_context_0&gt;, out=3D13 '\r')<br><br>=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=
=2E/=2E=2E/bsps/shared/dev/serial/ns16550-context=2Ec:535<br><br>#1=C2=A0 0=
x0004f1e0 in rtems_putc (c=3D10 '\n') at =2E=2E/=2E=2E/=2E=2E/cpukit/libcsu=
pport/src/rtems_putc=2Ec:49<br><br>#2=C2=A0 0x0004d264 in _IO_Vprintf (put_=
char=3D0x4f1a8 &lt;rtems_put_char&gt;, arg=3Darg@entry=3D0x0, fmt=3D0x10043=
11 "%s\n",<br><br>=C2=A0=C2=A0=C2=A0 fmt@entry=3D0x1004310 "\n%s\n", ap=3Da=
p@entry=3D0x2389e80 &lt;_ISR_Stack_area_begin+7872&gt;) at =2E=2E/=2E=2E/=
=2E=2E/cpukit/dev/iovprintf=2Ec:133<br><br>#3=C2=A0 0x00044e44 in vprintk (=
fmt=3Dfmt@entry=3D0x1004310 "\n%s\n", ap=3Dap@entry=3D0x2389e80 &lt;_ISR_St=
ack_area_begin+7872&gt;)<br><br>=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=2E/=2E=2E/=
cpukit/libcsupport/src/vprintk=2Ec:45<br><br>#4=C2=A0 0x00040df4 in printk =
(fmt=3Dfmt@entry=3D0x1004310 "\n%s\n") at =2E=2E/=2E=2E/=2E=2E/cpukit/libcs=
upport/src/printk=2Ec:41<br><br>#5=C2=A0 0x0003d410 in bsp_fatal_extension =
(source=3DRTEMS_FATAL_SOURCE_BSP, always_set_to_false=3D&lt;optimized out&g=
t;, code=3D2561)<br><br>=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=2E/=2E=2E/bsps/sha=
red/start/bspfatal-default=2Ec:66<br><br>#6=C2=A0 0x0004cc90 in _User_exten=
sions_Iterate (arg=3Darg@entry=3D0x2389f48 &lt;_ISR_Stack_area_begin+8072&g=
t;,<br><br>=C2=A0=C2=A0=C2=A0 visitor=3D0x4cb88 &lt;_User_extensions_Fatal_=
visitor&gt;, direction=3Ddirection@entry=3DCHAIN_ITERATOR_FORWARD)<br><br>=
=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=2E/=2E=2E/cpukit/score/src/userextiterate=
=2Ec:194<br><br>#7=C2=A0 0x0004889c in _User_extensions_Fatal (error=3D2561=
, source=3DRTEMS_FATAL_SOURCE_BSP)<br><br>=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=
=2E/=2E=2E/cpukit/include/rtems/score/userextimpl=2Eh:467<br><br>#8=C2=A0 _=
Terminate (the_source=3Dthe_source@entry=3DRTEMS_FATAL_SOURCE_BSP, the_erro=
r=3Dthe_error@entry=3D2561)<br><br>=C2=A0=C2=A0=C2=A0 at =2E=2E/=2E=2E/=2E=
=2E/cpukit/score/src/interr=2Ec:55<br><br>#9=C2=A0 0x0003d0b8 in rtems_fata=
l (fatal_code=3D2561, fatal_source=3DRTEMS_FATAL_SOURCE_BSP) at =2E=2E/=2E=
=2E/=2E=2E/cpukit/include/rtems/fatal=2Eh:160<br><br>#10 bsp_fatal (code=3D=
QORIQ_FATAL_FDT_NO_BUS_FREQUENCY) at =2E=2E/=2E=2E/=2E=2E/bsps/include/bsp/=
fatal=2Eh:222<br><br>#11 initialize_frequency_parameters () at =2E=2E/=2E=
=2E/=2E=2E/bsps/powerpc/qoriq/start/bspstart=2Ec:89<br><br>#12 bsp_start ()=
 at =2E=2E/=2E=2E/=2E=2E/bsps/powerpc/qoriq/start/bspstart=2Ec:178<br><br>#=
13 0x00047808 in rtems_initialize_executive () at =2E=2E/=2E=2E/=2E=2E/cpuk=
it/sapi/src/exinit=2Ec:135<br><br>#14 0x0003c68c in boot_card (cmdline=3D&l=
t;optimized out&gt;) at =2E=2E/=2E=2E/=2E=2E/bsps/shared/start/bootca<br><b=
r>#15 0x0000412c in bsp_section_start_begin () at =2E=2E/=2E=2E/=2E=2E/bsps=
/powerpc/qoriq/start/start=2ES:<br><br>```<br><br> <br><br>I suspect that t=
he flattened device tree is not being loaded correctly, which also leads to=
 the application not being able to push out characters to UART=2E<br><br> <=
br><br>Further investigation went as follows:<br><br>During initialize_freq=
uency_parameters() in bsps/powerpc/qoriq/start/bspstart=2Ec (<a href=3D"htt=
ps://gitlab=2Ertems=2Eorg/rtems/rtos/rtems/-/blob/main/bsps/powerpc/qoriq/s=
tart/bspstart=2Ec),">https://gitlab=2Ertems=2Eorg/rtems/rtos/rtems/-/blob/m=
ain/bsps/powerpc/qoriq/start/bspstart=2Ec),</a>=C2=A0the first call to fdt_=
node_offset_by_prop_value() returns the negative node integer -9, which, if=
 I traced everything correctly, means I have run into the error FDT_ERR_BAD=
MAGIC, telling me I don't have a real device tree present at all=2E<br><br>=
I then went a step back and followed the flow of initialize_frequency_param=
eters() from the beginning, ending up in bsp_fdt_get() of bsps/shared/start=
/bsp-fdt=2Ec (<a href=3D"https://gitlab=2Ertems=2Eorg/rtems/rtos/rtems/-/bl=
ob/main/bsps/shared/start/bsp-fdt=2Ec">https://gitlab=2Ertems=2Eorg/rtems/r=
tos/rtems/-/blob/main/bsps/shared/start/bsp-fdt=2Ec</a>)=2E<br><br>At this =
point I found out that BSP_DTB_IS_SUPPORTED is not defined, as only the arr=
ay bp_fdt_blob exists and is accessed=2E This array is filled with the pre-=
initialized `0xdeadbeef` values and does not contain any meaningful data=2E=
<br><br> <br><br>My question is:<br><br>I fail to see the mechanism by whic=
h a real FDT should have been available at this point=2E Is there a detail =
or some magic that I am missing here that would make this work usually? I c=
ould not find any trace of any linker scripts or any routines that are used=
 to add content to the blob/array=2E<br><br><br>Kind Regards,<br><br>Daniel=
</div></body></html>
------WCR89VTUQ2T2VZGK2H6IXNWQD8U5GR--

--===============7968927200423761885==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
users mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/users
--===============7968927200423761885==--