It is possible to run `build-docker.sh` if either your Docker is configured in rootless mode,
or if your user is a member of the `docker` group; see [Docker documentation](https://docs.docker.com/install/linux/linux-postinstall/)
for details.
If you don't satisfy the above conditions, and run `sudo ./build-docker.sh`, you might receive a `Permission denied`
error. To work around it, make sure that the directory hierarchy in `build/` directory
is world-writable - e.g., by running `chmod -R a+w build/`.
## Building older versions
For firmware versions **1.8.1** and newer, you can checkout the respective tag locally.
To build firmware 1.8.2, for example, run `git checkout legacy/v1.8.2` and then use
the instructions below.
Note that the unified Docker build was added after version 1.8.3, so it is not available
for older versions.
For firmwares older than 1.8.1, please clone the archived [trezor-mcu](https://github.com/trezor/trezor-mcu) repository and follow the instructions in its README.
If you want to build device firmware, also make sure that you have the [GNU ARM Embedded toolchain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads) installed.
See [Dockerfile](../../ci/Dockerfile#L72-L76) for up-to-date version of the toolchain.
The build process is configured via environment variables:
*`EMULATOR=1` specifies that an emulator should be built, instead of the device firmware.
*`DEBUG_LINK=1` specifies that DebugLink should be available in the built image.
*`MEMORY_PROTECT=0` disables memory protection. This is necessary for installing unofficial firmware.
*`DEBUG_LOG=1` enables debug messages to be printed on device screen.
*`BITCOIN_ONLY=1` specifies Bitcoin-only version of the firmware.
To run the build process, execute the following commands: