[Letux-kernel] X1600 upstreaming efforts

Paul Boddie paul at boddie.org.uk
Mon Apr 21 00:25:00 CEST 2025


On Saturday, 19 April 2025 23:35:50 CEST H. Nikolaus Schaller wrote:
> 
> So to me it is still not clear what triggers the TypeError.
> 
> Or is one of the &node; references in the aliases list broken/invalid?
> But they all look ok. So we need another clever idea to understand this.

So, after finally upgrading my distribution, installing the appropriate Python 
libraries, and then messing around with the absurdly complicated way that one 
is supposed to "install" Python packages, even if one is going to be 
developing and effectively running them from their source directory, I had a 
closer look at this.

The problem appears to be the special way that the prop_value function treats 
the aliases node:

    if nodename in {'__fixups__', 'aliases'}:
        return data[:-1].decode(encoding='ascii').split('\0')

This obtains encoded data of the form '\x00\x00\x00\x1b' from the device tree, 
which it then turns into the strange list of four empty strings that we saw. 
But this data resembles an encoded 32-bit big-endian integer value of 27, 
which could plausibly be the phandle index.

So, I just changed the above to omit 'aliases' and the error disappeared:

    if nodename in {'__fixups__'}:
        return data[:-1].decode(encoding='ascii').split('\0')

Printing out the node dictionary for each node indeed indicated that the 
phandle started at 27 with aliases and then incremented from there.

I imagine that this problem is due to some kind of change in the way an 
underlying library, maybe libfdt, exposes tree data. Maybe aliases nodes 
didn't have a phandle but now they do, meaning that the uniform decoding done 
above cannot be done. Instead, the prop_value function should just be allowed 
to process the properties as normal.

Running the tool on the device tree produces lots of complaints! One of them 
will be about the phandle of the aliases node, presumably because the 
validator assumes that every property in an aliases node is an alias, despite 
the phandle sneaking in. So, the phandle needs to be removed from the 
node_dict in the code that was raising the TypeError:

    node_dict = node_props(validator, fdt, nodename, offset)
    if 'phandle' in node_dict:
        #print('phandle', node_dict['phandle'])
        phandles[node_dict['phandle']] = node_dict
        if nodename == 'aliases':
            del node_dict['phandle']

Many of the genuine complaints are fairly trivial: "ok" instead of "okay", 
"disable" instead of "disabled". There are some complaints about names, value 
representations, and the groups provided in the aic_pb node. Some of these 
complaints are not particularly easy to follow.

Anyway, let me know if these changes aren't understandable.

Paul




More information about the Letux-kernel mailing list