blob: e54ea204b9f06ac56c2a8c23830e9117810776c6 [file] [log] [blame]
Simon Glassc8925112023-06-01 10:23:02 -06001.. SPDX-License-Identifier: GPL-2.0+:
2
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01003.. index::
4 single: cedit (command)
5
Simon Glassc8925112023-06-01 10:23:02 -06006cedit command
7=============
8
Heinrich Schuchardt44b09b32024-03-16 11:09:36 +01009Synopsis
10--------
Simon Glassc8925112023-06-01 10:23:02 -060011
12::
13
14 cedit load <interface> <dev[:part]> <filename>
15 cedit run
Simon Glass28bf4352023-08-14 16:40:33 -060016 cedit write_fdt <dev[:part]> <filename>
Simon Glassb1cd32b2023-08-14 16:40:34 -060017 cedit read_fdt <dev[:part]> <filename>
Simon Glass237f3752023-08-14 16:40:35 -060018 cedit write_env [-v]
Simon Glass0f2e5a62023-08-14 16:40:36 -060019 cedit read_env [-v]
Simon Glass2b91ca62023-08-14 16:40:37 -060020 cedit write_cmos [-v] [dev]
Simon Glass34344202024-10-14 16:32:11 -060021 cedit cb_load
Simon Glassc8925112023-06-01 10:23:02 -060022
23Description
24-----------
25
26The *cedit* command is used to load a configuration-editor description and allow
27the user to interact with it.
28
29It makes use of the expo subsystem.
30
31The description is in the form of a devicetree file, as documented at
32:ref:`expo_format`.
33
Simon Glass40eb3c32023-08-14 16:40:29 -060034See :doc:`../../develop/cedit` for information about the configuration editor.
35
Simon Glassf8cb2e82023-08-14 16:40:31 -060036cedit load
37~~~~~~~~~~
38
39Loads a configuration-editor description from a file. It creates a new cedit
40structure ready for use. Initially no settings are read, so default values are
41used for each object.
42
43cedit run
44~~~~~~~~~
45
46Runs the default configuration-editor event loop. This is very simple, just
47accepting character input and moving through the objects under user control.
48The implementation is at `cedit_run()`.
49
Simon Glass28bf4352023-08-14 16:40:33 -060050cedit write_fdt
51~~~~~~~~~~~~~~~
52
53Writes the current user settings to a devicetree file. For each menu item the
54selected ID and its text string are written.
55
Simon Glassb1cd32b2023-08-14 16:40:34 -060056cedit read_fdt
57~~~~~~~~~~~~~~
58
59Reads the user settings from a devicetree file and updates the cedit with those
60settings.
Simon Glassf8cb2e82023-08-14 16:40:31 -060061
Simon Glass0f2e5a62023-08-14 16:40:36 -060062cedit read_env
63~~~~~~~~~~~~~~
64
65Reads the settings from the environment variables. For each menu item `<name>`,
66cedit looks for a variable called `c.<name>` with the ID of the selected menu
67item.
68
69The `-v` flag enables verbose mode, where each variable is printed after it is
70read.
71
Simon Glass237f3752023-08-14 16:40:35 -060072cedit write_env
73~~~~~~~~~~~~~~~
74
75Writes the settings to environment variables. For each menu item the selected
76ID and its text string are written, similar to:
77
78 setenv c.<name> <selected_id>
79 setenv c.<name>-str <selected_id's text string>
80
81The `-v` flag enables verbose mode, where each variable is printed before it is
82set.
83
Simon Glass2b91ca62023-08-14 16:40:37 -060084cedit write_cmos
85~~~~~~~~~~~~~~~~
86
87Writes the settings to locations in the CMOS RAM. The locations used are
88specified by the schema. See `expo_format_`.
89
90The `-v` flag enables verbose mode, which shows which CMOS locations were
91updated.
92
93Normally the first RTC device is used to hold the data. You can specify a
94different device by name using the `dev` parameter.
95
Simon Glass34344202024-10-14 16:32:11 -060096.. _cedit_cb_load:
97
98cedit cb_load
99~~~~~~~~~~~~~
100
101This is supported only on x86 devices booted from coreboot. It creates a new
102configuration editor which can be used to edit CMOS settings.
Simon Glass237f3752023-08-14 16:40:35 -0600103
Simon Glassc8925112023-06-01 10:23:02 -0600104Example
105-------
106
107::
108
109 => cedit load hostfs - fred.dtb
110 => cedit run
Simon Glass28bf4352023-08-14 16:40:33 -0600111 => cedit write_fdt hostfs - settings.dtb
112
113That results in::
114
115 / {
116 cedit-values {
117 cpu-speed = <0x00000006>;
Simon Glass6f3e87a2024-10-14 16:32:00 -0600118 cpu-speed-value = <0x00000003>;
Simon Glass28bf4352023-08-14 16:40:33 -0600119 cpu-speed-str = "2 GHz";
120 power-loss = <0x0000000a>;
Simon Glass6f3e87a2024-10-14 16:32:00 -0600121 power-loss-value = <0x00000000>;
Simon Glass28bf4352023-08-14 16:40:33 -0600122 power-loss-str = "Always Off";
123 };
124 }
Simon Glassb1cd32b2023-08-14 16:40:34 -0600125
126 => cedit read_fdt hostfs - settings.dtb
Simon Glass237f3752023-08-14 16:40:35 -0600127
128This shows settings being stored in the environment::
129
130 => cedit write_env -v
Simon Glass6f3e87a2024-10-14 16:32:00 -0600131 c.cpu-speed=11
Simon Glass0f2e5a62023-08-14 16:40:36 -0600132 c.cpu-speed-str=2.5 GHz
Simon Glass6f3e87a2024-10-14 16:32:00 -0600133 c.cpu-speed-value=3
134 c.power-loss=14
135 c.power-loss-str=Always Off
136 c.power-loss-value=0
137 c.machine-name=my-machine
138 c.cpu-speed=11
139 c.power-loss=14
140 c.machine-name=my-machine
Simon Glass237f3752023-08-14 16:40:35 -0600141 => print
142 ...
143 c.cpu-speed=6
144 c.cpu-speed-str=2 GHz
145 c.power-loss=10
146 c.power-loss-str=Always Off
Simon Glass6f3e87a2024-10-14 16:32:00 -0600147 c.machine-name=my-machine
Simon Glass237f3752023-08-14 16:40:35 -0600148 ...
Simon Glass0f2e5a62023-08-14 16:40:36 -0600149
150 => cedit read_env -v
151 c.cpu-speed=7
152 c.power-loss=12
Simon Glass2b91ca62023-08-14 16:40:37 -0600153
154This shows writing to CMOS RAM. Notice that the bytes at 80 and 84 change::
155
156 => rtc read 80 8
157 00000080: 00 00 00 00 00 2f 2a 08 ...../*.
Simon Glass4462fa32023-08-14 16:40:38 -0600158 => cedit write_cmos -v
Simon Glass2b91ca62023-08-14 16:40:37 -0600159 Write 2 bytes from offset 80 to 84
160 => rtc read 80 8
161 00000080: 01 00 00 00 08 2f 2a 08 ...../*.
Simon Glass4462fa32023-08-14 16:40:38 -0600162 => cedit read_cmos -v
163 Read 2 bytes from offset 80 to 84
164
165Here is an example with the device specified::
166
167 => cedit write_cmos rtc@43
168 =>
Simon Glass34344202024-10-14 16:32:11 -0600169
170This example shows editing coreboot CMOS-RAM settings. A script could be used
171to automate this::
172
173 => cbsysinfo
174 Coreboot table at 500, size 5c4, records 1d (dec 29), decoded to 000000007dce3f40, forwarded to 000000007ff9a000
175
176 CPU KHz : 0
177 Serial I/O port: 00000000
178 base : 00000000
179 pointer : 000000007ff9a370
180 type : 1
181 base : 000003f8
182 baud : 0d115200
183 regwidth : 1
184 input_hz : 0d1843200
185 PCI addr : 00000010
186 Mem ranges : 7
187 id: type || base || size
188 0: 10:table 0000000000000000 0000000000001000
189 1: 01:ram 0000000000001000 000000000009f000
190 2: 02:reserved 00000000000a0000 0000000000060000
191 3: 01:ram 0000000000100000 000000007fe6d000
192 4: 10:table 000000007ff6d000 0000000000093000
193 5: 02:reserved 00000000fec00000 0000000000001000
194 6: 02:reserved 00000000ff800000 0000000000800000
195 option_table: 000000007ff9a018
196 Bit Len Cfg ID Name
197 0 180 r 0 reserved_memory
198 180 1 e 4 boot_option 0:Fallback 1:Normal
199 184 4 h 0 reboot_counter
200 190 8 r 0 reserved_century
201 1b8 8 r 0 reserved_ibm_ps2_century
202 1c0 1 e 1 power_on_after_fail 0:Disable 1:Enable
203 1c4 4 e 6 debug_level 5:Notice 6:Info 7:Debug 8:Spew
204 1d0 80 r 0 vbnv
205 3f0 10 h 0 check_sum
206 CMOS start : 1c0
207 CMOS end : 1cf
208 CMOS csum loc: 3f0
209 VBNV start : ffffffff
210 VBNV size : ffffffff
211 ...
212 Unimpl. : 10 37 40
213
214Check that the CMOS RAM checksum is correct, then create a configuration editor
215and load the settings from CMOS RAM::
216
217 => cbcmos check
218 => cedit cb
219 => cedit read_cmos
220
221Now run the cedit. In this case the user selected 'save' so `cedit run` returns
222success::
223
224 => if cedit run; then cedit write_cmos -v; fi
225 Write 2 bytes from offset 30 to 38
226 => echo $?
227 0
228
229Update the checksum in CMOS RAM::
230
231 => cbcmos check
232 Checksum 6100 error: calculated 7100
233 => cbcmos update
234 Checksum 7100 written
235 => cbcmos check
236 =>