RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

CMOS RAM on the Raspberry Pi

category: RaspberryPi

Introduction

The Raspberry Pi does not have any battery-backed memory, so a file called “CMOS” (in the DOS partition of the boot SD) holds the CMOS RAM settings.

This file is loaded into RAM when the system is booted, and any changes to CMOS RAM settings are stored in the file.

Creating the file

If the file does not already exist, you can create it as follows:

*SaveCMOS SDFS:$.!Boot.Loader.CMOS

After issuing the *SaveCMOS command, shut down (Shift-Ctrl-F12) and restart.1

1 RISC OS will only save configuration changes to the file if it was present at boot time. If the file is created after the session has started, any further configuration changes in that session will not be saved.

Loading

The Raspberry Pi bootloader looks for the file in the same partition that “config.txt” was found. Two lines in “config.txt” control the loading of the file:

ramfsfile=CMOS – the name of the file to load
ramfsaddr=0x508000 – the start location in memory to use

Saving

RISC OS will save CMOS RAM changes to the file. To allow for the possibility that the SD card is fully DOS format (i.e. !Boot has been moved to another drive), RISC OS tries two file locations in turn:

  1. SDFS:$.CMOS
  2. SDFS:$.!Boot.Loader.CMOS

It is important to note that RISC OS tries $.CMOS first. If you have placed another file called “CMOS” in SDFS:$, that file will be overwritten when you next try to make any configuration changes. Also, the attempted configuration changes will not survive a reboot as they have been saved in the wrong place. The fix is to delete (or rename) the additional “CMOS” file.

The “boot from USB” issue

The Pi 3 and Pi 4 will boot from USB, but there’s a problem. When booting from USB, the Pi boot loader will be loading the CMOS file from the USB drive, but RISC OS will be saving any CMOS RAM updates to the SD card. As these have been saved to the wrong place they won’t survive a reload.

You have two options:

  1. In !Boot.Choices.Boot, create a directory called PostDesk (if it doesn’t already exist) and then create an Obey file called !cmos-save inside !Boot.Choices.Boot.PostDesk. The Obey file should contain the following command:
    SaveCMOS <Boot$Dir>.Loader.CMOS
    This will save the CMOS contents to !Boot.Loader.CMOS (on USB) every time a tidy shutdown is performed. Note that CMOS changes will not be saved in other circumstances (system crash, Ctrl-Break etc.)
  2. Alternatively, modify the SDCMOS module so that RISC OS writes to SCSI:$.!Boot.Loader.CMOS instead of SDFS:$.!Boot.Loader.CMOS (a possible approach is given in this forum posting but it’s not for the faint-hearted).

Users wishing to reduce SD card wear-and-tear would be better advised to continue booting from the SD card, but to move the !Boot directory to a USB drive, as described here.

Resetting CMOS RAM

To reset CMOS RAM settings to factory defaults on the Raspberry Pi, simply delete the “CMOS” file.

After rebooting, you should recreate the file as described above.


Revised on September 13, 2020 07:31:55 by Stuart Painting (5389)?

Search the Wiki

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Instiki theme is based on Insitki's default layout

Valid XHTML 1.0  |  Valid CSS

Instiki 0.19.1(MML+)
This site runs on Rails

Hosted by Arachsys