davidchisnall / dtc

FreeBSD Device Tree Compiler
19 stars 15 forks source link

STM32MP1xxxx DTS fail to compile #81

Closed ssilnicki-dev closed 1 year ago

ssilnicki-dev commented 1 year ago

It appears, that STM uses char literals in their DTS to resolve GPIO id:

https://github.com/freebsd/freebsd-src/blob/a69b6af2024fdd501b4bbc674092fb2b6d466364/sys/contrib/device-tree/src/arm/stm32mp15-pinctrl.dtsi#L11

When compiling corresponding DTB under FBSD source tree, dtc fails with the following errors:

root@fbsd:/usr/src # make builddtb FDT_DTS_FILE=stm32mp157c-ev1.dts
converting stm32mp157c-ev1.dts -> /root/world/usr/src/arm.armv7/sys/STM32MP1//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.
*** Error code 1

Stop.
make[1]: stopped in /usr/src
*** Error code 1

Stop.
make: stopped in /usr/src
ssilnicki-dev commented 1 year ago

this fix works for me:

expression_ptr text_input_buffer::parse_expression(bool stopAtParen)
{
    next_token();
    unsigned long long leftVal;
    expression_ptr lhs;
    source_location l = location();
    switch (*(*this))
    {
        case '\'':
            consume('\'');
            if(!consume_char_literal(leftVal))
            {
                return nullptr;
            }
            lhs.reset(new terminal_expr(l, leftVal));
            skip_to('\'');
            if (!consume('\''))
            {
                return nullptr;
            }
            break;
        case '0'...'9':
            if (!consume_integer(leftVal))
            {
                return nullptr;
            }
            lhs.reset(new terminal_expr(l, leftVal));
            break;

is it a reasonable approach?

davidchisnall commented 1 year ago

Looks good to me.

ssilnicki-dev commented 1 year ago

may I issue a PR?

jlduran commented 1 year ago

may I issue a PR?

Yes please.