Update Modify openpilot - nasser2019/CommaAi GitHub Wiki
Table of Contents
- Git Branches
- Why Would a User Switch Branches?
- How to Switch to master-ci (Non-Developers)
- How to Checkout a Specific Release
- For Developers
Overview
Updating openpilot for most users is intended to be an automatic process, when it comes to official releases (i.e. versions that are listed here: https://github.com/commaai/openpilot/releases).
By switching away from the default release2
branch of Openpilot, you will lose the benefit of Comma's rigorous test and review process. All other branches can and likely do have bugs, some of which may cause undesirable behavior, you switch branches at your own risk.
Git Branches
See the Pro Git Book and specifically the chapter on Git Branches for an explanation of what a branch is. See the Openpilot Development Flow discussion on George's Medium post on Externalization for an explanation of the various Openpilot branches.
Why Would a User Switch Branches?
Switching branches is primarily the realm of developers. However, there are two reasons why a general user may want to switch to the master-ci
branch of Openpilot:
- Gaining access to a bug fix
- Gaining access to newly fingerprinted vehicles
master-ci
(Non-Developers)
How to Switch to SSH is more traditional but Shane's Fork Installer doesn't require SSH access and may be easier.
SSH
- You will first need to gain access to your device using SSH, see the SSH instructions.
- Then you need to run the following command:
This command will replace whatever version of openpilot you are currently running with the master-ci
branch. Caution: this command will blow away the openpilot directory, so if you are a developer who has made changes to openpilot, this command is not for you.
For comma2/EON:
cd /data && rm -rf openpilot && git clone -b master-ci https://github.com/commaai/openpilot && reboot
For comma3:
cd /data && rm -rf openpilot && git clone -b master-ci https://github.com/commaai/openpilot && sudo reboot
When switching between branches, if the version of cereal or some other submodule has changed between the branches, you may encounter errors including the "communication between processes" issue. To reinitialize the submodules after you checkout a new branch run the following commands:
git submodule deinit --all -f
git submodule init
git submodule update
Alternatively, switching to another branch can be done without pulling the entire repository, while retaining the necessary submodules, and with one less reboot.
For comma2/EON:
cd /data; rm -rf ./openpilot; git clone -b master-ci --depth 1 --single-branch --recurse-submodules --shallow-submodules https://github.com/commaai/openpilot.git openpilot; cd openpilot; pkill -f thermald; rm -f prebuilt && reboot
For comma3:
cd /data; rm -rf ./openpilot; git clone -b master-ci --depth 1 --single-branch --recurse-submodules --shallow-submodules https://github.com/commaai/openpilot.git openpilot; cd openpilot; pkill -f thermald; rm -f prebuilt && sudo reboot
Shane's Fork Installer
- Ensure you can "Factory Reset" the device.
- See https://youtu.be/0MPv_hSH3hk?t=218 and do a factory reset from recovery for C2 and https://www.youtube.com/watch?v=gNnRmEyVSVQ 's 1st part for C3's factory reset.
- Factory Reset the device.
- In place of the "openpilot.comma.ai" URL for Custom Software during installation, use "smiskol.com/fork/commaai/master-ci".
- The startup time for
master-ci
can be slower.
Factory Reset can also be done through "Uninstall Openpilot" in Settings but master-ci
is definitely not perfect, contains bleeding edge software, and the UI is more likely to break including access to the "Uninstall Openpilot" button. The preferred instructions above ensure the reader has visited Recovery.
How to Checkout a Specific Release
- You will first need to gain access to your device using SSH, see the SSH instructions.
- Then you need to run the following command:
This command will replace whatever version of openpilot you are currently running with version v0.7.6
. Caution: this command will blow away the openpilot directory, so if you are a developer who has made changes to openpilot, this command is not for you.
For comma2/EON:
cd /data && rm -rf openpilot && git clone -b v0.7.6 https://github.com/commaai/openpilot && reboot
For comma3:
cd /data && rm -rf openpilot && git clone -b v0.7.6 https://github.com/commaai/openpilot && sudo reboot
When switching between branches, if the version of cereal or some other submodule has changed between the branches, you may encounter errors including the "communication between processes" issue. To reinitialize the submodules after you checkout a new branch run the following commands:
git submodule deinit --all -f
git submodule init
git submodule update
For Developers
However, if you want to test out newer, unreleased version like 0.8.0, the easiest way is to git clone
openpilot directly onto your CommaTwo/EON and git checkout
the master branch (could potentially be unstable since changes are made daily). The steps below show how to ensure you are on the git branch that has the latest code changes.
The latest openpilot revisions come from the main repository: https://github.com/commaai/openpilot .
If you want to test out your own modified code, create a fork of the main repo and clone that one (branches should still be the same)
SSH into your comma2/EON
1.cd /data/
mv openpilot/ openpilot.backup
git clone https://github.com/commaai/openpilot.git
cd openpilot
2. Checkout your desired branch
release2
- latest official release with compiled binary. Does not need to be built on the devicegit checkout release2
master
- latest openpilot changes. The master branch has submodules, which need to be updated/initialized, otherwise once you reboot your build will fail. Needs to be built on the device.git checkout master
git submodule update --init --recursive
reboot
to start build
master-ci
- latest openpilot changes, with submodules already integrated. Needs to be built on the device.git checkout master-ci
reboot
to start build
devel
devel-staging
<version_number>
- release version (tag) (e.g.v0.8.7
,v0.7.3
). Use this to downgrade to an older release version, should not need to be built on the devicegit checkout v0.8.7
- If the checkout aborts due to overwrites, first deinitialize the modules then run
checkout
git submodule deinit --all -f
- If the checkout aborts due to overwrites, first deinitialize the modules then run
reboot
needed if<version_number>
uses older version of OS (will prompt for OS update on device after reboot)
3. (Optional) Monitor build process after reboot
For branches that need to be built, you can monitoring the building process by SSH'ing into your comma right after reboot and typing tmux a
Developer Notes
When switching between branches, if the version of cereal or some other submodule has changed between the branches, you may encounter errors including the "communication between processes" issue. To reinitialize the submodules after you checkout a new branch run the following commands:
git submodule deinit --all -f
git submodule init
git submodule update