DTB compile error for stm32mp15x platform

Hello!

I'm trying to boot stm32mp15 based board. Source tree contains all dtsi/h for that platform although, DTB compilation fails with unresolved preprocessor macros (as I think):

sh:
# $SRCROOT/sys/tools/fdt/make_dtb.sh $SRCROOT/sys stm32mp157c-ev1.dts .
converting stm32mp157c-ev1.dts -> ./stm32mp157c-ev1.dtb
Error at <standard input>:1615:19: Expected numbers in array of cells
   pinmux = <(((((('F') - 'A') * 0x10 + (12))) << 8) | (0x11))>;
                   ^
Error at <standard input>:1615:19: Expected ; at end of property
   pinmux = <(((((('F') - 'A') * 0x10 + (12))) << 8) | (0x11))>;
                   ^
Failed to parse tree.
#

It seems to fail at this code in DTS:
sh:
stm32mp15-pinctrl.dtsi
11:            pinmux = <STM32_PINMUX('F', 12, ANALOG)>;

STM's macros look like this:

C:
/usr/src/sys/contrib/device-tree/include/dt-bindings/pinctrl/stm32-pinfunc.h
33:#define STM32_PINMUX(port, line, mode) (((PIN_NO(port, line)) << 8) | (mode))

and

C:
/usr/src/sys/contrib/device-tree/include/dt-bindings/pinctrl/stm32-pinfunc.h
31:#define PIN_NO(port, line)    (((port) - 'A') * 0x10 + (line))

So, it looks like preprocessor does not resolve C char literals further to perform ultimate arithmetics ...
Any clues?

Thanks
 
I compiled this with dtc and I get a different error.
cd /usr/src/sys/contrib/device-tree
dtc -@ -O dtb -I dts -i /sys/contrib/device-tree/include/ -o /test.dtb /usr/src/sys/contrib/device-tree/src/arm/stm32mp157c-ev1.dts

Code:
Error at /usr/src/sys/contrib/device-tree/src/arm/stm32mp157c-ev1.dts:40:17: Expected numbers in array of cells
            linux,code = <KEY_ENTER>;
                          ^
Error at /usr/src/sys/contrib/device-tree/src/arm/stm32mp157c-ev1.dts:40:17: Expected ; at end of property
            linux,code = <KEY_ENTER>;
                          ^
Error at /usr/src/sys/contrib/device-tree/src/arm/stm32mp157c-ev1.dts:40:17: Failed to find root node /.
            linux,code = <KEY_ENTER>;
                          ^
Failed to parse tree.

It does not like the FDT property of "linux,code="

And I think it boils down to this include:
/usr/src/sys/contrib/device-tree/include/dt-bindings/input/input.h
 
I compiled this with dtc and I get a different error.
If you look into $SRCROOT/sys/tools/fdt/make_dtb.sh, you'll find that the preprocessor must be run first, dtc doesn't do that automatically.:
Code:
% cpp -P -x assembler-with-cpp -I /sys/contrib/device-tree/include/dt-bindings/input -I /sys/contrib/device-tree/include /usr/src/sys/contrib/device-tree/src/arm/stm32mp157c-ev1.dts > temp.dts
Then you can run dtc:
Code:
% dtc -@ -O dtb -I dts -o test.dtb temp.dts
Error at temp.dts:1852:19: Expected numbers in array of cells
   pinmux = <(((((('F') - 'A') * 0x10 + (12))) << 8) | (0x11))>;
                   ^
Error at temp.dts:1852:19: Expected ; at end of property
   pinmux = <(((((('F') - 'A') * 0x10 + (12))) << 8) | (0x11))>;
                   ^
Failed to parse tree.
 
Okay, the problem is in dtc. By the way, this is not the first time I'm experiencing issues with dtc from the base OS.
Everything works as expected if sysutils/dtc is used. A few warnings are generated in my example above, but it compiles *.dtb without errors:
Code:
% /usr/local/bin/dtc -@ -O dtb -I dts -o test.dtb temp.dts
temp.dts:1409.42-1413.5: Warning (simple_bus_reg): /soc/stmmac-axi-config: missing or empty reg/ranges property
temp.dts:413.22-425.5: Warning (unique_unit_address): /soc/spi@4000b000: duplicate unit-address (also used in node /soc/audio-controller@4000b000)
temp.dts:438.22-450.5: Warning (unique_unit_address): /soc/spi@4000c000: duplicate unit-address (also used in node /soc/audio-controller@4000c000)
temp.dts:697.22-709.5: Warning (unique_unit_address): /soc/spi@44004000: duplicate unit-address (also used in node /soc/audio-controller@44004000)
  also defined at temp.dts:4522.7-4526.3
temp.dts:1469.9-1472.6: Warning (graph_child_address): /soc/display-controller@5a001000/port: graph node has single child node 'endpoint@0', #address-cells/#size-cells are not necessary
  also defined at temp.dts:4467.7-4472.4
As you can see in /usr/src/sys/tools/fdt/make_dtb.sh:
Code:
: "${DTC:=dtc}"
an env var DTC can be set to point to the dtc from ports.
 
Back
Top