Changes between Initial Version and Version 1 of FlattenedDeviceTree


Ignore:
Timestamp:
Apr 14, 2010, 11:43:18 AM (15 years ago)
Author:
Nicolas Pouillon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FlattenedDeviceTree

    v1 v1  
     1DSX has some support for flattened device trees.
     2
     3DSX can convert:
     4 * a given flattened device tree to a soclib caba platform,
     5 * a given soclib caba platform to a flattened device tree.
     6
     7As all the needed data is '''not''' present in the components metadata,
     8these conversions involve custom translator code. Therefore, support
     9for translation is limited to known modules, i.e. modules having an
     10associated ''handler''.
     11
     12= From a platform to a device tree =
     13
     14For a given platform, we may extract the corresponding device tree
     15as seen for a given mapping table (a device tree can represent only one
     16address-space):
     17
     18Import converter and built-in handlers:
     19{{{
     20from dsx.contrib.dts_platform.platform_to_dts import PlatformToDts
     21import dsx.contrib.dts_platform.platform_handlers
     22}}}
     23
     24Convert the platform, for a given mapping table:
     25{{{
     26dtsgen = PlatformToDts(arch, mapping_table)
     27}}}
     28
     29Then we can retrieve the device tree
     30{{{
     31device_tree = dtsgen.create_device_tree()
     32}}}
     33
     34This device tree itself can be serialized to different formats. There
     35are drivers for this task
     36
     37== Device tree serialization as ascii source (`dts`) ==
     38
     39Import the driver
     40{{{
     41from dsx.device_tree.dts import Driver
     42}}}
     43
     44Call it for the device tree:
     45{{{
     46driver = Driver(
     47            outdir = '.',
     48            parent = None,
     49            output_file = "my_platform.dts",
     50            )
     51
     52device_tree.generate(driver)
     53}}}
     54
     55== Device tree serialization as device tree blob (`dtb`) ==
     56
     57Import the driver
     58{{{
     59from dsx.device_tree.dtb import Driver
     60}}}
     61
     62Call it for the device tree:
     63{{{
     64driver = Driver(
     65            outdir = '.',
     66            parent = None,
     67            output_file = "my_platform.dtb",
     68            )
     69
     70device_tree.generate(driver)
     71}}}
     72
     73= From a device tree to a platform =
     74
     75Likewise, you may convert a device tree source or blob to a platform.
     76
     77The architecture generated will be flat around a VGMN.
     78
     79== Programmatically ==
     80
     81import modules
     82{{{
     83from dsx.contrib.dts_platform.dts_to_platform import DtsToPlatform
     84import dsx.contrib.dts_platform.handlers
     85from soclib.platform import PfDriver
     86}}}
     87
     88Parse a dts and retrieve corresponding platform
     89{{{
     90pgen = DtsToPlatform("test_3.dts", binary = 'kernel-soclib-mips.out')
     91pf = pgen.create_caba_platform()
     92}}}
     93
     94Generate the simulator, as usual:
     95{{{
     96pf.generate(PfDriver("hard"))
     97}}}
     98
     99== With a command-line one-liner ==
     100
     101This tool can even create a netlist with GDB or memchecker-enabled platforms
     102
     103{{{
     104 $ python -m dsx.contrib.dts_platform.converter -h
     105Usage: converter.py [-o output_dir] [-b binary] file.dts
     106
     107Options:
     108  -h, --help     show this help message and exit
     109  -o OUTPUT_DIR  Output directory
     110  -b BINARY      Binary kernel to load
     111  --gdb          Whether to use GDB server
     112  --memchecker   Whether to use Memchecker
     113}}}
     114
     115For instance:
     116{{{
     117 $ python -m dsx.contrib.dts_platform.converter -o platform -b kernel.out --gdb my_platform.dts
     118}}}