Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: cedit (command) |
| 5 | |
Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 6 | cedit command |
| 7 | ============= |
| 8 | |
Heinrich Schuchardt | 44b09b3 | 2024-03-16 11:09:36 +0100 | [diff] [blame] | 9 | Synopsis |
| 10 | -------- |
Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 11 | |
| 12 | :: |
| 13 | |
| 14 | cedit load <interface> <dev[:part]> <filename> |
| 15 | cedit run |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 16 | cedit write_fdt <dev[:part]> <filename> |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 17 | cedit read_fdt <dev[:part]> <filename> |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 18 | cedit write_env [-v] |
Simon Glass | 0f2e5a6 | 2023-08-14 16:40:36 -0600 | [diff] [blame] | 19 | cedit read_env [-v] |
Simon Glass | 2b91ca6 | 2023-08-14 16:40:37 -0600 | [diff] [blame] | 20 | cedit write_cmos [-v] [dev] |
Simon Glass | 3434420 | 2024-10-14 16:32:11 -0600 | [diff] [blame] | 21 | cedit cb_load |
Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 22 | |
| 23 | Description |
| 24 | ----------- |
| 25 | |
| 26 | The *cedit* command is used to load a configuration-editor description and allow |
| 27 | the user to interact with it. |
| 28 | |
| 29 | It makes use of the expo subsystem. |
| 30 | |
| 31 | The description is in the form of a devicetree file, as documented at |
| 32 | :ref:`expo_format`. |
| 33 | |
Simon Glass | 40eb3c3 | 2023-08-14 16:40:29 -0600 | [diff] [blame] | 34 | See :doc:`../../develop/cedit` for information about the configuration editor. |
| 35 | |
Simon Glass | f8cb2e8 | 2023-08-14 16:40:31 -0600 | [diff] [blame] | 36 | cedit load |
| 37 | ~~~~~~~~~~ |
| 38 | |
| 39 | Loads a configuration-editor description from a file. It creates a new cedit |
| 40 | structure ready for use. Initially no settings are read, so default values are |
| 41 | used for each object. |
| 42 | |
| 43 | cedit run |
| 44 | ~~~~~~~~~ |
| 45 | |
| 46 | Runs the default configuration-editor event loop. This is very simple, just |
| 47 | accepting character input and moving through the objects under user control. |
| 48 | The implementation is at `cedit_run()`. |
| 49 | |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 50 | cedit write_fdt |
| 51 | ~~~~~~~~~~~~~~~ |
| 52 | |
| 53 | Writes the current user settings to a devicetree file. For each menu item the |
| 54 | selected ID and its text string are written. |
| 55 | |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 56 | cedit read_fdt |
| 57 | ~~~~~~~~~~~~~~ |
| 58 | |
| 59 | Reads the user settings from a devicetree file and updates the cedit with those |
| 60 | settings. |
Simon Glass | f8cb2e8 | 2023-08-14 16:40:31 -0600 | [diff] [blame] | 61 | |
Simon Glass | 0f2e5a6 | 2023-08-14 16:40:36 -0600 | [diff] [blame] | 62 | cedit read_env |
| 63 | ~~~~~~~~~~~~~~ |
| 64 | |
| 65 | Reads the settings from the environment variables. For each menu item `<name>`, |
| 66 | cedit looks for a variable called `c.<name>` with the ID of the selected menu |
| 67 | item. |
| 68 | |
| 69 | The `-v` flag enables verbose mode, where each variable is printed after it is |
| 70 | read. |
| 71 | |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 72 | cedit write_env |
| 73 | ~~~~~~~~~~~~~~~ |
| 74 | |
| 75 | Writes the settings to environment variables. For each menu item the selected |
| 76 | ID 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 | |
| 81 | The `-v` flag enables verbose mode, where each variable is printed before it is |
| 82 | set. |
| 83 | |
Simon Glass | 2b91ca6 | 2023-08-14 16:40:37 -0600 | [diff] [blame] | 84 | cedit write_cmos |
| 85 | ~~~~~~~~~~~~~~~~ |
| 86 | |
| 87 | Writes the settings to locations in the CMOS RAM. The locations used are |
| 88 | specified by the schema. See `expo_format_`. |
| 89 | |
| 90 | The `-v` flag enables verbose mode, which shows which CMOS locations were |
| 91 | updated. |
| 92 | |
| 93 | Normally the first RTC device is used to hold the data. You can specify a |
| 94 | different device by name using the `dev` parameter. |
| 95 | |
Simon Glass | 3434420 | 2024-10-14 16:32:11 -0600 | [diff] [blame] | 96 | .. _cedit_cb_load: |
| 97 | |
| 98 | cedit cb_load |
| 99 | ~~~~~~~~~~~~~ |
| 100 | |
| 101 | This is supported only on x86 devices booted from coreboot. It creates a new |
| 102 | configuration editor which can be used to edit CMOS settings. |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 103 | |
Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 104 | Example |
| 105 | ------- |
| 106 | |
| 107 | :: |
| 108 | |
| 109 | => cedit load hostfs - fred.dtb |
| 110 | => cedit run |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 111 | => cedit write_fdt hostfs - settings.dtb |
| 112 | |
| 113 | That results in:: |
| 114 | |
| 115 | / { |
| 116 | cedit-values { |
| 117 | cpu-speed = <0x00000006>; |
Simon Glass | 6f3e87a | 2024-10-14 16:32:00 -0600 | [diff] [blame] | 118 | cpu-speed-value = <0x00000003>; |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 119 | cpu-speed-str = "2 GHz"; |
| 120 | power-loss = <0x0000000a>; |
Simon Glass | 6f3e87a | 2024-10-14 16:32:00 -0600 | [diff] [blame] | 121 | power-loss-value = <0x00000000>; |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 122 | power-loss-str = "Always Off"; |
| 123 | }; |
| 124 | } |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 125 | |
| 126 | => cedit read_fdt hostfs - settings.dtb |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 127 | |
| 128 | This shows settings being stored in the environment:: |
| 129 | |
| 130 | => cedit write_env -v |
Simon Glass | 6f3e87a | 2024-10-14 16:32:00 -0600 | [diff] [blame] | 131 | c.cpu-speed=11 |
Simon Glass | 0f2e5a6 | 2023-08-14 16:40:36 -0600 | [diff] [blame] | 132 | c.cpu-speed-str=2.5 GHz |
Simon Glass | 6f3e87a | 2024-10-14 16:32:00 -0600 | [diff] [blame] | 133 | 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 Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 141 | => 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 Glass | 6f3e87a | 2024-10-14 16:32:00 -0600 | [diff] [blame] | 147 | c.machine-name=my-machine |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 148 | ... |
Simon Glass | 0f2e5a6 | 2023-08-14 16:40:36 -0600 | [diff] [blame] | 149 | |
| 150 | => cedit read_env -v |
| 151 | c.cpu-speed=7 |
| 152 | c.power-loss=12 |
Simon Glass | 2b91ca6 | 2023-08-14 16:40:37 -0600 | [diff] [blame] | 153 | |
| 154 | This 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 Glass | 4462fa3 | 2023-08-14 16:40:38 -0600 | [diff] [blame] | 158 | => cedit write_cmos -v |
Simon Glass | 2b91ca6 | 2023-08-14 16:40:37 -0600 | [diff] [blame] | 159 | Write 2 bytes from offset 80 to 84 |
| 160 | => rtc read 80 8 |
| 161 | 00000080: 01 00 00 00 08 2f 2a 08 ...../*. |
Simon Glass | 4462fa3 | 2023-08-14 16:40:38 -0600 | [diff] [blame] | 162 | => cedit read_cmos -v |
| 163 | Read 2 bytes from offset 80 to 84 |
| 164 | |
| 165 | Here is an example with the device specified:: |
| 166 | |
| 167 | => cedit write_cmos rtc@43 |
| 168 | => |
Simon Glass | 3434420 | 2024-10-14 16:32:11 -0600 | [diff] [blame] | 169 | |
| 170 | This example shows editing coreboot CMOS-RAM settings. A script could be used |
| 171 | to 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 | |
| 214 | Check that the CMOS RAM checksum is correct, then create a configuration editor |
| 215 | and load the settings from CMOS RAM:: |
| 216 | |
| 217 | => cbcmos check |
| 218 | => cedit cb |
| 219 | => cedit read_cmos |
| 220 | |
| 221 | Now run the cedit. In this case the user selected 'save' so `cedit run` returns |
| 222 | success:: |
| 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 | |
| 229 | Update 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 | => |