summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2021-03-27dtoc: Tweak ordering of fdt-offsets refreshingSimon Glass1-3/+4
Once the tree has been synced, thus potentially moving things around in the fdt, we set _cached_offsets to False so that a refresh will happen next time a property is accessed. This 'lazy' refresh doesn't really save much time, since refresh is a very fast operation, just a single walk of the tree. Also, having the refresh happen in the bowels of property access it makes it harder to figure out what is going on. Simplify the code by always doing a refresh before and after a sync. Set _cached_offsets to True immediately after this, in the Refresh() function, since this makes more sense than doing it in the caller. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Tidy up property-offset handlingSimon Glass1-3/+7
If a property does not yet have an offset, then that means it exists in the cache'd fdt but has not yet been synced back to the flat tree. Use the dirty flag for this so we don't need to check the offset too. Improve the comments for Prop and Node to make it clear what an offset of None means. Also clear the dirty flag after the property is synced. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Improve internal error for Refresh()Simon Glass2-3/+3
Add the node name too so it is easy to see which node failed. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27binman: Support default alignment for sectionsSimon Glass8-0/+58
Sometimes it is useful to specify the default alignment for all entries in a section, such as when word-alignment is necessary, for example. It is tedious and error-prone to specify this individually for each section. Add a property to control this for a section. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27binman: Support obtaining section contents immediatelySimon Glass6-19/+95
Generally the content of sections is not built until the final assembly of the image. This is partly to avoid wasting time, since the entries within sections may change multiple times as binman works through its various stages. This works quite well since sections exist in a strict hierarchy, so they can be processed in a depth-first manner. However the 'collection' entry type does not have this luxury. If it contains a section within its 'content' list, then it must produce the section contents, if available. That section is typically a sibling node, i.e. not part oc the collection's hierarchy. Add a new 'required' argument to section.GetData() to support this. When required is True, any referenced sections are immediately built. If this is not possible (because one of the subentries does not have its data yet) then an error is produced. The test for this uses a 'collection' entry type, referencing a section as its first member. This forces a call to _BuildSectionData() with required set to False, at first, then True later, when the image is assembled. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27binman: Add support for a collection of entriesSimon Glass6-14/+128
The vblock entry type includes code to collect the data from a number of other entries (not necessarily subentries) and concatenating it. This is a useful feature for other entry types. Make it a base class, so that vblock can use it, along with other entry types. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27binman: Allow disabling expanding an entrySimon Glass8-9/+56
At present there is a command-line flag to disable substitution of expanded entries. Add an option to the entry node as well, so it can be controlled at the node level. Add a test to cover this. Fix up the comment to the checkSymbols() function it uses, while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27binman: Use a unique number for the symbols test fileSimon Glass2-1/+1
Two test devicetree files currently have 192 as their unique number. Fix this by separating them out. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Update various pieces of the documentationSimon Glass1-39/+44
A few sections are a little out of date now. Update them. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Drop repetitive heading for each entrySimon Glass20-57/+57
Many entries start 'Entry containing a'. This looks fine in the source code but is annoying when viewed in the htmldocs table of contents. Drop these unnecessary words. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Incorporate entry documentationSimon Glass10-77/+87
Update this to avoid sphinx warnings and incorporate it into the new documentaiton tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Rearrange documentation into headingsSimon Glass1-257/+266
Collect the material into different top-level headings to make it easier to read. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: doc: Add documentation to htmldocsSimon Glass6-245/+257
Add a link to binman's documentation and adjust the files so that it is accessible. Use the name README.rst so it is easy to discover when binman is installed without U-Boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Automatically expand phase binaries into sectionsSimon Glass16-18/+571
When creating an entry, check for an expanded version of that entry, then use it instead. This allows, for example use of: u-boot { }; instead of having to write out in full: u-boot { type = "section"; u-boot-nodtb { }; u-boot-dtb { }; }; Add an implementaion of this and associated documentation. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Plumb expanded entries through fullySimon Glass3-8/+36
Add support for this feature in the control, image and section modules, so that expanded entries will be selected by default. So far there are no expanded entry types, so this is a nop. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Allow a way to select expanded entriesSimon Glass2-6/+16
Add a new command-line option to disable expanded entries. This is needed for most tests, since it is much easier to 'factor out' this function into a separate test and keep the existing packing tests simple. Add the option and select it by default from tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Allow using an an 'expanded' entry typeSimon Glass2-9/+63
As the first step in supporting expanded entries, add a way for binman to automatically select an 'expanded' version of an entry type, if requested. This is controlled by a class method. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Use standard filenames for SPL/TPL devicetreeSimon Glass2-13/+16
At present, before any entry expansion is done (such as a 'files' entry expanding out to individual entries for each file it contains), we check the binman definition (i.e. '/binman' node) to find out what devicetree files are used in the images. This is a pain, since the definition may change during expansion. For example if there is no u-boot-spl-dtb entry in the definition at the start, we assume that the SPL devicetree is not used. But if an entry later expands to include this, then we don't notice. In fact the flexibility provided by the current approach of checking the definition is not really useful. We know that we can have SPL and TPL devicetrees. We know the pathname to each, so we can simply check if the files are present. If they are present, we can prepare them and update them regardless of whether they are actually used. If they are not present, we cannot prepare/update them anyway, i.e. an error will be generated. Simplify state.Prepare() so it uses a hard-coded list of devicetree files. Note that state.PrepareFromLoadedData() is left untouched, since in that case we have a complete definition from the loaded file, but cannot of course rely on the devicetree files that created it still being present. So in that case we still check the image defitions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Move the comment for GetFdts() to the base classSimon Glass2-10/+1
Like with other methods this comment should be in the base class. Move it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Drop unnecessary field in output_fdt_infoSimon Glass1-12/+10
At present we store an entry as the third field in output_fdt_info[]. This is only used to get the type of the entry. Of course multiple entries may have this same type. Also the entry type is the key to this dict, so we can use that instead. Drop the field and update GetUpdateNodes() to suit. Improve the comment for output_fdt_info a little while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Use the fake SPL/TPL only if requestedSimon Glass1-8/+15
At present we always use the main devicetree for SPL/TPL as well when setting up the state. But this it not needed if there is a real devicetree for SPL or TPL. In fact it confuses things since we cannot distinguish between one being provided and using the fake one. Update the code to create the fakes only when requested. Put the mapping in a constant so we can use it elsewhere. Rename 'other_fname' to 'fname' while we are here since there is nothing 'other' about it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Drop unnecessary 'type' property in testsSimon Glass2-2/+0
A few tests declare a type when this can be inferred from the node name. Drop these lines, since it might cause confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Add support for u-boot-tpl-bss-badSimon Glass4-0/+101
This entry holds the padding between the end of of TPL binary and the end of BSS. This region must be left empty so that the devicetree can be appended correctly and remain accessible without interfering with BSS. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Add support for u-boot-tpl-nodtbSimon Glass4-0/+83
Allow this entry type to be placed in an image. This is the TPL binary, without a devicetree appended. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Support symbols in u-boot-spl-nodtbSimon Glass6-21/+81
Since this is an execuable we should be able insert symbol values into it. Add support for this. Use common code for this test and the original testSymbols. Use hex consistently for the values and add some more comments. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Correct the documentation for u-boot-spl-bss-padSimon Glass2-14/+20
The documentation for this entry indicates that the SPL binary is included along with the padding. It is not, so update it to correct the error. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Tidy up underscores in entry documentationSimon Glass7-24/+22
Several entries currently use an underscore in the entry-type name, but in fact a hyphen is used. Update the docs to fix this as it might be confusing. Also simplify the 'filename' comment and fix the 'operation' typo. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Update entry help for files-alignSimon Glass1-0/+1
Regenerate the entry documentation, which step was missed when the files-align feature was added. Fixes: 6eb9932668f ("binman: Support alignment of files") Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Document ExpandEntries() in the base classSimon Glass2-6/+11
Move the documentation to the base method as it is with other methods. Also update it a little while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Allow extracting to current directorySimon Glass1-1/+1
Extracting files to the current directory is not normally a very friendly thing to do, but it can be warranted, e.g. in a new temporary dir. At present binman reports an error when such an attempt is made. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26dtoc: Only generate the required filesSimon Glass2-5/+20
At present all possible files are generated, even if some of them just have a header and an empty body. It is better to generate only the files that are needed, so that the two types of build (based on the setting of OF_PLATDATA_INST) can be mutually exclusive. This is intended to fix a strange problem sometimes found with CI: Building current source for 1 boards (1 thread, 40 jobs per thread) sandbox: + sandbox_spl +drivers/built-in.o: In function `dm_setup_inst': +drivers/core/root.c:135: undefined reference to `_u_boot_list_2_udevice_2_root' +dts/dt-uclass.o:(.u_boot_list_2_uclass_2_serial+0x10): undefined reference to `_u_boot_list_2_udevice_2_serial' ... This likely happens when switching from !OF_PLATDATA_INST to OF_PLATDATA_INST since running 'make xxx_defconfig" does not currently cause any change in which files are generated. With !OF_PLATDATA_INST the dt-device.c file has no declarations and this is assumed to be the starting state. The error above seems to indicate that, after changing to OF_PLATDATA_INST, the dt-uclass.c file is regenerated but the dt-device.c files is not. This does not seem possible from the relevant Makefile.spl rule: u-boot-spl-platdata := $(obj)/dts/dt-plat.o $(obj)/dts/dt-uclass.o $(obj)/dts/dt-device.o cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all include/generated/dt-structs-gen.h $(u-boot-spl-platdata_c) &: \ $(obj)/$(SPL_BIN).dtb @[ -d $(obj)/dts ] || mkdir -p $(obj)/dts $(call if_changed,dtoc) It seems that this cannot regenerate dt-uclass.c without dt-device.c since 'dtoc all' is used. So here the trail ends for now. In any case it seems better to generate files that are uses and not bother with those that serve no purpose. So update dtoc to do this automatically. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Drop use of DECL() macrosSimon Glass2-36/+36
We can use extern instead, so let's drop these macros. It adds one more thing to learn about and doesn't make the code any clearer. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Generate device instancesSimon Glass2-15/+480
Add support for generating a file containing udevice instances. This avoids the need to create these at run time. Update a test uclass to include a 'per_device_plat_auto' member, to increase test coverage. Add another tab to the driver_info output so it lines up nicely like the device-instance output. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Generate uclass devicesSimon Glass2-13/+244
Add support for generating a file containing uclass instances. This avoids the need to create these at run time. Update a test uclass to include a 'priv_auto' member, to increase test coverage. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Generate a summary in the dt-plat.c fileSimon Glass2-35/+169
Add a summary to the top of the generated code, to make it easier to see what the file contains. Also add a tab to .plat so that its value lines up with the others. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Tidy up the list of supported phandle propertiesSimon Glass1-7/+21
For now dtoc only supports a hard-coded list of phandle properties, to avoid any situation where it makes a mistake in its determination. Make this into a constant dict, recording both the phandle property name and the associated #cells property in the target node. This makes it easier to find and modify. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Don't generate platform data with instantiationSimon Glass2-13/+75
This file is not used when instantiating devices. Update dtoc to skip generating its contents and just add a comment instead. Also it is useful to see the driver name and parent for each device. Update the file to show that information, to avoid updating the same tests twice. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Add support for decl fileSimon Glass2-7/+120
Add an option to generate the declaration file, which declares all drivers and uclasses, so references can be used in the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Add an option for device instantiationSimon Glass3-22/+36
Add an option to instantiate devices at build time. For now this just parses the option and sets up a few parameters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Support processing the root nodeSimon Glass4-20/+59
The device for the root node is normally bound by driver model on init. With devices being instantiated at build time, we must handle the root device also. Add support for processing the root node, which may not have a compatible string. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Set up the uclasses that are usedSimon Glass4-18/+119
We only care about uclasses that are actually used. This is determined by the drivers that use them. Check all the used drivers and build a list of 'valid' uclasses. Also add references to the uclasses so we can generate C code that uses them. Attach a uclass to each valid driver. For the tests, now that we have uclasses we must create an explicit test for the case where a node does not have one. This should only happen if the source code does not build, or the source-code scanning fails to find it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Assign a sequence number to each nodeSimon Glass2-15/+46
Now that we have the alias information we can assign a sequence number to each device in the uclass. Store this in the node associated with each device. This requires renaming the sandbox test drivers to have the right name. Note that test coverage is broken with this patch, but fixed in the next one. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Detect drivers only at the start of start of lineSimon Glass1-2/+2
If a driver declaration is included in a comment, dtoc currently gets confused. Update the parser to only consider declarations that begin at the start of a line. Since multi-line comments begin with an asterisk, this avoids the problem. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Read aliases for uclassesSimon Glass7-3/+345
Scan the aliases in the device tree to establish the number of devices within each uclass, and the sequence number of each. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Warn of duplicate driversSimon Glass2-1/+122
If drivers have the same name then we cannot distinguish them. This only matters if the driver is actually used by dtoc, but in that case, issue a warning. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Process driver aliases along with driversSimon Glass2-11/+9
Instead of using a separate step for this processing, handle it while scanning its associated driver. This allows us to drop the code coverage exception in this case. Note that only files containing drivers are scanned by dtoc, so aliases declared in a file that doesn't hold a driver will not be noticed. It would be confusing to put them anywhere other than in the driver that they relate to, but update the documentation to say this explicitly, just in case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Support headers needed for driversSimon Glass2-0/+11
Typically dtoc can detect the header file needed for a driver by looking for the structs that it uses. For example, if a driver as a .priv_auto that uses 'struct serial_priv', then dtoc can search header files for the definition of that struct and use the file. In some cases, enums are used in drivers, typically with the .data field of struct udevice_id. Since dtoc does not support searching for these, add a way to tell dtoc which header to use. This works as a macro included in the driver definition. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Support tracking the phase of U-BootSimon Glass5-12/+31
U-Boot operates in several phases, typically TPL, SPL and U-Boot proper. The latter does not use dtoc. In some rare cases different drivers are used for two phases. For example, in TPL it may not be necessary to use the full PCI subsystem, so a simple driver can be used instead. This works in the build system simply by compiling in one driver or the other (e.g. PCI driver + uclass for SPL; simple_bus for TPL). But dtoc has no way of knowing which code is compiled in for which phase, since it does not inspect Makefiles or dependency graphs. So to make this work for dtoc, we need to be able to explicitly mark drivers with their phase. This is done by adding an empty macro to the driver. Add support for this in dtoc. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Track nodes which are actually usedSimon Glass4-4/+37
Mark all nodes that are actually used, so we can perform extra checks on them. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Process nodes to set up required propertiesSimon Glass3-0/+124
Add logic to assign property values to nodes as required by dtoc. The references allow nodes to refer to each other in C code. The macros used by dtoc are not yet defined in driver model. They will be added along with the actual driver model implementation. Signed-off-by: Simon Glass <sjg@chromium.org>