TS-4710 NVRAM: Difference between revisions
(Clarification of NVRAM operation) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
nvram31=0x70544510 | nvram31=0x70544510 | ||
This breaks up the NVRAM into | This breaks up the NVRAM into 32 32-bit registers which can be accessed in bash. As this uses the name=value output, "eval" can be used for simple parsing: | ||
<source lang=bash> | <source lang=bash> | ||
eval `tshwctl --nvram` | eval `tshwctl --nvram` | ||
Line 18: | Line 18: | ||
</source> | </source> | ||
From the above value, this would return 0x48ca4278. To set values, | From the above value, this would return 0x48ca4278. To set values, the respective environment variable name can be set: | ||
<source lang=bash> | <source lang=bash> | ||
nvram0=0x42 tshwctl --nvram | nvram0=0x42 tshwctl --nvram | ||
</source> | </source> | ||
Note that the command 'tshwctl --nvram' will output the current contents of NVRAM before setting any new values. At this point, running 'tshwctl --nvram' once more will print the updated contents for verification. This can be used for reading a 32-bit quantity and updating it with a single command. |
Latest revision as of 16:56, 2 April 2018
The RTC has an included 128-byte battery-backed NVRAM which can be accessed using tshwctl. Its contents will remain with the main power off, so long as the RTC battery is installed and withing a valid voltage range.
tshwctl --nvram
This will return a format such as:
nvram0=0xf7f8a73e nvram1=0x2fef5ae0 nvram2=0x48ca4278 ... nvram31=0x70544510
This breaks up the NVRAM into 32 32-bit registers which can be accessed in bash. As this uses the name=value output, "eval" can be used for simple parsing:
eval `tshwctl --nvram`
echo $nvram2
From the above value, this would return 0x48ca4278. To set values, the respective environment variable name can be set:
nvram0=0x42 tshwctl --nvram
Note that the command 'tshwctl --nvram' will output the current contents of NVRAM before setting any new values. At this point, running 'tshwctl --nvram' once more will print the updated contents for verification. This can be used for reading a 32-bit quantity and updating it with a single command.