u-boot-brain/tools/dtoc/dtoc.py
Tom Rini 83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00

76 lines
2.3 KiB
Python
Executable File

#!/usr/bin/env python2
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2016 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
"""Device tree to C tool
This tool converts a device tree binary file (.dtb) into two C files. The
indent is to allow a C program to access data from the device tree without
having to link against libfdt. By putting the data from the device tree into
C structures, normal C code can be used. This helps to reduce the size of the
compiled program.
Dtoc produces two output files:
dt-structs.h - contains struct definitions
dt-platdata.c - contains data from the device tree using the struct
definitions, as well as U-Boot driver definitions.
This tool is used in U-Boot to provide device tree data to SPL without
increasing the code size of SPL. This supports the CONFIG_SPL_OF_PLATDATA
options. For more information about the use of this options and tool please
see doc/driver-model/of-plat.txt
"""
from optparse import OptionParser
import os
import sys
import unittest
# Bring in the patman libraries
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(our_path, '../patman'))
import dtb_platdata
def run_tests():
"""Run all the test we have for dtoc"""
import test_dtoc
result = unittest.TestResult()
sys.argv = [sys.argv[0]]
for module in (test_dtoc.TestDtoc,):
suite = unittest.TestLoader().loadTestsFromTestCase(module)
suite.run(result)
print result
for _, err in result.errors:
print err
for _, err in result.failures:
print err
if __name__ != '__main__':
sys.exit(1)
parser = OptionParser()
parser.add_option('-d', '--dtb-file', action='store',
help='Specify the .dtb input file')
parser.add_option('--include-disabled', action='store_true',
help='Include disabled nodes')
parser.add_option('-o', '--output', action='store', default='-',
help='Select output filename')
parser.add_option('-t', '--test', action='store_true', dest='test',
default=False, help='run tests')
(options, args) = parser.parse_args()
# Run our meagre tests
if options.test:
run_tests()
else:
dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
options.output)