OpenWrt Forum Archive

Topic: device.dts manuals?

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Does anyone know where I can find documents on how to write the device.dts files?

I see under target/linux/ramips/, there is no files/arch directory anymore, currently the dts is used for device definition. However, I failed to find any manuals on how to write it. sad

Your help to provide me the manual is much appreciated!

Below is mine in original mach-device.c file. However, I have no idea whether to map the rootfs and kernel partitions.
static struct mtd_partition hg255d_partitions[] = {

        {
                .name   = "u-boot",
                .offset = 0,
                .size   = SZ_128K,
        }, {
                .name   = "kernel",
                .offset = SZ_128K,
                .size   = SZ_1M,
        }, {
                .name   = "rootfs",
                .offset = SZ_1M + SZ_128K,
                .size   = FLASH_SIZE - (SZ_1M + SZ_128K * 2),
        }, {
                .name   = "firmware",
                .offset = SZ_128K,
                .size   = FLASH_SIZE - (SZ_128K * 2),
        }, {
                .name   = "factory",
                .offset = SZ_1M + (SZ_128K),
                .size   = SZ_128K,
        }, {
                .name   = "fullflash",
                .offset = 0x000000,
                .size   = FLASH_SIZE,
        }
};

(Last edited by wjding on 17 Aug 2013, 06:55)

plntyk helped to answer me on irc:
<plntyk> wjding: i think i saw some advice about dts aka DeviceTree at some linux-kernel arm page wiki
<plntyk> http://www.devicetree.org/Main_Page there for example and other stuff
<plntyk> that you find in google

Many thanks to plntyk!

Does DTS include partitioning? I'm not so sure about that. I thought it's for devices only, not MTD dev partitions.

It's also strange to me that some files include the partition information, while others not.

I have tried to add the partition information and it works well. However, do you know where does the partition information come if there's no such information in the DTS files?

Below is an example:
        cfi@1f000000 {
                compatible = "cfi-flash";
                reg = <0x1f000000 0x1000000>;

                bank-width = <2>;
                device-width = <2>;
                #address-cells = <1>;
                #size-cells = <1>;

                partition@0 {
                        label = "u-boot";
                        reg = <0x0 0x20000>;
                        read-only;
                };

                kernel: partition@20000 {
                        label = "kernel";
                        reg = <0x20000 0x100000>;
                        read-only;
                };
   
                rootfs: partition@120000 {
                        label = "rootfs";
                        reg = <0x120000 0xec0000>;
                };
   
                partition@fe0000 {
                        label = "factory";
                        reg = <0xfe0000 0x20000>;
                        read-only;
                };
        };

(Last edited by wjding on 19 Aug 2013, 16:03)

I think the information comes from the bootloader.
As I understand the devicetree dts file is some config file for the kernel - stating components etc. - so you can use the same kernel with different boards and you only switch your "config" file at boot.

zloop, do you mean the kenel parameters passed during boot by bootloader?
Or I don't think it has anything to do with bootloader. My bootloader was always the default one, but I can freely modify my partitions. Any ideas?

The discussion might have continued from here.