blob: 82305b921f0a341fc1fde30fb2dcafd07b540502 [file] [log] [blame]
Simon Glass40eb3c32023-08-14 16:40:29 -06001.. SPDX-License-Identifier: GPL-2.0+
2
3Configuration Editor
4====================
5
6Introduction
7------------
8
9U-Boot provides a configuration editor which allows settings to be changed in
10a GUI or text environment.
11
12
13This feature is still in development and has a number of limitations. For
14example, cedit only supports menu items (there is no numeric or text entry),
15provides no support for colour text and does not support scrolling. Still it is
16possible to use it for simple applications.
17
18
19Overview
20--------
21
22The configuration editor makes use of :doc:`expo` to build a description of the
23configuration screens and allow user to interact with it.
24
25To create a single-scene cedit for your application:
26
27#. Design the scene, i.e. the objects that need to be present and what their
28 possible values are
29
30#. Enter this in .dts format
31
32#. Create a header file containing the IDs
33
34#. Run the 'expo.py' tool to generate a .dtb file containing the layout, which
35 can be used by U-Boot
36
37#. Use the :doc:`../usage/cmd/cedit` to create the cedit, read the settings,
38 present the cedit to the user and save the settings afterwards.
39
40Each of these is described in a separate section. See :ref:`expo_example` for
41an example file.
42
43
44Design a scene
45--------------
46
47Using a piece of paper or a drawing tool, lay out the objects you want in your
48scene. Typically you will use the default layout engine, which simply puts items
49one after the other from top to bottom. So use a single column and show the
50prompt and value for each object.
51
52For menu items, show one of the values, but keep in mind what else you need.
53
54
55Create an expo-format file
56--------------------------
57
58The description is in the form of a devicetree file, as documented at
59:ref:`expo_format`. Since everything in an expo has an ID number (an integer
60greater than 1) the description is written terms of these IDs. They each have
61an enum value. which is typically taken care of by the `expo.py` tool.
62
63The expo should have a `scenes` node with a named scene as a subnode. Within the
64scene, add properties for the scene, then a subnode for each object in the
65scene.
66
67All object nodes require an `id` value and a `type` property. Other properties
68depend on the type. For example, a menu has a `title` and an `item-label` list
69proving the text for the menu items, as well as an `item-id` list providing the
70ID of each menu item, so it can be selected.
71
72Text properties may have two variants. For example `title` specifies the title
73of a menu, but you can instead use `title-id` to specify the string ID to use as
74the title. String are defined in a separate area, common to the whole expo,
75which contains a subnode for each string. Within that subnode are the ID and the
76`value` (i.e. the text). For now only English is supported, but in future it may
77be possible to append a language identifier to provide other values (e.g.
78'value-es' for Spanish).
79
80
81Create an ID header-file
82------------------------
83
84Expo needs to know the integer value to use for every ID referenced in your
85expo-format file. For example, if you have defined a `cpu-speed` node with an
86id of `ID_CPU_SPEED`, then Expo needs to know the value of `ID_CPU_SPEED`.
87
88When you write C code to use the expo, you may need to know the IDs. For
89example, to find which value the user selected in `cpu-speed` menu, you must
90use the `ID_CPU_SPEED` ID. The ID is the only way to refer to anything in Expo.
91
92Since we need a shared set of IDs, it is best to have a header file containing
93them. Expo supports doing this with an enum, where every ID is listed in the
94enum::
95
96 enum {
97 ZERO,
98
99 ID_PROMPT,
100
101 ID_SCENE1,
102 ID_SCENE1_TITLE,
103 ...
104 };
105
106The C compiler can parse this directly. The `expo.py` tool parses it for expo.
107
108Create a header file containing every ID mentioned in your expo. Try to group
109related things together.
110
111
112Build the expo layout
113---------------------
114
115Use the `expo.py` tool to build a .dtb for your expo::
116
117 ./tools/expo.py -e expo_ids.h -l expo_layout.dts -o expo.dtb
118
119This uses the enum in the provided header file to get the ID numbers, grabs
120the `.dts` file, inserts the ID numbers and then uses the devicetree compiler to
121build a `.dtb` file.
122
123If you get an error::
124
125 Devicetree compiler error:
126 Error: <stdin>:9.19-20 syntax error
127 FATAL ERROR: Unable to parse input tree
128
129that means that something is wrong with your syntax, or perhaps you have an ID
130in the `.dts` file that is not mentioned in your enum. Check both files and try
131again.
132
133
134Use the command interface
135-------------------------
136
137See the :doc:`../usage/cmd/cedit` command for information on available commands.
138Typically you will use `cedit load` to load the `.dtb` file and `cedit run` to
139let the user interact with it.
140
141
142Multiple scenes
143---------------
144
145Expo supports multiple scenes but has no pre-determined way of moving between
146them. You could use selection of a menu item as a signal to change the scene,
147but this is not currently implemented in the cedit code (see `cedit_run()`).
Simon Glass82adc292023-08-14 16:40:30 -0600148
149
150Themes
151------
152
153The configuration editor uses simple expo themes. The theme is read from
154`/bootstd/cedit-theme` in the devicetree.
Simon Glass9b68f942023-08-14 16:40:39 -0600155
156
157Reading and writing settings
158----------------------------
159
160Cedit provides several options for persistent settings:
161
162- Writing an FDT file to a filesystem
163- Writing to U-Boot's environment variables, which are then typically stored in
164 a persistent manner
Simon Glass00f6c402023-10-01 19:13:40 -0600165- Writing to CMOS RAM registers (common on x86 machines). Note that textline
166 objects do not appear in CMOS RAM registers
Simon Glass9b68f942023-08-14 16:40:39 -0600167
168For now, reading and writing settings is not automatic. See the
169:doc:`../usage/cmd/cedit` for how to do this on the command line or in a
170script.