# Stock Firmware Backup Convention
## Purpose
OreBolt OS and the stock Hiby Player firmware both boot from the
FAT32 MicroSD card. The SPI flash bootloader is never modified.
This directory holds a snapshot of the stock firmware so the System
Tools module can restore the device to its factory state.
## How the backup is created
On the **first deployment only**, run:
```bash
SD_CARD_MOUNT=/mnt/h2-sd ./build.sh --deploy --backup-stock
```
This snapshots the following paths from the stock SD card into this
directory, before any OreBolt OS files are written:
```
data/stock_backup/
usr/bin/ Stock binaries (including hiby_player)
usr/lib/ Stock shared libraries
etc/inittab Stock init configuration
etc/init.d/ Stock init scripts
res/ Stock resources (fonts, themes, assets)
setting/ Stock player settings and database
```
## How the restore works
The System Tools module (reset.mod) reads from this directory when
the operator selects "HIBY PLAYER -- Restore stock FW":
1. Stops all OreBolt OS init scripts (S98retro-input, S99broker, bt_input_daemon)
2. Removes /apps/*.mod (all module binaries)
3. Removes /usr/bin/h2_test and /usr/bin/retro_input_mapper
4. Removes OreBolt init scripts from /etc/init.d/
5. Removes /usr/lib/liblvgl.so
6. Restores stock files from /data/stock_backup/ back to their
original locations (/usr/bin/, /usr/lib/, /etc/, /res/, /setting/)
7. Calls sync() and reboots
After reboot, the device loads the original Hiby Player -- the music
player that shipped from the factory.
## User-installed Rockbox
OreBolt OS does not ship, bundle, or install Rockbox. If the user
has installed Rockbox on the SD card independently, the System Tools
module detects its presence (`.rockbox/` or `rockbox/` at the SD card
root) and offers a reboot option. No OreBolt OS files are modified
when booting to Rockbox -- a reboot is sufficient for the user's
Rockbox installation to load.