diff --git a/.github/actions/deploy-action/action.yml b/.github/actions/deploy-action/action.yml index 6b2e578f17..ac777a7daf 100644 --- a/.github/actions/deploy-action/action.yml +++ b/.github/actions/deploy-action/action.yml @@ -1,5 +1,5 @@ name: Deploy via Bastion Host -description: "Deploy specified files and directories to a server via a bastion host" +description: "Deploy specified files and directories to a primary and secondary server via a bastion host" inputs: private_ssh_key: description: "The private SSH key used to authenticate with the remote servers" @@ -13,8 +13,12 @@ inputs: description: "The [user@]hostname of the bastion server" required: true - host: - description: "The [user@]hostname of the web server" + primary_host: + description: "The [user@]hostname of the primary web server" + required: true + + secondary_host: + description: "The [user@]hostname of the secondary web server" required: true source: @@ -45,6 +49,10 @@ runs: chmod 600 ~/.ssh/known_hosts shell: bash - - name: rsync source to destination - run: rsync -avz --delete -e 'ssh -A ${{ inputs.bastion_host }} ssh' ${{ inputs.source }} ${{ inputs.host }}:${{ inputs.destination }} + - name: Deploy to primary server + run: rsync -avz --delete -e 'ssh -A ${{ inputs.bastion_host }} ssh' ${{ inputs.source }} ${{ inputs.primary_host }}:${{ inputs.destination }} + shell: bash + + - name: Deploy to secondary server + run: rsync -avz --delete -e 'ssh -A ${{ inputs.bastion_host }} ssh' ${{ inputs.source }} ${{ inputs.secondary_host }}:${{ inputs.destination }} shell: bash diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6d6fb3ff31..4d1565e612 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,13 @@ updates: schedule: interval: "weekly" target-branch: "develop" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + target-branch: "develop" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + target-branch: "develop" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70221f0a02..a81b5f78cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,45 @@ name: Build -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Only allow pull requests based on master from the develop branch of the current repository + if: ${{ github.base_ref == 'master' && !(github.head_ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository) }} + run: | + echo "Pull requests based on master can only come from the develop branch of this repository" + echo "Please check your base branch as it should be develop by default" + exit 1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 + - name: Install Python dependencies + uses: py-actions/py-dependency-install@v4 + - name: Install Python libs + run: pip3 install -r ./requirements.txt - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - - uses: seanmiddleditch/gha-setup-ninja@v3 + - uses: seanmiddleditch/gha-setup-ninja@v6 with: version: 1.10.2 + - name: Install arm-none-eabi-gcc GNU Arm Embedded Toolchain + uses: carlosperate/arm-none-eabi-gcc-action@v1.10.1 + - name: Install Doxygen + run: | + wget https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz + tar xf doxygen-1.10.0.linux.bin.tar.gz -C "$HOME" + echo "$HOME/doxygen-1.10.0/bin" >> $GITHUB_PATH + - name: Build Doxygen documentation + run: make build_doxygen_adoc - name: Build documentation run: make -j 2 - name: Deploy to Mythic Beasts @@ -26,7 +49,8 @@ jobs: private_ssh_key: ${{ secrets.DEPLOY_SSH_KEY }} public_bastion_host_keys: ${{ secrets.DEPLOY_KNOWN_HOSTS }} bastion_host: ${{ secrets.DEPLOY_BASTION_HOST }} - host: ${{ secrets.DEPLOY_HOST }} + primary_host: ${{ secrets.DEPLOY_PRIMARY_HOST }} + secondary_host: ${{ secrets.DEPLOY_SECONDARY_HOST }} # this needs to match destination: in _config.yml source: documentation/html/ destination: documentation diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..9ffb99cfcc --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,26 @@ +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '15 2 * * SUN' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v9 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' + stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' + stale-issue-label: 'stale issue' + stale-pr-label: 'stale pull request' + exempt-issue-labels: 'ready to merge,ready for copy-edit,paused,in progress,linked pull request,backlog' + exempt-pr-labels: 'ready to merge,ready for copy-edit,paused,in progress,backlog' + days-before-stale: 60 + days-before-close: 7 diff --git a/.gitignore b/.gitignore index 9fe563d56a..1d7ee958d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store __pycache__ build +build-pico-sdk-docs documentation/html -.sass-cache +documentation/asciidoc/pico-sdk +.venv diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..9f315972ef --- /dev/null +++ b/.gitmodules @@ -0,0 +1,13 @@ +[submodule "documentation/pico-sdk"] + path = lib/pico-sdk + url = https://github.com/raspberrypi/pico-sdk + branch = master +[submodule "documentation/pico-examples"] + path = lib/pico-examples + url = https://github.com/raspberrypi/pico-examples.git + branch = master + +[submodule "doxygentoasciidoc"] + path = lib/doxygentoasciidoc + url = https://github.com/raspberrypi/doxygentoasciidoc.git + branch = main diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000000..2d5ac2c6e3 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,103 @@ +# Making the documentation + +A brief overview of the files in this repo, and the make-targets in the `Makefile`, and how it all hangs together to build the final output html files from the initial adoc input files. + +**TL;DR version**: To build the 'regular' documentation site, run `make clean; make`. To build the documentation site with pico-sdk API docs included, run `make clean; make build_doxygen_adoc; make`. + +## Files in the repo + +* `documentation/asciidoc/` all our "regular" asciidoc documentation (referred to as `$(ASCIIDOC_DIR)` in the `Makefile`) +* `documentation/images/` the images shown on the "boxes" +* `documentation/pico-sdk/` [pico-sdk](https://github.com/raspberrypi/pico-sdk) submodule (initially empty) (referred to as `$(PICO_SDK_DIR)` in the `Makefile`) +* `documentation/pico-examples/` [pico-examples](https://github.com/raspberrypi/pico-examples) submodule (initially empty) (referred to as `$(PICO_EXAMPLES_DIR)` in the `Makefile`) +* `jekyll-assets/` various styling stuff used by the jekyll build (referred to as `$(JEKYLL_ASSETS_DIR)` in the `Makefile`) +* `scripts/` various Python build-scripts (referred to as `$(SCRIPTS_DIR)` in the `Makefile`) +* `Makefile` top-level Makefile that runs the build + +## When you clone the repo and run `make` + +1. `.DEFAULT_GOAL := html` is set in the `Makefile`, which means that `make` actually does `make html`. + 1. The `html` target has the `run_ninja` target as a prerequisite + 1. The `run_ninja` target has `$(AUTO_NINJABUILD)` (i.e. `build/autogenerated.ninja`) as a prerequisite + 1. `build/autogenerated.ninja` has `$(BUILD_DIR)` (i.e. `build/`) as a prerequisite + 1. So the `build/` directory gets created + 1. Then `build/autogenerated.ninja` gets created + 1. Then `ninja` gets invoked, which uses `build.ninja` (which includes `build/autogenerated.ninja`) to create a whole bunch of files in the `build/` directory + 1. Then `jekyll` gets invoked, which uses all the files in the `build/` directory to create all the final output files in the `$(HTML_DIR)` (i.e. `documentation/html/`) directory + +If you run `make` a second time, then `make` and `ninja` will spot that everything is up to date, and only re-run the `jekyll` stage. + +## When you run `make clean` + +1. The `clean` target has the `clean_html` and `clean_doxygen_adoc` targets as prerequisites + 1. In this case `clean_doxygen_adoc` doesn't do anything, but `clean_html` deletes the `documentation/html/` directory +1. Then the `build/` directory is deleted + +## When you run `make build_doxygen_adoc` + +1. The `build_doxygen_adoc` target has `$(ASCIIDOC_DOXYGEN_DIR)/index_doxygen.adoc` (i.e. `documentation/asciidoc/pico-sdk/index_doxygen.adoc`) as a prerequisite + 1. `documentation/asciidoc/pico-sdk/index_doxygen.adoc` has `$(DOXYGEN_HTML_DIR)` (i.e. `build-pico-sdk-docs/docs/doxygen/html/`) and `$(ASCIIDOC_DOXYGEN_DIR)` (i.e. `documentation/asciidoc/pico-sdk/`) as prerequisites + 1. So the `documentation/asciidoc/pico-sdk/` directory gets created + 1. `build-pico-sdk-docs/docs/doxygen/html/` has `$(ALL_SUBMODULE_CMAKELISTS)` (i.e. `documentation/pico-sdk/CMakeLists.txt` and `documentation/pico-examples/CMakeLists.txt`) and `$(DOXYGEN_PICO_SDK_BUILD_DIR)` (i.e. `build-pico-sdk-docs/`) as prerequisites + 1. So the `build-pico-sdk-docs/` directory gets created + 1. `documentation/pico-sdk/CMakeLists.txt` gets created by initialising the `pico-sdk` submodule + 1. `documentation/pico-examples/CMakeLists.txt` gets created by initialising the `pico-examples` submodule + 1. Then `cmake` gets invoked for `pico-sdk/`, which creates `build-pico-sdk-docs/Makefile` + 1. Then we run the `docs` target in `build-pico-sdk-docs/Makefile` which runs `doxygen` and creates a bunch of HTML files in `build-pico-sdk-docs/docs/doxygen/html/` (referred to as `$(DOXYGEN_HTML_DIR)` in the `Makefile`) +1. Then we run the new `scripts/transform_doxygen_html.py` to convert the HTML files from `build-pico-sdk-docs/docs/doxygen/html/` into adoc files in `documentation/asciidoc/pico-sdk/` + +If you run `make build_doxygen_adoc` a second time, then `make` will detect that everything is already up to date, and so not do anything. + +If we **now** run `make` (see the `make html` description above), it will now find `documentation/asciidoc/pico-sdk/` and include that in the "tabs" in the output html files in `documentation/html/`. + +And if we then run a `make clean`, the presence of `documentation/asciidoc/pico-sdk/` will cause the `clean_doxygen_adoc` target to delete the files in the `build/` directory (to prevent things getting into an "invalid state"), and then delete the `documentation/asciidoc/pico-sdk/` directory. +Note that `build-pico-sdk-docs/` (the raw Doxygen output) **isn't** deleted by `make clean`, because it's basically "static content" which can take a while to regenerate. To _also_ get rid of `build-pico-sdk-docs/` you can either `make clean_doxygen_html` or `make clean_everything` (with the latter also deinitialising the submodules). + +## Makefile targets + +Targets which might be useful for getting things to / from a particular state. + +* `make fetch_submodules` populates (initialises) the `documentation/pico-sdk/` and `documentation/pico-examples/` submodule directories +* `make clean_submodules` deinitialises the submodule directories, i.e. is the opposite of `fetch_submodules` +* `make build_doxygen_html` runs the `cmake` and `make` steps required to create the Doxygen HTML files (in `build-pico-sdk-docs/docs/doxygen/html/`) from the `pico-sdk` submodule +* `make clean_doxygen_html` deletes the `build-pico-sdk-docs/` directory i.e. is the opposite of `build_doxygen_html` +* `make build_doxygen_adoc` described in an earlier section, converts html files from `build-pico-sdk-docs/docs/doxygen/html/` to adoc files in `documentation/asciidoc/pico-sdk/` +* `make clean_doxygen_adoc` deletes the `documentation/asciidoc/pico-sdk/` directory i.e. is the opposite of `build_doxygen_adoc` +* `make run_ninja` converts adoc files from `documentation/asciidoc/` into adoc files in `build/` +* `make clean_ninja` deletes the files in `build/` i.e. is the opposite of `run_ninja` +* `make html` described in an earlier section, converts adoc files from `build/` into html files in `documentation/html/`. The default target invoked when no explicit target is given. +* `make clean_html` deletes the `documentation/html/` directory, i.e. is the opposite of `html` +* `make serve_html` converts adoc files from `build/` into html files in `documentation/html/` and then runs a mini webserver so that you can preview the output +* `make clean` runs both of `clean_html` & `clean_doxygen_adoc` and also deletes `build/` +* `make clean_everything` runs all of `clean_submodules`, `clean_doxygen_html` and `clean` i.e. returns your local directory to a fairly pristine state + +Note that for day-to-day usage, you'll typically only use the `make clean`, `make`, `make build_doxygen_adoc` and `make serve_html` commands - the dependencies in the `Makefile` are all set up so that any necessary intermediate steps are performed automatically. + +Bad ASCII-art time: + +``` ++---------------+ +| 'clean' state |--> make build_doxygen_adoc ++---------------+ | + | | ^ V + | V | +-----------------------------------------+ + | make make clean <---| documentation/asciidoc/pico-sdk/ exists | + | | ^ +-----------------------------------------+ + | | | | | + | | | V | + | V | make | + | +----------------------------+ | | + | | documentation/html/ exists |<---+ | + | +----------------------------+ | + | | ^ | + | V | | + +---> make serve_html <-----------------------+ + | | + | Ctrl-C + | ^ + V | ++----------------------------------------------------------+ +| documentation/html/ exists and preview webserver running | ++----------------------------------------------------------+ +``` + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1562c7e88..37fef6b8ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,35 +1,163 @@ -# Contributing to Raspberry Pi Documentation +# Contributing to the Raspberry Pi Documentation -Although you won't be able to directly change documentation on the official repository, you can take a look at all the source files and see how everything is arranged. The sources files and folders follow the hierarchical documentation as found on the Raspberry Pi website. +The Raspberry Pi Documentation website is built from Asciidoc source using: -In order to submit new or corrected documentation, you have to create a GitHub account (if you don't already have one) and **fork** the original repository to your account. You make changes as you see fit, save them in your repository, then make something called a **pull request** to the original Raspberry Pi repository. This pull request (**PR**) then appears in the Raspberry Pi repository where it can be assessed by the maintainers, copy edited, and, if appropriate, merged with the official repository. +* [Asciidoctor](https://asciidoctor.org/) +* [Jekyll](https://jekyllrb.com/) +* [jekyll-asciidoc](https://github.com/asciidoctor/jekyll-asciidoc) +* Python -The documentation which appears on the Raspberry Pi website is generated from the GitHub repository, and is updated approximately hourly. +The website automatically deploys to [www.raspberrypi.com/documentation](https://www.raspberrypi.com/documentation) using GitHub Actions when new commits appear in the `master` branch. -You will need a GitHub account to perform any of the following operations. +## Contribute -## Forking a repository +To contribute or update documentation: -This is easy. Go to the Raspberry Pi repository, https://github.com/raspberrypi/documentation, and look at the top right of the page. There should be a button labelled **Fork**, which will fork a copy of the repository to your own GitHub account. +1. Create a fork of this repository on your GitHub account. -## Make Changes +1. Make changes in your fork. Start from the default `develop` branch. -In your own copy of the repo, you can now alter or add files. +1. Read our [style guide](https://github.com/raspberrypi/style-guide/blob/master/style-guide.md) to ensure that your changes are consistent with the rest of our documentation. Since Raspberry Pi is a British company, be sure to include all of your extra `u`s and transfigure those `z`s (pronounced 'zeds') into `s`s! -To edit a file, first find the file in the filename tree, and click on it. This displays the page in fully rendered markup, and on the toolbar at the top of the document (not top of the page) is a small icon of a pencil. This is the edit button. Click on it and the file will appear in the Github editor. You can now edit away to your heart's content. You can click on **Preview changes** to see the fully rendered file with your edits. +1. [Open a pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against this repository. -At the end of the page is a box called **Commit Changes**. You can either commit your changes directly to your own master branch or create a new branch for use as a pull request. Use the master option, as this means you are making changes to your master copy. Using the branch option will create a new branch in your own repository, but that's a little more complicated to deal with so it won't be described here. If you are making a lot of independent changes over time before pushing the changes to Raspberry Pi, you may wish to investigate the branch option. Update the commit title and enter a description of the change at this point. +1. The maintainers will assess and copy-edit the PR. This can take anywhere from a few minutes to a few days, depending on the size of your PR, the time of year, and the availability of the maintainers. -Selecting **Commit changes** will make the change to your master branch. You now need to take that change and make a pull request from it. +1. After making any requested improvements to your PR, the maintainers will accept the PR and merge your changes into `develop`. -## Opening a Pull Request +1. When the maintainers next release the documentation by merging `develop` into `master`, your changes will go public on the production documentation site. -This is pretty easy. Click on the **Pull Requests** tab on the toolbar. Afterwards, there should be a green button just below the toolbar that is labelled **New pull request**. Click it, and a page should appear that asks you to compare changes. This PR page is actually on the Raspberry Pi GitHub page, not the contributor's, because a PR requests the Raspberry Pi repository maintainers to 'pull' from the contributor's repository. The left-hand side should be the `raspberrypi/documentation` repository, and the branch should be the master one. The right-hand side is where the PR is coming from: your GitHub account, and your master branch. Further down the page you should see a list of the commits you want to have in the PR, and, below that, the actual changes. +Alternatively, [open an issue](https://github.com/raspberrypi/documentation/issues) to discuss proposed changes. -If you are happy for the PR to be created, click on **Create pull request**. +## Build -And that's it! The Raspberry Pi documentation PR list will now have your entry in it. It will be read, assessed for technical correctness, passed to copy editors for final checking, and finally merged to the main documentation tree. +### Install dependencies +To build the Raspberry Pi documentation locally, you'll need Ruby, Python, and the Ninja build system. -This is a very quick guide to contributing via GitHub, but it will get you started and enable you to make a difference! +#### Linux + +Use `apt` to install the dependencies: + +```console +$ sudo apt install -y ruby ruby-dev python3 python3-pip make ninja-build +``` + +Then, append the following lines to your `~/.bashrc` file (or equivalent shell configuration): + +```bash +export GEM_HOME="$(ruby -e 'puts Gem.user_dir')" +export PATH="$PATH:$GEM_HOME/bin" +``` + +Close and re-launch your terminal window to use the new dependencies and configuration. + +#### macOS + +If you don't already have it, we recommend installing the [Homebrew](https://brew.sh/) package manager: + +```console +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +``` + +Next, use Homebrew to install Ruby: + +```console +$ brew install ruby +``` + +After installing Ruby, follow the instructions provided by Homebrew to make your new Ruby version easily accessible from the command line. + +Then, use Homebrew to install the most recent version of Python: + +```console +$ brew install python +``` + +Then, install the [Ninja build system](https://formulae.brew.sh/formula/ninja#default): + +```console +$ brew install ninja +``` + +### Set up environment + +Use the `gem` package manager to install the [Ruby bundler](https://bundler.io/), which this repository uses to manage Ruby dependencies: + +```console +$ gem install bundler +``` + +And then install the required Ruby gems: + +```console +$ bundle install +``` + +Configure a Python virtual environment for this project: + +```console +$ python -m venv .env +``` + +Activate the virtual environment: + +```console +$ source .env/bin/activate +``` + +> [!TIP] +> When you're using a virtual environment, you should see a `(.env)` prefix at the start of your terminal prompt. At any time, run the `deactivate` command to exit the virtual environment. + +In the virtual environment, install the required Python modules: + +```console +$ pip3 install -r requirements.txt +``` + +### Build HTML + +> [!IMPORTANT] +> If you configured a Python virtual environment as recommended in the previous step, **always** run `source .env/bin/activate` before building. You must activate the virtual environment to access to all of the Python dependencies installed in that virtual environment. + +To build the documentation and start a local server to preview the built site, run the following command: + +```console +$ make serve_html +``` + +You can access the virtual server at [http://127.0.0.1:4000/documentation/](http://127.0.0.1:4000/documentation/). + +> [!TIP] +> To delete and rebuild the documentation site, run `make clean`, then re-run the build command. You'll need to do this every time you add or remove an Asciidoc, image, or video file. + + +### Build the Pico C SDK Doxygen documentation + +The Raspberry Pi documentation site includes a section of generated Asciidoc that we build from the [Doxygen Pico SDK documentation](https://github.com/raspberrypi/pico-sdk). + +We use the tooling in this repository and [doxygentoasciidoc](https://github.com/raspberrypi/doxygentoasciidoc) to generate that documentation section. By default, local documentation builds don't include this section because it takes a bit longer to build (tens of seconds) than the rest of the site. + +Building the Pico C SDK Doxygen documentation requires the following additional package dependencies: + +```console +$ sudo apt install -y cmake gcc-arm-none-eabi doxygen graphviz +``` + +Then, initialise the Git submodules used in the Pico C SDK section build: + +```console +$ git submodule update --init +``` + +Run the following command to build the Pico C SDK section Asciidoc files from the Doxygen source: + +```console +$ make build_doxygen_adoc +``` + +The next time you build the documentation site, you'll see the Pico C SDK section in your local preview. + +> [!TIP] +> To delete and rebuild the generated files, run `make clean_doxygen_xml`, then re-run the build command. diff --git a/Gemfile b/Gemfile index 5d9a7e74af..bb73401e41 100644 --- a/Gemfile +++ b/Gemfile @@ -8,10 +8,10 @@ source "https://rubygems.org" # # This will help ensure the proper Jekyll version is running. # Happy Jekylling! -gem "jekyll", "~> 4.2.0" +gem "jekyll", "~> 4.4.1" # This is the default theme for new Jekyll sites. You may change this to anything you like. -gem "minima", "~> 2.0" +gem "minima", "~> 2.5" # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. @@ -19,8 +19,10 @@ gem "minima", "~> 2.0" # If you have any plugins, put them here! group :jekyll_plugins do - gem "jekyll-feed", "~> 0.6" + gem "jekyll-feed", "~> 0.17" gem 'jekyll-asciidoc' + gem 'asciidoctor' + gem 'asciidoctor-tabs', ">= 1.0.0.beta.6" end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem @@ -31,5 +33,10 @@ install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do end # Performance-booster for watching directories on Windows -gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform? +gem "wdm", "~> 0.2.0", :install_if => Gem.win_platform? +gem "nokogiri", "~> 1.18" + +# So we can add custom element templates +gem 'slim', '~> 5.2.1' +gem 'thread_safe', '~> 0.3.5' diff --git a/Gemfile.lock b/Gemfile.lock index 684aa374ed..385a34392c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,90 +1,122 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - asciidoctor (2.0.15) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + asciidoctor (2.0.23) + asciidoctor-tabs (1.0.0.beta.6) + asciidoctor (>= 2.0.0, < 3.0.0) + base64 (0.2.0) + bigdecimal (3.1.9) colorator (1.1.0) - concurrent-ruby (1.1.9) - em-websocket (0.5.2) + concurrent-ruby (1.3.5) + csv (3.3.2) + em-websocket (0.5.3) eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) + http_parser.rb (~> 0) eventmachine (1.2.7) - ffi (1.15.3) + ffi (1.17.1) forwardable-extended (2.6.0) - http_parser.rb (0.6.0) - i18n (1.8.10) + google-protobuf (4.29.3) + bigdecimal + rake (>= 13) + http_parser.rb (0.8.0) + i18n (1.14.7) concurrent-ruby (~> 1.0) - jekyll (4.2.0) + jekyll (4.4.1) addressable (~> 2.4) + base64 (~> 0.2) colorator (~> 1.0) + csv (~> 3.0) em-websocket (~> 0.5) i18n (~> 1.0) - jekyll-sass-converter (~> 2.0) + jekyll-sass-converter (>= 2.0, < 4.0) jekyll-watch (~> 2.0) - kramdown (~> 2.3) + json (~> 2.6) + kramdown (~> 2.3, >= 2.3.1) kramdown-parser-gfm (~> 1.0) liquid (~> 4.0) - mercenary (~> 0.4.0) + mercenary (~> 0.3, >= 0.3.6) pathutil (~> 0.9) - rouge (~> 3.0) + rouge (>= 3.0, < 5.0) safe_yaml (~> 1.0) - terminal-table (~> 2.0) - jekyll-asciidoc (3.0.0) - asciidoctor (>= 1.5.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-asciidoc (3.0.1) + asciidoctor (>= 1.5.0, < 3.0.0) jekyll (>= 3.0.0) - jekyll-feed (0.15.1) + jekyll-feed (0.17.0) jekyll (>= 3.7, < 5.0) - jekyll-sass-converter (2.1.0) - sassc (> 2.0.1, < 3.0) - jekyll-seo-tag (2.7.1) + jekyll-sass-converter (3.1.0) + sass-embedded (~> 1.75) + jekyll-seo-tag (2.8.0) jekyll (>= 3.8, < 5.0) jekyll-watch (2.2.1) listen (~> 3.0) - kramdown (2.3.1) - rexml + json (2.9.1) + kramdown (2.5.1) + rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - liquid (4.0.3) - listen (3.5.1) + liquid (4.0.4) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.4.0) - minima (2.5.1) + mini_portile2 (2.8.8) + minima (2.5.2) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) + nokogiri (1.18.8) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (4.0.6) - rb-fsevent (0.11.0) - rb-inotify (0.10.1) + public_suffix (6.0.1) + racc (1.8.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.2.5) - rouge (3.26.0) + rexml (3.4.0) + rouge (4.5.1) safe_yaml (1.0.5) - sassc (2.4.0) - ffi (~> 1.9) - terminal-table (2.0.0) - unicode-display_width (~> 1.1, >= 1.1.1) - tzinfo (2.0.4) + sass-embedded (1.83.4) + google-protobuf (~> 4.29) + rake (>= 13) + slim (5.2.1) + temple (~> 0.10.0) + tilt (>= 2.1.0) + temple (0.10.3) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + thread_safe (0.3.6) + tilt (2.3.0) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2021.1) + tzinfo-data (1.2025.2) tzinfo (>= 1.0.0) - unicode-display_width (1.7.0) - wdm (0.1.1) + unicode-display_width (2.6.0) + wdm (0.2.0) + webrick (1.9.1) PLATFORMS ruby DEPENDENCIES - jekyll (~> 4.2.0) + asciidoctor + asciidoctor-tabs (>= 1.0.0.beta.6) + jekyll (~> 4.4.1) jekyll-asciidoc - jekyll-feed (~> 0.6) - minima (~> 2.0) + jekyll-feed (~> 0.17) + minima (~> 2.5) + nokogiri (~> 1.18) + slim (~> 5.2.1) + thread_safe (~> 0.3.5) tzinfo (~> 2.0) tzinfo-data - wdm (~> 0.1.0) + wdm (~> 0.2.0) BUNDLED WITH - 2.2.15 + 2.3.22 diff --git a/LICENSE.md b/LICENSE.md index 3cb65d4914..4b2db9cd3d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -4,7 +4,7 @@ The Raspberry Pi documentation is licensed under a [Creative Commons Attribution # Creative Commons Attribution-ShareAlike 4.0 International -Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. +Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. ### Using Creative Commons Public Licenses @@ -12,7 +12,7 @@ Creative Commons public licenses provide a standard set of terms and conditions * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). -* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). +* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). ## Creative Commons Attribution-ShareAlike 4.0 International Public License @@ -66,7 +66,7 @@ a. ___License grant.___ A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. - B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. + B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply. C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. @@ -112,7 +112,7 @@ b. ___ShareAlike.___ In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. -1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. +1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. @@ -170,6 +170,6 @@ c. No term or condition of this Public License will be waived and no failure to d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. -> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. > > Creative Commons may be contacted at creativecommons.org. \ No newline at end of file diff --git a/Makefile b/Makefile index db9e2751cb..711219f453 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,125 @@ -# The top-level Makefile which does things by calling rules in other makefiles +# The top-level Makefile which builds everything -# these need to be done in a specific order, which is why they're rules rather than simply being listed as prerequisites -all: - $(MAKE) jekyll - $(MAKE) html +ASCIIDOC_DIR = documentation/asciidoc +HTML_DIR = documentation/html +IMAGES_DIR = documentation/images +JEKYLL_ASSETS_DIR = jekyll-assets +SCRIPTS_DIR = scripts +DOCUMENTATION_REDIRECTS_DIR = documentation/redirects +DOCUMENTATION_INDEX = documentation/index.json +SITE_CONFIG = _config.yml -clean: - $(MAKE) clean_html - $(MAKE) clean_jekyll - rm -rf build +BUILD_DIR = build +ASCIIDOC_BUILD_DIR = $(BUILD_DIR)/jekyll +ASCIIDOC_INCLUDES_DIR = $(BUILD_DIR)/adoc_includes +AUTO_NINJABUILD = $(BUILD_DIR)/autogenerated.ninja -.PHONY: all clean jekyll clean_jekyll invalidate_jekyll update_offline_includes html clean_html invalidate_html serve_html +PICO_SDK_DIR = lib/pico-sdk +PICO_EXAMPLES_DIR = lib/pico-examples +DOXYGEN_TO_ASCIIDOC_DIR = lib/doxygentoasciidoc +ALL_SUBMODULE_CMAKELISTS = $(PICO_SDK_DIR)/CMakeLists.txt $(PICO_EXAMPLES_DIR)/CMakeLists.txt +DOXYGEN_PICO_SDK_BUILD_DIR = build-pico-sdk-docs +DOXYGEN_XML_DIR = $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined/docs/doxygen/xml +# The pico-sdk here needs to match up with the "from_json" entry in index.json +ASCIIDOC_DOXYGEN_DIR = $(ASCIIDOC_DIR)/pico-sdk -# Copy all needed files to the build/jekyll folder -jekyll: - $(MAKE) -f makefiles/jekyll.mk all +JEKYLL_CMD = bundle exec jekyll -# Delete the build/jekyll directory -clean_jekyll: - $(MAKE) -f makefiles/jekyll.mk clean +.DEFAULT_GOAL := html -# Tell the build/jekyll directory that some of its source-files might have changed -invalidate_jekyll: - $(MAKE) -f makefiles/jekyll.mk invalidate +.PHONY: clean run_ninja clean_ninja html serve_html clean_html build_doxygen_xml clean_doxygen_xml build_doxygen_adoc clean_doxygen_adoc fetch_submodules clean_submodules clean_everything -# Update the files in the offline_includes directory -update_offline_includes: - $(MAKE) -f makefiles/jekyll.mk $@ +$(BUILD_DIR): + @mkdir -p $@ -# Convert asciidoc files to html files -html: - $(MAKE) -f makefiles/html.mk all +$(DOXYGEN_PICO_SDK_BUILD_DIR): + mkdir $@ -# Delete the documentation/html directory -clean_html: - $(MAKE) -f makefiles/html.mk clean +$(ASCIIDOC_DOXYGEN_DIR): | $(ASCIIDOC_DIR) + mkdir $@ + +# Delete all autogenerated files +clean: clean_html clean_doxygen_adoc + rm -rf $(BUILD_DIR) + +# Initialise pico-sdk submodule (and the subnmodules that it uses) +$(PICO_SDK_DIR)/CMakeLists.txt $(PICO_SDK_DIR)/docs/index.h: | $(PICO_SDK_DIR) + git submodule update --init $(PICO_SDK_DIR) + git -C $(PICO_SDK_DIR) submodule update --init + +# Initialise pico-examples submodule +$(PICO_EXAMPLES_DIR)/CMakeLists.txt: | $(PICO_SDK_DIR)/CMakeLists.txt $(PICO_EXAMPLES_DIR) + git submodule update --init $(PICO_EXAMPLES_DIR) + +# Initialise doxygentoasciidoc submodule +$(DOXYGEN_TO_ASCIIDOC_DIR)/__main__.py: + git submodule update --init $(DOXYGEN_TO_ASCIIDOC_DIR) + +fetch_submodules: $(ALL_SUBMODULE_CMAKELISTS) $(DOXYGEN_TO_ASCIIDOC_DIR)/__main__.py + +# Get rid of the submodules +clean_submodules: + git submodule deinit --all + +# Create the pico-sdk Doxygen XML files +$(DOXYGEN_XML_DIR) $(DOXYGEN_XML_DIR)/index.xml: | $(ALL_SUBMODULE_CMAKELISTS) $(DOXYGEN_PICO_SDK_BUILD_DIR) + cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_NO_PICOTOOL=1 -D PICO_PLATFORM=combined-docs + cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2040 -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_NO_PICOTOOL=1 -D PICO_PLATFORM=rp2040 + cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2350 -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_NO_PICOTOOL=1 -D PICO_PLATFORM=rp2350 + $(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined docs + $(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2040 docs + $(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2350 docs + python3 $(SCRIPTS_DIR)/postprocess_doxygen_xml.py $(DOXYGEN_PICO_SDK_BUILD_DIR) + +$(DOXYGEN_PICO_SDK_BUILD_DIR)/combined/docs/Doxyfile: | $(DOXYGEN_XML_DIR) + +build_doxygen_xml: | $(DOXYGEN_XML_DIR) -# Tell the documentation/html directory that some of its source-files might have changed -invalidate_html: - $(MAKE) -f makefiles/html.mk invalidate +# Clean all the Doxygen HTML files +clean_doxygen_xml: + rm -rf $(DOXYGEN_PICO_SDK_BUILD_DIR) -# Serve the html directory with Jekyll -serve_html: - $(MAKE) -f makefiles/html.mk serve +# create the sdk adoc and the json file +$(ASCIIDOC_DOXYGEN_DIR)/picosdk_index.json $(ASCIIDOC_DOXYGEN_DIR)/index_doxygen.adoc: $(ASCIIDOC_DOXYGEN_DIR) $(DOXYGEN_XML_DIR)/index.xml $(DOXYGEN_TO_ASCIIDOC_DIR)/__main__.py $(DOXYGEN_TO_ASCIIDOC_DIR)/cli.py $(DOXYGEN_TO_ASCIIDOC_DIR)/nodes.py $(DOXYGEN_TO_ASCIIDOC_DIR)/helpers.py | $(BUILD_DIR) $(DOXYGEN_TO_ASCIIDOC_DIR)/requirements.txt + $(MAKE) clean_ninja + pip3 install -r $(DOXYGEN_TO_ASCIIDOC_DIR)/requirements.txt + PYTHONPATH=$(DOXYGEN_TO_ASCIIDOC_DIR)/.. python3 -m doxygentoasciidoc -o $(ASCIIDOC_DOXYGEN_DIR)/all_groups.adoc $(DOXYGEN_XML_DIR)/index.xml + PYTHONPATH=$(DOXYGEN_TO_ASCIIDOC_DIR)/.. python3 -m doxygentoasciidoc -c -o $(ASCIIDOC_DOXYGEN_DIR)/index_doxygen.adoc $(DOXYGEN_XML_DIR)/indexpage.xml + PYTHONPATH=$(DOXYGEN_TO_ASCIIDOC_DIR)/.. python3 -m doxygentoasciidoc -c -o $(ASCIIDOC_DOXYGEN_DIR)/examples_page.adoc $(DOXYGEN_XML_DIR)/examples_page.xml + python3 $(SCRIPTS_DIR)/postprocess_doxygen_adoc.py $(ASCIIDOC_DOXYGEN_DIR) + -cp $(DOXYGEN_XML_DIR)/*.png $(ASCIIDOC_DOXYGEN_DIR) 2>/dev/null || true +build_doxygen_adoc: $(ASCIIDOC_DOXYGEN_DIR)/index_doxygen.adoc + +# Clean all the Doxygen asciidoc files +clean_doxygen_adoc: + if [ -d $(ASCIIDOC_DOXYGEN_DIR) ]; then $(MAKE) clean_ninja; fi + rm -rf $(ASCIIDOC_DOXYGEN_DIR) + +clean_everything: clean_submodules clean_doxygen_xml clean + +# AUTO_NINJABUILD contains all the parts of the ninjabuild where the rules themselves depend on other files +$(AUTO_NINJABUILD): $(SCRIPTS_DIR)/create_auto_ninjabuild.py $(DOCUMENTATION_INDEX) $(SITE_CONFIG) | $(BUILD_DIR) + $< $(DOCUMENTATION_INDEX) $(SITE_CONFIG) $(ASCIIDOC_DIR) $(SCRIPTS_DIR) $(ASCIIDOC_BUILD_DIR) $(ASCIIDOC_INCLUDES_DIR) $(JEKYLL_ASSETS_DIR) $(DOXYGEN_PICO_SDK_BUILD_DIR) $(DOCUMENTATION_REDIRECTS_DIR) $(IMAGES_DIR) $@ + +# This runs ninjabuild to build everything in the ASCIIDOC_BUILD_DIR (and ASCIIDOC_INCLUDES_DIR) +run_ninja: $(AUTO_NINJABUILD) + ninja + +# Delete all the files created by the 'run_ninja' target +clean_ninja: + rm -rf $(ASCIIDOC_BUILD_DIR) + rm -rf $(ASCIIDOC_INCLUDES_DIR) + rm -f $(AUTO_NINJABUILD) + +# Build the html output files +html: run_ninja + $(JEKYLL_CMD) build + +# Build the html output files and additionally run a small webserver for local previews +serve_html: run_ninja + $(JEKYLL_CMD) serve --watch + +# Delete all the files created by the 'html' target +clean_html: + rm -rf $(HTML_DIR) diff --git a/README.md b/README.md index cbb7f83167..69df3a28f8 100644 --- a/README.md +++ b/README.md @@ -1,101 +1,22 @@ -# README +
+ + + + Raspberry Pi: computers and microcontrollers + -Instructions on how to checkout the `documentation` repo, and then install the toolchain needed to convert from Asciidoc to HTML and build the documentation site. +[Website][Raspberry Pi] | [Getting started] | [Documentation] | [Contribute] +
-## Checking out the repository +This repository contains the source and tools used to build the [Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/). -Install `git` if you don't already have it, and check out the `documentation` repo as follows, -``` -$ git clone https://github.com/raspberrypi/documentation.git -$ cd documentation -``` +[Raspberry Pi]: https://www.raspberrypi.com/ +[Getting Started]: https://www.raspberrypi.com/documentation/computers/getting-started.html +[Documentation]: https://www.raspberrypi.com/documentation/ +[Contribute]: CONTRIBUTING.md -## Installing the toolchain +## Licence -### On Linux - -You can install the necessary dependencies on Liunux as follows, - -``` -$ sudo apt-get -qq -y install ruby ruby-bundler ruby-dev build-essential python3 git ninja-build -``` - -This works on both regular Ubuntu Linux — and has been tested in a minimal Docker container — and also under Raspberry Pi OS if you are working from a Raspberry Pi. - -### On macOS - -If you don't already have it installed you should go ahead and install [HomeBrew](https://brew.sh/), - -``` -$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" -``` - -Then you need to install Ruby, - -``` -$ brew install ruby@2.7 -``` - -**NOTE:** Homebrew defaults to Ruby 3.0 which is incompatible with Asciidoctor. - -#### Set up Homebrew version of Ruby - -If you're using `csh` or `tcsh` add the following lines to your `.cshrc` or `.tcshrc`, - -``` -setenv PATH /usr/local/opt/ruby/bin:${PATH} -setenv PATH ${PATH}:/usr/local/lib/ruby/gems/2.7.0/bin -setenv LDFLAGS -L/usr/local/opt/ruby@2.7/lib -setenv CPPFLAGS -I/usr/local/opt/ruby@2.7/include -setenv PKG_CONFIG_PATH /usr/local/opt/ruby@2.7/lib/pkgconfig -``` - -or if you're using `bash` add the following lines to your `.bash_profile`, - -``` -export PATH="/usr/local/opt/ruby/bin:$PATH" -export PATH="$PATH:/usr/local/lib/ruby/gems/2.7.0/bin" -export PATH="/usr/local/opt/ruby@2.7/bin:$PATH" -export LDFLAGS="-L/usr/local/opt/ruby@2.7/lib" -export CPPFLAGS="-I/usr/local/opt/ruby@2.7/include" -export PKG_CONFIG_PATH="/usr/local/opt/ruby@2.7/lib/pkgconfig" -``` - -#### Install dependencies - -Go ahead and `brew install` the other dependencies, - -``` -$ brew install python@3 -$ brew install ninja -``` - -## Configuring the repository - -After you've installed the toolchain, you'll need to install the required Ruby gems. Make sure you're in the `documentation` directory and then run, -``` -$ bundle install -``` - -## Building the documentation - -After you've installed the toolchain and configured the repository you can build the documentation with, - -``` -$ make -``` - -This will automatically convert the `build/jekyll/` files to HTML and put them into `documentation/html/`. - -You can also start a local server to view the compiled site by running, -``` -$ make serve_html -``` - -As the local server launches, the local URL will be printed in the terminal -- open this URL in a browser to see the locally-built site. - -To build without an active internet connection, run -``` -$ OFFLINE_MODE=1 make -``` -which will copy the `fonts.html` and `header.html` files from `offline_includes` (instead of downloading them from esi.raspberrypi.org). +The Raspberry Pi documentation is [licensed](https://github.com/raspberrypi/documentation/blob/develop/LICENSE.md) under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA). Documentation tools (everything outside of the `documentation/` subdirectory) are licensed under the [BSD 3-Clause](https://opensource.org/licenses/BSD-3-Clause) licence. diff --git a/_config.yml b/_config.yml index af6e8d492b..4d740515b5 100644 --- a/_config.yml +++ b/_config.yml @@ -17,24 +17,31 @@ title: Raspberry Pi Documentation description: >- # this means to ignore newlines until "baseurl:" Raspberry Pi Documentation. baseurl: "/documentation" # the subpath of your site, e.g. /blog -url: "" # the base hostname & protocol for your site, e.g. http://example.com +url: "https://www.raspberrypi.com/documentation" # the base hostname & protocol for your site, e.g. http://example.com githuburl: "https://github.com/raspberrypi/documentation/" +mainsite: https://raspberrypi.com/ githubbranch: master +githubbranch_edit: develop # Build settings theme: minima plugins: + - asciidoctor-tabs - jekyll-asciidoc - jekyll-feed -# this corresponds to ASCIIDOC_BUILD_DIR in makefiles/shared.mk +# this corresponds to ASCIIDOC_BUILD_DIR in Makefile source: build/jekyll -# this corresponds to HTML_DIR in makefiles/shared_vars.txt +# this corresponds to HTML_DIR in Makefile destination: documentation/html sass: sass_dir: css + quiet_deps: true + +asciidoctor: + template_dir: build/jekyll/_templates # Exclude from processing. # The following items will not be processed, by default. Create a custom list diff --git a/build.ninja b/build.ninja new file mode 100644 index 0000000000..56acd19aef --- /dev/null +++ b/build.ninja @@ -0,0 +1,52 @@ +# All the static (non-changing) parts of the ninjabuild + +# These uppercase variables are used in autogenerated.ninja +DOCUMENTATION_IMAGES_DIR = documentation/images +GITHUB_EDIT_TEMPLATE = jekyll-assets/_includes/github_edit.adoc +HTACCESS_EXTRA = documentation/htaccess_extra.txt +DOXYGEN_PICOSDK_INDEX_JSON = documentation/asciidoc/pico-sdk/picosdk_index.json + +# this corresponds to BUILD_DIR in Makefile +builddir = build + +rule copy + command = cp $in $out + +rule create_categories_page + command = echo "---\nlayout: boxes\n---\n:doctitle: $title" > $out + +rule create_toc + command = $scripts_dir/create_nav.py $in $src_dir $out + +rule create_output_supplemental_data + command = $scripts_dir/create_output_supplemental_data.py $in $out + +rule create_build_adoc + command = $scripts_dir/create_build_adoc.py $documentation_index $site_config $GITHUB_EDIT_TEMPLATE $in $inc_dir $out + +rule create_build_adoc_doxygen + command = $scripts_dir/create_build_adoc_doxygen.py $documentation_index $site_config $in $DOXYGEN_PICOSDK_INDEX_JSON $out_dir $out + +rule create_build_adoc_include + command = $scripts_dir/create_build_adoc_include.py $site_config $GITHUB_EDIT_TEMPLATE $in $out + +rule create_htaccess + command = $scripts_dir/create_htaccess.py $in $redirects_dir $out + +rule create_index_json + command = $scripts_dir/create_output_index_json.py $in $out $src_dir $DOCUMENTATION_IMAGES_DIR + +rule create_edit_warning + command = echo "Do not edit any files in this directory. Everything will get overwritten when you run 'make'" > $out + +# created (as AUTO_NINJABUILD) in Makefile before invoking ninja +include $builddir/autogenerated.ninja + +build $out_dir/_data/index.json: create_index_json $documentation_index | $scripts_dir/create_output_index_json.py +default $out_dir/_data/index.json + +build $out_dir/images/opensocial.png: copy $DOCUMENTATION_IMAGES_DIR/opensocial.png +default $out_dir/images/opensocial.png + +build $out_dir/DO_NOT_EDIT.txt: create_edit_warning +default $out_dir/DO_NOT_EDIT.txt diff --git a/documentation/asciidoc/accessories/ai-camera.adoc b/documentation/asciidoc/accessories/ai-camera.adoc new file mode 100644 index 0000000000..55d35cba57 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera.adoc @@ -0,0 +1,7 @@ +include::ai-camera/about.adoc[] + +include::ai-camera/getting-started.adoc[] + +include::ai-camera/details.adoc[] + +include::ai-camera/model-conversion.adoc[] diff --git a/documentation/asciidoc/accessories/ai-camera/about.adoc b/documentation/asciidoc/accessories/ai-camera/about.adoc new file mode 100644 index 0000000000..927fcf19ab --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/about.adoc @@ -0,0 +1,9 @@ +[[ai-camera]] +== About + +The Raspberry Pi AI Camera uses the Sony IMX500 imaging sensor to provide low-latency, high-performance AI capabilities to any camera application. Tight integration with xref:../computers/camera_software.adoc[Raspberry Pi's camera software stack] allows users to deploy their own neural network models with minimal effort. + +image::images/ai-camera.png[The Raspberry Pi AI Camera] + +This section demonstrates how to run either a pre-packaged or custom neural network model on the camera. Additionally, this section includes the steps required to interpret inference data generated by neural networks running on the IMX500 in https://github.com/raspberrypi/rpicam-apps[`rpicam-apps`] and https://github.com/raspberrypi/picamera2[Picamera2]. + diff --git a/documentation/asciidoc/accessories/ai-camera/details.adoc b/documentation/asciidoc/accessories/ai-camera/details.adoc new file mode 100644 index 0000000000..e640f289c9 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/details.adoc @@ -0,0 +1,262 @@ + +== Under the hood + +=== Overview + +The Raspberry Pi AI Camera works differently from traditional AI-based camera image processing systems, as shown in the diagram below: + +image::images/imx500-comparison.svg[Traditional versus IMX500 AI camera systems] + +The left side demonstrates the architecture of a traditional AI camera system. In such a system, the camera delivers images to the Raspberry Pi. The Raspberry Pi processes the images and then performs AI inference. Traditional systems may use external AI accelerators (as shown) or rely exclusively on the CPU. + +The right side demonstrates the architecture of a system that uses IMX500. The camera module contains a small Image Signal Processor (ISP) which turns the raw camera image data into an **input tensor**. The camera module sends this tensor directly into the AI accelerator within the camera, which produces **output tensors** that contain the inferencing results. The AI accelerator sends these tensors to the Raspberry Pi. There is no need for an external accelerator, nor for the Raspberry Pi to run neural network software on the CPU. + +To fully understand this system, familiarise yourself with the following concepts: + +Input Tensor:: The part of the sensor image passed to the AI engine for inferencing. Produced by a small on-board ISP which also crops and scales the camera image to the dimensions expected by the neural network that has been loaded. The input tensor is not normally made available to applications, though it is possible to access it for debugging purposes. + +Region of Interest (ROI):: Specifies exactly which part of the sensor image is cropped out before being rescaled to the size demanded by the neural network. Can be queried and set by an application. The units used are always pixels in the full resolution sensor output. The default ROI setting uses the full image received from the sensor, cropping no data. + +Output Tensors:: The results of inferencing performed by the neural network. The precise number and shape of the outputs depend on the neural network. Application code must understand how to handle the tensors. + +=== System architecture + +The diagram below shows the various camera software components (in green) used during our imaging/inference use case with the Raspberry Pi AI Camera module hardware (in red): + +image::images/imx500-block-diagram.svg[IMX500 block diagram] + +At startup, the IMX500 sensor module loads firmware to run a particular neural network model. During streaming, the IMX500 generates _both_ an image stream and an inference stream. This inference stream holds the inputs and outputs of the neural network model, also known as input/output **tensors**. + +=== Device drivers + +At the lowest level, the the IMX500 sensor kernel driver configures the camera module over the I2C bus. The CSI2 driver (`CFE` on Pi 5, `Unicam` on all other Pi platforms) sets up the receiver to write the image data stream into a frame buffer, together with the embedded data and inference data streams into another buffer in memory. + +The firmware files also transfer over the I2C bus wires. On most devices, this uses the standard I2C protocol, but Raspberry Pi 5 uses a custom high speed protocol. The RP2040 SPI driver in the kernel handles firmware file transfer, since the transfer uses the RP2040 microcontroller. The microcontroller bridges the I2C transfers from the kernel to the IMX500 via a SPI bus. Additionally, the RP2040 caches firmware files in on-board storage. This avoids the need to transfer entire firmware blobs over the I2C bus, significantly speeding up firmware loading for firmware you've already used. + +=== `libcamera` + +Once `libcamera` dequeues the image and inference data buffers from the kernel, the IMX500 specific `cam-helper` library (part of the Raspberry Pi IPA within `libcamera`) parses the inference buffer to access the input/output tensors. These tensors are packaged as Raspberry Pi vendor-specific https://libcamera.org/api-html/namespacelibcamera_1_1controls.html[`libcamera` controls]. `libcamera` returns the following controls: + +[%header,cols="a,a"] +|=== +| Control +| Description + +| `CnnOutputTensor` +| Floating point array storing the output tensors. + +| `CnnInputTensor` +| Floating point array storing the input tensor. + +| `CnnOutputTensorInfo` +| Network specific parameters describing the output tensors' structure: + +[source,c] +---- +struct OutputTensorInfo { + uint32_t tensorDataNum; + uint32_t numDimensions; + uint16_t size[MaxNumDimensions]; +}; + +struct CnnOutputTensorInfo { + char networkName[NetworkNameLen]; + uint32_t numTensors; + OutputTensorInfo info[MaxNumTensors]; +}; +---- + +| `CnnInputTensorInfo` +| Network specific parameters describing the input tensor's structure: + +[source,c] +---- +struct CnnInputTensorInfo { + char networkName[NetworkNameLen]; + uint32_t width; + uint32_t height; + uint32_t numChannels; +}; +---- + +|=== + +=== `rpicam-apps` + +`rpicam-apps` provides an IMX500 post-processing stage base class that implements helpers for IMX500 post-processing stages: https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/imx500/imx500_post_processing_stage.hpp[`IMX500PostProcessingStage`]. Use this base class to derive a new post-processing stage for any neural network model running on the IMX500. For an example, see https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/imx500/imx500_object_detection.cpp[`imx500_object_detection.cpp`]: + +[source,cpp] +---- +class ObjectDetection : public IMX500PostProcessingStage +{ +public: + ObjectDetection(RPiCamApp *app) : IMX500PostProcessingStage(app) {} + + char const *Name() const override; + + void Read(boost::property_tree::ptree const ¶ms) override; + + void Configure() override; + + bool Process(CompletedRequestPtr &completed_request) override; +}; +---- + +For every frame received by the application, the `Process()` function is called (`ObjectDetection::Process()` in the above case). In this function, you can extract the output tensor for further processing or analysis: + +[source,cpp] +---- +auto output = completed_request->metadata.get(controls::rpi::CnnOutputTensor); +if (!output) +{ + LOG_ERROR("No output tensor found in metadata!"); + return false; +} + +std::vector output_tensor(output->data(), output->data() + output->size()); +---- + +Once completed, the final results can either be visualised or saved in metadata and consumed by either another downstream stage, or the top level application itself. In the object inference case: + +[source,cpp] +---- +if (objects.size()) + completed_request->post_process_metadata.Set("object_detect.results", objects); +---- + +The `object_detect_draw_cv` post-processing stage running downstream fetches these results from the metadata and draws the bounding boxes onto the image in the `ObjectDetectDrawCvStage::Process()` function: + +[source,cpp] +---- +std::vector detections; +completed_request->post_process_metadata.Get("object_detect.results", detections); +---- + +The following table contains a full list of helper functions provided by `IMX500PostProcessingStage`: + +[%header,cols="a,a"] +|=== +| Function +| Description + +| `Read()` +| Typically called from `::Read()`, this function reads the config parameters for input tensor parsing and saving. + +This function also reads the neural network model file string (`"network_file"`) and sets up the firmware to be loaded on camera open. + +| `Process()` +| Typically called from `::Process()` this function processes and saves the input tensor to a file if required by the JSON config file. + +| `SetInferenceRoiAbs()` +| Sets an absolute region of interest (ROI) crop rectangle on the sensor image to use for inferencing on the IMX500. + +| `SetInferenceRoiAuto()` +| Automatically calculates region of interest (ROI) crop rectangle on the sensor image to preserve the input tensor aspect ratio for a given neural network. + +| `ShowFwProgressBar()` +| Displays a progress bar on the console showing the progress of the neural network firmware upload to the IMX500. + +| `ConvertInferenceCoordinates()` +| Converts from the input tensor coordinate space to the final ISP output image space. + +There are a number of scaling/cropping/translation operations occurring from the original sensor image to the fully processed ISP output image. This function converts coordinates provided by the output tensor to the equivalent coordinates after performing these operations. + +|=== + +=== Picamera2 + +IMX500 integration in Picamera2 is very similar to what is available in `rpicam-apps`. Picamera2 has an IMX500 helper class that provides the same functionality as the `rpicam-apps` `IMX500PostProcessingStage` base class. This can be imported to any Python script with: + +[source,python] +---- +from picamera2.devices.imx500 import IMX500 + +# This must be called before instantiation of Picamera2 +imx500 = IMX500(model_file) +---- + +To retrieve the output tensors, fetch them from the controls. You can then apply additional processing in your Python script. + +For example, in an object inference use case such as https://github.com/raspberrypi/picamera2/tree/main/examples/imx500/imx500_object_detection_demo.py[imx500_object_detection_demo.py], the object bounding boxes and confidence values are extracted in `parse_detections()` and draw the boxes on the image in `draw_detections()`: + +[source,python] +---- +class Detection: + def __init__(self, coords, category, conf, metadata): + """Create a Detection object, recording the bounding box, category and confidence.""" + self.category = category + self.conf = conf + obj_scaled = imx500.convert_inference_coords(coords, metadata, picam2) + self.box = (obj_scaled.x, obj_scaled.y, obj_scaled.width, obj_scaled.height) + +def draw_detections(request, detections, stream="main"): + """Draw the detections for this request onto the ISP output.""" + labels = get_labels() + with MappedArray(request, stream) as m: + for detection in detections: + x, y, w, h = detection.box + label = f"{labels[int(detection.category)]} ({detection.conf:.2f})" + cv2.putText(m.array, label, (x + 5, y + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1) + cv2.rectangle(m.array, (x, y), (x + w, y + h), (0, 0, 255, 0)) + if args.preserve_aspect_ratio: + b = imx500.get_roi_scaled(request) + cv2.putText(m.array, "ROI", (b.x + 5, b.y + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 1) + cv2.rectangle(m.array, (b.x, b.y), (b.x + b.width, b.y + b.height), (255, 0, 0, 0)) + +def parse_detections(request, stream='main'): + """Parse the output tensor into a number of detected objects, scaled to the ISP output.""" + outputs = imx500.get_outputs(request.get_metadata()) + boxes, scores, classes = outputs[0][0], outputs[1][0], outputs[2][0] + detections = [ Detection(box, category, score, metadata) + for box, score, category in zip(boxes, scores, classes) if score > threshold] + draw_detections(request, detections, stream) +---- + +Unlike the `rpicam-apps` example, this example applies no additional hysteresis or temporal filtering. + +The IMX500 class in Picamera2 provides the following helper functions: + +[%header,cols="a,a"] +|=== +| Function +| Description + +| `IMX500.get_full_sensor_resolution()` +| Return the full sensor resolution of the IMX500. + +| `IMX500.config` +| Returns a dictionary of the neural network configuration. + +| `IMX500.convert_inference_coords(coords, metadata, picamera2)` +| Converts the coordinates _coords_ from the input tensor coordinate space to the final ISP output image space. Must be passed Picamera2's image metadata for the image, and the Picamera2 object. + +There are a number of scaling/cropping/translation operations occurring from the original sensor image to the fully processed ISP output image. This function converts coordinates provided by the output tensor to the equivalent coordinates after performing these operations. + +| `IMX500.show_network_fw_progress_bar()` +| Displays a progress bar on the console showing the progress of the neural network firmware upload to the IMX500. + +| `IMX500.get_roi_scaled(request)` +| Returns the region of interest (ROI) in the ISP output image coordinate space. + +| `IMX500.get_isp_output_size(picamera2)` +| Returns the ISP output image size. + +| `IMX5000.get_input_size()` +| Returns the input tensor size based on the neural network model used. + +| `IMX500.get_outputs(metadata)` +| Returns the output tensors from the Picamera2 image metadata. + +| `IMX500.get_output_shapes(metadata)` +| Returns the shape of the output tensors from the Picamera2 image metadata for the neural network model used. + +| `IMX500.set_inference_roi_abs(rectangle)` +| Sets the region of interest (ROI) crop rectangle which determines which part of the sensor image is converted to the input tensor that is used for inferencing on the IMX500. The region of interest should be specified in units of pixels at the full sensor resolution, as a `(x_offset, y_offset, width, height)` tuple. + +| `IMX500.set_inference_aspect_ratio(aspect_ratio)` +| Automatically calculates region of interest (ROI) crop rectangle on the sensor image to preserve the given aspect ratio. To make the ROI aspect ratio exactly match the input tensor for this network, use `imx500.set_inference_aspect_ratio(imx500.get_input_size())`. + +| `IMX500.get_kpi_info(metadata)` +| Returns the frame-level performance indicators logged by the IMX500 for the given image metadata. + +|=== diff --git a/documentation/asciidoc/accessories/ai-camera/getting-started.adoc b/documentation/asciidoc/accessories/ai-camera/getting-started.adoc new file mode 100644 index 0000000000..b237208957 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/getting-started.adoc @@ -0,0 +1,141 @@ +== Getting started + +The instructions below describe how to run the pre-packaged MobileNet SSD and PoseNet neural network models on the Raspberry Pi AI Camera. + +=== Hardware setup + +Attach the camera to your Raspberry Pi 5 board following the instructions at xref:../accessories/camera.adoc#install-a-raspberry-pi-camera[Install a Raspberry Pi Camera]. + +=== Prerequisites + +These instructions assume you are using the AI Camera attached to either a Raspberry Pi 4 Model B or Raspberry Pi 5 board. With minor changes, you can follow these instructions on other Raspberry Pi models with a camera connector, including the Raspberry Pi Zero 2 W and Raspberry Pi 3 Model B+. + +First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: + +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +=== Install the IMX500 firmware + +The AI camera must download runtime firmware onto the IMX500 sensor during startup. To install these firmware files onto your Raspberry Pi, run the following command: + +[source,console] +---- +$ sudo apt install imx500-all +---- + +This command: + +* installs the `/lib/firmware/imx500_loader.fpk` and `/lib/firmware/imx500_firmware.fpk` firmware files required to operate the IMX500 sensor +* places a number of neural network model firmware files in `/usr/share/imx500-models/` +* installs the IMX500 post-processing software stages in `rpicam-apps` +* installs the Sony network model packaging tools + +NOTE: The IMX500 kernel device driver loads all the firmware files when the camera starts. This may take several minutes if the neural network model firmware has not been previously cached. The demos below display a progress bar on the console to indicate firmware loading progress. + +=== Reboot + +Now that you've installed the prerequisites, restart your Raspberry Pi: + +[source,console] +---- +$ sudo reboot +---- + +== Run example applications + +Once all the system packages are updated and firmware files installed, we can start running some example applications. As mentioned earlier, the Raspberry Pi AI Camera integrates fully with `libcamera`, `rpicam-apps`, and `Picamera2`. + +=== `rpicam-apps` + +The xref:../computers/camera_software.adoc#rpicam-apps[`rpicam-apps` camera applications] include IMX500 object detection and pose estimation stages that can be run in the post-processing pipeline. For more information about the post-processing pipeline, see xref:../computers/camera_software.adoc#post-process-file[the post-processing documentation]. + +The examples on this page use post-processing JSON files located in `/usr/share/rpi-camera-assets/`. + +==== Object detection + +The MobileNet SSD neural network performs basic object detection, providing bounding boxes and confidence values for each object found. `imx500_mobilenet_ssd.json` contains the configuration parameters for the IMX500 object detection post-processing stage using the MobileNet SSD neural network. + +`imx500_mobilenet_ssd.json` declares a post-processing pipeline that contains two stages: + +. `imx500_object_detection`, which picks out bounding boxes and confidence values generated by the neural network in the output tensor +. `object_detect_draw_cv`, which draws bounding boxes and labels on the image + +The MobileNet SSD tensor requires no significant post-processing on your Raspberry Pi to generate the final output of bounding boxes. All object detection runs directly on the AI Camera. + +The following command runs `rpicam-hello` with object detection post-processing: + +[source,console] +---- +$ rpicam-hello -t 0s --post-process-file /usr/share/rpi-camera-assets/imx500_mobilenet_ssd.json --viewfinder-width 1920 --viewfinder-height 1080 --framerate 30 +---- + +After running the command, you should see a viewfinder that overlays bounding boxes on objects recognised by the neural network: + +image::images/imx500-mobilenet.jpg[IMX500 MobileNet] + +To record video with object detection overlays, use `rpicam-vid` instead: + +[source,console] +---- +$ rpicam-vid -t 10s -o output.264 --post-process-file /usr/share/rpi-camera-assets/imx500_mobilenet_ssd.json --width 1920 --height 1080 --framerate 30 +---- + +You can configure the `imx500_object_detection` stage in many ways. + +For example, `max_detections` defines the maximum number of objects that the pipeline will detect at any given time. `threshold` defines the minimum confidence value required for the pipeline to consider any input as an object. + +The raw inference output data of this network can be quite noisy, so this stage also preforms some temporal filtering and applies hysteresis. To disable this filtering, remove the `temporal_filter` config block. + +==== Pose estimation + +The PoseNet neural network performs pose estimation, labelling key points on the body associated with joints and limbs. `imx500_posenet.json` contains the configuration parameters for the IMX500 pose estimation post-processing stage using the PoseNet neural network. + +`imx500_posenet.json` declares a post-processing pipeline that contains two stages: + +* `imx500_posenet`, which fetches the raw output tensor from the PoseNet neural network +* `plot_pose_cv`, which draws line overlays on the image + +The AI Camera performs basic detection, but the output tensor requires additional post-processing on your host Raspberry Pi to produce final output. + +The following command runs `rpicam-hello` with pose estimation post-processing: + +[source,console] +---- +$ rpicam-hello -t 0s --post-process-file /usr/share/rpi-camera-assets/imx500_posenet.json --viewfinder-width 1920 --viewfinder-height 1080 --framerate 30 +---- + +image::images/imx500-posenet.jpg[IMX500 PoseNet] + +You can configure the `imx500_posenet` stage in many ways. + +For example, `max_detections` defines the maximum number of bodies that the pipeline will detect at any given time. `threshold` defines the minimum confidence value required for the pipeline to consider input as a body. + +=== Picamera2 + +For examples of image classification, object detection, object segmentation, and pose estimation using Picamera2, see https://github.com/raspberrypi/picamera2/blob/main/examples/imx500/[the `picamera2` GitHub repository]. + +Most of the examples use OpenCV for some additional processing. To install the dependencies required to run OpenCV, run the following command: + +[source,console] +---- +$ sudo apt install python3-opencv python3-munkres +---- + +Now download the https://github.com/raspberrypi/picamera2[the `picamera2` repository] to your Raspberry Pi to run the examples. You'll find example files in the root directory, with additional information in the `README.md` file. + +Run the following script from the repository to run YOLOv8 object detection: + +[source,console] +---- +$ python imx500_object_detection_demo.py --model /usr/share/imx500-models/imx500_network_ssd_mobilenetv2_fpnlite_320x320_pp.rpk +---- + +To try pose estimation in Picamera2, run the following script from the repository: + +[source,console] +---- +$ python imx500_pose_estimation_higherhrnet_demo.py +---- diff --git a/documentation/asciidoc/accessories/ai-camera/images/ai-camera.png b/documentation/asciidoc/accessories/ai-camera/images/ai-camera.png new file mode 100644 index 0000000000..a0186287cb Binary files /dev/null and b/documentation/asciidoc/accessories/ai-camera/images/ai-camera.png differ diff --git a/documentation/asciidoc/accessories/ai-camera/images/imx500-block-diagram.svg b/documentation/asciidoc/accessories/ai-camera/images/imx500-block-diagram.svg new file mode 100644 index 0000000000..142854adb0 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/images/imx500-block-diagram.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/documentation/asciidoc/accessories/ai-camera/images/imx500-comparison.svg b/documentation/asciidoc/accessories/ai-camera/images/imx500-comparison.svg new file mode 100644 index 0000000000..5355ecb23d --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/images/imx500-comparison.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/documentation/asciidoc/accessories/ai-camera/images/imx500-mobilenet.jpg b/documentation/asciidoc/accessories/ai-camera/images/imx500-mobilenet.jpg new file mode 100644 index 0000000000..871f7b9eb0 Binary files /dev/null and b/documentation/asciidoc/accessories/ai-camera/images/imx500-mobilenet.jpg differ diff --git a/documentation/asciidoc/accessories/ai-camera/images/imx500-posenet.jpg b/documentation/asciidoc/accessories/ai-camera/images/imx500-posenet.jpg new file mode 100644 index 0000000000..0c145d748b Binary files /dev/null and b/documentation/asciidoc/accessories/ai-camera/images/imx500-posenet.jpg differ diff --git a/documentation/asciidoc/accessories/ai-camera/model-conversion.adoc b/documentation/asciidoc/accessories/ai-camera/model-conversion.adoc new file mode 100644 index 0000000000..3465a6d364 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-camera/model-conversion.adoc @@ -0,0 +1,106 @@ +== Model deployment + +To deploy a new neural network model to the Raspberry Pi AI Camera, complete the following steps: + +. Provide a floating-point neural network model (PyTorch or TensorFlow). +. Run the model through Edge-MDT (Edge AI Model Development Toolkit). +.. *Quantise* and compress the model so that it can run using the resources available on the IMX500 camera module. +.. *Convert* the compressed model to IMX500 format. +. Package the model into a firmware file that can be loaded at runtime onto the camera. + +The first two steps will normally be performed on a more powerful computer such as a desktop or server. You must run the final packaging step on a Raspberry Pi. + +=== Model creation + +The creation of neural network models is beyond the scope of this guide. Existing models can be re-used, or new ones created using popular AI frameworks like TensorFlow or PyTorch. + +For more information, see the official https://developer.aitrios.sony-semicon.com/en/raspberrypi-ai-camera[AITRIOS developer website]. + +=== Model compression and conversion + +==== Edge-MDT installation + +The Edge-MDT (Model Development Toolkit) software package installs all the tools required to quantise, compress, and convert models to run on your IMX500 device. + +The Edge-MDT package takes a parameter to select between installing the PyTorch or TensorFlow version of the tools. + +[tabs] +====== +TensorFlow:: ++ +[source,console] +---- +$ pip install edge-mdt[tf] +---- ++ +TIP: Always use the same version of TensorFlow you used to compress your model. + +PyTorch:: ++ +[source,console] +---- +$ pip install edge-mdt[pt] +---- +====== + +If you need to install both packages, use two separate Python virtual environments. This prevents TensorFlow and PyTorch from causing conflicts with each other. + +==== Model Optimization + +Models are quantised and compressed using Sony's Model Compression Toolkit (MCT). This tool is automatically installed as part of the Edge-MDT installation step. For more information, see the https://github.com/sony/model_optimization[Sony model optimization GitHub repository]. + +The Model Compression Toolkit generates a quantised model in the following formats: + +* Keras (TensorFlow) +* ONNX (PyTorch) + +=== Conversion + +The converter is a command line application that compiles the quantised model (in .onnx or .keras formats) into a binary file that can be packaged and loaded onto the AI Camera. This tool is automatically installed as part of the Edge-MDT installation step. + +To convert a model model: + +[tabs] +====== +TensorFlow:: ++ +[source,console] +---- +$ imxconv-tf -i -o +---- + +PyTorch:: ++ +[source,console] +---- +$ imxconv-pt -i -o +---- +====== + +IMPORTANT: For optimal use of the memory available to the accelerator on the IMX500 sensor, add `--no-input-persistency` to the above commands. However, this will disable input tensor generation that may be used for debugging purposes. + +Both commands create an output folder that contains a memory usage report and a `packerOut.zip` file. + +For more information on the model conversion process, see the official https://developer.aitrios.sony-semicon.com/en/raspberrypi-ai-camera/documentation/imx500-converter[Sony IMX500 Converter documentation]. + +=== Packaging + +IMPORTANT: You must run this step on a Raspberry Pi. + +The final step packages the model into an RPK file. When running the neural network model, we'll upload this file to the AI Camera. Before proceeding, run the following command to install the necessary tools: + +[source,console] +---- +$ sudo apt install imx500-tools +---- + +To package the model into an RPK file, run the following command: + +[source,console] +---- +$ imx500-package -i -o +---- + +This command should create a file named `network.rpk` in the output folder. You'll pass the name of this file to your IMX500 camera applications. + +For a more comprehensive set of instructions and further specifics on the tools used, see the https://developer.aitrios.sony-semicon.com/en/raspberrypi-ai-camera/documentation/imx500-packager[Sony IMX500 Packager documentation]. diff --git a/documentation/asciidoc/accessories/ai-hat-plus.adoc b/documentation/asciidoc/accessories/ai-hat-plus.adoc new file mode 100644 index 0000000000..dc6a3a7cfe --- /dev/null +++ b/documentation/asciidoc/accessories/ai-hat-plus.adoc @@ -0,0 +1,5 @@ +include::ai-hat-plus/about.adoc[] + +== Product brief + +For more information about the AI HAT+, including mechanical specifications and operating environment limitations, see the https://datasheets.raspberrypi.com/ai-hat-plus/raspberry-pi-ai-hat-plus-product-brief.pdf[product brief]. diff --git a/documentation/asciidoc/accessories/ai-hat-plus/about.adoc b/documentation/asciidoc/accessories/ai-hat-plus/about.adoc new file mode 100644 index 0000000000..98f1923bf5 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-hat-plus/about.adoc @@ -0,0 +1,75 @@ +[[ai-hat-plus]] +== About + +.The 26 tera-operations per second (TOPS) Raspberry Pi AI HAT+ +image::images/ai-hat-plus-hero.jpg[width="80%"] + +The Raspberry Pi AI HAT+ add-on board has a built-in Hailo AI accelerator compatible with +Raspberry Pi 5. The NPU in the AI HAT+ can be used for applications including process control, security, home automation, and robotics. + +The AI HAT+ is available in 13 and 26 tera-operations per second (TOPS) variants, built around the Hailo-8L and Hailo-8 neural network inference accelerators. The 13 TOPS variant works best with moderate workloads, with performance similar to the xref:ai-kit.adoc[AI Kit]. The 26 TOPS variant can run larger networks, can run networks faster, and can more effectively run multiple networks simultaneously. + +The AI HAT+ communicates using Raspberry Pi 5’s PCIe interface. The host Raspberry Pi 5 automatically detects the on-board Hailo accelerator and uses the NPU for supported AI computing tasks. Raspberry Pi OS's built-in `rpicam-apps` camera applications automatically use the NPU to run compatible post-processing tasks. + +[[ai-hat-plus-installation]] +== Install + +To use the AI HAT+, you will need: + +* a Raspberry Pi 5 + +Each AI HAT+ comes with a ribbon cable, GPIO stacking header, and mounting hardware. Complete the following instructions to install your AI HAT+: + +. First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: ++ +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +. Next, xref:../computers/raspberry-pi.adoc#update-the-bootloader-configuration[ensure that your Raspberry Pi firmware is up-to-date]. Run the following command to see what firmware you're running: ++ +[source,console] +---- +$ sudo rpi-eeprom-update +---- ++ +If you see 6 December 2023 or a later date, proceed to the next step. If you see a date earlier than 6 December 2023, run the following command to open the Raspberry Pi Configuration CLI: ++ +[source,console] +---- +$ sudo raspi-config +---- ++ +Under `Advanced Options` > `Bootloader Version`, choose `Latest`. Then, exit `raspi-config` with `Finish` or the *Escape* key. ++ +Run the following command to update your firmware to the latest version: ++ +[source,console] +---- +$ sudo rpi-eeprom-update -a +---- ++ +Then, reboot with `sudo reboot`. + +. Disconnect the Raspberry Pi from power before beginning installation. + +. For the best performance, we recommend using the AI HAT+ with the Raspberry Pi Active Cooler. If you have an Active Cooler, install it before installing the AI HAT+. ++ +-- +image::images/ai-hat-plus-installation-01.png[width="60%"] +-- +. Install the spacers using four of the provided screws. Firmly press the GPIO stacking header on top of the Raspberry Pi GPIO pins; orientation does not matter as long as all pins fit into place. Disconnect the ribbon cable from the AI HAT+, and insert the other end into the PCIe port of your Raspberry Pi. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing inward, towards the USB ports. With the ribbon cable fully and evenly inserted into the PCIe port, push the cable holder down from both sides to secure the ribbon cable firmly in place. ++ +-- +image::images/ai-hat-plus-installation-02.png[width="60%"] +-- +. Set the AI HAT+ on top of the spacers, and use the four remaining screws to secure it in place. + +. Insert the ribbon cable into the slot on the AI HAT+. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing up. With the ribbon cable fully and evenly inserted into the port, push the cable holder down from both sides to secure the ribbon cable firmly in place. + +. Congratulations, you have successfully installed the AI HAT+. Connect your Raspberry Pi to power; Raspberry Pi OS will automatically detect the AI HAT+. + +== Get started with AI on your Raspberry Pi + +To start running AI accelerated applications on your Raspberry Pi, check out our xref:../computers/ai.adoc[Getting Started with the AI Kit and AI HAT+] guide. diff --git a/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-hero.jpg b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-hero.jpg new file mode 100644 index 0000000000..08064ca25a Binary files /dev/null and b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-hero.jpg differ diff --git a/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-01.png b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-01.png new file mode 100644 index 0000000000..33fb88280e Binary files /dev/null and b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-01.png differ diff --git a/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-02.png b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-02.png new file mode 100644 index 0000000000..b2a60016ae Binary files /dev/null and b/documentation/asciidoc/accessories/ai-hat-plus/images/ai-hat-plus-installation-02.png differ diff --git a/documentation/asciidoc/accessories/ai-kit.adoc b/documentation/asciidoc/accessories/ai-kit.adoc new file mode 100644 index 0000000000..c5d54d1d43 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-kit.adoc @@ -0,0 +1,6 @@ +include::ai-kit/about.adoc[] + +== Product brief + +For more information about the AI Kit, including mechanical specifications and operating environment limitations, see the https://datasheets.raspberrypi.com/ai-kit/raspberry-pi-ai-kit-product-brief.pdf[product brief]. + diff --git a/documentation/asciidoc/accessories/ai-kit/about.adoc b/documentation/asciidoc/accessories/ai-kit/about.adoc new file mode 100644 index 0000000000..bc93a483f5 --- /dev/null +++ b/documentation/asciidoc/accessories/ai-kit/about.adoc @@ -0,0 +1,93 @@ +[[ai-kit]] +== About + +.The Raspberry Pi AI Kit +image::images/ai-kit.jpg[width="80%"] + +The Raspberry Pi AI Kit bundles the xref:m2-hat-plus.adoc#m2-hat-plus[Raspberry Pi M.2 HAT+] with a Hailo AI acceleration module for use with Raspberry Pi 5. The kit contains the following: + +* Hailo AI module containing a Neural Processing Unit (NPU) +* Raspberry Pi M.2 HAT+, to connect the AI module to your Raspberry Pi 5 +* thermal pad pre-fitted between the module and the M.2 HAT+ +* mounting hardware kit +* 16mm stacking GPIO header + +== AI module features + +* 13 tera-operations per second (TOPS) neural network inference accelerator built around the Hailo-8L chip. +* M.2 2242 form factor + +[[ai-kit-installation]] +== Install + +To use the AI Kit, you will need: + +* a Raspberry Pi 5 + +Each AI Kit comes with a pre-installed AI module, ribbon cable, GPIO stacking header, and mounting hardware. Complete the following instructions to install your AI Kit: + +. First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: ++ +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +. Next, xref:../computers/raspberry-pi.adoc#update-the-bootloader-configuration[ensure that your Raspberry Pi firmware is up-to-date]. Run the following command to see what firmware you're running: ++ +[source,console] +---- +$ sudo rpi-eeprom-update +---- ++ +If you see 6 December 2023 or a later date, proceed to the next step. If you see a date earlier than 6 December 2023, run the following command to open the Raspberry Pi Configuration CLI: ++ +[source,console] +---- +$ sudo raspi-config +---- ++ +Under `Advanced Options` > `Bootloader Version`, choose `Latest`. Then, exit `raspi-config` with `Finish` or the *Escape* key. ++ +Run the following command to update your firmware to the latest version: ++ +[source,console] +---- +$ sudo rpi-eeprom-update -a +---- ++ +Then, reboot with `sudo reboot`. + +. Disconnect the Raspberry Pi from power before beginning installation. + +. For the best performance, we recommend using the AI Kit with the Raspberry Pi Active Cooler. If you have an Active Cooler, install it before installing the AI Kit. ++ +-- +image::images/ai-kit-installation-01.png[width="60%"] +-- +. Install the spacers using four of the provided screws. Firmly press the GPIO stacking header on top of the Raspberry Pi GPIO pins; orientation does not matter as long as all pins fit into place. Disconnect the ribbon cable from the AI Kit, and insert the other end into the PCIe port of your Raspberry Pi. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing inward, towards the USB ports. With the ribbon cable fully and evenly inserted into the PCIe port, push the cable holder down from both sides to secure the ribbon cable firmly in place. ++ +-- +image::images/ai-kit-installation-02.png[width="60%"] +-- +. Set the AI Kit on top of the spacers, and use the four remaining screws to secure it in place. ++ +-- +image::images/ai-kit-installation-03.png[width="60%"] +-- +. Insert the ribbon cable into the slot on the AI Kit. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing up. With the ribbon cable fully and evenly inserted into the port, push the cable holder down from both sides to secure the ribbon cable firmly in place. ++ +-- +image::images/ai-kit-installation-04.png[width="60%"] +-- +. Congratulations, you have successfully installed the AI Kit. Connect your Raspberry Pi to power; Raspberry Pi OS will automatically detect the AI Kit. ++ +-- +image::images/ai-kit-installation-05.png[width="60%"] +-- + +WARNING: Always disconnect your Raspberry Pi from power before connecting or disconnecting a device from the M.2 slot. + +== Get started with AI on your Raspberry Pi + +To start running AI accelerated applications on your Raspberry Pi, check out our xref:../computers/ai.adoc[Getting Started with the AI Kit and AI HAT+] guide. diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-01.png b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-01.png new file mode 100644 index 0000000000..33fb88280e Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-01.png differ diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-02.png b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-02.png new file mode 100644 index 0000000000..b2a60016ae Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-02.png differ diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-03.png b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-03.png new file mode 100644 index 0000000000..2e821583c7 Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-03.png differ diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-04.png b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-04.png new file mode 100644 index 0000000000..7bf45e8162 Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-04.png differ diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-05.png b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-05.png new file mode 100644 index 0000000000..67b0d969a2 Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit-installation-05.png differ diff --git a/documentation/asciidoc/accessories/ai-kit/images/ai-kit.jpg b/documentation/asciidoc/accessories/ai-kit/images/ai-kit.jpg new file mode 100644 index 0000000000..d519b0ff43 Binary files /dev/null and b/documentation/asciidoc/accessories/ai-kit/images/ai-kit.jpg differ diff --git a/documentation/asciidoc/accessories/audio.adoc b/documentation/asciidoc/accessories/audio.adoc new file mode 100644 index 0000000000..87e227f58f --- /dev/null +++ b/documentation/asciidoc/accessories/audio.adoc @@ -0,0 +1,17 @@ +include::audio/introduction.adoc[] + +include::audio/dac_pro.adoc[] + +include::audio/dac_plus.adoc[] + +include::audio/digiamp_plus.adoc[] + +include::audio/codec_zero.adoc[] + +include::audio/configuration.adoc[] + +include::audio/getting_started.adoc[] + +include::audio/hardware-info.adoc[] + +include::audio/update-firmware.adoc[] diff --git a/documentation/asciidoc/accessories/audio/codec_zero.adoc b/documentation/asciidoc/accessories/audio/codec_zero.adoc new file mode 100644 index 0000000000..cfb9dd967b --- /dev/null +++ b/documentation/asciidoc/accessories/audio/codec_zero.adoc @@ -0,0 +1,33 @@ +=== Raspberry Pi Codec Zero + +Raspberry Pi Codec Zero is a Raspberry Pi Zero-sized audio HAT. It delivers bi-directional digital audio signals (I2S) between a Raspberry Pi and the Codec Zero's on-board Dialog Semiconductor DA7212 codec. The Codec Zero supports a range of input and output devices. + +* High performance 24-bit audio codec +* Supports common audio sample rates between 8-96kHz +* Built in micro-electro-mechanical (MEMS) microphone (Mic2) +* Mono electret microphone (Mic2 left) +* Automatic MEMS disabling on Mic2 insert detect +* Supports additional (no fit) mono electret microphone (Mic1 right) +* Stereo auxiliary input channel (AUX IN) - PHONO/RCA connectors +* Stereo auxiliary output channel (Headphone/AUX OUT) +* Flexible analogue and digital mixing paths +* Digital signal processors (DSP) for automatic level control (ALC) +* Five-band EQ +* Mono line-out/mini speaker driver: 1.2W @ 5V, THD<10%, R=8Ω + +image::images/Codec_Zero_Board_Diagram.jpg[width="80%"] + +The Codec Zero includes an EEPROM which can be used for auto-configuration of the Linux environment if necessary. It has an integrated MEMS microphone, and can be used with stereo microphone input via a 3.5mm socket and a mono speaker (1.2W/8Ω). + +In addition to the green (GPIO23) and red (GPIO24) LEDs, a tactile programmable button (GPIO27) is also provided. + +==== Pinouts + +[cols="1,12"] +|=== +| *P1/2* | Support external PHONO/RCA sockets if needed. P1: AUX IN, P2: AUX OUT. +| *P1* | Pin 1 is square. +|=== +image::images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.jpg[width="50%"] + +Codec Zero is an ideal design starting point for small-scale projects such as walkie-talkies, smart doorbells, vintage radio hacks, or smart speakers. diff --git a/documentation/asciidoc/accessories/audio/configuration.adoc b/documentation/asciidoc/accessories/audio/configuration.adoc new file mode 100644 index 0000000000..79a5d2136e --- /dev/null +++ b/documentation/asciidoc/accessories/audio/configuration.adoc @@ -0,0 +1,245 @@ +== Configuration + +A pre-programmed EEPROM is included on all Raspberry Pi audio boards. Raspberry Pi audio boards are designed to be plug-and-play; Raspberry Pi OS is able to automatically detect and configure itself. In Raspberry Pi OS, right-clicking on the audio settings in the top right-hand corner of your screen will allow you to switch between the on-board audio settings and the HAT audio settings: + +image::images/gui.png[] + +There are a number of third-party audio software applications available for Raspberry Pi that will support the plug-and-play feature of our audio boards. Often these are used headless. They can be controlled via a PC or Mac application, or by a web server installed on Raspberry Pi, with interaction through a webpage. + +If you need to configure Raspberry Pi OS yourself, perhaps if you're running a headless system of your own and don't have the option of control via the GUI, you will need to make your Raspberry Pi audio board the primary audio device in Raspberry Pi OS, disabling the Raspberry Pi's on-board audio device. This is done by editing the xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] file. Using a Terminal session connected to your Raspberry Pi via SSH, run the following command to edit the file: + +[source,console] +---- +$ sudo nano /boot/firmware/config.txt +---- + +Find the `dtparam=audio=on` line in the file and comment it out by placing a # symbol at the start of the line. Anything written after the # symbol in any given line will be disregarded by the program. Your `/boot/firmware/config.txt` file should now contain the following entry: + +[source,ini] +---- +#dtparam=audio=on +---- + +Press `Ctrl+X`, then the `Y` key, then *Enter* to save. Finally, reboot your Raspberry Pi in order for the settings to take effect. + +[source,console] +---- +$ sudo reboot +---- + +Alternatively, the `/boot/firmware/config.txt` file can be edited directly onto the Raspberry Pi's microSD card, inserted into your usual computer. Using the default file manager, open the `/boot/firmware/` volume on the card and edit the `config.txt` file using an appropriate text editor, then save the file, eject the microSD card and reinsert it back into your Raspberry Pi. + +=== Attach the HAT + +The Raspberry Pi audio boards attach to the Raspberry Pi's 40-pin header. They are designed to be supported on the Raspberry Pi using the supplied circuit board standoffs and screws. No soldering is required on the Raspberry Pi audio boards for normal operation unless you are using hardwired connections for specific connectors such as XLR (External Line Return) connections on the DAC Pro. + +All the necessary mounting hardware including spacers, screws and connectors is provided. The PCB spacers should be screwed, finger-tight only, to the Raspberry Pi before adding the audio board. The remaining screws should then be screwed into the spacers from above. + +=== Hardware versions + +There are multiple versions of the audio cards. Your specific version determines the actions required for configuration. Older, IQaudIO-branded boards have a black PCB. Newer Raspberry Pi-branded boards have a green PCB. These boards are electrically equivalent, but have different EEPROM contents. + +After attaching the HAT and applying power, check that the power LED on your audio card is illuminated, if it has one. For example, the Codec Zero has an LED marked `PWR`. + +After establishing the card has power, use the following command to check the version of your board: + +[source,console] +---- +$ grep -a . /proc/device-tree/hat/* +---- + +If the vendor string says "Raspberry Pi Ltd." then no further action is needed (but see below for the extra Codec Zero configuration). If it says "IQaudIO Limited www.iqaudio.com" then you will need the additional config.txt settings outlined below. If it says "No such file or directory" then the HAT is not being detected, but these config.txt settings may still make it work. + +[source,ini] +---- +# Some magic to prevent the normal HAT overlay from being loaded +dtoverlay= +# And then choose one of the following, according to the model: +dtoverlay=rpi-codeczero +dtoverlay=rpi-dacplus +dtoverlay=rpi-dacpro +dtoverlay=rpi-digiampplus +---- + +=== Extra Codec Zero configuration + +The Raspberry Pi Codec Zero board uses the Dialog Semiconductor DA7212 codec. This allows +the recording of audio from the built-in MEMS microphone, from stereo phono sockets (AUX +IN) or two mono external electret microphones. Playback is through stereo phono sockets (AUX OUT) +or a mono speaker connector. + +Each input and output device has its own mixer, allowing the audio levels and volume to be adjusted +independently. Within the codec itself, other mixers and switches exist to allow the output to be mixed to a single mono channel for single-speaker output. Signals may also be inverted; there is a five-band equaliser to adjust certain frequency bands. These settings can be controlled interactively, using AlsaMixer, or programmatically. + +Both the AUX IN and AUX OUT are 1V RMS. It may be necessary to adjust +the AUX IN's mixer to ensure that the input signal doesn't saturate the ADC. Similarly, the output mixers can be to be adjusted to get the best possible output. + +Preconfigured scripts (loadable ALSA settings) https://github.com/raspberrypi/Pi-Codec[are available on GitHub], offering: + +* Mono MEMS mic recording, mono speaker playback +* Mono MEMS mic recording, mono AUX OUT playback +* Stereo AUX IN recording, stereo AUX OUT playback +* Stereo MIC1/MIC2 recording, stereo AUX OUT playback + +The Codec Zero needs to know which of these input and output settings are being used each time the Raspberry Pi powers on. Using a Terminal session on your Raspberry Pi, run the following command to download the scripts: + +[source,console] +---- +$ git clone https://github.com/raspberrypi/Pi-Codec.git +---- + +If git is not installed, run the following command to install it: + +[source,console] +---- +$ sudo apt install git +---- + +The following command will set your device to use the on-board MEMS microphone and output for speaker playback: + +[source,console] +---- +$ sudo alsactl restore -f /home//Pi-Codec/Codec_Zero_OnboardMIC_record_and_SPK_playback.state +---- + +This command may result in erroneous messages, including the following: + +* "failed to import hw" +* "No state is present for card" + +In most cases, these warnings are harmless; you can safely ignore them. + +However, the following warnings may indicate a hardware failure: + +* "Remote I/O error" + +In Linux, the following warnings indicate that the kernel can't communicate with an I2C device: + +* "Remote I/O error" (`REMOTEIO`) + +In order for your project to operate with your required settings when it is powered on, edit the `/etc/rc.local` file. The contents of this file are run at the end of every boot process, so it is ideal for this purpose. Edit the file: + +[source,console] +---- +$ sudo nano /etc/rc.local +---- + +Add the chosen script command above the exit 0 line and then *Ctrl X*, *Y* and *Enter* to save. The file should now look similar to this depending on your chosen setting: + +[source,bash] +---- +#!/bin/sh +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +sudo alsactl restore -f /home//Pi-Codec/Codec_Zero_OnboardMIC_record_and_SPK_playback.state + +exit 0 +---- + +Press `Ctrl+X`, then the `Y` key, then *Enter* to save. Reboot for the settings to take effect: + +[source,console] +---- +$ sudo reboot +---- + +If you are using your Raspberry Pi and Codec Zero in a headless environment, there is one final step required to make the Codec Zero the default audio device without access to the GUI audio settings on the desktop. We need to create a small file in your home folder: + +[source,console] +---- +$ sudo nano .asoundrc +---- + +Add the following to the file: + +---- +pcm.!default { + type hw + card Zero +} +---- + +Press `Ctrl+X`, then the `Y` key, then *Enter* to save. Reboot once more to complete the configuration: + +Modern Linux distributions such as Raspberry Pi OS typically use PulseAudio or PipeWire for audio control. These frameworks are capable of mixing and switching audio from multiple sources. They provide a high-level API for audio applications to use. Many audio apps use these frameworks by default. + +Only create `~/.asoundrc` if an audio application needs to: + +* communicate directly with ALSA +* run in an environment where PulseAudio or PipeWire are not present + +This file can interfere with the UI's view of underlying audio resources. As a result, we do not recommend creating `~/.asoundrc` when running the Raspberry Pi OS desktop. +The UI may automatically clean up and remove this file if it exists. + +[source,console] +---- +$ sudo reboot +---- + +=== Mute and unmute the DigiAMP{plus} + +The DigiAMP{plus} mute state is toggled by GPIO22 on Raspberry Pi. The latest audio device tree +supports the unmute of the DigiAMP{plus} through additional parameters. + +Firstly a "one-shot" unmute when kernel module loads. + +For Raspberry Pi boards: + +[source,ini] +---- +dtoverlay=rpi-digiampplus,unmute_amp +---- + +For IQaudIO boards: + +[source,ini] +---- +dtoverlay=iqaudio-digiampplus,unmute_amp +---- + +Unmute the amp when an ALSA device is opened by a client. Mute, with a five-second delay +when the ALSA device is closed. (Reopening the device within the five-second close +window will cancel mute.) + +For Raspberry Pi boards: + +[source,ini] +---- +dtoverlay=rpi-digiampplus,auto_mute_amp +---- + +For IQaudIO boards: + +[source,ini] +---- +dtoverlay=iqaudio-digiampplus,auto_mute_amp +---- + +If you do not want to control the mute state through the device tree, you can also script your own +solution. + +The amp will start up muted. To unmute the amp: + +[source,console] +---- +$ sudo sh -c "echo 22 > /sys/class/gpio/export" +$ sudo sh -c "echo out >/sys/class/gpio/gpio22/direction" +$ sudo sh -c "echo 1 >/sys/class/gpio/gpio22/value" +---- + +To mute the amp once more: + +[source,console] +---- +$ sudo sh -c "echo 0 >/sys/class/gpio/gpio22/value" +---- diff --git a/documentation/asciidoc/accessories/audio/dac_plus.adoc b/documentation/asciidoc/accessories/audio/dac_plus.adoc new file mode 100644 index 0000000000..dbef84b71e --- /dev/null +++ b/documentation/asciidoc/accessories/audio/dac_plus.adoc @@ -0,0 +1,16 @@ +=== Raspberry Pi DAC{plus} + +Raspberry Pi DAC{plus} is a high-resolution audio output HAT that provides 24-bit 192kHz digital audio output. + +image::images/DAC+_Board_Diagram.jpg[width="80%"] + +A Texas Instruments PCM5122 is used in the DAC{plus} to deliver analogue audio to the phono connectors of the device. It also supports a dedicated headphone amplifier and is powered via the Raspberry Pi through the GPIO header. + +==== Pinouts + +[cols="1,12"] +|=== +| *P1* | Analogue out (0-2V RMS), carries GPIO27, MUTE signal (headphone detect), left and right +audio and left and right ground. +| *P6* | Headphone socket signals (pin1: LEFT, 2:GROUND, 3: RIGHT, 4:GROUND, 5:DETECT). +|=== diff --git a/documentation/asciidoc/accessories/audio/dac_pro.adoc b/documentation/asciidoc/accessories/audio/dac_pro.adoc new file mode 100644 index 0000000000..2e8c444a5b --- /dev/null +++ b/documentation/asciidoc/accessories/audio/dac_pro.adoc @@ -0,0 +1,30 @@ +=== Raspberry Pi DAC Pro + +The Raspberry Pi DAC Pro HAT is our highest-fidelity digital to analogue converter (DAC). + +image::images/DAC_Pro_Board_Diagram.jpg[width="80%"] + +With the Texas Instruments PCM5242, the DAC Pro provides outstanding signal-to-noise ratio (SNR) +and supports balanced/differential output in parallel to phono/RCA line-level output. It also includes a +dedicated headphone amplifier. The DAC Pro is powered by a Raspberry Pi through the GPIO header. + +As part of the DAC Pro, two three-pin headers (P7/P9) are exposed above the Raspberry Pi's USB and Ethernet ports for use by the optional XLR board, allowing differential/balanced output. + +==== Pinouts + +[cols="1,12"] +|=== +| *P1* | Analogue out (0-2V RMS), carries GPIO27, MUTE signal (headphone detect), left and right +audio and left and right ground. +| *P6* | Headphone socket signals (1: LEFT, 2: GROUND, 3: RIGHT, 4: GROUND, 5: DETECT). +| *P7/9* | Differential (0-4V RMS) output (P7: LEFT, P9: RIGHT). +| *P10* | Alternative 5V input, powering Raspberry Pi in parallel. +|=== + +==== Optional XLR Board + +The Pi-DAC PRO exposes a 6 pin header used by the optional XLR board to provide Differential / Balanced output exposed by XLR sockets above the Pi's USB/Ethernet ports. + +image::images/optional_xlr_board.jpg[width="80%"] + +An XLR connector is used in Studio and some hi-end hifi systems. It can also be used to drive ACTIVE "monitor" speakers as used at discos or on stage. diff --git a/documentation/asciidoc/accessories/audio/digiamp_plus.adoc b/documentation/asciidoc/accessories/audio/digiamp_plus.adoc new file mode 100644 index 0000000000..51347778ec --- /dev/null +++ b/documentation/asciidoc/accessories/audio/digiamp_plus.adoc @@ -0,0 +1,22 @@ +=== Raspberry Pi DigiAMP{plus} + +With Raspberry Pi DigiAMP{plus}, you can connect 2 passive stereo speakers up to 35W with variable output, making it ideal for use in Raspberry Pi-based hi-fi systems. + +DigiAMP{plus} uses the Texas Instruments TAS5756M PowerDAC and must be powered from an external supply. It requires a 12-24V DC power source (the XP Power VEC65US19 power supply is recommended). + +image::images/DigiAMP+_Board_Diagram.jpg[width="80%"] + +DigiAMP{plus}'s power in barrel connector is 5.5mm × 2.5mm. + +At power-on, the amplifier is muted by default (the mute LED is illuminated). Software is responsible for the mute state and LED control (Raspberry Pi GPIO22). + +DigiAMP{plus} is designed to provide power to the Raspberry Pi and DigiAMP{plus} together in parallel, delivering 5.1V at 2.5amp to the Raspberry Pi through the GPIO header. + +WARNING: Do not apply power to the Raspberry Pi's own power input when using DigiAMP{plus}. + +==== Pinouts +[cols="1,12"] +|=== +| *P5* | Alternative power input for hard wired installations (polarity must be observed). +| *P8* | TAS5756m Internal GPIO1/2/3 +|=== diff --git a/documentation/asciidoc/accessories/audio/getting_started.adoc b/documentation/asciidoc/accessories/audio/getting_started.adoc new file mode 100644 index 0000000000..7efbd7f9a3 --- /dev/null +++ b/documentation/asciidoc/accessories/audio/getting_started.adoc @@ -0,0 +1,139 @@ +== Getting started + +=== Create a toy chatter box + +As an example of what Raspberry Pi Audio Boards can do, let's walk through the creation of a toy chatter box. Its on-board microphone, programmable button and speaker driver make the Codec Zero an ideal choice for this application. + +image::images/Chatter_Box.jpg[width="80%"] + +A random pre-recorded five-second audio clip will be played when the button is pressed. After holding for ten seconds, a notifying burp sound will be emitted, after which a new five-second clip will be recorded. Holding the button down for more than 20 seconds will play a second burp sound, and then erase all previous recordings. + +=== Hardware and wiring + +For this project, any small passive speaker should be sufficient. We're using one available https://shop.pimoroni.com/products/3-speaker-4-3w?variant=380549926[here], which handles 5W of power at 4Ω. We have also used an illuminated momentary push button, and a laser-cut box to house all the components; but both are entirely optional. This example will work just using the Codec Zero's on-board button, which is pre-wired to GPIO 27. (Alternatively, you can use any momentary push button, such as those available https://shop.pimoroni.com/products/mini-arcade-buttons?variant=40377171274[here].) + +image::images/Chatterbox_Labels.png[width="80%"] + +Use a small flat-head screwdriver to attach your speaker to the screw terminals. For the additional push button, solder the button wires directly to the Codec Zero pads as indicated, using GPIO pin 27 and Ground for the switch, and +3.3V and Ground for the LED, if necessary. + +=== Set up your Raspberry Pi + +In this example, we are using Raspberry Pi OS Lite. Refer to our guide on xref:../computers/getting-started.adoc#installing-the-operating-system[installing Raspberry Pi OS] for more details. + +Make sure that you update your operating system before proceeding and follow the instructions provided for Codec Zero configuration, including the commands to enable the on-board microphone and speaker output. + +=== Program your Raspberry Pi + +Open a shell — for instance by connecting via SSH — on your Raspberry Pi and run the following to create our Python script: + +[source,console] +---- +$ sudo nano chatter_box.py +---- + +Add the following to the file, replacing `` with your username: + +[source,python] +---- +#!/usr/bin/env python3 +from gpiozero import Button +from signal import pause +import time +import random +import os +from datetime import datetime + +# Print current date + +date = datetime.now().strftime("%d_%m_%Y-%H:%M:%S") +print(f"{date}") + +# Make sure that the 'sounds' folder exists, and if it does not, create it + +path = '/home//sounds' + +isExist = os.path.exists(path) + +if not isExist: + os.makedirs(path) + print("The new directory is created!") + os.system('chmod 777 -R /home//sounds') + +# Download a 'burp' sound if it does not already exist + +burp = '/home//burp.wav' + +isExist = os.path.exists(burp) +if not isExist: + os.system('wget http://rpf.io/burp -O burp.wav') + print("Burp sound downloaded!") + +# Setup button functions - Pin 27 = Button hold time 10 seconds. + +button = Button(27, hold_time=10) + +def pressed(): + global press_time + press_time = time.time() + print("Pressed at %s" % (press_time)); + +def released(): + release_time = time.time() + pressed_for = release_time - press_time + print("Released at %s after %.2f seconds" % (release_time, pressed_for)) + if pressed_for < button.hold_time: + print("This is a short press") + randomfile = random.choice(os.listdir("/home//sounds/")) + file = '/home//sounds/' + randomfile + os.system('aplay ' + file) + elif pressed_for > 20: + os.system('aplay ' + burp) + print("Erasing all recorded sounds") + os.system('rm /home//sounds/*'); + +def held(): + print("This is a long press") + os.system('aplay ' + burp) + os.system('arecord --format S16_LE --duration=5 --rate 48000 -c2 /home//sounds/$(date +"%d_%m_%Y-%H_%M_%S")_voice.m4a'); + +button.when_pressed = pressed +button.when_released = released +button.when_held = held + +pause() + +---- + +Press `Ctrl+X`, then the `Y` key, then *Enter* to save. To make the script executable, type the following: + +[source,console] +---- +$ sudo chmod +x chatter_box.py +---- + +Next, we need to create a crontab daemon that will automatically start the script each time the device is powered on. Run the following command to open your crontab for editing: + +[source,console] +---- +$ crontab -e +---- + +You will be asked to select an editor; we recommend you use `nano`. Select it by entering the corresponding number, and press Enter to continue. The following line should be added to the bottom of the file, replacing `` with your username: + +---- +@reboot python /home//chatter_box.py +---- + +Press *Ctrl X*, then *Y*, then *Enter* to save, then reboot your device with `sudo reboot`. + +=== Use the toy chatter box + +The final step is to ensure that everything is operating as expected. Press the button and release it when you hear the burp. The recording will now begin for a period of five seconds. Once you have released the button, press it briefly again to hear the recording. Repeat this process as many times as you wish, and your sounds will be played at random. You can delete all recordings by pressing and holding the button, keeping the button pressed during the first burp and recording process, and releasing it after at least 20 seconds, at which point you will hear another burp sound confirming that the recordings have been deleted. + +video::BjXERzu8nS0[youtube,width=80%,height=400px] + +=== Next steps + +Upgrades! It is always fun to upgrade a project, so why not add some additional features, such as an LED that will illuminate when recording? This project has all the parts required to make your own version of a https://aiyprojects.withgoogle.com/[Google intelligent speaker system], or you may want to consider building a second device that can be used to create a pair of walkie-talkies that are capable of transferring audio files over a network via SSH. + + diff --git a/documentation/asciidoc/accessories/audio/hardware-info.adoc b/documentation/asciidoc/accessories/audio/hardware-info.adoc new file mode 100644 index 0000000000..c7d445d64b --- /dev/null +++ b/documentation/asciidoc/accessories/audio/hardware-info.adoc @@ -0,0 +1,95 @@ +== Hardware information + +Hardware information: + +* PCB screws are all M2.5. +* PCB standoffs (for case) are 5mm male/female. +* PCB standoffs (for Raspberry Pi to audio boards) are 9mm female/female. +* PCB standoffs (for XLR to DAC PRO) are 8mm female/male. +* PCB standoffs (for the official Raspberry Pi 7-inch display) are 5mm male/female. +* The rotary encoders we have used and tested are the Alpha three-pin rotary encoder +RE160F-40E3-20A-24P, the ALPS EC12E2430804 (RS: 729-5848), and the Bourns ECW0JB24-AC0006L (RS: 263-2839). +* The barrel connector used for powering the DigiAMP{plus} is 2.5mmID, 5.5mmOD, 11mm. +* The DigiAMP{plus} is designed to operate with a 12V to 24V, 3A supply such as the XPPower +VEC65US19 or similar. +* The DigiAMP{plus} uses CamdenBoss two-part connectors. Those fitted to the PCB are +CTBP9350/2AO. +* The speaker terminal used on the Codec Zero will accept wires of between 14~26 AWG +(wire of max 1.6mm in diameter). + +=== GPIO usage + +Raspberry Pi audio boards take advantage of a number of pins on the GPIO header in +order to operate successfully. Some of these pins are solely for the use of the board, and +some can be shared with other peripherals, sensors, etc. + +The following Raspberry Pi GPIO pins will be used by the audio boards: + +* All power pins +* All ground pins +* GPIO 2/3 (I2C) +* GPIO 18/19/20/21 (I2S) + +If appropriate then the following are also used: + +* GPIO 22 (DigiAMP+ mute/unmute support) +* GPIO 23/24 for rotary encoder (physical volume control) or status LED (Codec Zero) +* GPIO 25 for the IR Sensor +* GPIO 27 for the rotary encoder push switch/Codec Zero switch + +=== DAC PRO, DAC{plus}, DigiAMP{plus}, Codec Zero + +image::images/pin_table_new.jpg[width="80%"] + +The DAC PRO, DAC{plus} and DigiAMP{plus} re-expose the Raspberry Pi signals, allowing additional sensors and peripherals +to be added easily. Please note that some signals are for exclusive use (I2S and EEPROM) by some +of our boards; others such as I2C can be shared across multiple boards. + +image::images/pin_out_new.jpg[width="80%"] + + +=== Saving AlsaMixer settings + +To store the AlsaMixer settings, add the following at the command line: + +[source,console] +---- +$ sudo alsactl store +---- + +You can save the current state to a file, then reload that state at startup. + +To save, run the following command, replacing `` with your username: + +[source,console] +---- +$ sudo alsactl store -f /home//usecase.state +---- + +To restore a saved file, run the following command, replacing `` with your username: + +[source,console] +---- +$ sudo alsactl restore -f /home//usecase.state +---- + +=== MPD-based audio with volume control + +To allow Music Player Daemon (MPD)-based audio software to control the audio board's built in volume, the file +`/etc/mpd.conf` may need to be changed to support the correct AlsaMixer name. + +This can be achieved by ensuring the 'Audio output' section of `/etc/mpd.conf` has the 'mixer_control' +line. Below is an example for the Texas Instruments-based boards (DAC +PRO/DAC{plus}/DigiAMP{plus}): + +---- +audio_output { + type "alsa" + name "ALSA Device" + mixer_control "Digital" +} +---- + + + + diff --git a/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.jpg b/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.jpg new file mode 100644 index 0000000000..8429a3f1f8 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.png b/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.png new file mode 100644 index 0000000000..fb1a111c2d Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/CODEC_ZERO_ZOOMED_IN_DIAGRAM.png differ diff --git a/documentation/asciidoc/accessories/audio/images/Chatter_Box.jpg b/documentation/asciidoc/accessories/audio/images/Chatter_Box.jpg new file mode 100644 index 0000000000..b09c695215 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/Chatter_Box.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/Chatterbox_Labels.png b/documentation/asciidoc/accessories/audio/images/Chatterbox_Labels.png new file mode 100644 index 0000000000..379df111f8 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/Chatterbox_Labels.png differ diff --git a/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.jpg b/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.jpg new file mode 100644 index 0000000000..31d6840161 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.png b/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.png new file mode 100644 index 0000000000..4e02bdedb7 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/Codec_Zero_Board_Diagram.png differ diff --git a/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.jpg b/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.jpg new file mode 100644 index 0000000000..d7ae6fae24 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.png b/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.png new file mode 100644 index 0000000000..7a68f02c4b Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DAC+_Board_Diagram.png differ diff --git a/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.jpg b/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.jpg new file mode 100644 index 0000000000..6f3770d092 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.png b/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.png new file mode 100644 index 0000000000..033ed5e1bc Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DAC_Pro_Board_Diagram.png differ diff --git a/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.jpg b/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.jpg new file mode 100644 index 0000000000..92d7aa96da Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.png b/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.png new file mode 100644 index 0000000000..e4f2b336b7 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/DigiAMP+_Board_Diagram.png differ diff --git a/documentation/asciidoc/accessories/audio/images/codec_zero.png b/documentation/asciidoc/accessories/audio/images/codec_zero.png new file mode 100644 index 0000000000..559743c203 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/codec_zero.png differ diff --git a/documentation/asciidoc/accessories/audio/images/dac_plus.png b/documentation/asciidoc/accessories/audio/images/dac_plus.png new file mode 100644 index 0000000000..61154d683f Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/dac_plus.png differ diff --git a/documentation/asciidoc/accessories/audio/images/dac_pro.png b/documentation/asciidoc/accessories/audio/images/dac_pro.png new file mode 100644 index 0000000000..f76af08e9d Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/dac_pro.png differ diff --git a/documentation/asciidoc/accessories/audio/images/digiamp_plus.png b/documentation/asciidoc/accessories/audio/images/digiamp_plus.png new file mode 100644 index 0000000000..fa566a2e3b Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/digiamp_plus.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/detected.png b/documentation/asciidoc/accessories/audio/images/firmware-update/detected.png new file mode 100644 index 0000000000..22d5d2cec0 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/detected.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/flashed.png b/documentation/asciidoc/accessories/audio/images/firmware-update/flashed.png new file mode 100644 index 0000000000..0e180fe633 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/flashed.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/flashing.png b/documentation/asciidoc/accessories/audio/images/firmware-update/flashing.png new file mode 100644 index 0000000000..1ee3f5ae23 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/flashing.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/nodac.png b/documentation/asciidoc/accessories/audio/images/firmware-update/nodac.png new file mode 100644 index 0000000000..6990d38e87 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/nodac.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/nohat.png b/documentation/asciidoc/accessories/audio/images/firmware-update/nohat.png new file mode 100644 index 0000000000..214548586e Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/nohat.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/select.png b/documentation/asciidoc/accessories/audio/images/firmware-update/select.png new file mode 100644 index 0000000000..4e07972386 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/select.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/timeout.png b/documentation/asciidoc/accessories/audio/images/firmware-update/timeout.png new file mode 100644 index 0000000000..38a6aa04c3 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/timeout.png differ diff --git a/documentation/asciidoc/accessories/audio/images/firmware-update/warning.png b/documentation/asciidoc/accessories/audio/images/firmware-update/warning.png new file mode 100644 index 0000000000..95ac638f5a Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/firmware-update/warning.png differ diff --git a/documentation/asciidoc/accessories/audio/images/gui.png b/documentation/asciidoc/accessories/audio/images/gui.png new file mode 100755 index 0000000000..61e97df724 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/gui.png differ diff --git a/documentation/asciidoc/accessories/audio/images/hat.png b/documentation/asciidoc/accessories/audio/images/hat.png new file mode 100644 index 0000000000..dc1e881cdf Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/hat.png differ diff --git a/documentation/asciidoc/accessories/audio/images/optional_xlr_board.jpg b/documentation/asciidoc/accessories/audio/images/optional_xlr_board.jpg new file mode 100644 index 0000000000..526b1c2d5f Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/optional_xlr_board.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/pin_out.png b/documentation/asciidoc/accessories/audio/images/pin_out.png new file mode 100644 index 0000000000..0672954f9b Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/pin_out.png differ diff --git a/documentation/asciidoc/accessories/audio/images/pin_out_new.jpg b/documentation/asciidoc/accessories/audio/images/pin_out_new.jpg new file mode 100644 index 0000000000..a0fdde9dca Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/pin_out_new.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/pin_table.png b/documentation/asciidoc/accessories/audio/images/pin_table.png new file mode 100644 index 0000000000..b01b5fb660 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/pin_table.png differ diff --git a/documentation/asciidoc/accessories/audio/images/pin_table_new.jpg b/documentation/asciidoc/accessories/audio/images/pin_table_new.jpg new file mode 100644 index 0000000000..b9ca1a8bc5 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/pin_table_new.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/rotary.png b/documentation/asciidoc/accessories/audio/images/rotary.png new file mode 100644 index 0000000000..9168ce6d7f Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/rotary.png differ diff --git a/documentation/asciidoc/accessories/audio/images/square.png b/documentation/asciidoc/accessories/audio/images/square.png new file mode 100644 index 0000000000..b213f1b464 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/square.png differ diff --git a/documentation/asciidoc/accessories/audio/images/wiring.jpg b/documentation/asciidoc/accessories/audio/images/wiring.jpg new file mode 100644 index 0000000000..3a22c834b9 Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/wiring.jpg differ diff --git a/documentation/asciidoc/accessories/audio/images/write_protect_tabs.jpg b/documentation/asciidoc/accessories/audio/images/write_protect_tabs.jpg new file mode 100644 index 0000000000..91e2f65f1b Binary files /dev/null and b/documentation/asciidoc/accessories/audio/images/write_protect_tabs.jpg differ diff --git a/documentation/asciidoc/accessories/audio/introduction.adoc b/documentation/asciidoc/accessories/audio/introduction.adoc new file mode 100644 index 0000000000..01abb46903 --- /dev/null +++ b/documentation/asciidoc/accessories/audio/introduction.adoc @@ -0,0 +1,30 @@ +== Overview + +Raspberry Pi Audio Boards bring high quality audio to your existing hi-fi or Raspberry Pi-based equipment and projects. We offer four different Hardware Attached on Top (HAT) options that will fit any Raspberry Pi using the 40-pin GPIO header. + +Each board has a specific purpose and set of features. The highest audio quality playback is available from our DAC PRO, DAC{plus} and DigiAMP{plus} boards, which support up to full HD audio (192kHz); while the Codec Zero supports up to HD audio (96kHz) and includes a built-in microphone, making it ideal for compact projects. + +=== Features at a glance + +[cols="2,1,1,1,1,1,1,1,1,1"] +|=== +| | *Line out* | *Balanced out* | *Stereo speakers* | *Mono speaker* | *Headphones* | *Aux in* | *Aux out* | *Ext mic* | *Built-in mic* + +| DAC Pro ^| ✓ ^| ✓ | | ^| ✓ | | | | +| DAC{plus} ^| ✓ | | | ^| ✓ | | | | +| DigiAmp{plus} | | ^| ✓ | | | | | | +| Codec Zero | | | ^| ✓ | ^| ✓ ^| ✓ ^| ✓ ^| ✓ +|=== + +Line out:: A double phono/RCA connector, normally red and white in colour. This output is a variable +analogue signal (0-2V RMS) and can connect to your existing hi-fi (pre-amp or amplifier), or can be used +to drive active speakers which have their own amplifier built in. +Balanced out:: An XLR connector, normally a three-pin male connector. This is used in a studio set-up, and in some +high-end hi-fi systems. It can also be used to drive active monitor speakers like those used at clubs or on +stage directed towards the DJ or performers. +Stereo speakers:: Two sets of screw terminals for 2×25W speakers. These are for traditional hi-fi speakers without built-in amplification. These are known as passive speakers. +Mono speaker:: A screw terminal for a single 1.2W speaker, as found in a transistor radio or similar. +Headphones:: A 3.5mm jack socket delivering stereo audio for a set of headphones. The headphone amplifiers on the Raspberry Pi DAC boards can drive up to 80/90Ω impedance headphones. +Aux in:: A double Phono/RCA connector or 3.5mm socket. Accepts analogue audio in up to 1V RMS. This can be used to record audio from a variable analogue source such as a mobile phone, MP3 player or similar. +Aux out:: A double Phono/RCA connector or 3.5mm socket. Delivers analogue audio out up to 1V RMS. This can be used to feed audio into an amplifier at a reduced volume compared to Line out. +Ext mic:: A 3.5mm socket for use with an external electret microphone. The built-in MEMS microphone on the Codec Zero is automatically disabled when the external Mic in connector is used. diff --git a/documentation/asciidoc/accessories/audio/update-firmware.adoc b/documentation/asciidoc/accessories/audio/update-firmware.adoc new file mode 100644 index 0000000000..d5a16fdb9e --- /dev/null +++ b/documentation/asciidoc/accessories/audio/update-firmware.adoc @@ -0,0 +1,47 @@ +== Updating your firmware + +Raspberry Pi Audio Boards use an EEPROM that contains information that is used by the host Raspberry Pi device to select the appropriate driver at boot time. This information is programmed into the EEPROM during manufacture. There are some circumstances where the end user may wish to update the EEPROM contents: this can be done from the command line. + +IMPORTANT: Before proceeding, update the version of Raspberry Pi OS running on your Raspberry Pi to the latest version. + +=== The EEPROM write-protect link + +During the programming process you will need to connect the two pads shown in the red box with a wire to pull down the EEPROM write-protect link. + +image::images/write_protect_tabs.jpg[width="80%"] + +NOTE: In some cases the two pads may already have a 0Ω resistor fitted to bridge the write-protect link, as illustrated in the picture of the Codec Zero board above. + +=== Program the EEPROM + +Once the write-protect line has been pulled down, the EEPROM can be programmed. + +You should first install the utilities and then run the programmer. Open up a terminal window and type the following: + +[source,console] +---- +$ sudo apt update +$ sudo apt install rpi-audio-utils +$ sudo rpi-audio-flash +---- + +After starting, you will see a warning screen. + +image::images/firmware-update/warning.png[] + +Select "Yes" to proceed. You should see a menu where you can select your hardware. + +image::images/firmware-update/select.png[] + +NOTE: If no HAT is present, or if the connected HAT is not a Raspberry Pi Audio board, you will be presented with an error screen. If the firmware has already been updated on the board, a message will be displayed informing you that you do not have to continue. + +After selecting the hardware, a screen will display while the new firmware is flashed to the HAT. + +image::images/firmware-update/flashing.png[] + +Afterwards a screen will display telling you that the new firmware has installed. + +image::images/firmware-update/flashed.png[] + +NOTE: If the firmware fails to install correctly, you will see an error screen. Try removing and reseating the HAT, then flash the firmware again. + diff --git a/documentation/asciidoc/accessories/build-hat.adoc b/documentation/asciidoc/accessories/build-hat.adoc new file mode 100644 index 0000000000..472c939c47 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat.adoc @@ -0,0 +1,31 @@ +// Intro + +include::build-hat/introduction.adoc[] + +include::build-hat/preparing-build-hat.adoc[] + +// Python + +include::build-hat/py-installing-software.adoc[] + +include::build-hat/py-motors.adoc[] + +include::build-hat/py-sensors.adoc[] + +// .NET + +include::build-hat/net-installing-software.adoc[] + +include::build-hat/net-brick.adoc[] + +include::build-hat/net-motors.adoc[] + +include::build-hat/net-sensors.adoc[] + +// Close out + +include::build-hat/links-to-other.adoc[] + +include::build-hat/compat.adoc[] + +include::build-hat/mech.adoc[] diff --git a/documentation/asciidoc/accessories/build-hat/compat.adoc b/documentation/asciidoc/accessories/build-hat/compat.adoc new file mode 100644 index 0000000000..70fb160a8b --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/compat.adoc @@ -0,0 +1,46 @@ +== Device Compatibility + +The Build HAT library supports all the LEGO® Technic™ devices included in the SPIKE™ Portfolio, along with those from the LEGO® Mindstorms Robot Inventor kit and other devices that use a PoweredUp connector. + +IMPORTANT: The product code for the SPIKE™ Prime Expansion Set that includes the Maker Plate is 45681. The original Expansion Set is 45680 and does not include the Maker Plate. + +[cols="2,2,1,1,1,1,1,3,1,1,1,1", width="100%", options="header"] +|=== +| Description | Colour | LEGO Item Number | Supported in FW | Supported in Python | Alt Number | BrickLink | Available In | Set Numbers | Class | Type | Device ID + +| Large Angular Motor | White/Cyan | 45602| Yes | Yes | 45602 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=45602-1#T=S&O={%22iconly%22:0}[Link] | SPIKE Prime Set, +SPIKE Prime Expansion Set | 45678, 45680 | Motor | Active | 31 + +| Medium Angular Motor | White/Cyan | 45603 | Yes | Yes | 45603 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=45603-1#T=S&O={%22iconly%22:0}[Link] | SPIKE Prime Set | 45678 | Motor | Active | 30 + +| Medium Angular Motor | White/Grey | 6299646, 6359216, 6386708 | Yes | Yes | 436655 | https://www.bricklink.com/v2/catalog/catalogitem.page?P=54696c01&idColor=86#T=C&C=86[Link] | Mindstorms Robot Inventor | 51515 | Motor | Active | 4B + +| Small Angular Motor | White/Cyan | 45607, 6296520 | Yes| Yes| | https://www.bricklink.com/v2/catalog/catalogitem.page?P=45607c01[Link] | SPIKE Essentials Set| | Motor| Active| 41 + +| Light/Colour sensor |White/Black | 6217705 |Yes | Yes | | https://www.bricklink.com/v2/catalog/catalogitem.page?P=37308c01&idColor=11#T=C&C=11[Link] | SPIKE Prime Set, SPIKE Prime Expansion Set, Mindstorms Robot Inventor, SPIKE Essentials | 45678, 45680, 51515 | ColorSensor |Active | 3D + +| Distance Sensor | White/Black | 6302968 | Yes | Yes | | https://www.bricklink.com/v2/catalog/catalogitem.page?P=37316c01&idColor=11#T=C&C=11[Link] | SPIKE Prime Set, Mindstorms Robot Inventor | 45678, 51515 |DistanceSensor | Active | 3E + +| System medium motor | White/Grey | 45303, 6138854, 6290182, 6127110 | Yes | Yes | | | Wedo 2.0, LEGO Ideas Piano, App controlled Batmobile | 76112 | | Passive | 1 + +| Force Sensor | White/Black | 6254354 | Yes | Yes | 45606 | https://www.bricklink.com/v2/catalog/catalogitem.page?P=37312c01&idColor=11#T=C&C=11[Link] | SPIKE Prime Set | 45678 | ForceSensor | Active | 3F + +| 3×3 LED | White/Cyan | 45608, 6297023 | Yes | Yes | | https://www.bricklink.com/v2/catalog/catalogitem.page?P=45608c01[Link] | SPIKE Essentials | | Matrix | Active | 40 + +| System train motor | Black | 88011 | Yes | Yes | 28740, 88011-1 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88011-1#T=S&O={%22iconly%22:0}[Link] | Cargo Train, Disney Train and Station, Passenger Train| | | Passive | 2 + +| PoweredUp LED lights | Black | 88005 | Yes | | | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88005-1#T=S&O={%22iconly%22:0}[Link] | | | | Passive | 8 + +| Medium linear motor | White/Grey | 88008 | Yes | Yes | 26913, 88008-1 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88008-1#T=S&O={%22iconly%22:0}[Link] | Boost, Droid Commander| | Motor | Active | 26 + +| Technic large motor | Grey/Grey | 88013 | Yes | Yes | 22169 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88013-1#T=S&O={%22iconly%22:0}[Link] | | | | Active | 2E + +| Technic XL motor | Grey/Grey | 88014 | Yes | Yes | 22172, 88014 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88014-1#T=S&O={%22iconly%22:0}[Link] | | | | Active | 2F + +| Colour + distance sensor | White/Grey | 88007 | Partial | ? | 26912 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=88007-1#T=S&O={%22iconly%22:0}[Link] | | | | Active | 25 + +| WeDo 2.0 Motion sensor | White/Grey | 45304, 6138855 | | | 5003423-1| https://www.bricklink.com/v2/catalog/catalogitem.page?S=9583-1#T=S&O={%22iconly%22:0}}[Link] | | | | Active | 35 + +| WeDo 2.0 Tilt sensor | White/Grey | 45305, 6138856 | | | 5003423-1 | https://www.bricklink.com/v2/catalog/catalogitem.page?S=9584-1#T=S&O={%22iconly%22:0}[Link] | | | | Active | 34 + +|=== diff --git a/documentation/asciidoc/accessories/build-hat/images/3x3matrix.png b/documentation/asciidoc/accessories/build-hat/images/3x3matrix.png new file mode 100644 index 0000000000..ce0c1efe45 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/3x3matrix.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/active-motor.png b/documentation/asciidoc/accessories/build-hat/images/active-motor.png new file mode 100644 index 0000000000..c933668fa2 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/active-motor.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/blinking-light.webm b/documentation/asciidoc/accessories/build-hat/images/blinking-light.webm new file mode 100644 index 0000000000..12ecb8a3bb Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/blinking-light.webm differ diff --git a/documentation/asciidoc/accessories/build-hat/images/build-hat.jpg b/documentation/asciidoc/accessories/build-hat/images/build-hat.jpg new file mode 100644 index 0000000000..6507e51dfb Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/build-hat.jpg differ diff --git a/documentation/asciidoc/accessories/build-hat/images/color-distance.png b/documentation/asciidoc/accessories/build-hat/images/color-distance.png new file mode 100644 index 0000000000..653ecb38c3 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/color-distance.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/connect-motor.webm b/documentation/asciidoc/accessories/build-hat/images/connect-motor.webm new file mode 100644 index 0000000000..70da881290 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/connect-motor.webm differ diff --git a/documentation/asciidoc/accessories/build-hat/images/fitting-build-hat.webm b/documentation/asciidoc/accessories/build-hat/images/fitting-build-hat.webm new file mode 100644 index 0000000000..8d64b6817b Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/fitting-build-hat.webm differ diff --git a/documentation/asciidoc/accessories/build-hat/images/mech-build-hat.png b/documentation/asciidoc/accessories/build-hat/images/mech-build-hat.png new file mode 100644 index 0000000000..3816fa65b5 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/mech-build-hat.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/passive-light.png b/documentation/asciidoc/accessories/build-hat/images/passive-light.png new file mode 100644 index 0000000000..632489fd4b Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/passive-light.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/powering-build-hat.webm b/documentation/asciidoc/accessories/build-hat/images/powering-build-hat.webm new file mode 100644 index 0000000000..e358683f90 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/powering-build-hat.webm differ diff --git a/documentation/asciidoc/accessories/build-hat/images/psu.jpg b/documentation/asciidoc/accessories/build-hat/images/psu.jpg new file mode 100644 index 0000000000..f75ced65fa Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/psu.jpg differ diff --git a/documentation/asciidoc/accessories/build-hat/images/raspi-config-1.png b/documentation/asciidoc/accessories/build-hat/images/raspi-config-1.png new file mode 100644 index 0000000000..6e36757652 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/raspi-config-1.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/raspi-config-2.png b/documentation/asciidoc/accessories/build-hat/images/raspi-config-2.png new file mode 100755 index 0000000000..4dfd19cbaf Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/raspi-config-2.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/raspi-config-3.png b/documentation/asciidoc/accessories/build-hat/images/raspi-config-3.png new file mode 100644 index 0000000000..239872e522 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/raspi-config-3.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/raspi-config-4.png b/documentation/asciidoc/accessories/build-hat/images/raspi-config-4.png new file mode 100644 index 0000000000..656f84895c Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/raspi-config-4.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/raspi-config-5.png b/documentation/asciidoc/accessories/build-hat/images/raspi-config-5.png new file mode 100644 index 0000000000..c0117b0857 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/raspi-config-5.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/setting-up.png b/documentation/asciidoc/accessories/build-hat/images/setting-up.png new file mode 100755 index 0000000000..8964b0e449 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/setting-up.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/spike-color.png b/documentation/asciidoc/accessories/build-hat/images/spike-color.png new file mode 100644 index 0000000000..5fd8088591 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/spike-color.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/spike-distance.png b/documentation/asciidoc/accessories/build-hat/images/spike-distance.png new file mode 100644 index 0000000000..2cb55a1c4e Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/spike-distance.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/spike-force.png b/documentation/asciidoc/accessories/build-hat/images/spike-force.png new file mode 100644 index 0000000000..06dc942aef Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/spike-force.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/tall-headers.png b/documentation/asciidoc/accessories/build-hat/images/tall-headers.png new file mode 100644 index 0000000000..cf89aa68ef Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/tall-headers.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/train-motor.png b/documentation/asciidoc/accessories/build-hat/images/train-motor.png new file mode 100644 index 0000000000..00c342aaf5 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/train-motor.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/turning-motor.webm b/documentation/asciidoc/accessories/build-hat/images/turning-motor.webm new file mode 100644 index 0000000000..334b43eae7 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/turning-motor.webm differ diff --git a/documentation/asciidoc/accessories/build-hat/images/wedo-distance.png b/documentation/asciidoc/accessories/build-hat/images/wedo-distance.png new file mode 100644 index 0000000000..47bc9925e0 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/wedo-distance.png differ diff --git a/documentation/asciidoc/accessories/build-hat/images/wedo-tilt.png b/documentation/asciidoc/accessories/build-hat/images/wedo-tilt.png new file mode 100644 index 0000000000..153eb43b02 Binary files /dev/null and b/documentation/asciidoc/accessories/build-hat/images/wedo-tilt.png differ diff --git a/documentation/asciidoc/accessories/build-hat/introduction.adoc b/documentation/asciidoc/accessories/build-hat/introduction.adoc new file mode 100644 index 0000000000..3ee1e7fd8b --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/introduction.adoc @@ -0,0 +1,31 @@ +[[about-build-hat]] +== About + +The https://raspberrypi.com/products/build-hat[Raspberry Pi Build HAT] is an add-on board that connects to the 40-pin GPIO header of your Raspberry Pi, which was designed in collaboration with LEGO® Education to make it easy to control LEGO® Technic™ motors and sensors with Raspberry Pi computers. + +image::images/build-hat.jpg[width="80%"] + +NOTE: A full list of supported devices can be found in the xref:build-hat.adoc#device-compatibility[Device Compatibility] section. + +It provides four connectors for LEGO® Technic™ motors and sensors from the SPIKE™ Portfolio. The available sensors include a distance sensor, a colour sensor, and a versatile force sensor. The angular motors come in a range of sizes and include integrated encoders that can be queried to find their position. + +The Build HAT fits all Raspberry Pi computers with a 40-pin GPIO header, including, with the addition of a ribbon cable or other extension device, Keyboard-series devices. Connected LEGO® Technic™ devices can easily be controlled in Python, alongside standard Raspberry Pi accessories such as a camera module. + +The Raspberry Pi Build HAT power supply (PSU), which is https://raspberrypi.com/products/build-hat-power-supply[available separately], is designed to power both the Build HAT and Raspberry Pi computer along with all connected LEGO® Technic™ devices. + +image::images/psu.jpg[width="80%"] + +The LEGO® Education SPIKE™ Prime Set 45678 and SPIKE™ Prime Expansion Set 45681, available separately from LEGO® Education resellers, include a collection of useful elements supported by the Build HAT. + +NOTE: The HAT works with all 40-pin GPIO Raspberry Pi boards, including Zero-series devices. With the addition of a ribbon cable or other extension device, it can also be used with Keyboard-series devices. + +* Controls up to 4 LEGO® Technic™ motors and sensors included in the SPIKE™ Portfolio +* Easy-to-use https://buildhat.readthedocs.io/[Python library] to control your LEGO® Technic™ devices +* Fits onto any Raspberry Pi computer with a 40-pin GPIO header +* Onboard xref:../microcontrollers/silicon.adoc[RP2040] microcontroller manages low-level control of LEGO® Technic™ devices +* External 8V PSU https://raspberrypi.com/products/build-hat-power-supply[available separately] to power both Build HAT and Raspberry Pi + +[NOTE] +==== +The Build HAT cannot power Keyboard-series devices, since they do not support power supply over the GPIO headers. +==== diff --git a/documentation/asciidoc/accessories/build-hat/links-to-other.adoc b/documentation/asciidoc/accessories/build-hat/links-to-other.adoc new file mode 100644 index 0000000000..99a7abb352 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/links-to-other.adoc @@ -0,0 +1,16 @@ +== Further Resources + +You can download documentation on the, + +* https://datasheets.raspberrypi.com/build-hat/build-hat-serial-protocol.pdf[Raspberry Pi Build HAT Serial Protocol] +* https://datasheets.raspberrypi.com/build-hat/build-hat-python-library.pdf[Raspberry Pi Build HAT Python Library] + +and full details of the Python Library documentation can also be found https://buildhat.readthedocs.io/[on ReadTheDocs]. You can find more information on the .NET library in the https://github.com/dotnet/iot/tree/main/src/devices/BuildHat[.NET IoT] Github repository. + +You can also follow along with projects from the Raspberry Pi Foundation, + +* https://projects.raspberrypi.org/en/projects/lego-game-controller[LEGO® Game Controller] +* https://projects.raspberrypi.org/en/projects/lego-robot-car[LEGO® Robot Car] +* https://projects.raspberrypi.org/en/projects/lego-plotter[LEGO® Plotter] +* https://projects.raspberrypi.org/en/projects/lego-robot-face[LEGO® Robot Face] +* https://projects.raspberrypi.org/en/projects/lego-data-dash[LEGO® Data Dash] diff --git a/documentation/asciidoc/accessories/build-hat/mech.adoc b/documentation/asciidoc/accessories/build-hat/mech.adoc new file mode 100644 index 0000000000..73dc28e614 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/mech.adoc @@ -0,0 +1,5 @@ +== Mechanical Drawings + +Mechanical drawing of the Raspberry Pi Build HAT. + +image::images/mech-build-hat.png[width="80%"] diff --git a/documentation/asciidoc/accessories/build-hat/net-brick.adoc b/documentation/asciidoc/accessories/build-hat/net-brick.adoc new file mode 100644 index 0000000000..f5f42ad8c3 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/net-brick.adoc @@ -0,0 +1,114 @@ +=== Use the Build HAT from .NET + +The Raspberry Pi Built HAT is referred to "Brick" in LEGO® parlance and you can talk directly to it from .NET using the https://datasheets.raspberrypi.com/build-hat/build-hat-serial-protocol.pdf[Build HAT Serial Protocol]. + +You can create a `brick` object as below, + +[source,csharp] +---- +Brick brick = new("/dev/serial0"); +---- + +but you need to remember to dispose of the `brick` at the end of your code. + +[source,csharp] +---- +brick.Dispose(); +---- + +WARNING: If you do not call `brick.Dispose()` your program will not terminate. + +If you want to avoid calling `brick.Dispose` at the end, then create your brick with the `using` statement: + +[source,csharp] +---- +using Brick brick = new("/dev/serial0"); +---- + +In this case, when reaching the end of the program, your brick will be automatically disposed. + +==== Display Build HAT information + +You can gather the various software versions, the signature, and the input voltage: + +[source,csharp] +---- +var info = brick.BuildHatInformation; +Console.WriteLine($"version: {info.Version}, firmware date: {info.FirmwareDate}, signature:"); +Console.WriteLine($"{BitConverter.ToString(info.Signature)}"); +Console.WriteLine($"Vin = {brick.InputVoltage.Volts} V"); +---- + +NOTE: The input voltage is read only once at boot time and is not read again afterwards. + +==== Getting sensors and motors details + +The functions `GetSensorType`, `GetSensor` will allow you to retrieve any information on connected sensor. + +[source,csharp] +---- +SensorType sensor = brick.GetSensorType((SensorPort)i); +Console.Write($"Port: {i} {(Brick.IsMotor(sensor) ? "Sensor" : "Motor")} type: {sensor} Connected: "); +---- + +In this example, you can as well use the `IsMotor` static function to check if the connected element is a sensor or a motor. + +[source,csharp] +---- +if (Brick.IsActiveSensor(sensor)) +{ + ActiveSensor activeSensor = brick.GetActiveSensor((SensorPort)i); +} +else +{ + var passive = (Sensor)brick.GetSensor((SensorPort)i); + Console.WriteLine(passive.IsConnected); +} +---- + +`ActiveSensor` have a collection of advanced properties and functions allowing to understand every element of the sensor. It is also possible to call the primitive functions from the brick from them. This will allow you to select specific modes and do advance scenarios. While this is possible, motor and sensor classes have been created to make your life easier. + +==== Events + +Most sensors implements events on their special properties. You can simply subscribe to `PropertyChanged` and `PropertyUpdated`. The changed one will be fired when the value is changing while the updated one when there is a success update to the property. Depending on the modes used, some properties may be updated in the background all the time while some others occasionally. + +You may be interested only when a colour is changing or the position of the motor is changing, using it as a tachometer. In this case, the `PropertyChanged` is what you need! + +[source,csharp] +---- +Console.WriteLine("Move motor on Port A to more than position 100 to stop this test."); +brick.WaitForSensorToConnect(SensorPort.PortA); +var active = (ActiveMotor)brick.GetMotor(SensorPort.PortA); +bool continueToRun = true; +active.PropertyChanged += MotorPropertyEvent; +while (continueToRun) +{ + Thread.Sleep(50); +} + +active.PropertyChanged -= MotorPropertyEvent; +Console.WriteLine($"Current position: {active.Position}, eventing stopped."); + +void MotorPropertyEvent(object? sender, PropertyChangedEventArgs e) +{ + Console.WriteLine($"Property changed: {e.PropertyName}"); + if (e.PropertyName == nameof(ActiveMotor.Position)) + { + if (((ActiveMotor)brick.GetMotor(SensorPort.PortA)).Position > 100) + { + continueToRun = false; + } + } +} +---- + +==== Wait for initialization + +The brick can take a long time before it initializes. A wait for a sensor to be connected has been implemented. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortB); +---- + +It does as well take a `CancellationToken` if you want to implement advance features like warning the user after some time and retrying. diff --git a/documentation/asciidoc/accessories/build-hat/net-installing-software.adoc b/documentation/asciidoc/accessories/build-hat/net-installing-software.adoc new file mode 100644 index 0000000000..0c9330e0b4 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/net-installing-software.adoc @@ -0,0 +1,52 @@ +== Use the Build HAT from .NET + +=== Install the .NET Framework + +The .NET framework from Microsoft is not available via `apt` on Raspberry Pi. However, you can follow the https://docs.microsoft.com/en-us/dotnet/iot/deployment[official instructions] from Microsoft to install the .NET framework. Alternatively, there is a simplified https://www.petecodes.co.uk/install-and-use-microsoft-dot-net-5-with-the-raspberry-pi/[third party route] to get the .NET toolchain on to your Raspberry Pi. + +WARNING: The installation script is run as `root`. You should read it first and make sure you understand what it is doing. If you are at all unsure you should follow the https://docs.microsoft.com/en-us/dotnet/iot/deployment[official instructions] manually. + +[source,console] +---- +$ wget -O - https://raw.githubusercontent.com/pjgpetecodes/dotnet5pi/master/install.sh | sudo bash +---- + +After installing the .NET framework you can create your project: + +[source,console] +---- +$ dotnet new console --name buildhat +---- + +This creates a default program in the `buildhat` subdirectory, and we need to be in that directory in order to continue: + +[source,console] +---- +$ cd buildhat +---- + +You will now need to install the following nuget packages: + +[source,console] +---- +$ dotnet add package System.Device.Gpio --version 2.1.0 +$ dotnet add package Iot.Device.Bindings --version 2.1.0 +---- + +=== Run C# Code + +You can run the program with the `dotnet run` command. Let's try it now to make sure everything works. It should print "Hello World!" + +[source,console] +---- +$ dotnet run +Hello World! +---- + +(When instructed to "run the program" in the instructions that follow, you will simply rerun `dotnet run`) + +=== Edit C# Code + +In the instructions below, you will be editing the file `buildhat/Program.cs`, the C# program which was generated when you ran the above commands. + +Any text editor will work to edit C# code, including Geany, the IDE/Text Editor that comes pre-installed. https://code.visualstudio.com/docs/setup/raspberry-pi/[Visual Studio Code] (often called "VS Code") is also a popular alternative. diff --git a/documentation/asciidoc/accessories/build-hat/net-motors.adoc b/documentation/asciidoc/accessories/build-hat/net-motors.adoc new file mode 100644 index 0000000000..9e9d9ab543 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/net-motors.adoc @@ -0,0 +1,128 @@ +=== Use Motors from .NET + +There are two types of motors, the *passive* ones and the *active* ones. Active motors will provide detailed position, absolute position and speed while passive motors can only be controlled with speed. + +A common set of functions to control the speed of the motors are available. There are 2 important ones: `SetPowerLimit` and `SetBias`: + +[source,csharp] +---- +train.SetPowerLimit(1.0); +train.SetBias(0.2); +---- + +The accepted values are only from 0.0 to 1.0. The power limit is a convenient ay to reduce in proportion the maximum power. + +The bias value sets for the current port which is added to positive motor drive values and subtracted from negative motor drive values. This can be used to compensate for the fact that most DC motors require a certain amount of drive before they will turn at all. + +The default values when a motor is created is 0.7 for the power limit and 0.3 for the bias. + +==== Passive Motors + +.Train motor, https://www.bricklink.com/v2/catalog/catalogitem.page?S=88011-1&name=Train%20Motor&category=%5BPower%20Functions%5D%5BPowered%20Up%5D#T=S&O={%22iconly%22:0}[Image from Bricklink] +image::images/train-motor.png[Train motor,width="60%"] + +The typical passive motor is a train and older Powered Up motors. The `Speed` property can be set and read. It is the target and the measured speed at the same time as those sensors do not have a way to measure them. The value is from -100 to +100. + +Functions to control `Start`, `Stop` and `SetSpeed` are also available. Here is an example of how to use it: + +[source,csharp] +---- +Console.WriteLine("This will run the motor for 20 secondes incrementing the PWM"); +train.SetPowerLimit(1.0); +train.Start(); +for (int i = 0; i < 100; i++) +{ + train.SetSpeed(i); + Thread.Sleep(250); +} + +Console.WriteLine("Stop the train for 2 seconds"); +train.Stop(); +Thread.Sleep(2000); +Console.WriteLine("Full speed backward for 2 seconds"); +train.Start(-100); +Thread.Sleep(2000); +Console.WriteLine("Full speed forward for 2 seconds"); +train.Start(100); +Thread.Sleep(2000); +Console.WriteLine("Stop the train"); +train.Stop(); +---- + +NOTE: Once the train is started, you can adjust the speed and the motor will adjust accordingly. + +==== Active Motors + +.Active motor, https://www.bricklink.com/v2/catalog/catalogitem.page?S=88014-1&name=Technic%20XL%20Motor&category=%5BPower%20Functions%5D%5BPowered%20Up%5D#T=S&O={%22iconly%22:0}[Image from Bricklink] +image::images/active-motor.png[Active motor,width="60%"] + +Active motors have `Speed`, `AbsolutePosition`, `Position` and `TargetSpeed` as special properties. They are read continuously even when the motor is stopped. + +The code snippet shows how to get the motors, start them and read the properties: + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +brick.WaitForSensorToConnect(SensorPort.PortD); +var active = (ActiveMotor)brick.GetMotor(SensorPort.PortA); +var active2 = (ActiveMotor)brick.GetMotor(SensorPort.PortD); +active.Start(50); +active2.Start(50); +// Make sure you have an active motor plug in the port A and D +while (!Console.KeyAvailable) +{ + Console.CursorTop = 1; + Console.CursorLeft = 0; + Console.WriteLine($"Absolute: {active.AbsolutePosition} "); + Console.WriteLine($"Position: {active.Position} "); + Console.WriteLine($"Speed: {active.Speed} "); + Console.WriteLine(); + Console.WriteLine($"Absolute: {active2.AbsolutePosition} "); + Console.WriteLine($"Position: {active2.Position} "); + Console.WriteLine($"Speed: {active2.Speed} "); +} + +active.Stop(); +active2.Stop(); +---- + +NOTE: Don't forget to start and stop your motors when needed. + +Advance features are available for active motors. You can request to move for seconds, to a specific position, a specific absolute position. Here are couple of examples: + +[source,csharp] +---- +// From the previous example, this will turn the motors back to their initial position: +active.TargetSpeed = 100; +active2.TargetSpeed = 100; +// First this motor and will block the thread +active.MoveToPosition(0, true); +// Then this one and will also block the thread +active2.MoveToPosition(0, true); +---- + +Each function allow you to block or not the thread for the time the operation will be performed. Note that for absolute and relative position moves, there is a tolerance of few degrees. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var active = (ActiveMotor)brick.GetMotor(SensorPort.PortA); +active.TargetSpeed = 70; +Console.WriteLine("Moving motor to position 0"); +active.MoveToPosition(0, true); +Console.WriteLine("Moving motor to position 3600 (10 turns)"); +active.MoveToPosition(3600, true); +Console.WriteLine("Moving motor to position -3600 (so 20 turns the other way"); +active.MoveToPosition(-3600, true); +Console.WriteLine("Moving motor to absolute position 0, should rotate by 90°"); +active.MoveToAbsolutePosition(0, PositionWay.Shortest, true); +Console.WriteLine("Moving motor to position 90"); +active.MoveToAbsolutePosition(90, PositionWay.Shortest, true); +Console.WriteLine("Moving motor to position 179"); +active.MoveToAbsolutePosition(179, PositionWay.Shortest, true); +Console.WriteLine("Moving motor to position -180"); +active.MoveToAbsolutePosition(-180, PositionWay.Shortest, true); +active.Float(); +---- + +You can place the motor in a float position, meaning, there are no more constrains on it. This is a mode that you can use when using the motor as a tachometer, moving it and reading the position. If you still have constrains on the motors, you may not be able to move it. diff --git a/documentation/asciidoc/accessories/build-hat/net-sensors.adoc b/documentation/asciidoc/accessories/build-hat/net-sensors.adoc new file mode 100644 index 0000000000..d6e6284f4e --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/net-sensors.adoc @@ -0,0 +1,213 @@ +=== Use Sensors from .NET + +Like for motors, you have active and passive sensors. Most recent sensors are active. The passive one are lights and simple buttons. Active ones are distance or colour sensors, as well as small 3×3 pixel displays. + +==== Button/Touch Passive Sensor + +The button/touch passive sensor have one specific property `IsPressed`. The property is set to true when the button is pressed. Here is a complete example with events: + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var button = (ButtonSensor)brick.GetSensor(SensorPort.PortA); +bool continueToRun = true; +button.PropertyChanged += ButtonPropertyEvent; +while (continueToRun) +{ + // You can do many other things here + Thread.Sleep(50); +} + +button.PropertyChanged -= ButtonPropertyEvent; +Console.WriteLine($"Button has been pressed, we're stopping the program."); +brick.Dispose(); + +void ButtonPropertyEvent(object? sender, PropertyChangedEventArgs e) +{ + Console.WriteLine($"Property changed: {e.PropertyName}"); + if (e.PropertyName == nameof(ButtonSensor.IsPressed)) + { + continueToRun = false; + } +} +---- + +==== Passive Light + +.Passive light, https://www.bricklink.com/v2/catalog/catalogitem.page?P=22168c01&name=Electric,%20Light%20Unit%20Powered%20Up%20Attachment&category=%5BElectric,%20Light%20&%20Sound%5D#T=C&C=11[Image from Bricklink] +image::images/passive-light.png[Passive light, width="60%"] + +The passive light are the train lights. They can be switched on and you can controlled their brightness. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var light = (PassiveLight)brick.GetSensor(SensorPort.PortA); +// Brightness 50% +light.On(50); +Thread.Sleep(2000); +// 70% Brightness +light.Brightness = 70; +Thread.Sleep(2000); +// Switch light off +light.Off() +---- + +==== Active Sensor + +The active sensor class is a generic one that all the active sensor inherit including active motors. They contains a set of properties regarding how they are connected to the Build HAT, the modes, the detailed Combi modes, the hardware, software versions and a specific property called `ValueAsString`. The value as string contains the last measurement as a collection of strings. A measurement arrives like `P0C0: +23 -42 0`, the enumeration will contains `P0C0:`, `+23`, `-42` and `0`. This is made so if you are using advance modes and managing yourself the Combi modes and commands, you'll be able to get the measurements. + +All active sensor can run a specific measurement mode or a Combi mode. You can setup one through the advance mode using the `SelectModeAndRead` and `SelectCombiModesAndRead` functions with the specific mode(s) you'd like to continuously have. It is important to understand that changing the mode or setting up a new mode will stop the previous mode. + +The modes that can be combined in the Combi mode are listed in the `CombiModes` property. Al the properties of the sensors will be updated automatically when you'll setup one of those modes. + +==== WeDo Tilt Sensor + +.WeDo Tilt sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?S=45305-1&name=WeDo%202.0%20Tilt%20Sensor&category=%5BEducational%20&%20Dacta%5D%5BWeDo%5D#T=S&O={%22iconly%22:0}[Image from Bricklink] +image::images/wedo-tilt.png[WeDo Tilt sensor, width="60%"] + +WeDo Tilt Sensor has a special `Tilt` property. The type is a point with X is the X tilt and Y is the Y tilt. The values goes from -45 to + 45, they are caped to those values and represent degrees. + +You can set a continuous measurement for this sensor using the `ContinuousMeasurement` property. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var tilt = (WeDoTiltSensor)brick.GetSensor(SensorPort.PortA); +tilt.ContinuousMeasurement = true; +Point tiltValue; +while(!console.KeyAvailable) +{ + tiltValue = tilt.Tilt; + console.WriteLine($"Tilt X: {tiltValue.X}, Tilt Y: {tiltValue.Y}"); + Thread.Sleep(200); +} +---- + +==== WeDoDistance Sensor + +.WeDo Distance sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?S=45304-1&name=WeDo%202.0%20Motion%20Sensor&category=%5BEducational%20&%20Dacta%5D%5BWeDo%5D#T=S&O={%22iconly%22:0}[Image from Bricklink] +image::images/wedo-distance.png[WeDo Distance sensor, width="60%"] + +WeDo Distance Sensor gives you a distance in millimetres with the Distance property. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var distance = (WeDoDistanceSensor)brick.GetSensor(SensorPort.PortA); +distance.ContinuousMeasurement = true; +while(!console.KeyAvailable) +{ + console.WriteLine($"Distance: {distance.Distance} mm"); + Thread.Sleep(200); +} +---- + +==== SPIKE Prime Force Sensor + +.Spike Force Sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?P=37312c01&name=Electric%20Sensor,%20Force%20-%20Spike%20Prime&category=%5BElectric%5D#T=C&C=11[Image from Bricklink] +image::images/spike-force.png[spike force sensor, width="60%"] + +This force sensor measure the pressure applies on it and if it is pressed. The two properties can be access through `Force` and `IsPressed` properties. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var force = (ForceSensor)brick.GetSensor(SensorPort.PortA); +force.ContinuousMeasurement = true; +while(!force.IsPressed) +{ + console.WriteLine($"Force: {force.Force} N"); + Thread.Sleep(200); +} +---- + +==== SPIKE Essential 3×3 Colour Light Matrix + +.spike 3×3 matrix, https://www.bricklink.com/v2/catalog/catalogitem.page?P=45608c01&name=Electric,%203%20x%203%20Color%20Light%20Matrix%20-%20SPIKE%20Prime&category=%5BElectric%5D#T=C[Image from Bricklink] +image::images/3x3matrix.png[spike 3×3 matrix, width="60%"] + +This is a small 3×3 display with 9 different LEDs that can be controlled individually. The class exposes functions to be able to control the screen. Here is an example using them: + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var matrix = (ColorLightMatrix)brick.GetSensor(SensorPort.PortA); +for(byte i = 0; i < 10; i++) +{ + // Will light every led one after the other like a progress bar + matrix.DisplayProgressBar(i); + Thread.Sleep(1000); +} + +for(byte i = 0; i < 11; i++) +{ + // Will display the matrix with the same color and go through all of them + matrix.DisplayColor((LedColor)i); + Thread.Sleep(1000); +} + +Span brg = stackalloc byte[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; +Span col = stackalloc LedColor[9] { LedColor.White, LedColor.White, LedColor.White, + LedColor.White, LedColor.White, LedColor.White, LedColor.White, LedColor.White, LedColor.White }; +// Shades of grey +matrix.DisplayColorPerPixel(brg, col); +---- + +==== SPIKE Prime Colour Sensor and Colour and Distance Sensor + +SPIKE colour sensor: + +.spike colour sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?P=37308c01&name=Electric%20Sensor,%20Color%20-%20Spike%20Prime&category=%5BElectric%5D#T=C&C=11[Image from Bricklink] +image::images/spike-color.png[spike color sensor, width="60%"] + +Colour and distance sensor: + +.Color distance sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?P=bb0891c01&name=Electric%20Sensor,%20Color%20and%20Distance%20-%20Boost&category=%5BElectric%5D#T=C&C=1[Image from Bricklink] +image::images/color-distance.png[Colour distance sensor, width="60%"] + +Those colour sensor has multiple properties and functions. You can get the `Color`, the `ReflectedLight` and the `AmbiantLight`. + +On top of this, the Colour and Distance sensor can measure the `Distance` and has an object `Counter`. It will count automatically the number of objects which will go in and out of the range. This does allow to count objects passing in front of the sensor. The distance is limited from 0 to 10 centimetres. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortC); + +var colorSensor = (ColorAndDistanceSensor)brick.GetActiveSensor(SensorPort.PortC); +while (!Console.KeyAvailable) +{ + var colorRead = colorSensor.GetColor(); + Console.WriteLine($"Color: {colorRead}"); + var reflected = colorSensor.GetReflectedLight(); + Console.WriteLine($"Reflected: {reflected}"); + var ambiant = colorSensor.GetAmbiantLight(); + Console.WriteLine($"Ambiant: {ambiant}"); + var distance = colorSensor.GetDistance(); + Console.WriteLine($"Distance: {distance}"); + var counter = colorSensor.GetCounter(); + Console.WriteLine($"Counter: {counter}"); + Thread.Sleep(200); +} +---- + +NOTE: For better measurement, it is not recommended to change the measurement mode in a very fast way, the colour integration may not be done in a proper way. This example gives you the full spectrum of what you can do with the sensor. Also, this class do not implement a continuous measurement mode. You can setup one through the advance mode using the `SelectModeAndRead` function with the specific mode you'd like to continuously have. It is important to understand that changing the mode or setting up a new mode will stop the previous mode. + +==== SPIKE Prime Ultrasonic Distance Sensor + +.Spike distance sensor, https://www.bricklink.com/v2/catalog/catalogitem.page?P=37316c01&name=Electric%20Sensor,%20Distance%20-%20Spike%20Prime&category=%5BElectric%5D#T=C&C=11[Image from Bricklink] +image::images/spike-distance.png[Spike distance sensor, width="60%"] + +This is a distance sensor and it does implement a `Distance` property that will give the distance in millimetre. A `ContinuousMeasurement` mode is also available on this one. + +[source,csharp] +---- +brick.WaitForSensorToConnect(SensorPort.PortA); +var distance = (UltrasonicDistanceSensor)brick.GetSensor(SensorPort.PortA); +distance.ContinuousMeasurement = true; +while(!console.KeyAvailable) +{ + console.WriteLine($"Distance: {distance.Distance} mm"); + Thread.Sleep(200); +} +---- diff --git a/documentation/asciidoc/accessories/build-hat/preparing-build-hat.adoc b/documentation/asciidoc/accessories/build-hat/preparing-build-hat.adoc new file mode 100644 index 0000000000..0e19d8bdac --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/preparing-build-hat.adoc @@ -0,0 +1,78 @@ +== Prepare your Build HAT + +NOTE: Before starting to work with your Raspberry Pi Build HAT you should xref:../computers/getting-started.adoc#setting-up-your-raspberry-pi[set up] your Raspberry Pi, xref:../computers/getting-started.adoc#installing-the-operating-system[install] the latest version of the operating system using https://www.raspberrypi.com/downloads/[Raspberry Pi Imager]. + +Attach 9mm spacers to the bottom of the board. Seat the Raspberry Pi Build HAT onto your Raspberry Pi. Make sure you put it on the right way up. Unlike other HATs, all the components are on the bottom, leaving room for a breadboard or LEGO® elements on top. + +video::images/fitting-build-hat.webm[width="80%"] + +=== Access the GPIO Pins + +If you want to access the GPIO pins of the Raspberry Pi, you can add an optional tall header and use 15 mm spacers. + +image::images/tall-headers.png[width="80%"] + +The following pins are used by the Build HAT itself and you should not connect anything to them. + +[[table_passive_ids]] +[cols="^1,^1,^1", width="75%", options="header"] +|=== +| GPIO| Use | Status +| GPIO0/1 | ID prom | +| GPIO4| Reset | +| GPIO14| Tx | +| GPIO15| Rx | +| GPIO16 | RTS | unused +| GPIO17 | CTS | unused +|=== + + +=== Set up your Raspberry Pi + +Once the Raspberry Pi has booted, open the Raspberry Pi Configuration tool by clicking on the Raspberry Menu button and then selecting "Preferences" and then "Raspberry Pi Configuration". + +Click on the "interfaces" tab and adjust the Serial settings as shown below: + +image::images/setting-up.png[width="50%"] + +==== Use your Raspberry Pi headless + +If you are running your Raspberry Pi headless and using `raspi-config`, select "Interface Options" from the first menu. + +image::images/raspi-config-1.png[width="70%"] + +Then "P6 Serial Port". + +image::images/raspi-config-2.png[width="70%"] + +Disable the serial console: + +image::images/raspi-config-3.png[width="70%"] + +And enable the serial port hardware. + +image::images/raspi-config-4.png[width="70%"] + +The final settings should look like this. + +image::images/raspi-config-5.png[width="70%"] + +You will need to reboot at this point if you have made any changes. + +=== Power the Build HAT + +Connect an external power supply — the https://raspberrypi.com/products/build-hat-power-supply[official Raspberry Pi Build HAT power supply] is recommended — however any reliable +8V±10% power supply capable of supplying 48W via a DC 5521 centre positive barrel connector (5.5mm × 2.1mm × 11mm) will power the Build HAT. You don't need to connect an additional USB power supply to the Raspberry Pi unless you are using a Keyboard-series device. + +[NOTE] +==== +The Build HAT cannot power Keyboard-series devices, since they do not support power supply over the GPIO headers. +==== + +video::images/powering-build-hat.webm[width="80%"] + +[NOTE] +==== +The LEGO® Technic™ motors are very powerful; so to drive them you'll need an external 8V power supply. If you want to read from motor encoders and the SPIKE™ force sensor, you can power your Raspberry Pi and Build HAT the usual way, via your Raspberry Pi's USB power socket. The SPIKE™ colour and distance sensors, like the motors, require an https://raspberrypi.com/products/build-hat-power-supply[external power supply]. +==== + +You have the choice to use Build HAT with Python or .NET. diff --git a/documentation/asciidoc/accessories/build-hat/py-installing-software.adoc b/documentation/asciidoc/accessories/build-hat/py-installing-software.adoc new file mode 100644 index 0000000000..b9a93f8be5 --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/py-installing-software.adoc @@ -0,0 +1,19 @@ +== Use the Build HAT from Python + +=== Install the Build HAT Python Library + +To install the Build HAT Python library, open a terminal window and run the following command: + +[source,console] +---- +$ sudo apt install python3-build-hat +---- + +Raspberry Pi OS versions prior to _Bookworm_ do not have access to the library with `apt`. Instead, run the following command to install the library using `pip`: + +[source,console] +---- +$ sudo pip3 install buildhat +---- + +For more information about the Build HAT Python Library see https://buildhat.readthedocs.io/[ReadTheDocs]. diff --git a/documentation/asciidoc/accessories/build-hat/py-motors.adoc b/documentation/asciidoc/accessories/build-hat/py-motors.adoc new file mode 100644 index 0000000000..7cf498f67b --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/py-motors.adoc @@ -0,0 +1,61 @@ +=== Use Motors from Python + +There are xref:build-hat.adoc#device-compatibility[a number of motors] that work with the Build HAT. + +==== Connect a Motor + +Connect a motor to port A on the Build HAT. The LPF2 connectors need to be inserted the correct way up. If the connector doesn't slide in easily, rotate by 180 degrees and try again. + +video::images/connect-motor.webm[width="80%"] + + +==== Work with Motors + +Start the https://thonny.org/[Thonny IDE]. Add the program code below: + +[source,python] +---- +from buildhat import Motor + +motor_a = Motor('A') + +motor_a.run_for_seconds(5) +---- + +Run the program by clicking the play/run button. If this is the first time you're running a Build HAT program since the Raspberry Pi has booted, there will be a few seconds pause while the firmware is copied across to the board. You should see the red LED extinguish and the green LED illuminate. Subsequent executions of a Python program will not require this pause. + +video::images/blinking-light.webm[width="80%"] + +Your motor should turn clockwise for 5 seconds. + +video::images/turning-motor.webm[width="80%"] + +Change the final line of your program and re-run. + +[source,python] +---- +motor_a.run_for_seconds(5, speed=50) +---- + +The motor should now turn faster. Make another change: + +[source,python] +---- +motor_a.run_for_seconds(5, speed=-50) +---- + +The motor should turn in the opposite (anti-clockwise) direction + +Create a new program by clicking on the plus button in Thonny. Add the code below: + +[source,python] +---- +from buildhat import Motor + +motor_a = Motor('A') + +while True: + print("Position: ", motor_a.get_aposition()) +---- + +Run the program. Grab the motor and turn the shaft. You should see the numbers printed in the Thonny REPL changing. diff --git a/documentation/asciidoc/accessories/build-hat/py-sensors.adoc b/documentation/asciidoc/accessories/build-hat/py-sensors.adoc new file mode 100644 index 0000000000..15571eae8e --- /dev/null +++ b/documentation/asciidoc/accessories/build-hat/py-sensors.adoc @@ -0,0 +1,33 @@ +=== Use Sensors from Python + +There is a xref:build-hat.adoc#device-compatibility[large range of sensors] that work with the Build HAT. + +==== Work with Sensors + +Connect a Colour sensor to port B on the Build HAT, and a Force sensor to port C. + +NOTE: If you're not intending to drive a motor, then you don't need an external power supply and you can use a standard USB power supply for your Raspberry Pi. + +Create another new program: + +[source,python] +---- +from signal import pause +from buildhat import ForceSensor, ColorSensor + +button = ForceSensor('C') +cs = ColorSensor('B') + +def handle_pressed(force): + cs.on() + print(cs.get_color()) + +def handle_released(force): + cs.off() + +button.when_pressed = handle_pressed +button.when_released = handle_released +pause() +---- + +Run it and hold a coloured object (LEGO® elements are ideal) in front of the colour sensor and press the Force sensor plunger. The sensor's LED should switch on and the name of the closest colour should be displayed in the Thonny REPL. diff --git a/documentation/asciidoc/accessories/bumper.adoc b/documentation/asciidoc/accessories/bumper.adoc new file mode 100644 index 0000000000..01e8de0fbe --- /dev/null +++ b/documentation/asciidoc/accessories/bumper.adoc @@ -0,0 +1 @@ +include::bumper/about.adoc[] diff --git a/documentation/asciidoc/accessories/bumper/about.adoc b/documentation/asciidoc/accessories/bumper/about.adoc new file mode 100644 index 0000000000..ee9f120523 --- /dev/null +++ b/documentation/asciidoc/accessories/bumper/about.adoc @@ -0,0 +1,31 @@ +== About + +.The Raspberry Pi Bumper for Raspberry Pi 5 +image::images/bumper.jpg[width="80%"] + +The Raspberry Pi Bumper for Raspberry Pi 5 is a snap-on silicone cover that protects +the bottom and edges of the board. When attached, the mounting holes of the Raspberry Pi remain accessible through the bumper. + +The Bumper is only compatible with Raspberry Pi 5. + +== Assembly instructions + +.Assembling the bumper +image::images/assembly.png[width="80%"] + +To attach the Raspberry Pi Bumper to your Raspberry Pi: + +. Turn off your Raspberry Pi and disconnect the power cable. +. Remove the SD card from the SD card slot of your Raspberry Pi. +. Align the bumper with the board. +. Press the board gently but firmly into the bumper, taking care to avoid contact between the bumper and any of the board’s components. +. Insert your SD card back into the SD card slot of your Raspberry Pi. +. Reconnect your Raspberry Pi to power. + +To remove the Raspberry Pi Bumper from your Raspberry Pi: + +. Turn off your Raspberry Pi and disconnect the power cable. +. Remove the SD card from the SD card slot of your Raspberry Pi. +. Gently but firmly peel the bumper away from the board, taking care to avoid contact between the bumper and any of the board’s components. +. Insert your SD card back into the SD card slot of your Raspberry Pi. +. Reconnect your Raspberry Pi to power. diff --git a/documentation/asciidoc/accessories/bumper/images/assembly.png b/documentation/asciidoc/accessories/bumper/images/assembly.png new file mode 100644 index 0000000000..bdcfb03289 Binary files /dev/null and b/documentation/asciidoc/accessories/bumper/images/assembly.png differ diff --git a/documentation/asciidoc/accessories/bumper/images/bumper.jpg b/documentation/asciidoc/accessories/bumper/images/bumper.jpg new file mode 100644 index 0000000000..14682676a2 Binary files /dev/null and b/documentation/asciidoc/accessories/bumper/images/bumper.jpg differ diff --git a/documentation/asciidoc/accessories/camera.adoc b/documentation/asciidoc/accessories/camera.adoc index 42ef13b8c2..f5076f9fa0 100644 --- a/documentation/asciidoc/accessories/camera.adoc +++ b/documentation/asciidoc/accessories/camera.adoc @@ -1,22 +1,9 @@ -include::camera/camera_usage.adoc[] - include::camera/camera_hardware.adoc[] -include::camera/camera_installing.adoc[] - -include::camera/raspicam.adoc[] - -include::camera/libcamera_software.adoc[] - -include::camera/timelapse.adoc[] - -include::camera/raw.adoc[] - -include::camera/longexp.adoc[] - -include::camera/v4l2.adoc[] +include::camera/filters.adoc[] -include::camera/csi-2-usage.adoc[] +include::camera/lens.adoc[] -include::camera/hqcam_filter_removal.adoc[] +include::camera/synchronous_cameras.adoc[] +include::camera/external_trigger.adoc[] diff --git a/documentation/asciidoc/accessories/camera/camera_hardware.adoc b/documentation/asciidoc/accessories/camera/camera_hardware.adoc index 5f47e5b756..3b8dafbd56 100644 --- a/documentation/asciidoc/accessories/camera/camera_hardware.adoc +++ b/documentation/asciidoc/accessories/camera/camera_hardware.adoc @@ -1,246 +1,271 @@ -== Camera Modules +:figure-caption!: +== About the Camera Modules -The Raspberry Pi Camera Modules are official products from the Raspberry Pi Foundation. The original 5-megapixel model was https://www.raspberrypi.org/blog/camera-board-available-for-sale/[released] in 2013, and an 8-megapixel https://www.raspberrypi.org/products/camera-module-v2/[Camera Module v2] was https://www.raspberrypi.org/blog/new-8-megapixel-camera-board-sale-25/[released] in 2016. For both iterations, there are visible light and infrared versions. A 12-megapixel https://www.raspberrypi.org/products/raspberry-pi-high-quality-camera/[High Quality Camera] was https://www.raspberrypi.org/blog/new-product-raspberry-pi-high-quality-camera-on-sale-now-at-50/[released] in 2020. There is no infrared version of the HQ Camera, however the xref:camera.adoc#raspberry-pi-hq-camera-filter-removal[IR Filter can be removed] if required. +There are now several official Raspberry Pi camera modules. The original 5-megapixel model was https://www.raspberrypi.com/news/camera-board-available-for-sale/[released] in 2013, it was followed by an 8-megapixel https://www.raspberrypi.com/products/camera-module-v2/[Camera Module 2] which was https://www.raspberrypi.com/news/new-8-megapixel-camera-board-sale-25/[released] in 2016. The latest camera model is the 12-megapixel https://raspberrypi.com/products/camera-module-3/[Camera Module 3] which was https://www.raspberrypi.com/news/new-autofocus-camera-modules/[released] in 2023. The original 5MP device is no longer available from Raspberry Pi. -=== Hardware Specification +All of these cameras come in visible light and infrared versions, while the Camera Module 3 also comes as a standard or wide FoV model for a total of four different variants. + +.Camera Module 3 (left) and Camera Module 3 Wide (right) +image::images/cm3.jpg[Camera Module 3 normal and wide angle] + +.Camera Module 3 NoIR (left) and Camera Module 3 NoIR Wide (right) +image::images/cm3_noir.jpg[Camera Module 3 NoIR normal and wide angle] + +Additionally, a 12-megapixel https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/[High Quality Camera] with CS- or M12-mount variants for use with external lenses was https://www.raspberrypi.com/news/new-product-raspberry-pi-high-quality-camera-on-sale-now-at-50/[released in 2020] and https://www.raspberrypi.com/news/new-autofocus-camera-modules/[2023] respectively. There is no infrared version of the HQ Camera, however the xref:camera.adoc#filter-removal[IR Filter can be removed] if required. + +.HQ Camera, M12-mount (left) and C/CS-mount (right) +image::images/hq.jpg[M12- and C/CS-mount versions of the HQ Camera] + +The Raspberry Pi AI Camera uses the Sony IMX500 imaging sensor to provide low-latency and high-performance AI capabilities to any camera application. Tight integration with xref:../computers/camera_software.adoc[Raspberry Pi's camera software stack] allows users to deploy their own neural network models with minimal effort. + +image::images/ai-camera-hero.png[The Raspberry Pi AI Camera] + +Finally, there is the Global Shutter camera, which was http://raspberrypi.com/news/new-raspberry-pi-global-shutter-camera[released in 2023]. There is no infrared version of the GS Camera, however the xref:camera.adoc#filter-removal[IR Filter can be removed] if required. + +.Global Shutter Camera +image::images/gs-camera.jpg[GS Camera] + +NOTE: Raspberry Pi Camera Modules are compatible with all Raspberry Pi computers with CSI connectors. + +=== Rolling or Global shutter? + +Most digital cameras, including our Camera Modules, use a **rolling shutter**: they scan the image they're capturing line-by-line, then output the results. You may have noticed that this can cause distortion effects in some settings; if you've ever photographed rotating propeller blades, you've probably spotted the image shimmering rather than looking like an object that is rotating. The propeller blades have had enough time to change position in the tiny moment that the camera has taken to swipe across and observe the scene. + +A **global shutter**, like the one on our Global Shutter Camera Module, doesn't do this. It captures the light from every pixel in the scene at once, so your photograph of propeller blades will not suffer from the same distortion. + +Why is this useful? Fast-moving objects, like those propeller blades, are now easy to capture; we can also synchronise several cameras to take a photo at precisely the same moment in time. There are plenty of benefits here, like minimising distortion when capturing stereo images. (The human brain is confused if any movement that appears in the left eye has not appeared in the right eye yet.) The Raspberry Pi Global Shutter Camera can also operate with shorter exposure times - down to 30µs, given enough light - than a rolling shutter camera, which makes it useful for high-speed photography. + +NOTE: The Global Shutter Camera's image sensor has a 6.3mm diagonal active sensing area, which is similar in size to Raspberry Pi's HQ Camera. However, the pixels are larger and can collect more light. Large pixel size and low pixel count are valuable in machine-vision applications; the more pixels a sensor produces, the harder it is to process the image in real time. To get around this, many applications downsize and crop images. This is unnecessary with the Global Shutter Camera and the appropriate lens magnification, where the lower resolution and large pixel size mean an image can be captured natively. + +== Install a Raspberry Pi camera + +WARNING: Cameras are sensitive to static. Earth yourself prior to handling the PCB. A sink tap or similar should suffice if you don't have an earthing strap. + +=== Connect the Camera + +Before connecting any Camera, shut down your Raspberry Pi and disconnect it from power. + +The flex cable inserts into the connector labelled CAMERA on the Raspberry Pi, which is located between the Ethernet and HDMI ports. The cable must be inserted with the silver contacts facing the HDMI port. To open the connector, pull the tabs on the top of the connector upwards, then towards the Ethernet port. The flex cable should be inserted firmly into the connector, with care taken not to bend the flex at too acute an angle. To close the connector, push the top part of the connector down and away from the Ethernet port while holding the flex cable in place. + +The following video shows how to connect the original camera on the original Raspberry Pi 1: + +video::GImeVqHQzsE[youtube,width=80%,height=400px] + +All Raspberry Pi boards with a camera connector use the same installation method, though the Raspberry Pi 5 and all Raspberry Pi Zero models require a https://www.raspberrypi.com/products/camera-cable/[different camera cable]. + +Some cameras may come with a small piece of translucent blue plastic film covering the lens. This is only present to protect the lens during shipping. To remove it, gently peel it off. + +NOTE: There is additional documentation available around fitting the recommended https://datasheets.raspberrypi.com/hq-camera/cs-mount-lens-guide.pdf[6mm] and https://datasheets.raspberrypi.com/hq-camera/c-mount-lens-guide.pdf[16mm] lens to the HQ Camera. + +=== Prepare the Software + +Before proceeding, we recommend ensuring that your kernel, GPU firmware and applications are all up to date. Please follow the instructions on xref:../computers/os.adoc#update-software[keeping your operating system up to date]. + +Then, please follow the relevant setup instructions for xref:../computers/camera_software.adoc#rpicam-apps[`rpicam-apps`], and the https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf[Picamera2 Python library]. + +== Hardware Specification |=== -| | Camera Module v1 | Camera Module v2 | HQ Camera +| | Camera Module v1 | Camera Module v2 | Camera Module 3 | Camera Module 3 Wide | HQ Camera | AI Camera | GS Camera | Net price | $25 | $25 +| $25 +| $35 +| $50 +| $70 | $50 | Size | Around 25 × 24 × 9 mm -| -| 38 x 38 x 18.4mm (excluding lens) +| Around 25 × 24 × 9 mm +| Around 25 × 24 × 11.5 mm +| Around 25 × 24 × 12.4 mm +| 38 × 38 × 18.4mm (excluding lens) +| 25 × 24 × 11.9mm +| 38 × 38 × 19.8mm (29.5mm with adaptor and dust cap) | Weight | 3g | 3g -| +| 4g +| 4g +| 30.4g +| 6g +| 34g (41g with adaptor and dust cap) | Still resolution -| 5 Megapixels -| 8 Megapixels -| 12.3 Megapixels +| 5 megapixels +| 8 megapixels +| 11.9 megapixels +| 11.9 megapixels +| 12.3 megapixels +| 12.3 megapixels +| 1.58 megapixels | Video modes | 1080p30, 720p60 and 640 × 480p60/90 -| 1080p30, 720p60 and 640 × 480p60/90 -| 1080p30, 720p60 and 640 × 480p60/90 - -| Linux integration -| V4L2 driver available -| V4L2 driver available -| V4L2 driver available - -| C programming API -| OpenMAX IL and others available -| OpenMAX IL and others available -| +| 1080p47, 1640 × 1232p41 and 640 × 480p206 +| 2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120 +| 2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120 +| 2028 × 1080p50, 2028 × 1520p40 and 1332 × 990p120 +| 2028 × 1520p30, 4056 × 3040p10 +| 1456 × 1088p60 | Sensor | OmniVision OV5647 | Sony IMX219 -| https://www.sony-semicon.co.jp/products/common/pdf/IMX477-AACK_Flyer.pdf[Sony IMX477] +| Sony IMX708 +| Sony IMX708 +| Sony IMX477 +| Sony IMX500 +| Sony IMX296 | Sensor resolution | 2592 × 1944 pixels | 3280 × 2464 pixels -| 4056 x 3040 pixels +| 4608 × 2592 pixels +| 4608 × 2592 pixels +| 4056 × 3040 pixels +| 4056 × 3040 pixels +| 1456 × 1088 pixels | Sensor image area | 3.76 × 2.74 mm -| 3.68 x 2.76 mm (4.6 mm diagonal) -| 6.287mm x 4.712 mm (7.9mm diagonal) +| 3.68 × 2.76 mm (4.6 mm diagonal) +| 6.45 × 3.63mm (7.4mm diagonal) +| 6.45 × 3.63mm (7.4mm diagonal) +| 6.287mm × 4.712 mm (7.9mm diagonal) +| 6.287mm × 4.712 mm (7.9mm diagonal) +| 6.3mm diagonal | Pixel size | 1.4 µm × 1.4 µm -| 1.12 µm x 1.12 µm -| 1.55 µm x 1.55 µm +| 1.12 µm × 1.12 µm +| 1.4 µm × 1.4 µm +| 1.4 µm × 1.4 µm +| 1.55 µm × 1.55 µm +| 1.55 µm × 1.55 µm +| 3.45 µm × 3.45 µm | Optical size | 1/4" | 1/4" -| - -| Full-frame SLR lens equivalent -| 35 mm -| -| - -| S/N ratio -| 36 dB -| -| - -| Dynamic range -| 67 dB @ 8x gain -| -| - -| Sensitivity -| 680 mV/lux-sec -| -| - -| Dark current -| 16 mV/sec @ 60 C -| -| - -| Well capacity -| 4.3 Ke- -| -| - -| Fixed focus -| 1 m to infinity -| +| 1/2.43" +| 1/2.43" +| 1/2.3" +| 1/2.3" +| 1/2.9" + +| Focus +| Fixed +| Adjustable +| Motorized +| Motorized +| Adjustable +| Adjustable +| Adjustable + +| Depth of field +| Approx 1 m to ∞ +| Approx 10 cm to ∞ +| Approx 10 cm to ∞ +| Approx 5 cm to ∞ +| N/A +| Approx 20 cm to ∞ | N/A | Focal length | 3.60 mm +/- 0.01 | 3.04 mm +| 4.74 mm +| 2.75 mmm +| Depends on lens +| 4.74 mm | Depends on lens -| Horizontal field of view +| Horizontal Field of View (FoV) | 53.50 +/- 0.13 degrees | 62.2 degrees +| 66 degrees +| 102 degrees +| Depends on lens +| 66 ±3 degrees | Depends on lens -| Vertical field of view +| Vertical Field of View (FoV) | 41.41 +/- 0.11 degrees | 48.8 degrees +| 41 degrees +| 67 degrees +| Depends on lens +| 52.3 ±3 degrees | Depends on lens | Focal ratio (F-Stop) -| 2.9 -| 2.0 +| F2.9 +| F2.0 +| F1.8 +| F2.2 +| Depends on lens +| F1.79 | Depends on lens -|=== -=== Hardware Features +| Maximum exposure time (seconds) +| 3.28 +| 11.76 +| 112 +| 112 +| 670.74 +| 112 +| 15.5 -|=== -| Available | Implemented +| Lens Mount +| N/A +| N/A +| N/A +| N/A +| C/CS- or M12-mount +| N/A +| C/CS -| Chief ray angle correction +| NoIR version available? | Yes - -| Global and rolling shutter -| Rolling shutter - -| Automatic exposure control (AEC) -| No - done by ISP instead - -| Automatic white balance (AWB) -| No - done by ISP instead - -| Automatic black level calibration (ABLC) -| No - done by ISP instead - -| Automatic 50/60 Hz luminance detection -| No - done by ISP instead - -| Frame rate up to 120 fps -| Max 90fps. Limitations on frame size for the higher frame rates (VGA only for above 47fps) - -| AEC/AGC 16-zone size/position/weight control -| No - done by ISP instead - -| Mirror and flip | Yes - -| Cropping -| No - done by ISP instead (except 1080p mode) - -| Lens correction -| No - done by ISP instead - -| Defective pixel cancelling -| No - done by ISP instead - -| 10-bit RAW RGB data -| Yes - format conversions available via GPU - -| Support for LED and flash strobe mode -| LED flash - -| Support for internal and external frame synchronisation for frame exposure mode -| No - -| Support for 2 × 2 binning for better SNR in low light conditions -| Anything output res below 1296 x 976 will use the 2 x 2 binned mode - -| Support for horizontal and vertical sub-sampling -| Yes, via binning and skipping - -| On-chip phase lock loop (PLL) | Yes - -| Standard serial SCCB interface | Yes - -| Digital video port (DVP) parallel output interface | No - -| MIPI interface (two lanes) -| Yes - -| 32 bytes of embedded one-time programmable (OTP) memory | No - -| Embedded 1.5V regulator for core power -| Yes -|=== - -=== Software Features - -[cols=2] +| No |=== -| Picture formats -| JPEG (accelerated), JPEG + RAW, GIF, BMP, PNG, YUV420, RGB888 +NOTE: There is https://github.com/raspberrypi/libcamera/issues/43[some evidence] to suggest that the Camera Module 3 may emit RFI at a harmonic of the CSI clock rate. This RFI is in a range to interfere with GPS L1 frequencies (1575 MHz). Please see the https://github.com/raspberrypi/libcamera/issues/43[thread on Github] for details and proposed workarounds. -| Video formats -| raw h.264 (accelerated) - -| Effects -| negative, solarise, posterize, whiteboard, blackboard, sketch, denoise, emboss, oilpaint, hatch, gpen, pastel, watercolour, film, blur, saturation - -| Exposure modes -| auto, night, nightpreview, backlight, spotlight, sports, snow, beach, verylong, fixedfps, antishake, fireworks - -| Metering modes -| average, spot, backlit, matrix - -| Automatic white balance modes -| off, auto, sun, cloud, shade, tungsten, fluorescent, incandescent, flash, horizon - -| Triggers -| Keypress, UNIX signal, timeout +=== Mechanical Drawings -| Extra modes -| demo, burst/timelapse, circular buffer, video with motion vectors, segmented video, live preview on 3D models -|=== +Available mechanical drawings; -=== HQ Camera IR Filter Transmission +* Camera Module 2 https://datasheets.raspberrypi.com/camera/camera-module-2-mechanical-drawing.pdf[PDF] +* Camera Module 3 https://datasheets.raspberrypi.com/camera/camera-module-3-standard-mechanical-drawing.pdf[PDF] +* Camera Module 3 Wide https://datasheets.raspberrypi.com/camera/camera-module-3-wide-mechanical-drawing.pdf[PDF] +* Camera Module 3 https://datasheets.raspberrypi.com/camera/camera-module-3-step.zip[STEP files] +* HQ Camera Module (CS-mount version) https://datasheets.raspberrypi.com/hq-camera/hq-camera-cs-mechanical-drawing.pdf[PDF] +** The CS-mount https://datasheets.raspberrypi.com/hq-camera/hq-camera-cs-lensmount-drawing.pdf[PDF] +* HQ Camera Module (M12-mount version) https://datasheets.raspberrypi.com/hq-camera/hq-camera-m12-mechanical-drawing.pdf[PDF] +* GS Camera Module +https://datasheets.raspberrypi.com/gs-camera/gs-camera-mechanical-drawing.pdf[PDF] -The HQ Camera uses a Hoya CM500 infrared filter. Its transmission characteristics are as represented in the following graph. +NOTE: Board dimensions and mounting-hole positions for Camera Module 3 are identical to Camera Module 2. However, due to changes in the size and position of the sensor module, it is not mechanically compatible with the camera lid for the Raspberry Pi Zero Case. -image::images/hoyacm500.png[CM500 Transmission Graph] +=== Schematics -=== Mechanical Drawings +.Schematic of the Raspberry Pi CSI camera connector. +image:images/RPi-S5-conn.png[camera connector, width="65%"] -* Camera Module v2 https://datasheets.raspberrypi.org/camera/camera-v2-mechanical-drawing.pdf[PDF] -* HQ Camera Module https://datasheets.raspberrypi.org/hq-camera/hq-camera-mechanical-drawing.pdf[PDF] -* HQ Camera Module lens mount https://datasheets.raspberrypi.org/hq-camera/hq-camera-lensmount-drawing.pdf[PDF] +Other available schematics; -=== Schematics +* Camera Module v2 https://datasheets.raspberrypi.com/camera/camera-module-2-schematics.pdf[PDF] +* Camera Module v3 https://datasheets.raspberrypi.com/camera/camera-module-3-schematics.pdf[PDF] +* HQ Camera Module https://datasheets.raspberrypi.com/hq-camera/hq-camera-schematics.pdf[PDF] -* Camera Module v2 https://datasheets.raspberrypi.org/camera/camera-v2-schematics.pdf[PDF] -* HQ Camera Module https://datasheets.raspberrypi.org/hq-camera/hq-camera-schematics.pdf[PDF] diff --git a/documentation/asciidoc/accessories/camera/camera_installing.adoc b/documentation/asciidoc/accessories/camera/camera_installing.adoc deleted file mode 100644 index 91bbe02169..0000000000 --- a/documentation/asciidoc/accessories/camera/camera_installing.adoc +++ /dev/null @@ -1,61 +0,0 @@ -== Installing a Raspberry Pi camera - -WARNING: Cameras are sensitive to static. Earth yourself prior to handling the PCB. A sink tap or similar should suffice if you don't have an earthing strap. - -=== Connecting the Camera - -The flex cable inserts into the connector labelled CAMERA on the Raspberry Pi, which is located between the Ethernet and HDMI ports. The cable must be inserted with the silver contacts facing the HDMI port. To open the connector, pull the tabs on the top of the connector upwards, then towards the Ethernet port. The flex cable should be inserted firmly into the connector, with care taken not to bend the flex at too acute an angle. To close the connector, push the top part of the connector towards the HDMI port and down, while holding the flex cable in place. - -We have created a video to illustrate the process of connecting the camera. Although the video shows the original camera on the original Raspberry Pi 1, the principle is the same for all camera boards: - -video::GImeVqHQzsE[youtube] - -Depending on the model, the camera may come with a small piece of translucent blue plastic film covering the lens. This is only present to protect the lens while it is being mailed to you, and needs to be removed by gently peeling it off. - -=== Enabling the Camera - -==== Using the desktop - -Select `Preferences` and `Raspberry Pi Configuration` from the desktop menu: a window will appear. Select the `Interfaces` tab, then click on the `enable camera` option. Click `OK`. You will need to reboot for the changes to take effect. - -==== Using the command line - -Open the `raspi-config` tool from the terminal: - -[,bash] ----- -sudo raspi-config ----- - -Select `Interfacing Options` then `Camera` and press `Enter`. Choose `Yes` then `Ok`. Go to `Finish` and you'll be prompted to reboot. - -=== Setting up the Camera Software - -Execute the following instructions on the command line to download and install the latest kernel, GPU firmware, and applications. You'll need an internet connection for this to work correctly. - -[,bash] ----- -sudo apt update -sudo apt full-upgrade ----- - -Now you need to enable camera support using the `raspi-config` program you will have used when you first set up your Raspberry Pi. - -[,bash] ----- -sudo raspi-config ----- - -Use the cursor keys to select and open _Interfacing Options_, and then select _Camera_ and follow the prompt to enable the camera. - -Upon exiting `raspi-config`, it will ask to reboot. The enable option will ensure that on reboot the correct GPU firmware will be running with the camera driver and tuning, and the GPU memory split is sufficient to allow the camera to acquire enough memory to run correctly. - -To test that the system is installed and working, try the following command: - -[,bash] ----- -raspistill -v -o test.jpg ----- - -The display should show a five-second preview from the camera and then take a picture, saved to the file `test.jpg`, whilst displaying various informational messages. - diff --git a/documentation/asciidoc/accessories/camera/camera_usage.adoc b/documentation/asciidoc/accessories/camera/camera_usage.adoc deleted file mode 100644 index e711172a5d..0000000000 --- a/documentation/asciidoc/accessories/camera/camera_usage.adoc +++ /dev/null @@ -1,16 +0,0 @@ -== Basic Camera Usage - -Raspberry Pi currently sell two types of camera board: an https://www.raspberrypi.org/products/camera-module-v2/[8MP device] and a https://www.raspberrypi.org/products/raspberry-pi-high-quality-camera/[12MP High Quality (HQ)] camera. The 8MP device is also available in https://www.raspberrypi.org/products/pi-noir-camera-v2/[NoIR form] without an IR filter. The original 5MP device is no longer available from Raspberry Pi. - -All Raspberry Pi cameras are capable of taking high-resolution photographs, along with full HD 1080p video, and can be fully controlled programmatically. This documentation describes how to use the camera in various scenarios, and how to use the various software tools. - -Once xref:camera.adoc#installing-a-raspberry-pi-camera[installed], there are various ways the cameras can be used. The simplest option is to use one of the provided camera applications. There are four Linux xref:camera.adoc#raspicam-commands[command-line applications] installed by default (e.g. `raspistill`). - -You can also programatically access the camera using the Python programming language, using the https://projects.raspberrypi.org/en/projects/getting-started-with-picamera[`picamera` library]. - -=== About `libcamera` - -libcamera is a new Linux API for interfacing to cameras. Raspberry Pi have been involved with the development of libcamera and are now using this sophisticated system for new camera software. This means Raspberry Pi are moving away from the firmware-based camera image processing pipeline (ISP) to a more open system. - -* http://libcamera.org/[Libcamera's main website]. -* https://datasheets.raspberrypi.org/camera/raspberry-pi-camera-guide.pdf[Tuning guide for the Raspberry Pi cameras and libcamera] diff --git a/documentation/asciidoc/accessories/camera/csi-2-usage.adoc b/documentation/asciidoc/accessories/camera/csi-2-usage.adoc deleted file mode 100644 index 6c65b4b045..0000000000 --- a/documentation/asciidoc/accessories/camera/csi-2-usage.adoc +++ /dev/null @@ -1,202 +0,0 @@ -== Camera Serial Interface 2 (CSI2) "Unicam" - -The SoC's used on the Raspberry Pi range all have two camera interfaces that support either CSI-2 D-PHY 1.1 or CCP2 (Compact Camera Port 2) sources. This interface is known by the codename "Unicam". The first instance of Unicam supports 2 CSI-2 data lanes, whilst the second supports 4. Each lane can run at up to 1Gbit/s (DDR, so the max link frequency is 500MHz). - -However, the normal variants of the Raspberry Pi only expose the second instance, and route out _only_ 2 of the data lanes to the camera connector. The Compute Module range route out all lanes from both peripherals. - -=== Software Interfaces - -There are 3 independent software interfaces available for communicating with the Unicam peripheral: - -==== Firmware - -The closed source GPU firmware has drivers for Unicam and three camera sensors plus a bridge chip. They are the Raspberry Pi Camera v1.3 (Omnivision OV5647), Raspberry Pi Camera v2.1 (Sony IMX219), Raspberry Pi HQ camera (Sony IMX477), and an unsupported driver for the Toshiba TC358743 HDMI\->CSI2 bridge chip. - -This driver integrates the source driver, Unicam, ISP, and tuner control into a full camera stack delivering processed output images. It can be used via MMAL, OpenMAX IL and V4L2 using the bcm2835-v4l2 kernel module. Only Raspberry Pi cameras are supported via this interface. - -==== MMAL rawcam component - -This was an interim option before the V4L2 driver was available. The MMAL component `vc.ril.rawcam` allows receiving of the raw CSI2 data in the same way as the V4L2 driver, but all source configuration has to be done by userland over whatever interface the source requires. The raspiraw application is available on https://github.com/raspberrypi/raspiraw[github]. It uses this component and the standard I2C register sets for OV5647, IMX219, and ADV7282M to support streaming. - -==== V4L2 - -There is a fully open source kernel driver available for the Unicam block; this is a kernel module called bcm2835-unicam. This interfaces to V4L2 subdevice drivers for the source to deliver the raw frames. This bcm2835-unicam driver controls the sensor, and configures the CSI-2 receiver so that the peripheral will write the raw frames (after Debayer) to SDRAM for V4L2 to deliver to applications. Except for this ability to unpack the CSI-2 Bayer formats to 16bits/pixel, there is no image processing between the image source (e.g. camera sensor) and bcm2835-unicam placing the image data in SDRAM. - ----- -|------------------------| -| bcm2835-unicam | -|------------------------| - ^ | - | |-------------| - img | | Subdevice | - | |-------------| - v -SW/HW- | -|---------| |-----------| -| Unicam | | I2C or SPI| -|---------| |-----------| -csi2/ ^ | -ccp2 | | - |-----------------| - | sensor | - |-----------------| ----- - -Mainline Linux has a range of existing drivers. The Raspberry Pi kernel tree has some additional drivers and device tree overlays to configure them that have all been tested and confirmed to work. They include: - -|=== -| Device | Type | Notes - -| Omnivision OV5647 -| 5MP Camera -| Original Raspberry Pi Camera - -| Sony IMX219 -| 8MP Camera -| Revision 2 Raspberry Pi camera - -| Sony IMX477 -| 12MP Camera -| Raspberry Pi HQ camera - -| Toshiba TC358743 -| HDMI to CSI-2 bridge -| - -| Analog Devices ADV728x-M -| Analog video to CSI-2 bridge -| No interlaced support - -| Infineon IRS1125 -| Time-of-flight depth sensor -| Supported by a third party -|=== - -As the subdevice driver is also a kernel driver, with a standardised API, 3rd parties are free to write their own for any source of their choosing. - -=== Developing a Third-Party Drivers - -This is the recommended approach to interfacing via Unicam. - -When developing a driver for a new device intended to be used with the bcm2835-unicam module, you need the driver and corresponding device tree overlays. Ideally the driver should be submitted to the http://vger.kernel.org/vger-lists.html#linux-media[linux-media] mailing list for code review and merging into mainline, then moved to the https://github.com/raspberrypi/linux[Raspberry Pi kernel tree], but exceptions may be made for the driver to be reviewed and merged directly to the Raspberry Pi kernel. - -Please note that all kernel drivers are licensed under the GPLv2 licence, therefore source code *MUST* be available. Shipping of binary modules only is a violation of the GPLv2 licence under which the Linux kernel is licensed. - -The bcm2835-unicam has been written to try and accommodate all types of CSI-2 source driver as are currently found in the mainline Linux kernel. Broadly these can be split into camera sensors and bridge chips. Bridge chips allow for conversion between some other format and CSI-2. - -==== Camera sensors - -The sensor driver for a camera sensor is responsible for all configuration of the device, usually via I2C or SPI. Rather than writing a driver from scratch, it is often easier to take an existing driver as a basis and modify it as appropriate. - -The https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/media/i2c/imx219.c[IMX219 driver] is a good starting point. This driver supports both 8bit and 10bit Bayer readout, so enumerating frame formats and frame sizes is slightly more involved. - -Sensors generally support https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html[V4L2 user controls]. Not all these controls need to be implemented in a driver. The IMX219 driver only implements a small subset, listed below, the implementation of which is handled by the `imx219_set_ctrl` function. - -* `V4L2_CID_PIXEL_RATE` / `V4L2_CID_VBLANK` / `V4L2_CID_HBLANK`: allows the application to set the frame rate. -* `V4L2_CID_EXPOSURE`: sets the exposure time in lines. The application needs to use `V4L2_CID_PIXEL_RATE`, `V4L2_CID_HBLANK`, and the frame width to compute the line time. -* `V4L2_CID_ANALOGUE_GAIN`: analogue gain in sensor specific units. -* `V4L2_CID_DIGITAL_GAIN`: optional digital gain in sensor specific units. -* `V4L2_CID_HFLIP / V4L2_CID_VFLIP`: flips the image either horizontally or vertically. Note that this operation may change the Bayer order of the data in the frame, as is the case on the imx219. -* `V4L2_CID_TEST_PATTERN` / `V4L2_CID_TEST_PATTERN_*`: Enables output of various test patterns from the sensor. Useful for debugging. - -In the case of the IMX219, many of these controls map directly onto register writes to the sensor itself. - -Device tree is used to select the sensor driver and configuren parameters such as number of CSI-2 lanes, continuous clock lane operation, and link frequency (often only one is supported). - -* The IMX219 https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/imx219-overlay.dts[device tree overlay] for the 5.4 kernel - -==== Bridge chips - -These are devices that convert an incoming video stream, for example HDMI or composite, into a CSI-2 stream that can be accepted by the Raspberry Pi CSI-2 receiver. - -Handling bridge chips is more complicated, as unlike camera sensors they have to respond to the incoming signal and report that to the application. - -The mechanisms for handling bridge chips can be broadly split into either analogue or digital. - -When using `ioctls` in the sections below, an `_S_` in the `ioctl` name means it is a set function, whilst `_G_` is a get function and `_ENUM` enumerates a set of permitted values. - -===== Analogue video sources - -Analogue video sources use the standard `ioctls` for detecting and setting video standards. :https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-std.html[`VIDIOC_G_STD`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-std.html[`VIDIOC_S_STD`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enumstd.html[`VIDIOC_ENUMSTD`], and https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-querystd.html[`VIDIOC_QUERYSTD`] - -Selecting the wrong standard will generally result in corrupt images. Setting the standard will typically also set the resolution on the V4L2 CAPTURE queue. It can not be set via `VIDIOC_S_FMT`. Generally requesting the detected standard via `VIDIOC_QUERYSTD` and then setting it with `VIDIOC_S_STD` before streaming is a good idea. - -===== Digital video sources - -For digital video sources, such as HDMI, there is an alternate set of calls that allow specifying of all the digital timing parameters (https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-dv-timings.html[`VIDIOC_G_DV_TIMINGS`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-dv-timings.html[`VIDIOC_S_DV_TIMINGS`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enum-dv-timings.html[`VIDIOC_ENUM_DV_TIMINGS`], and https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-query-dv-timings.html[`VIDIOC_QUERY_DV_TIMINGS`]). - -As with analogue bridges, the timings typically fix the V4L2 CAPTURE queue resolution, and calling `VIDIOC_S_DV_TIMINGS` with the result of `VIDIOC_QUERY_DV_TIMINGS` before streaming should ensure the format is correct. - -Depending on the bridge chip and the driver, it may be possible for changes in the input source to be reported to the application via `VIDIOC_SUBSCRIBE_EVENT` and `V4L2_EVENT_SOURCE_CHANGE`. - -===== Currently supported devices - -There are 2 bridge chips that are currently supported by the Raspberry Pi Linux kernel, the Analog Devices ADV728x-M for analogue video sources, and the Toshiba TC358743 for HDMI sources. - -_Analog Devices ADV728x(A)-M Analogue video to CSI2 bridge_ - -These chips convert composite, S-video (Y/C), or component (YPrPb) video into a single lane CSI-2 interface, and are supported by the https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/media/i2c/adv7180.c[ADV7180 kernel driver]. - -Product details for the various versions of this chip can be found on the Analog Devices website. - -https://www.analog.com/en/products/adv7280a.html[ADV7280A], https://www.analog.com/en/products/adv7281a.html[ADV7281A], https://www.analog.com/en/products/adv7282a.html[ADV7282A] - -Because of some missing code in the current core V4L2 implementation, selecting the source fails, so the Raspberry Pi kernel version adds a kernel module parameter called `dbg_input` to the ADV7180 kernel driver which sets the input source every time VIDIOC_S_STD is called. At some point mainstream will fix the underlying issue (a disjoin between the kernel API call s_routing, and the userspace call `VIDIOC_S_INPUT`) and this modification will be removed. - -Please note that receiving interlaced video is not supported, therefore the ADV7281(A)-M version of the chip is of limited use as it doesn't have the necessary I2P deinterlacing block. Also ensure when selecting a device to specify the -M option. Without that you will get a parallel output bus which can not be interfaced to the Raspberry Pi. - -There are no known commercially available boards using these chips, but this driver has been tested via the Analog Devices https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/EVAL-ADV7282A-M.html[EVAL-ADV7282-M evaluation board] - -This driver can be loaded using the `config.txt` dtoverlay `adv7282m` if you are using the `ADV7282-M` chip variant; or `adv728x-m` with a parameter of either `adv7280m=1`, `adv7281m=1`, or `adv7281ma=1` if you are using a different variant. e.g. - ----- -dtoverlay=adv728x-m,adv7280m=1 ----- - -_Toshiba TC358743 HDMI to CSI2 bridge_ - -This is a HDMI to CSI-2 bridge chip, capable of converting video data at up to 1080p60. - -Information on this bridge chip can be found on the https://toshiba.semicon-storage.com/ap-en/semiconductor/product/interface-bridge-ics-for-mobile-peripheral-devices/hdmir-interface-bridge-ics/detail.TC358743XBG.html[Toshiba Website] - -The TC358743 interfaces HDMI in to CSI-2 and I2S outputs. It is supported by the https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/media/i2c/tc358743.c[TC358743 kernel module]. - -The chip supports incoming HDMI signals as either RGB888, YUV444, or YUV422, at up to 1080p60. It can forward RGB888, or convert it to YUV444 or YUV422, and convert either way between YUV444 and YUV422. Only RGB888 and YUV422 support has been tested. When using 2 CSI-2 lanes, the maximum rates that can be supported are 1080p30 as RGB888, or 1080p50 as YUV422. When using 4 lanes on a Compute Module, 1080p60 can be received in either format. - -HDMI negotiates the resolution by a receiving device advertising an https://en.wikipedia.org/wiki/Extended_Display_Identification_Data[EDID] of all the modes that it can support. The kernel driver has no knowledge of the resolutions, frame rates, or formats that you wish to receive, therefore it is up to the user to provide a suitable file. -This is done via the VIDIOC_S_EDID ioctl, or more easily using `v4l2-ctl --fix-edid-checksums --set-edid=file=filename.txt` (adding the --fix-edid-checksums option means that you don't have to get the checksum values correct in the source file). Generating the required EDID file (a textual hexdump of a binary EDID file) is not too onerous, and there are tools available to generate them, but it is beyond the scope of this page. - -As described above, use the `DV_TIMINGS` ioctls to configure the driver to match the incoming video. The easiest approach for this is to use the command `v4l2-ctl --set-dv-bt-timings query`. The driver does support generating the SOURCE_CHANGED events should you wish to write an application to handle a changing source. Changing the output pixel format is achieved by setting it via VIDIOC_S_FMT, however only the pixel format field will be updated as the resolution is configured by the dv timings. - -There are a couple of commercially available boards that connect this chip to the Raspberry Pi. The Auvidea B101 and B102 are the most widely obtainable, but other equivalent boards are available. - -This driver is loaded using the `config.txt` dtoverlay `tc358743`. - -The chip also supports capturing stereo HDMI audio via I2S. The Auvidea boards break the relevant signals out onto a header, which can be connected to the Pi's 40 pin header. The required wiring is: - -[cols=",^,^,^"] -|=== -| Signal | B101 header | Pi 40 pin header | BCM GPIO - -| LRCK/WFS -| 7 -| 35 -| 19 - -| BCK/SCK -| 6 -| 12 -| 18 - -| DATA/SD -| 5 -| 38 -| 20 - -| GND -| 8 -| 39 -| N/A -|=== - -The `tc358743-audio` overlay is required _in addition to_ the `tc358743` overlay. This should create an ALSA recording device for the HDMI audio. -Please note that there is no resampling of the audio. The presence of audio is reflected in the V4L2 control TC358743_CID_AUDIO_PRESENT / "audio-present", and the sample rate of the incoming audio is reflected in the V4L2 control TC358743_CID_AUDIO_SAMPLING_RATE / "Audio sampling-frequency". Recording when no audio is present will generate warnings, as will recording at a sample rate different from that reported. diff --git a/documentation/asciidoc/accessories/camera/external_trigger.adoc b/documentation/asciidoc/accessories/camera/external_trigger.adoc new file mode 100644 index 0000000000..642412d54d --- /dev/null +++ b/documentation/asciidoc/accessories/camera/external_trigger.adoc @@ -0,0 +1,80 @@ +== External Trigger on the GS Camera + +The Global Shutter (GS) camera can be triggered externally by pulsing the external trigger (denoted on the board as XTR) connection on the board. Multiple cameras can be connected to the same pulse, allowing for an alternative way to synchronise two cameras. + +The exposure time is equal to the low pulse-width time plus an additional 14.26us. i.e. a low pulse of 10000us leads to an exposure time of 10014.26us. Framerate is directly controlled by how often you pulse the pin. A PWM frequency of 30Hz will lead to a framerate of 30 frames per second. + +image::images/external_trigger.jpg[alt="Image showing pulse format",width="80%"] + +=== Preparation + +WARNING: This modification includes removing an SMD soldered part. You should not attempt this modification unless you feel you are competent to complete it. When soldering to the Camera board, please remove the plastic back cover to avoid damaging it. + +If your board has transistor Q2 fitted (shown in blue on the image below), then you will need to remove R11 from the board (shown in red). This connects GP1 to XTR and without removing R11, the camera will not operate in external trigger mode. +The location of the components is displayed below. + +image::images/resistor.jpg[alt="Image showing resistor to be removed",width="80%"] + +Next, solder a wire to the touchpoints of XTR and GND on the GS Camera board. Note that XTR is a 1.8V input, so you may need a level shifter or potential divider. + +We can use a Raspberry Pi Pico to provide the trigger. Connect any Pico GPIO pin (GP28 is used in this example) to XTR via a 1.5kΩ resistor. Also connect a 1.8kΩ resistor between XTR and GND to reduce the high logic level to 1.8V. A wiring diagram is shown below. + +image::images/pico_wiring.jpg[alt="Image showing Raspberry Pi Pico wiring",width="50%"] + +==== Raspberry Pi Pico MicroPython Code + +[source,python] +---- +from machine import Pin, PWM + +from time import sleep + +pwm = PWM(Pin(28)) + +framerate = 30 +shutter = 6000 # In microseconds + +frame_length = 1000000 / framerate +pwm.freq(framerate) + +pwm.duty_u16(int((1 - (shutter - 14) / frame_length) * 65535)) +---- + +The low pulse width is equal to the shutter time, and the frequency of the PWM equals the framerate. + +NOTE: In this example, Pin 28 connects to the XTR touchpoint on the GS camera board. + +=== Camera driver configuration + +This step is only necessary if you have more than one camera with XTR wired in parallel. + +Edit `/boot/firmware/config.txt`. Change `camera_auto_detect=1` to `camera_auto_detect=0`. + +Append this line: +[source] +---- +dtoverlay=imx296,always-on +---- +When using the CAM0 port on a Raspberry Pi 5, CM4 or CM5, append `,cam0` to that line without a space. If both cameras are on the same Raspberry Pi you will need two dtoverlay lines, only one of them ending with `,cam0`. + +If the external trigger will not be started right away, you also need to increase the libcamera timeout xref:camera.adoc#libcamera-configuration[as above]. + +=== Starting the camera + +Enable external triggering: + +[source,console] +---- +$ echo 1 | sudo tee /sys/module/imx296/parameters/trigger_mode +---- + +Run the code on the Pico, then set the camera running: + +[source,console] +---- +$ rpicam-hello -t 0 --qt-preview --shutter 3000 +---- + +Every time the Pico pulses the pin, it should capture a frame. However, if `--gain` and `--awbgains` are not set, some frames will be dropped to allow AGC and AWB algorithms to settle. + +NOTE: When running `rpicam-apps`, always specify a fixed shutter duration, to ensure the AGC does not try to adjust the camera's shutter speed. The value is not important, since it is actually controlled by the external trigger pulse. diff --git a/documentation/asciidoc/accessories/camera/filters.adoc b/documentation/asciidoc/accessories/camera/filters.adoc new file mode 100644 index 0000000000..32ac70e027 --- /dev/null +++ b/documentation/asciidoc/accessories/camera/filters.adoc @@ -0,0 +1,71 @@ +== Camera Filters + +Some transmission characteristics are available for the Camera Module 3 and the HQ and GS cameras. + +NOTE: These graphs are available as https://datasheets.raspberrypi.com/camera/camera-extended-spectral-sensitivity.pdf[a PDF]. + +=== Camera Module 3 + +The Camera Module 3 is built around the IMX708, which has the following spectral sensitivity characteristics. + +image::images/cm3-filter.png[Camera Module 3 Transmission Graph, width="65%"] + +=== HQ Camera + +Raspberry Pi HQ Camera without IR-Cut filter. + +image::images/hq.png[HQ Camera Transmission Graph without IR-Cut filter,width="65%"] + + +=== GS Camera + +Raspberry Pi GS Camera without IR-Cut filter. + +image::images/gs.png[GS Camera Transmission Graph without IR-Cut filter,width="65%"] + + +=== HQ and GS Cameras + +The HQ and GS Cameras use a Hoya CM500 infrared filter. Its transmission characteristics are as represented in the following graph. + +image::images/hoyacm500.png[CM500 Transmission Graph,width="65%"] + +== IR Filter + +Both the High Quality Camera and Global Shutter Camera contain an IR filter to reduce the camera's sensitivity to infrared light and help outdoor photos look more natural. However, you may remove the filter to: + +* Enhance colours in certain types of photography, such as images of plants, water, and the sky +* Provide night vision in a location that is illuminated with infrared light + +=== Filter Removal + +WARNING: *This procedure cannot be reversed:* the adhesive that attaches the filter will not survive being lifted and replaced, and while the IR filter is about 1.1mm thick, it may crack when it is removed. *Removing it will void the warranty on the product*. + +You can remove the filter from both the HQ and GS cameras. The HQ camera is shown in the demonstration below. + +image:images/FILTER_ON_small.jpg[width="65%"] + +NOTE: Make sure to work in a clean and dust-free environment, as the sensor will be exposed to the air. + +. Unscrew the two 1.5 mm hex lock keys on the underside of the main circuit board. Be careful not to let the washers roll away. ++ +image:images/SCREW_REMOVED_small.jpg[width="65%"] +. There is a gasket of slightly sticky material between the housing and PCB which will require some force to separate. You may try some ways to weaken the adhesive, such as a little isopropyl alcohol and/or heat (~20-30 C). +. Once the adhesive is loose, lift up the board and place it down on a very clean surface. Make sure the sensor does not touch the surface. ++ +image:images/FLATLAY_small.jpg[width="65%"] +. Face the lens upwards and place the mount on a flat surface. ++ +image:images/SOLVENT_small.jpg[width="65%"] +. To minimise the risk of breaking the filter, use a pen top or similar soft plastic item to push down on the filter only at the very edges where the glass attaches to the aluminium. The glue will break and the filter will detach from the lens mount. ++ +image:images/REMOVE_FILTER_small.jpg[width="65%"] +. Given that changing lenses will expose the sensor, at this point you could affix a clear filter (for example, OHP plastic) to minimize the chance of dust entering the sensor cavity. +. Replace the main housing over the circuit board. Be sure to realign the housing with the gasket, which remains on the circuit board. +. Apply the nylon washer first to prevent damage to the circuit board. +. Next, fit the steel washer, which prevents damage to the nylon washer. Screw down the two hex lock keys. As long as the washers have been fitted in the correct order, they do not need to be screwed very tightly. ++ +image:images/FILTER_OFF_small.jpg[width="65%"] + +NOTE: It is likely to be difficult or impossible to glue the filter back in place and return the device to functioning as a normal optical camera. + diff --git a/documentation/asciidoc/accessories/camera/hqcam_filter_removal.adoc b/documentation/asciidoc/accessories/camera/hqcam_filter_removal.adoc deleted file mode 100644 index 666421816a..0000000000 --- a/documentation/asciidoc/accessories/camera/hqcam_filter_removal.adoc +++ /dev/null @@ -1,23 +0,0 @@ -== Raspberry Pi HQ Camera Filter Removal - -The High Quality Camera contains an IR filter, which is used to reduce the camera's sensitivity to infrared light. This ensures that outdoor photos look more natural. However, some nature photography can be enhanced with the removal of this filter; the colours of sky, plants, and water can be affected by its removal. The camera can also be used without the filter for night vision in a location that is illuminated with infrared light. - -WARNING: *This procedure cannot be reversed:* the adhesive that attaches the filter will not survive being lifted and replaced, and while the IR filter is about 1.1mm thick, it may crack when it is removed. *Removing it will void the warranty on the product*. Nevertheless, removing the filter will be desirable to some users. - -To remove the filter: - -. Work in a clean and dust-free environment, as the sensor will be exposed to the air. -image:images/rpi_hq_cam_sensor.jpg[camera sensor] -. Unscrew the two 1.5 mm hex lock keys on the underside of the main circuit board. Be careful not to let the washers roll away. There is a gasket of slightly sticky material between the housing and PCB which will require some force to separate. -image:images/rpi_hq_cam_gasket.jpg[camera gasket] -. Lift up the board and place it down on a very clean surface. Make sure the sensor does not touch the surface. -. Before completing the next step, read through all of the steps and decide whether you are willing to void your warranty. *Do not proceed* unless you are sure that you are willing to void your warranty. -. Turn the lens around so that it is "looking" upwards and place it on a table. -You may try some ways to weaken the adhesive, such as a little isopropyl alcohol and/or heat (~20-30 C). Using a pen top or similar soft plastic item, push down on the filter only at the very edges where the glass attaches to the aluminium - to minimise the risk of breaking the filter. The glue will break and the filter will detach from the lens mount. -image:images/rpi_hq_cam_ir_filter.jpg[camera ir filter] -. Given that changing lenses will expose the sensor, at this point you could affix a clear filter (for example, OHP plastic) to minimize the chance of dust entering the sensor cavity. -image:images/rpi_hq_cam_clear_filter.jpg[camera protective filter] -. Replace the main housing over the circuit board. Be sure to realign the housing with the gasket, which remains on the circuit board. -. The nylon washer prevents damage to the circuit board; apply this washer first. Next, fit the steel washer, which prevents damage to the nylon washer. -. Screw down the two hex lock keys. As long as the washers have been fitted in the correct order, they do not need to be screwed very tightly. -. Note that it is likely to be difficult or impossible to glue the filter back in place and return the device to functioning as a normal optical camera. diff --git a/documentation/asciidoc/accessories/camera/images/FILTER_OFF.jpg b/documentation/asciidoc/accessories/camera/images/FILTER_OFF.jpg new file mode 100644 index 0000000000..918eb217f2 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FILTER_OFF.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/FILTER_OFF_small.jpg b/documentation/asciidoc/accessories/camera/images/FILTER_OFF_small.jpg new file mode 100644 index 0000000000..a0ab753ff8 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FILTER_OFF_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/FILTER_ON.jpg b/documentation/asciidoc/accessories/camera/images/FILTER_ON.jpg new file mode 100644 index 0000000000..47abc24c71 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FILTER_ON.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/FILTER_ON_small.jpg b/documentation/asciidoc/accessories/camera/images/FILTER_ON_small.jpg new file mode 100644 index 0000000000..4de5eefe39 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FILTER_ON_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/FLATLAY.jpg b/documentation/asciidoc/accessories/camera/images/FLATLAY.jpg new file mode 100644 index 0000000000..6fad88e33f Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FLATLAY.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/FLATLAY_small.jpg b/documentation/asciidoc/accessories/camera/images/FLATLAY_small.jpg new file mode 100644 index 0000000000..2cb6d17c2a Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/FLATLAY_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER.jpg b/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER.jpg new file mode 100644 index 0000000000..845fda2980 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER_small.jpg b/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER_small.jpg new file mode 100644 index 0000000000..46d2e73fc5 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/REMOVE_FILTER_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/RPi-S5-conn.png b/documentation/asciidoc/accessories/camera/images/RPi-S5-conn.png new file mode 100644 index 0000000000..b587a6afcb Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/RPi-S5-conn.png differ diff --git a/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED.jpg b/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED.jpg new file mode 100644 index 0000000000..02cb97774a Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED_small.jpg b/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED_small.jpg new file mode 100644 index 0000000000..0c9cb169cf Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/SCREW_REMOVED_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/SOLVENT.jpg b/documentation/asciidoc/accessories/camera/images/SOLVENT.jpg new file mode 100644 index 0000000000..e7c4e965ae Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/SOLVENT.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/SOLVENT_small.jpg b/documentation/asciidoc/accessories/camera/images/SOLVENT_small.jpg new file mode 100644 index 0000000000..589f1a8c70 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/SOLVENT_small.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/ai-camera-hero.png b/documentation/asciidoc/accessories/camera/images/ai-camera-hero.png new file mode 100644 index 0000000000..a0186287cb Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/ai-camera-hero.png differ diff --git a/documentation/asciidoc/accessories/camera/images/cam.jpg b/documentation/asciidoc/accessories/camera/images/cam.jpg deleted file mode 100644 index 38963884d2..0000000000 Binary files a/documentation/asciidoc/accessories/camera/images/cam.jpg and /dev/null differ diff --git a/documentation/asciidoc/accessories/camera/images/cam2.jpg b/documentation/asciidoc/accessories/camera/images/cam2.jpg deleted file mode 100644 index 01d39ca9c1..0000000000 Binary files a/documentation/asciidoc/accessories/camera/images/cam2.jpg and /dev/null differ diff --git a/documentation/asciidoc/accessories/camera/images/cm3-filter.png b/documentation/asciidoc/accessories/camera/images/cm3-filter.png new file mode 100644 index 0000000000..669f8c86e8 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/cm3-filter.png differ diff --git a/documentation/asciidoc/accessories/camera/images/cm3.jpg b/documentation/asciidoc/accessories/camera/images/cm3.jpg new file mode 100644 index 0000000000..a05ed4c117 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/cm3.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/cm3_noir.jpg b/documentation/asciidoc/accessories/camera/images/cm3_noir.jpg new file mode 100644 index 0000000000..1673bf392e Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/cm3_noir.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/external_trigger.jpg b/documentation/asciidoc/accessories/camera/images/external_trigger.jpg new file mode 100644 index 0000000000..dd6f4d27b3 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/external_trigger.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/gs-camera.jpg b/documentation/asciidoc/accessories/camera/images/gs-camera.jpg new file mode 100644 index 0000000000..f03c35928a Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/gs-camera.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/gs.png b/documentation/asciidoc/accessories/camera/images/gs.png new file mode 100644 index 0000000000..e75662f401 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/gs.png differ diff --git a/documentation/asciidoc/accessories/camera/images/hq.jpg b/documentation/asciidoc/accessories/camera/images/hq.jpg new file mode 100644 index 0000000000..ff213e3a8f Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/hq.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/hq.png b/documentation/asciidoc/accessories/camera/images/hq.png new file mode 100644 index 0000000000..42cd3b7c1e Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/hq.png differ diff --git a/documentation/asciidoc/accessories/camera/images/m12-lens.jpg b/documentation/asciidoc/accessories/camera/images/m12-lens.jpg new file mode 100644 index 0000000000..875f0297a2 Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/m12-lens.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/pico_wiring.jpg b/documentation/asciidoc/accessories/camera/images/pico_wiring.jpg new file mode 100644 index 0000000000..c26df7a84f Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/pico_wiring.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/resistor.jpg b/documentation/asciidoc/accessories/camera/images/resistor.jpg new file mode 100644 index 0000000000..7d9fc1077e Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/resistor.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_clear_filter.jpg b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_clear_filter.jpg index 00daf6b070..dc401f9adc 100644 Binary files a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_clear_filter.jpg and b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_clear_filter.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_gasket.jpg b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_gasket.jpg index b4cd564a4e..572ca31674 100644 Binary files a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_gasket.jpg and b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_gasket.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_ir_filter.jpg b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_ir_filter.jpg index 8b786511b4..ee09e5b4cd 100644 Binary files a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_ir_filter.jpg and b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_ir_filter.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_sensor.jpg b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_sensor.jpg index d9792c2f33..40bb170bbe 100644 Binary files a/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_sensor.jpg and b/documentation/asciidoc/accessories/camera/images/rpi_hq_cam_sensor.jpg differ diff --git a/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.fzz b/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.fzz new file mode 100644 index 0000000000..d17305956d Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.fzz differ diff --git a/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.jpg b/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.jpg new file mode 100644 index 0000000000..995a59882c Binary files /dev/null and b/documentation/asciidoc/accessories/camera/images/synchronous_camera_wiring.jpg differ diff --git a/documentation/asciidoc/accessories/camera/lens.adoc b/documentation/asciidoc/accessories/camera/lens.adoc new file mode 100644 index 0000000000..ad461444fe --- /dev/null +++ b/documentation/asciidoc/accessories/camera/lens.adoc @@ -0,0 +1,42 @@ +== Recommended Lenses + +The following lenses are recommended for use with our HQ and GS cameras. + +NOTE: While the HQ Camera is available in both C/CS- and M12-mount versions, the GS Camera is available only with a C/CS-mount. + +=== C/CS Lenses + +We recommend two lenses, a 6mm wide angle lens and a 16mm telephoto lens. These lenses should be available from your nearest https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/[Authorised Reseller]. + +[cols="1,1,1,1"] +|=== +2+| | 16mm telephoto | 6mm wide angle + +2+| Resolution | 10MP | 3MP +2+| Image format | 1" | 1/2" +2+| Aperture | F1.4 to F16 | F1.2 +2+| Mount | C | CS +.2+| Field of View H°×V° (D°) +| HQ | 22.2°×16.7° (27.8°)| 55°×45° (71°) +| GS| 17.8°×13.4° (22.3) | 45°×34° (56°) +2+| Back focal length | 17.53mm | 7.53mm +2+| M.O.D. | 0.2m | 0.2m +2+| Dimensions | φ39.00×50.00mm | φ30×34mm +|=== + +=== M12 Lenses + +image::images/m12-lens.jpg[] + +We recommend three lenses manufactured by https://www.gaojiaoptotech.com/[Gaojia Optotech]. These lenses should be available from your nearest https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/[Authorised Reseller]. + +[cols="1,1,1,1,1"] +|=== +2+| | 8mm | 25mm | Fish Eye + +2+| Resolution | 12MP | 5MP | 15MP +2+| Image format | 1/1.7" | 1/2" | 1/2.3" +2+| Aperture | F1.8 | F2.4 | F2.5 +2+| Mount 3+| M12 +2+| HQ Field of View H°×V° (D°) | 49°×36° (62°) | 14.4°×10.9° (17.9)° | 140°×102.6° (184.6°) +|=== diff --git a/documentation/asciidoc/accessories/camera/libcamera_software.adoc b/documentation/asciidoc/accessories/camera/libcamera_software.adoc deleted file mode 100644 index 113d63f326..0000000000 --- a/documentation/asciidoc/accessories/camera/libcamera_software.adoc +++ /dev/null @@ -1,121 +0,0 @@ -== _libcamera_ and _libcamera-apps_ Installation - -Your Raspberry Pi should be running the latest version of the Raspberry Pi OS (_Buster_ at the time of writing), and the camera and I2C interfaces must both be enabled (check the _Interfaces_ tab of the _Raspberry Pi Configuration_ tool, from the _Preferences_ menu). First ensure your system, firmware and all its applications and repositories are up to date by entering the following commands into a terminal window. - -[,bash] ----- -sudo apt update -sudo apt full-upgrade ----- - -libcamera is under active development which sometimes means that new features need to be supported in Raspberry Pi OS, even before they are officially released. Therefore we currently recommend updating to the latest release candidate. To do this, first reboot your Pi, and then use - -[,bash] ----- -sudo rpi-update ----- - -WARNING: Note that the release candidate is not as thoroughly tested as an official release. If your Raspberry Pi contains important or critical data we would strongly advise that it is backed up first, or that a fresh SD card is used for the purpose of trying _libcamera_. - -Next, the `/boot/config.txt` file must be updated to load and use the camera driver, by adding the following to the bottom. - -[,bash] ----- -dtoverlay=imx219 ----- - -If you are using a sensor other than the `imx219` you will need to supply the alternative name here (for example, `ov5647` for the V1 camera, or `imx477` for the HQ Cam). - -*NOTE*: after rebooting, control of the camera system will be passed to the ARM cores, and firmware-based camera functions (such as raspistill and so forth) will no longer work. Setting `/boot/config.txt` back and rebooting will restore the previous behaviour. - -=== Select the Correct Graphics Driver - -There are 3 different graphics drivers available on the Raspberry Pi: firmware, FKMS and KMS. The firmware graphics driver cannot be used with _libcamera-apps_. The Raspberry Pi 4 and 400 use the newer FKMS graphics driver by default: this is compatible with _libcamera-apps_. For all other models of Raspberry Pi, you must select the FKMS driver by adding the following line to the `/boot/config.txt` file: - ----- -dtoverlay=vc4-fkms-v3d ----- - -=== Building _libcamera_ and _qcam_ - -The build system and runtime environment of _libcamera_ have a number of dependencies. They can be installed with the following commands. - -[,bash] ----- -sudo apt install libboost-dev -sudo apt install libgnutls28-dev openssl libtiff5-dev -sudo apt install qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 -sudo apt install meson -sudo pip3 install pyyaml ply ----- - -The Qt libraries are only required for _libcamera_'s _qcam_ demo app. - -Unfortunately, at the time of writing, the default version of meson is a little old, so please execute: - -[,bash] ----- -sudo pip3 install --upgrade meson ----- - -We can now check out the code and build _libcamera_ as follows. Note that if you are using a 1GB system (such as a Pi 3) you may need to replace `ninja -C build` by `ninja -C build -j 2` as this will stop ninja exhausting the system memory and aborting. - -[,bash] ----- -git clone git://linuxtv.org/libcamera.git -cd libcamera -meson build -cd build -meson configure -Dpipelines=raspberrypi -Dtest=false -cd .. -ninja -C build -sudo ninja -C build install ----- - -At this stage you may wish to check that _qcam_ works. Type `build/src/qcam/qcam` and check that you see a camera image. - -=== Raspberry Pi's _libcamera-apps_ - -Raspberry Pi's _libcamera-apps_ provide very similar functionality to the _raspistill_ and _raspivid_ applications that use the proprietary firmware-based camera stack. To build them, we must first install _libepoxy_. - -[,bash] ----- -cd -sudo apt install libegl1-mesa-dev -git clone https://github.com/anholt/libepoxy.git -cd libepoxy -mkdir _build -cd _build -meson -ninja -sudo ninja install ----- - -Finally we can build the _libcamera-apps_. As we saw previously, 1GB platforms may need `make -j2` in place of `make -j4`. - -[,bash] ----- -cd -sudo apt install cmake libboost-program-options-dev libdrm-dev libexif-dev -git clone https://github.com/raspberrypi/libcamera-apps.git -cd libcamera-apps -mkdir build -cd build -cmake .. -make -j4 ----- - -To check everything is working correctly, type `./libcamera-hello` - you should see a preview window displayed for about 5 seconds. - -[NOTE] -====== -For Pi 3 devices, as we saw previously, 1GB devices may need `make -j2` instead of `make -j4`. - -Also, Pi 3s do not by default use the correct GL driver, so please ensure you have `dtoverlay=vc4-fkms-v3d` in the `[all]` (not in the `[pi4]`) section of your `/boot/config.txt` file. -====== - -=== Further Documentation - -You can find out more in the https://datasheets.raspberrypi.org/camera/raspberry-pi-camera-guide.pdf[_Raspberry Pi Camera Algorithm and Tuning Guide_.]. - -More information on the _libcamera-apps_ is available https://github.com/raspberrypi/libcamera-apps/blob/main/README.md[on Github]. diff --git a/documentation/asciidoc/accessories/camera/longexp.adoc b/documentation/asciidoc/accessories/camera/longexp.adoc deleted file mode 100644 index 0abac483cb..0000000000 --- a/documentation/asciidoc/accessories/camera/longexp.adoc +++ /dev/null @@ -1,27 +0,0 @@ -== Long Exposures - -The different camera modules have different capabilities with regard to exposure times: - -[cols=",^"] -|=== -| Module | Max exposure (seconds) - -| V1 (OMx5647) -| 6 - -| V2 (IMX219) -| 10 - -| HQ (IMX417) -| 230 -|=== - -Due to the way the ISP works, by default asking for a long exposure can result in the capture process taking up to 7 times the exposure time, so a 200 second exposure on the HQ camera could take 1400 seconds to actually return an image. This is due to the way the camera system works out the correct exposures and gains to use in the image, using it's AGC (automatic gain control) and AWB (automatic white balance) algorithms. The system needs a few frames to calculate these numbers in order to produce a decent image. When combined with frame discards at the start of processing (in case they are corrupt), and the switching between preview and captures modes, this can result in up to 7 frames needed to produce a final image. With long exposures, that can take a long time. - -Fortunately, the camera parameters can be altered to reduce frame time dramatically; however this means turning off the automatic algorithms and manually providing values for the AGC and, if required, AWB. In addition, a burst mode can be used to mitigate the effects of moving between preview and captures modes. - -For the HQ camera, the following example will take a 100 second exposure. - -`raspistill -t 10 -bm -ex off -ag 1 -ss 100000000 -st -o long_exposure.jpg` - -This example turns on burst mode (`-bm`) which will disable the preview switching, turns off automatic gain control and manually sets it to 1 (`-ag 1`). The `-st` option forces statistics like AWB to be calculated from the captured frame, avoiding the need to provide specific values, although these can be entered if necessary. diff --git a/documentation/asciidoc/accessories/camera/raspicam.adoc b/documentation/asciidoc/accessories/camera/raspicam.adoc deleted file mode 100644 index 19aefe8092..0000000000 --- a/documentation/asciidoc/accessories/camera/raspicam.adoc +++ /dev/null @@ -1,1334 +0,0 @@ -== Raspicam commands - -`raspistill`, `raspivid` and `raspiyuv` are command line tools for using the camera module. - -=== `raspistill` - -`raspistill` is the command line tool for capturing still photographs with a Raspberry Pi camera module. - -==== Basic usage of raspistill - -With a camera module xref:camera.adoc#camera-modules[connected and enabled], enter the following command in the terminal to take a picture: - -[,bash] ----- -raspistill -o cam.jpg ----- - -image::images/cam.jpg[Upside-down photo] - -In this example the camera has been positioned upside-down. If the camera is placed in this position, the image must be flipped to appear the right way up. - -==== Vertical flip and horizontal flip - -With the camera placed upside-down, the image must be rotated 180° to be displayed correctly. The way to correct for this is to apply both a vertical and a horizontal flip by passing in the `-vf` and `-hf` flags: - -[,bash] ----- -raspistill -vf -hf -o cam2.jpg ----- - -image::images/cam2.jpg[Vertical and horizontal flipped photo] - -Now the photo has been captured correctly. - -==== Resolution - -The camera module takes pictures at a resolution of `2592 x 1944` which is 5,038,848 pixels or 5 megapixels. - -==== File size - -A photo taken with the camera module will be around 2.4MB. This is about 425 photos per GB. - -Taking 1 photo per minute would take up 1GB in about 7 hours. This is a rate of about 144MB per hour or 3.3GB per day. - -==== Bash script - -You can create a Bash script which takes a picture with the camera. To create a script, open up your editor of choice and write the following example code: - -[,bash] ----- -#!/bin/bash - -DATE=$(date +"%Y-%m-%d_%H%M") - -raspistill -vf -hf -o /home/pi/camera/$DATE.jpg ----- - -This script will take a picture and name the file with a timestamp. - -You'll also need to make sure the path exists by creating the `camera` folder: - -[,bash] ----- -mkdir camera ----- - -Say we saved it as `camera.sh`, we would first make the file executable: - -[,bash] ----- -chmod +x camera.sh ----- - -Then run with: - -[,bash] ----- -./camera.sh ----- - -==== More options - -For a full list of possible options, run `raspistill` with no arguments. To scroll, redirect stderr to stdout and pipe the output to `less`: - -[,bash] ----- -raspistill 2>&1 | less ----- - -Use the arrow keys to scroll and type `q` to exit. - -=== `raspivid` - -`raspivid` is the command line tool for capturing video with a Raspberry Pi camera module. - -==== Basic usage of raspivid - -With a camera module xref:camera.adoc#camera-modules[connected and enabled], record a video using the following command: - -[,bash] ----- -raspivid -o vid.h264 ----- - -Remember to use `-hf` and `-vf` to flip the image if required, like with xref:camera.adoc#raspistill[raspistill] - -This will save a 5 second video file to the path given here as `vid.h264` (default length of time). - -==== Specify length of video - -To specify the length of the video taken, pass in the `-t` flag with a number of milliseconds. For example: - -[,bash] ----- -raspivid -o video.h264 -t 10000 ----- - -This will record 10 seconds of video. - -==== More options - -For a full list of possible options, run `raspivid` with no arguments, or pipe this command through `less` and scroll through: - -[,bash] ----- -raspivid 2>&1 | less ----- - -Use the arrow keys to scroll and type `q` to exit. - -==== MP4 Video Format - -The Pi captures video as a raw H264 video stream. Many media players will refuse to play it, or play it at an incorrect speed, unless it is "wrapped" in a suitable container format like MP4. The easiest way to obtain an MP4 file from the raspivid command is using MP4Box. - -Install MP4Box with this command: - -[,bash] ----- -sudo apt install -y gpac ----- - -Capture your raw video with raspivid and wrap it in an MP4 container like this: - -[,bash] ----- -# Capture 30 seconds of raw video at 640x480 and 150kB/s bit rate into a pivideo.h264 file: -raspivid -t 30000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o pivideo.h264 -# Wrap the raw video with an MP4 container: -MP4Box -add pivideo.h264 pivideo.mp4 -# Remove the source raw file, leaving the remaining pivideo.mp4 file to play -rm pivideo.h264 ----- - -Alternatively, wrap MP4 around your existing raspivid output, like this: - -[,bash] ----- -MP4Box -add video.h264 video.mp4 ----- - -=== `raspiyuv` - -`raspiyuv` has the same set of features as `raspistill` but instead of outputting standard image files such as ``.jpg``s, it generates YUV420 or RGB888 image files from the output of the camera ISP. - -In most cases using `raspistill` is the best option for standard image capture, but using YUV can be of benefit in certain circumstances. For example if you just need a uncompressed black and white image for computer vision applications, you can simply use the Y channel of a YUV capture. - -There are some specific points about the YUV420 files that are required in order to use them correctly. Line stride (or pitch) is a multiple of 32, and each plane of YUV is a multiple of 16 in height. This can mean there may be extra pixels at the end of lines, or gaps between planes, depending on the resolution of the captured image. These gaps are unused. - -=== Troubleshooting - -If the Camera Module isn't working correctly, there are number of things to try: - -* Is the ribbon cable attached to the Camera Serial Interface (CSI), not the Display Serial Interface (DSI)? The ribbon connector will fit into either port. The Camera port is located near the HDMI connector. -* Are the ribbon connectors all firmly seated, and are they the right way round? They must be straight in their sockets. -* Is the Camera Module connector, between the smaller black Camera Module itself and the PCB, firmly attached? Sometimes this connection can come loose during transit or when putting the Camera Module in a case. Using a fingernail, flip up the connector on the PCB, then reconnect it with gentle pressure. It engages with a very slight click. Don't force it; if it doesn't engage, it's probably slightly misaligned. -* Have `sudo apt update` and `sudo apt full-upgrade` been run? -* Has `raspi-config` been run and the Camera Module enabled? -* Is your power supply sufficient? The Camera Module adds about 200-250mA to the power requirements of your Raspberry Pi. - -If things are still not working, try the following: - -* `Error : raspistill/raspivid command not found`. This probably means your update/upgrade failed in some way. Try it again. -* `Error : ENOMEM`. The Camera Module is not starting up. Check all connections again. -* `Error : ENOSPC`. The Camera Module is probably running out of GPU memory. Check `config.txt` in the /boot/ folder. The `gpu_mem` option should be at least 128. Alternatively, use the Memory Split option in the Advanced section of `raspi-config` to set this. -* If you've checked all the above issues and the Camera Module is still not working, try posting on our forums for more help. - -=== Command Line Options - -==== Preview window - ----- - --preview, -p Preview window settings <'x,y,w,h'> ----- - -Allows the user to define the size of the preview window and its location on the screen. Note this will be superimposed over the top of any other windows/graphics. - ----- - --fullscreen, -f Fullscreen preview mode ----- - -Forces the preview window to use the whole screen. Note that the aspect ratio of the incoming image will be retained, so there may be bars on some edges. - ----- - --nopreview, -n Do not display a preview window ----- - -Disables the preview window completely. Note that even though the preview is disabled, the camera will still be producing frames, so will be using power. - ----- - --opacity, -op Set preview window opacity ----- - -Sets the opacity of the preview windows. 0 = invisible, 255 = fully opaque. - -==== Camera control options - ----- - --sharpness, -sh Set image sharpness (-100 - 100) ----- - -Sets the sharpness of the image. 0 is the default. - ----- - --contrast, -co Set image contrast (-100 - 100) ----- - -Sets the contrast of the image. 0 is the default. - ----- - --brightness, -br Set image brightness (0 - 100) ----- - -Sets the brightness of the image. 50 is the default. 0 is black, 100 is white. - ----- - --saturation, -sa Set image saturation (-100 - 100) ----- - -Sets the colour saturation of the image. 0 is the default. - ----- - --ISO, -ISO Set capture ISO (100 - 800) ----- - -Sets the ISO to be used for captures. - ----- - --vstab, -vs Turn on video stabilisation ----- - -In video mode only, turns on video stabilisation. - ----- - --ev, -ev Set EV compensation (-10 - 10) ----- - -Sets the EV compensation of the image. Default is 0. - ----- - --exposure, -ex Set exposure mode ----- - -Possible options are: - -* auto: use automatic exposure mode -* night: select setting for night shooting -* nightpreview: -* backlight: select setting for backlit subject -* spotlight: -* sports: select setting for sports (fast shutter etc.) -* snow: select setting optimised for snowy scenery -* beach: select setting optimised for beach -* verylong: select setting for long exposures -* fixedfps: constrain fps to a fixed value -* antishake: antishake mode -* fireworks: select setting optimised for fireworks - -Note that not all of these settings may be implemented, depending on camera tuning. - ----- - --flicker, -fli Set flicker avoidance mode ----- - -Set a mode to compensate for lights flickering at the mains frequency, which can be seen as a dark horizontal band across an image. Flicker avoidance locks the exposure time to a multiple of the mains flicker frequency (8.33ms for 60Hz, or 10ms for 50Hz). This means that images can be noisier as the control algorithm has to increase the gain instead of exposure time should it wish for an intermediate exposure value. `auto` can be confused by external factors, therefore it is preferable to leave this setting off unless actually required. - -Possible options are: - -* off: turn off flicker avoidance -* auto: automatically detect mains frequency -* 50hz: set avoidance at 50Hz -* 60hz: set avoidance at 60Hz - ----- - --awb, -awb Set Automatic White Balance (AWB) mode ----- - -Modes for which colour temperature ranges (K) are available have these settings in brackets. - -* off: turn off white balance calculation -* auto: automatic mode (default) -* sun: sunny mode (between 5000K and 6500K) -* cloud: cloudy mode (between 6500K and 12000K) -* shade: shade mode -* tungsten: tungsten lighting mode (between 2500K and 3500K) -* fluorescent: fluorescent lighting mode (between 2500K and 4500K) -* incandescent: incandescent lighting mode -* flash: flash mode -* horizon: horizon mode -* greyworld: Use this on the NoIR camera to fix incorrect AWB results due to the lack of the IR filter. - -Note that not all of these settings may be implemented, depending on camera type. - ----- - --imxfx, -ifx Set image effect ----- - -Set an effect to be applied to the image: - -* none: no effect (default) -* negative: invert the image colours -* solarise: solarise the image -* posterise: posterise the image -* whiteboard: whiteboard effect -* blackboard: blackboard effect -* sketch: sketch effect -* denoise: denoise the image -* emboss: emboss the image -* oilpaint: oil paint effect -* hatch: hatch sketch effect -* gpen: graphite sketch effect -* pastel: pastel effect -* watercolour: watercolour effect -* film: film grain effect -* blur: blur the image -* saturation: colour saturate the image -* colourswap: not fully implemented -* washedout: not fully implemented -* colourpoint: not fully implemented -* colourbalance: not fully implemented -* cartoon: not fully implemented - -Note that not all of these settings may be available in all circumstances. - ----- - --colfx, -cfx Set colour effect ----- - -The supplied U and V parameters (range 0 - 255) are applied to the U and Y channels of the image. For example, --colfx 128:128 should result in a monochrome image. - ----- - --metering, -mm Set metering mode ----- - -Specify the metering mode used for the preview and capture: - -* average: average the whole frame for metering -* spot: spot metering -* backlit: assume a backlit image -* matrix: matrix metering - ----- - --rotation, -rot Set image rotation (0 - 359) ----- - -Sets the rotation of the image in the viewfinder and resulting image. This can take any value from 0 upwards, but due to hardware constraints only 0, 90, 180, and 270 degree rotations are supported. - ----- - --hflip, -hf Set horizontal flip ----- - -Flips the preview and saved image horizontally. - ----- - --vflip, -vf Set vertical flip ----- - -Flips the preview and saved image vertically. - ----- - --roi, -roi Set sensor region of interest ----- - -Allows the specification of the area of the sensor to be used as the source for the preview and capture. This is defined as x,y for the top-left corner, and a width and height, with all values in normalised coordinates (0.0 - 1.0). So, to set a ROI at halfway across and down the sensor, and a width and height of a quarter of the sensor, use: - ----- --roi 0.5,0.5,0.25,0.25 ----- - ----- - --shutter, -ss Set shutter speed/time ----- - -Sets the shutter open time to the specified value (in microseconds). Shutter speed limits are as follows: - -[cols=",^"] -|=== -| Camera Version | Max (microseconds) - -| V1 (OV5647) -| 6000000 (i.e. 6s) - -| V2 (IMX219) -| 10000000 (i.e. 10s) - -| HQ (IMX477) -| 200000000 (i.e. 200s) -|=== - -Using values above these maximums will result in undefined behaviour. - ----- - --drc, -drc Enable/disable dynamic range compression ----- - -DRC changes the images by increasing the range of dark areas, and decreasing the brighter areas. This can improve the image in low light areas. - -* off -* low -* med -* high - -By default, DRC is off. - ----- - --stats, -st Use stills capture frame for image statistics ----- - -Force recomputation of statistics on stills capture pass. Digital gain and AWB are recomputed based on the actual capture frame statistics, rather than the preceding preview frame. - ----- - --awbgains, -awbg ----- - -Sets blue and red gains (as floating point numbers) to be applied when `-awb off` is set e.g. -awbg 1.5,1.2 - ----- - --analoggain, -ag ----- - -Sets the analog gain value directly on the sensor (floating point value from 1.0 to 8.0 for the OV5647 sensor on Camera Module V1, and 1.0 to 12.0 for the IMX219 sensor on Camera Module V2 and the IMX447 on the HQ Camera). - ----- - --digitalgain, -dg ----- - -Sets the digital gain value applied by the ISP (floating point value from 1.0 to 64.0, but values over about 4.0 will produce overexposed images) - ----- - --mode, -md ----- - -Sets a specified sensor mode, disabling the automatic selection. Possible values depend on the version of the Camera Module being used: - -Version 1.x (OV5647) - -|=== -| Mode | Size | Aspect Ratio | Frame rates | FOV | Binning - -| 0 -| automatic selection -| -| -| -| - -| 1 -| 1920x1080 -| 16:9 -| 1-30fps -| Partial -| None - -| 2 -| 2592x1944 -| 4:3 -| 1-15fps -| Full -| None - -| 3 -| 2592x1944 -| 4:3 -| 0.1666-1fps -| Full -| None - -| 4 -| 1296x972 -| 4:3 -| 1-42fps -| Full -| 2x2 - -| 5 -| 1296x730 -| 16:9 -| 1-49fps -| Full -| 2x2 - -| 6 -| 640x480 -| 4:3 -| 42.1-60fps -| Full -| 2x2 plus skip - -| 7 -| 640x480 -| 4:3 -| 60.1-90fps -| Full -| 2x2 plus skip -|=== - -Version 2.x (IMX219) - -|=== -| Mode | Size | Aspect Ratio | Frame rates | FOV | Binning - -| 0 -| automatic selection -| -| -| -| - -| 1 -| 1920x1080 -| 16:9 -| 0.1-30fps -| Partial -| None - -| 2 -| 3280x2464 -| 4:3 -| 0.1-15fps -| Full -| None - -| 3 -| 3280x2464 -| 4:3 -| 0.1-15fps -| Full -| None - -| 4 -| 1640x1232 -| 4:3 -| 0.1-40fps -| Full -| 2x2 - -| 5 -| 1640x922 -| 16:9 -| 0.1-40fps -| Full -| 2x2 - -| 6 -| 1280x720 -| 16:9 -| 40-90fps -| Partial -| 2x2 - -| 7 -| 640x480 -| 4:3 -| 40-200fps^1^ -| Partial -| 2x2 -|=== - -^1^For frame rates over 120fps, it is necessary to turn off automatic exposure and gain control using `-ex off`. Doing so should achieve the higher frame rates, but exposure time and gains will need to be set to fixed values supplied by the user. - -HQ Camera - -|=== -| Mode | Size | Aspect Ratio | Frame rates | FOV | Binning/Scaling - -| 0 -| automatic selection -| -| -| -| - -| 1 -| 2028x1080 -| 169:90 -| 0.1-50fps -| Partial -| 2x2 binned - -| 2 -| 2028x1520 -| 4:3 -| 0.1-50fps -| Full -| 2x2 binned - -| 3 -| 4056x3040 -| 4:3 -| 0.005-10fps -| Full -| None - -| 4 -| 1332x990 -| 74:55 -| 50.1-120fps -| Partial -| 2x2 binned -|=== - ----- - --camselect, -cs ----- - -Selects which camera to use on a multi-camera system. Use 0 or 1. - ----- - --annotate, -a Enable/set annotate flags or text ----- - -Adds some text and/or metadata to the picture. - -Metadata is indicated using a bitmask notation, so add them together to show multiple parameters. For example, 12 will show time(4) and date(8), since 4+8=12. - -Text may include date/time placeholders by using the '%' character, as used by http://man7.org/linux/man-pages/man3/strftime.3.html[strftime]. - -|=== -| Value | Meaning | Example Output - -| -a 4 -| Time -| 20:09:33 - -| -a 8 -| Date -| 10/28/15 - -| -a 12 -| 4+8=12 Show the date(4) and time(8) -| 20:09:33 10/28/15 - -| -a 16 -| Shutter Settings -| - -| -a 32 -| CAF Settings -| - -| -a 64 -| Gain Settings -| - -| -a 128 -| Lens Settings -| - -| -a 256 -| Motion Settings -| - -| -a 512 -| Frame Number -| - -| -a 1024 -| Black Background -| - -| -a "ABC %Y-%m-%d %X" -| Show some text -| ABC %Y-%m-%d %X - -| -a 4 -a "ABC %Y-%m-%d %X" -| Show custom http://man7.org/linux/man-pages/man3/strftime.3.html[formatted] date/time -| ABC 2015-10-28 20:09:33 - -| -a 8 -a "ABC %Y-%m-%d %X" -| Show custom http://man7.org/linux/man-pages/man3/strftime.3.html[formatted] date/time -| ABC 2015-10-28 20:09:33 -|=== - ----- - --annotateex, -ae Set extra annotation parameters ----- - -Specifies annotation size, text colour, and background colour. Colours are in hex YUV format. - -Size ranges from 6 - 160; default is 32. Asking for an invalid size should give you the default. - -|=== -| Example | Explanation - -| -ae 32,0xff,0x808000 -a "Annotation text" -| gives size 32 white text on black background - -| -ae 10,0x00,0x8080FF -a "Annotation text" -| gives size 10 black text on white background -|=== - ----- - --stereo, -3d ----- - -Select the specified stereo imaging mode; `sbs` selects side-by-side mode, `tb` selects top/bottom mode; `off` turns off stereo mode (the default). - ----- - --decimate, -dec ----- - -Halves the width and height of the stereo image. - ----- - --3dswap, -3dswap ----- - -Swaps the camera order used in stereoscopic imaging; NOTE: currently not working. - ----- - --settings, -set ----- - -Retrieves the current camera settings and writes them to stdout. - -=== Application-specific Settings - -==== `raspistill` - ----- - --width, -w Set image width - - --height, -h Set image height - - --quality, -q Set JPEG quality <0 to 100> ----- - -Quality 100 is almost completely uncompressed. 75 is a good all-round value. - ----- - --raw, -r Add raw Bayer data to JPEG metadata ----- - -This option inserts the raw Bayer data from the camera into the JPEG metadata. - ----- - --output, -o Output filename ----- - -Specifies the output filename. If not specified, no file is saved. If the filename is '-', then all output is sent to stdout. - ----- - --latest, -l Link latest frame to filename ----- - -Makes a file system link under this name to the latest frame. - ----- - --verbose, -v Output verbose information during run ----- - -Outputs debugging/information messages during the program run. - ----- - --timeout, -t Time before the camera takes picture and shuts down ----- - -The program will run for the specified length of time, entered in milliseconds. It then takes the capture and saves it if an output is specified. If a timeout value is not specified, then it is set to 5 seconds (-t 5000). Note that low values (less than 500ms, although it can depend on other settings) may not give enough time for the camera to start up and provide enough frames for the automatic algorithms like AWB and AGC to provide accurate results. - -If set to 0, the preview will run indefinitely, until stopped with CTRL-C. In this case no capture is made. - ----- - --timelapse, -tl time-lapse mode ----- - -The specific value is the time between shots in milliseconds. Note that you should specify `%04d` at the point in the filename where you want a frame count number to appear. So, for example, the code below will produce a capture every 2 seconds, over a total period of 30s, named `image0001.jpg`, `image0002.jpg` and so on, through to `image0015.jpg`. - ----- --t 30000 -tl 2000 -o image%04d.jpg ----- - -Note that the `%04d` indicates a 4-digit number, with leading zeroes added to make the required number of digits. So, for example, `%08d` would result in an 8-digit number. - -If a time-lapse value of 0 is entered, the application will take pictures as fast as possible. Note that there's an minimum enforced pause of 30ms between captures to ensure that exposure calculations can be made. - ----- - --framestart, -fs ----- - -Specifies the first frame number in the timelapse. Useful if you have already saved a number of frames, and want to start again at the next frame. - ----- - --datetime, -dt ----- - -Instead of a simple frame number, the timelapse file names will use a date/time value of the format `aabbccddee`, where `aa` is the month, `bb` is the day of the month, `cc` is the hour, `dd` is the minute, and `ee` is the second. - ----- - --timestamp, -ts ----- - -Instead of a simple frame number, the timelapse file names will use a single number which is the Unix timestamp, i.e. the seconds since 1970. - ----- - --thumb, -th Set thumbnail parameters (x:y:quality) ----- - -Allows specification of the thumbnail image inserted into the JPEG file. If not specified, defaults are a size of 64x48 at quality 35. - -if `--thumb none` is specified, no thumbnail information will be placed in the file. This reduces the file size slightly. - ----- - --demo, -d Run a demo mode ----- - -This options cycles through the range of camera options. No capture is taken, and the demo will end at the end of the timeout period, irrespective of whether all the options have been cycled. The time between cycles should be specified as a millisecond value. - ----- - --encoding, -e Encoding to use for output file ----- - -Valid options are `jpg`, `bmp`, `gif`, and `png`. Note that unaccelerated image types (GIF, PNG, BMP) will take much longer to save than jpg, which is hardware accelerated. Also note that the filename suffix is completely ignored when deciding the encoding of a file. - ----- - --restart, -rs ----- - -Sets the JPEG restart marker interval to a specific value. Can be useful for lossy transport streams because it allows a broken JPEG file to still be partially displayed. - ----- - --exif, -x EXIF tag to apply to captures (format as 'key=value') ----- - -Allows the insertion of specific EXIF tags into the JPEG image. You can have up to 32 EXIF tag entries. This is useful for tasks like adding GPS metadata. For example, to set the longitude: - ----- ---exif GPS.GPSLongitude=5/1,10/1,15/1 ----- - -would set the longitude to 5 degs, 10 minutes, 15 seconds. See EXIF documentation for more details on the range of tags available; the supported tags are as follows: - ----- -IFD0.< or -IFD1.< -ImageWidth, ImageLength, BitsPerSample, Compression, PhotometricInterpretation, ImageDescription, Make, Model, StripOffsets, Orientation, SamplesPerPixel, RowsPerString, StripByteCounts, XResolution, YResolution, PlanarConfiguration, ResolutionUnit, TransferFunction, Software, DateTime, Artist, WhitePoint, PrimaryChromaticities, JPEGInterchangeFormat, JPEGInterchangeFormatLength, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, Copyright> - -EXIF.< -ExposureTime, FNumber, ExposureProgram, SpectralSensitivity, ISOSpeedRatings, OECF, ExifVersion, DateTimeOriginal, DateTimeDigitized, ComponentsConfiguration, CompressedBitsPerPixel, ShutterSpeedValue, ApertureValue, BrightnessValue, ExposureBiasValue, MaxApertureValue, SubjectDistance, MeteringMode, LightSource, Flash, FocalLength, SubjectArea, MakerNote, UserComment, SubSecTime, SubSecTimeOriginal, SubSecTimeDigitized, FlashpixVersion, ColorSpace, PixelXDimension, PixelYDimension, RelatedSoundFile, FlashEnergy, SpatialFrequencyResponse, FocalPlaneXResolution, FocalPlaneYResolution, FocalPlaneResolutionUnit, SubjectLocation, ExposureIndex, SensingMethod, FileSource, SceneType, CFAPattern, CustomRendered, ExposureMode, WhiteBalance, DigitalZoomRatio, FocalLengthIn35mmFilm, SceneCaptureType, GainControl, Contrast, Saturation, Sharpness, DeviceSettingDescription, SubjectDistanceRange, ImageUniqueID> - -GPS.< -GPSVersionID, GPSLatitudeRef, GPSLatitude, GPSLongitudeRef, GPSLongitude, GPSAltitudeRef, GPSAltitude, GPSTimeStamp, GPSSatellites, GPSStatus, GPSMeasureMode, GPSDOP, GPSSpeedRef, GPSSpeed, GPSTrackRef, GPSTrack, GPSImgDirectionRef, GPSImgDirection, GPSMapDatum, GPSDestLatitudeRef, GPSDestLatitude, GPSDestLongitudeRef, GPSDestLongitude, GPSDestBearingRef, GPSDestBearing, GPSDestDistanceRef, GPSDestDistance, GPSProcessingMethod, GPSAreaInformation, GPSDateStamp, GPSDifferential> - -EINT.< -InteroperabilityIndex, InteroperabilityVersion, RelatedImageFileFormat, RelatedImageWidth, RelatedImageLength> ----- - -Note that a small subset of these tags will be set automatically by the camera system, but will be overridden by any EXIF options on the command line. - -Setting `--exif none` will prevent any EXIF information being stored in the file. This reduces the file size slightly. - ----- - --gpsdexif, -gps ----- - -Applies real-time EXIF information from any attached GPS dongle (using GSPD) to the image; requires `libgps.so` to be installed. - ----- - --fullpreview, -fp Full preview mode ----- - -This runs the preview window using the full resolution capture mode. Maximum frames per second in this mode is 15fps, and the preview will have the same field of view as the capture. Captures should happen more quickly, as no mode change should be required. This feature is currently under development. - ----- - --keypress, -k Keypress mode ----- - -The camera is run for the requested time (`-t`), and a capture can be initiated throughout that time by pressing the Enter key. Pressing X then Enter will exit the application before the timeout is reached. If the timeout is set to 0, the camera will run indefinitely until the user presses X then Enter. Using the verbose option (`-v`) will display a prompt asking for user input, otherwise no prompt is displayed. - ----- - --signal, -s Signal mode ----- - -The camera is run for the requested time (`-t`), and a capture can be initiated throughout that time by sending a `USR1` signal to the camera process. This can be done using the `kill` command. You can find the camera process ID using the `pgrep raspistill` command. - -`kill -USR1 ` - ----- - --burst, -bm ----- - -Sets burst capture mode. This prevents the camera from returning to preview mode in between captures, meaning that captures can be taken closer together. - -==== `raspivid` - ----- - --width, -w Set image width ----- - -Width of resulting video. This should be between 64 and 1920. - ----- - --height, -h Set image height ----- - -Height of resulting video. This should be between 64 and 1080. - ----- - --bitrate, -b Set bitrate ----- - -Use bits per second, so 10Mbits/s would be `-b 10000000`. For H264, 1080p30 a high quality bitrate would be 15Mbits/s or more. Maximum bitrate is 25Mbits/s (`-b 25000000`), but much over 17Mbits/s won't show noticeable improvement at 1080p30. - ----- - --output, -o Output filename ----- - -Specify the output filename. If not specified, no file is saved. If the filename is '-', then all output is sent to stdout. - -To connect to a remote IPv4 host, use `tcp` or `udp` followed by the required IP Address. e.g. `tcp://192.168.1.2:1234` or `udp://192.168.1.2:1234`. - -To listen on a TCP port (IPv4) and wait for an incoming connection use `--listen (-l)` option, e.g. `raspivid -l -o tcp://0.0.0.0:3333` will bind to all network interfaces, `raspivid -l -o tcp://192.168.1.1:3333` will bind to a local IPv4. - ----- - --listen, -l ----- - -When using a network connection as the data sink, this option will make the system wait for a connection from the remote system before sending data. - ----- - --verbose, -v Output verbose information during run ----- - -Outputs debugging/information messages during the program run. - ----- - --timeout, -t Time before the camera takes picture and shuts down ----- - -The total length of time that the program will run for. If not specified, the default is 5000ms (5 seconds). If set to 0, the application will run indefinitely until stopped with Ctrl-C. - ----- - --demo, -d Run a demo mode ----- - -This options cycles through the range of camera options. No recording is done, and the demo will end at the end of the timeout period, irrespective of whether all the options have been cycled. The time between cycles should be specified as a millisecond value. - ----- - --framerate, -fps Specify the frames per second to record ----- - -At present, the minimum frame rate allowed is 2fps, and the maximum is 30fps. This is likely to change in the future. - ----- - --penc, -e Display preview image after encoding ----- - -Switch on an option to display the preview after compression. This will show any compression artefacts in the preview window. In normal operation, the preview will show the camera output prior to being compressed. This option is not guaranteed to work in future releases. - ----- - --intra, -g Specify the intra refresh period (key frame rate/GoP) ----- - -Sets the intra refresh period (GoP) rate for the recorded video. H264 video uses a complete frame (I-frame) every intra refresh period, from which subsequent frames are based. This option specifies the number of frames between each I-frame. Larger numbers here will reduce the size of the resulting video, and smaller numbers make the stream less error-prone. - ----- - --qp, -qp Set quantisation parameter ----- - -Sets the initial quantisation parameter for the stream. Varies from approximately 10 to 40, and will greatly affect the quality of the recording. Higher values reduce quality and decrease file size. Combine this setting with a bitrate of 0 to set a completely variable bitrate. - ----- - --profile, -pf Specify H264 profile to use for encoding ----- - -Sets the H264 profile to be used for the encoding. Options are: - -* baseline -* main -* high - ----- - --level, -lev ----- - -Specifies the H264 encoder level to use for encoding. Options are `4`, `4.1`, and `4.2`. - ----- - --irefresh, -if ----- - -Sets the H264 intra-refresh type. Possible options are `cyclic`, `adaptive`, `both`, and `cyclicrows`. - ----- - --inline, -ih Insert PPS, SPS headers ----- - -Forces the stream to include PPS and SPS headers on every I-frame. Needed for certain streaming cases e.g. Apple HLS. These headers are small, so don't greatly increase the file size. - ----- - --spstimings, -stm ----- - -Insert timing information into the SPS block. - ----- - --timed, -td Do timed switches between capture and pause ----- - -This options allows the video capture to be paused and restarted at particular time intervals. Two values are required: the on time and the off time. On time is the amount of time the video is captured, and off time is the amount it is paused. The total time of the recording is defined by the `timeout` option. Note that the recording may take slightly over the timeout setting depending on the on and off times. - -For example: - ----- -raspivid -o test.h264 -t 25000 -timed 2500,5000 ----- - -will record for a period of 25 seconds. The recording will be over a timeframe consisting of 2500ms (2.5s) segments with 5000ms (5s) gaps, repeating over the 20s. So the entire recording will actually be only 10s long, since 4 segments of 2.5s = 10s separated by 5s gaps. So: - -2.5 record -- 5 pause - 2.5 record -- 5 pause - 2.5 record -- 5 pause -- 2.5 record - -gives a total recording period of 25s, but only 10s of actual recorded footage. - ----- - --keypress, -k Toggle between record and pause on Enter keypress ----- - -On each press of the Enter key, the recording will be paused or restarted. Pressing X then Enter will stop recording and close the application. Note that the timeout value will be used to signal the end of recording, but is only checked after each Enter keypress; so if the system is waiting for a keypress, even if the timeout has expired, it will still wait for the keypress before exiting. - ----- - --signal, -s Toggle between record and pause according to SIGUSR1 ----- - -Sending a `USR1` signal to the `raspivid` process will toggle between recording and paused. This can be done using the `kill` command, as below. You can find the `raspivid` process ID using `pgrep raspivid`. - -`kill -USR1 ` - -Note that the timeout value will be used to indicate the end of recording, but is only checked after each receipt of the `SIGUSR1` signal; so if the system is waiting for a signal, even if the timeout has expired, it will still wait for the signal before exiting. - ----- - --split, -sp ----- - -When in a signal or keypress mode, each time recording is restarted, a new file is created. - ----- - --circular, -c ----- - -Select circular buffer mode. All encoded data is stored in a circular buffer until a trigger is activated, then the buffer is saved. - ----- - --vectors, -x ----- - -Turns on output of motion vectors from the H264 encoder to the specified file name. - ----- - --flush, -fl ----- - -Forces a flush of output data buffers as soon as video data is written. This bypasses any OS caching of written data, and can decrease latency. - ----- - --save-pts, -pts ----- - -Saves timestamp information to the specified file. Useful as an imput file to `mkvmerge`. - ----- - --codec, -cd ----- - -Specifies the encoder codec to use. Options are `H264` and `MJPEG`. H264 can encode up to 1080p, whereas MJPEG can encode up to the sensor size, but at decreased framerates due to the higher processing and storage requirements. - ----- - --initial, -i Define initial state on startup ----- - -Define whether the camera will start paused or will immediately start recording. Options are `record` or `pause`. Note that if you are using a simple timeout, and `initial` is set to `pause`, no output will be recorded. - ----- - --segment, -sg Segment the stream into multiple files ----- - -Rather than creating a single file, the file is split into segments of approximately the number of milliseconds specified. In order to provide different filenames, you should add `%04d` or similar at the point in the filename where you want a segment count number to appear e.g: - ----- ---segment 3000 -o video%04d.h264 ----- - -will produce video clips of approximately 3000ms (3s) long, named `video0001.h264`, `video0002.h264` etc. The clips should be seamless (no frame drops between clips), but the accuracy of each clip length will depend on the intraframe period, as the segments will always start on an I-frame. They will therefore always be equal or longer to the specified period. - -The most recent version of Raspivid will also allow the file name to be time-based, rather than using a segment number. For example: - ----- ---segment 3000 -o video_%c.h264 ----- - -will produce file names formatted like so: `video_Fri Jul 20 16:23:48 2018.h264` - -There are http://man7.org/linux/man-pages/man3/strftime.3.html[many different formatting options] available. Note than the `%d` and `%u` options are not available, as they are used for the segment number formatting, and that some combinations may produce invalid file names. - ----- - --wrap, -wr Set the maximum value for segment number ----- - -When outputting segments, this is the maximum the segment number can reach before it's reset to 1, giving the ability to keep recording segments, but overwriting the oldest one. So if set to 4, in the segment example above, the files produced will be `video0001.h264`, `video0002.h264`, `video0003.h264`, and `video0004.h264`. Once `video0004.h264` is recorded, the count will reset to 1, and `video0001.h264` will be overwritten. - ----- - --start, -sn Set the initial segment number ----- - -When outputting segments, this is the initial segment number, giving the ability to resume a previous recording from a given segment. The default value is 1. - ----- - --raw, -r ----- - -Specify the output file name for any raw data files requested. - ----- - --raw-format, -rf ----- - -Specify the raw format to be used if raw output requested. Options as `yuv`, `rgb`, and `grey`. `grey` simply saves the Y channel of the YUV image. - -==== `raspiyuv` - -Many of the options for `raspiyuv` are the same as those for `raspistill`. This section shows the differences. - -Unsupported options: - ----- ---exif, --encoding, --thumb, --raw, --quality ----- - -Extra options : - ----- - --rgb, -rgb Save uncompressed data as RGB888 ----- - -This option forces the image to be saved as RGB data with 8 bits per channel, rather than YUV420. - -Note that the image buffers saved in `raspiyuv` are padded to a horizontal size divisible by 32, so there may be unused bytes at the end of each line. Buffers are also padded vertically to be divisible by 16, and in the YUV mode, each plane of Y,U,V is padded in this way. - ----- - --luma, -y ----- - -Only outputs the luma (Y) channel of the YUV image. This is effectively the black and white, or intensity, part of the image. - ----- - --bgr, -bgr ----- - -Saves the image data as BGR data rather than YUV. - -=== Command Line Examples - -==== Still Captures - -By default, captures are done at the highest resolution supported by the sensor. This can be changed using the `-w` and `-h` command line options. - -Take a default capture after 2s (times are specified in milliseconds) on the viewfinder, saving in `image.jpg`: - -[,bash] ----- -raspistill -t 2000 -o image.jpg ----- - -Take a capture at a different resolution: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -w 640 -h 480 ----- - -Reduce the quality considerably to reduce file size: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -q 5 ----- - -Force the preview to appear at coordinate 100,100, with width 300 pixels and height 200 pixels: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -p 100,100,300,200 ----- - -Disable preview entirely: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -n ----- - -Save the image as a PNG file (lossless compression, but slower than JPEG). Note that the filename suffix is ignored when choosing the image encoding: - -[,bash] ----- -raspistill -t 2000 -o image.png –e png ----- - -Add some EXIF information to the JPEG. This sets the Artist tag name to Boris, and the GPS altitude to 123.5m. Note that if setting GPS tags you should set as a minimum GPSLatitude, GPSLatitudeRef, GPSLongitude, GPSLongitudeRef, GPSAltitude, and GPSAltitudeRef: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -x IFD0.Artist=Boris -x GPS.GPSAltitude=1235/10 ----- - -Set an emboss image effect: - -[,bash] ----- -raspistill -t 2000 -o image.jpg -ifx emboss ----- - -Set the U and V channels of the YUV image to specific values (128:128 produces a greyscale image): - -[,bash] ----- -raspistill -t 2000 -o image.jpg -cfx 128:128 ----- - -Run preview for 2s, with no saved image: - -[,bash] ----- -raspistill -t 2000 ----- - -Take a time-lapse picture, every 10 seconds for 10 minutes (10 minutes = 600000ms), naming the files `image_num_001_today.jpg`, `image_num_002_today.jpg` and so on, with the latest picture also available under the name `latest.jpg`: - -[,bash] ----- -raspistill -t 600000 -tl 10000 -o image_num_%03d_today.jpg -l latest.jpg ----- - -Take a picture and send the image data to stdout: - -[,bash] ----- -raspistill -t 2000 -o - ----- - -Take a picture and send the image data to a file: - -[,bash] ----- -raspistill -t 2000 -o - > my_file.jpg ----- - -Run the camera forever, taking a picture when Enter is pressed: - -[,bash] ----- -raspistill -t 0 -k -o my_pics%02d.jpg ----- - -==== Video captures - -Image size and preview settings are the same as for stills capture. Default size for video recording is 1080p (1920x1080). - -Record a 5s clip with default settings (1080p30): - -[,bash] ----- -raspivid -t 5000 -o video.h264 ----- - -Record a 5s clip at a specified bitrate (3.5Mbits/s): - -[,bash] ----- -raspivid -t 5000 -o video.h264 -b 3500000 ----- - -Record a 5s clip at a specified framerate (5fps): - -[,bash] ----- -raspivid -t 5000 -o video.h264 -f 5 ----- - -Encode a 5s camera stream and send the image data to stdout: - -[,bash] ----- -raspivid -t 5000 -o - ----- - -Encode a 5s camera stream and send the image data to a file: - -[,bash] ----- -raspivid -t 5000 -o - > my_file.h264 ----- - -=== Shell Error Codes - -The applications described here will return a standard error code to the shell on completion. Possible error codes are: - -|=== -| C Define | Code | Description - -| EX_OK -| 0 -| Application ran successfully - -| EX_USAGE -| 64 -| Bad command line parameter - -| EX_SOFTWARE -| 70 -| Software or camera error - -| -| 130 -| Application terminated by Ctrl-C -|=== - diff --git a/documentation/asciidoc/accessories/camera/raw.adoc b/documentation/asciidoc/accessories/camera/raw.adoc deleted file mode 100644 index dd73d05685..0000000000 --- a/documentation/asciidoc/accessories/camera/raw.adoc +++ /dev/null @@ -1,27 +0,0 @@ -== Shooting RAW using the Camera Modules - -The definition of raw images can vary. The usual meaning is raw Bayer data directly from the sensor, although some may regard an uncompressed image that has passed through the ISP (and has therefore been processed) as raw. - -Both options are available from the Raspberry Pi cameras. - -=== Processed, Non-Lossy Images - -The usual output from `raspistill` is a compressed JPEG file that has passed through all the stages of image processing to produce a high-quality image. However, JPEG, being a lossy format does throw away some information that the user may want. - -`raspistill` has an `encoding` option that allows you to specify the output format: either `jpg`, `gif`, `bmp` or `png`. The latter two are non-lossy, so no data is thrown away in an effort to improve compression, but do require conversion from the original YUV, and because these formats do not have hardware support they produce images slightly more slowly than JPEG. - -e.g. - -`raspistill --encoding png -o fred.png` - -Another option is to use the xref:camera.adoc#raspiyuv[`raspiyuv`] application. This avoids any final formatting stage, and writes raw YUV420 or RGB888 data to the requested file. YUV420 is the format used in much of the ISP, so this can be regarded as a dump of the processed image data at the end of the ISP processing. - -=== Unprocessed Images - -For some applications, such as astrophotography, having the raw Bayer data direct from the sensor can be useful. This data will need to be post-processed to produce a useful image. - -`raspistill` has a raw option that will append this raw Bayer data onto the end of the output JPEG file. - -`raspistill --raw -o fred.jpg` - -The raw data will https://www.raspberrypi.org/blog/processing-raw-image-files-from-a-raspberry-pi-high-quality-camera/[need to be extracted] from the `JPEG` file. \ No newline at end of file diff --git a/documentation/asciidoc/accessories/camera/synchronous_cameras.adoc b/documentation/asciidoc/accessories/camera/synchronous_cameras.adoc new file mode 100644 index 0000000000..9561864ffb --- /dev/null +++ b/documentation/asciidoc/accessories/camera/synchronous_cameras.adoc @@ -0,0 +1,108 @@ +== Synchronous Captures + +The High Quality (HQ) Camera supports synchronous captures. +One camera (the "source") can be configured to generate a pulse on its XVS (Vertical Sync) pin when a frame capture is initiated. +Other ("sink") cameras can listen for this pulse, and capture a frame at the same time as the source camera. + +This method is largely superseded by xref:../computers/camera_software.adoc#software-camera-synchronisation[software camera synchronisation] which can operate over long distances without additional wires and has sub-millisecond accuracy. But when cameras are physically close, wired synchronisation may be used. + +NOTE: Global Shutter (GS) Cameras can also be operated in a synchronous mode. However, the source camera will record one extra frame. Instead, for GS Cameras we recommend using an xref:camera.adoc#external-trigger-on-the-gs-camera[external trigger source]. You cannot synchronise a GS Camera and an HQ Camera. + +=== Connecting the cameras + +Solder a wire to the XVS test point of each camera, and connect them together. + +Solder a wire to the GND test point of each camera, and connect them together. + +*For GS Cameras only,* you will also need to connect the XHS (Horizontal Sync) test point of each camera together. On any GS Camera that you wish to act as a sink, bridge the two halves of the MAS pad with solder. + +NOTE: An earlier version of this document recommended an external pull-up for XVS. This is no longer recommended. Instead, ensure you have the latest version of Raspberry Pi OS and set the `always-on` property for all connected cameras. + +=== Driver configuration + +You will need to configure the camera drivers to keep their 1.8V power supplies on when not streaming, and optionally to select the source and sink roles. + +==== For the HQ Camera + +Edit `/boot/firmware/config.txt`. Change `camera_auto_detect=1` to `camera_auto_detect=0`. + +Append this line for a source camera: +[source] +---- +dtoverlay=imx477,always-on,sync-source +---- + +Or for a sink: +[source] +---- +dtoverlay=imx477,always-on,sync-sink +---- + +When using the CAM0 port on a Raspberry Pi 5, CM4 or CM5, append `,cam0` to that line without a space. If two cameras are on the same Raspberry Pi you will need two dtoverlay lines, only one of them ending with `,cam0`. + +Alternatively, if you wish to swap the cameras' roles at runtime (and they are not both connected to the same Raspberry Pi), omit `,sync-source` or `,sync-sink` above. Instead you can set a module parameter before starting each camera: + +For the Raspbery Pi with the source camera: +[source,console] +---- +$ echo 1 | sudo tee /sys/module/imx477/parameters/trigger_mode +---- + +For the Raspberry Pi with the sink camera: +[source,console] +---- +$ echo 2 | sudo tee /sys/module/imx477/parameters/trigger_mode +---- +You will need to do this every time the system is booted. + +==== For the GS Camera + +Edit `/boot/firmware/config.txt`. Change `camera_auto_detect=1` to `camera_auto_detect=0`. + +For either a source or a sink, append this line: +[source] +---- +dtoverlay=imx296,always-on +---- +When using the CAM0 port on a Raspberry Pi 5, CM4 or CM5, append `,cam0` to that line without a space. If two cameras are on the same Raspberry Pi you will need two dtoverlay lines, only one of them ending with `,cam0`. + +On the GS Camera, the sink role is enabled by the MAS pin and cannot be configured by software ("trigger_mode" and "sync-sink" relate to the xref:camera.adoc#external-trigger-on-the-gs-camera[external trigger method], and should _not_ be set for this method). + +=== Libcamera configuration + +If the cameras are not all started within 1 second, the `rpicam` applications can time out. To prevent this, you must edit a configuration file on any Raspberry Pi(s) with sink cameras. + +On Raspberry Pi 5 or CM5: +[source,console] +---- +$ cp /usr/share/libcamera/pipeline/rpi/pisp/example.yaml timeout.yaml +---- + +On other Raspberry Pi models: +[source,console] +---- +$ cp /usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml timeout.yaml +---- + +Now edit the copy. In both cases, delete the `#` (comment) from the `"camera_timeout_value_ms":` line, and change the number to `60000` (60 seconds). + +=== Starting the cameras + +Run the following commands to start the sink: + +[source,console] +---- +$ export LIBCAMERA_RPI_CONFIG_FILE=timeout.yaml +$ rpicam-vid --frames 300 --qt-preview -o sink.h264 +---- + +Wait a few seconds, then run the following command to start the source: + +[source,console] +---- +$ rpicam-vid --frames 300 --qt-preview -o source.h264 +---- +Frames should be synchronised. Use `--frames` to ensure the same number of frames are captured, and that the recordings are exactly the same length. +Running the sink first ensures that no frames are missed. + +NOTE: When using the GS camera in synchronous mode, the sink will not record exactly the same number of frames as the source. **The source records one extra frame before the sink starts recording**. Because of this, you need to specify that the sink records one less frame with the `--frames` option. diff --git a/documentation/asciidoc/accessories/camera/timelapse.adoc b/documentation/asciidoc/accessories/camera/timelapse.adoc deleted file mode 100644 index 9edeafc856..0000000000 --- a/documentation/asciidoc/accessories/camera/timelapse.adoc +++ /dev/null @@ -1,70 +0,0 @@ -== Creating Timelapse Video - -To create a time-lapse video, you simply configure the Raspberry Pi to take a picture at a regular interval, such as once a minute, then use an application to stitch the pictures together into a video. There are a couple of ways of doing this. - -=== Using `raspistill` Timelapse Mode - -The `raspistill` application has a built in time-lapse mode, using the `--timelapse` (or `-tl`) command line switch. The value that follows the switch is the time between shots in milliseconds: - ----- -raspistill -t 30000 -tl 2000 -o image%04d.jpg ----- - -[NOTE] -====== -The `%04d` in the output filename: this indicates the point in the filename where you want a frame count number to appear. So, for example, the command above will produce a capture every two seconds (2000ms), over a total period of 30 seconds (30000ms), named image0001.jpg, image0002.jpg, and so on, through to image0015.jpg. - -The `%04d` indicates a four-digit number, with leading zeros added to make up the required number of digits. So, for example, `%08d` would result in an eight-digit number. You can miss out the `0` if you don't want leading zeros. - -If a timelapse value of 0 is entered, the application will take pictures as fast as possible. Note that there's an minimum enforced pause of approximately 30 milliseconds between captures to ensure that exposure calculations can be made. -====== - -=== Automating using `cron` Jobs - -A good way to automate taking a picture at a regular interval is using `cron`. Open the cron table for editing: - ----- -crontab -e ----- - -This will either ask which editor you would like to use, or open in your default editor. Once you have the file open in an editor, add the following line to schedule taking a picture every minute (referring to the Bash script from the xref:camera.adoc#raspistill[raspistill page]): - ----- -* * * * * /home/pi/camera.sh 2>&1 ----- - -Save and exit and you should see the message: - ----- -crontab: installing new crontab ----- - -Make sure that you use e.g. `%04d` to make `raspistill` output each image to a new file: if you don't, then each time `raspistill` writes an image it will overwrite the same file. - -=== Stitching Images Together - -Now you'll need to stitch the photos together into a video. You can do this on the Pi using `ffmpeg` but the processing will be slow. You may prefer to transfer the image files to your desktop computer or laptop and produce the video there. - -First you will need to install `ffmpeg` if it's not already installed. - ----- -sudo apt install ffmpeg ----- - -Now you can use the `ffmpeg` tool to convert your JPEG files into an mp4 video: - ----- -ffmpeg -r 10 -f image2 -pattern_type glob -i 'image*.jpg' -s 1280x720 -vcodec libx264 timelapse.mp4 ----- - -On a Raspberry Pi 3, this can encode a little more than two frames per second. The performance of other Pi models will vary. The parameters used are: - -* `-r 10` Set frame rate (Hz value) to ten frames per second in the output video. -* `-f image2` Set ffmpeg to read from a list of image files specified by a pattern. -* `-pattern_type glob` When importing the image files, use wildcard patterns (globbing) to interpret the filename input by `-i`, in this case "image__.jpg", where "__" would be the image number. -* `-i 'image*.jpg'` The input file specification (to match the files produced during the capture). -* `-s 1280x720` Scale to 720p. You can also use 1920x1080, or lower resolutions, depending on your requirements. -* `-vcodec libx264` Use the software x264 encoder. -* `timelapse.mp4` The name of the output video file. - -`ffmpeg` has a comprehensive parameter set for varying encoding options and other settings. These can be listed using `ffmpeg --help`. diff --git a/documentation/asciidoc/accessories/camera/v4l2.adoc b/documentation/asciidoc/accessories/camera/v4l2.adoc deleted file mode 100644 index f747cb4cd6..0000000000 --- a/documentation/asciidoc/accessories/camera/v4l2.adoc +++ /dev/null @@ -1,58 +0,0 @@ -== The V4L2 Driver - -The V4L2 driver provides a standard Linux driver for accessing camera features: this is the driver needed to use a Raspberry Pi camera as, for example, a webcam. The V4L2 driver provides a standard API on top of the firmware-based camera system. - -=== Installing the V4L2 Driver - -Installation of the V4L2 driver is automatic. It is loaded as a child of the VCHIQ driver, and once loaded it will check how many cameras are attached and then create the right number of device nodes. - -[cols=",^,"] -|=== -| \dev\videoX | Default Action | - -| video10 -| Decode -| - -| video11 -| Encode -| - -| video12 -| Simple ISP -| - -| video13 -| Full ISP In -| - -| video14 -| Full ISP Hi-res Out -| - -| video15 -| Full ISP Lo-res Out -| - -| video16 -| Full ISP statistics -| - -| video19 -| HEVC Decode -| -|=== - -=== Testing the Driver - -There are many Linux applications that use the V4L2 API. The kernel maintainers provide a test tool called `Qv4l2` which can be installed from the Raspberry Pi OS repositories as follows: - ----- -sudo apt install Qv4l2 ----- - -Running this tool will test whether the driver has been successfully installed. - -=== Using the Driver - -Please see the https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/v4l2.html[V4L2 documentation] for details on using this driver. diff --git a/documentation/asciidoc/accessories/display.adoc b/documentation/asciidoc/accessories/display.adoc index 818837521a..abfac0c017 100644 --- a/documentation/asciidoc/accessories/display.adoc +++ b/documentation/asciidoc/accessories/display.adoc @@ -1,6 +1,3 @@ include::display/display_intro.adoc[] include::display/legacy.adoc[] - -include::display/troubleshooting.adoc[] - diff --git a/documentation/asciidoc/accessories/display/display_intro.adoc b/documentation/asciidoc/accessories/display/display_intro.adoc index 0b6388b65b..d61ea0398b 100644 --- a/documentation/asciidoc/accessories/display/display_intro.adoc +++ b/documentation/asciidoc/accessories/display/display_intro.adoc @@ -1,139 +1,165 @@ == Raspberry Pi Touch Display -The Raspberry Pi Touch Display is an LCD display which connects to the Raspberry Pi through the DSI connector. In some situations, it allows for the use of both the HDMI and LCD displays at the same time (this requires software support). +The https://www.raspberrypi.com/products/raspberry-pi-touch-display/[Raspberry Pi Touch Display] is an LCD display that connects to a Raspberry Pi using a DSI connector and GPIO connector. -=== Board Support +.The Raspberry Pi 7-inch Touch Display +image::images/display.png[The Raspberry Pi 7-inch Touch Display, width="70%"] -The DSI display is designed to work with all models of Raspberry Pi, however early models that do not have mounting holes (the Raspberry Pi 1 model A and B) will require additional mounting hardware to fit the HAT-dimensioned stand-offs on the display PCB. +The Touch Display is compatible with all models of Raspberry Pi, except the Zero series and Keyboard series, which lack a DSI connector. The earliest Raspberry Pi models lack appropriate mounting holes, requiring additional mounting hardware to fit the stand-offs on the display PCB. -=== Physical Installation +The display has the following key features: -The following image shows how to attach the Raspberry Pi to the back of the Touch Display (if required), and how to connect both the data (ribbon cable) and power (red/black wires) from the Raspberry Pi to the display. If you are not attaching the Raspberry Pi to the back of the display, take extra care when attaching the ribbon cable to ensure it is the correct way round. The black and red power wires should be attached to the GND and 5v pins respectively. +* 800×480px RGB LCD display +* 24-bit colour +* Industrial quality: 140 degree viewing angle horizontal, 120 degree viewing angle vertical +* 10-point multi-touch touchscreen +* PWM backlight control and power control over I2C interface +* Metal-framed back with mounting points for Raspberry Pi display conversion board and Raspberry Pi +* Backlight lifetime: 20000 hours +* Operating temperature: -20 to +70 degrees centigrade +* Storage temperature: -30 to +80 degrees centigrade +* Contrast ratio: 500 +* Average brightness: 250 cd/m^2^ +* Viewing angle (degrees): + ** Top - 50 + ** Bottom - 70 + ** Left - 70 + ** Right - 70 +* Power requirements: 200mA at 5V typical, at maximum brightness. +* Outer dimensions: 192.96 × 110.76mm +* Viewable area: 154.08 × 85.92mm -image::images/GPIO_power-500x333.jpg[DSI Display Connections] -xref:display.adoc#legacy-support[Legacy support for Raspberry Pi 1 Model A/B] +=== Mount the Touch Display -=== Screen Orientation +You can mount a Raspberry Pi to the back of the Touch Display using its stand-offs and then connect the appropriate cables. You can also mount the Touch Display in a separate chassis if you have one available. The connections remain the same, though you may need longer cables depending on the chassis. -LCD displays have an optimum viewing angle, and depending on how the screen is mounted it may be necessary to change the orientation of the display to give the best results. By default, the Raspberry Pi Touch Display and Raspberry Pi are set up to work best when viewed from slightly above, for example on a desktop. If viewing from below, you can physically rotate the display, and then tell the system software to compensate by running the screen upside down. +.A Raspberry Pi connected to the Touch Display +image::images/GPIO_power-500x333.jpg[Image of Raspberry Pi connected to the Touch Display, width="70%"] -==== FKMS Mode +Connect one end of the Flat Flexible Cable (FFC) to the `RPI-DISPLAY` port on the Touch Display PCB. The silver or gold contacts should face away from the display. Then connect the other end of the FFC to the `DISPLAY` port on the Raspberry Pi. The contacts on this end should face inward, towards the Raspberry Pi. -FKMS mode is used by default on the Raspberry Pi 4B. FKMS uses the DRM/MESA libraries to provide graphics and 3D acceleration. +If the FFC is not fully inserted or positioned correctly, you will experience issues with the display. You should always double check this connection when troubleshooting, especially if you don't see anything on your display, or the display shows only a single colour. -To set screen orientation when running the graphical desktop, select the `Screen Configuration` option from the `Preferences` menu. Right click on the DSI display rectangle in the layout editor, select Orientation then the required option. +NOTE: A https://datasheets.raspberrypi.com/display/7-inch-display-mechanical-drawing.pdf[mechanical drawing] of the Touch Display is available for download. -To set screen orientation when in console mode, you will need to edit the kernel command line to pass the required orientation to the system. +=== Power the Touch Display -[,bash] ----- -sudo nano /boot/cmdline.txt ----- +We recommend using the Raspberry Pi's GPIO to provide power to the Touch Display. Alternatively, you can power the display directly with a separate micro USB power supply. -To rotate by 90 degrees clockwise, add the following to the cmdline, making sure everything is on the same line, do not add any carriage returns. Possible rotation values are 0, 90, 180 and 270. +==== Power from a Raspberry Pi ----- -video=DSI-1:800x480@60,rotate=90 ----- +To power the Touch Display using a Raspberry Pi, you need to connect two jumper wires between the 5V and `GND` pins on xref:../computers/raspberry-pi.adoc#gpio[Raspberry Pi's GPIO] and the 5V and `GND` pins on the display, as shown in the following illustration. -NOTE: In console mode it is not possible to rotate the DSI display separately to the HDMI display, so if you have both attached they must both be set to the same value. +.The location of the display's 5V and `GND` pins +image::images/display_plugs.png[Illustration of display pins, width="40%"] -==== Legacy Graphics Mode +Before you begin, make sure the Raspberry Pi is powered off and not connected to any power source. Connect one end of the black jumper wire to pin six (`GND`) on the Raspberry Pi and one end of the red jumper wire to pin four (5V). If pin six isn't available, you can use any other open `GND` pin to connect the black wire. If pin four isn't available, you can use any other 5V pin to connect the red wire, such as pin two. -Legacy graphics mode is used by default on all Raspberry Pi models prior to the Raspberry Pi 4B, and can also be used on the Raspberry Pi 4B if required, by disabling FKMS mode by commenting out the FKMS line in `config.txt`. Note: legacy mode on the Raspberry Pi 4B has no 3D acceleration so it should only be used if you have a specific reason for needing it. +.The location of the Raspberry Pi headers +image::images/pi_plugs.png[Illustration of Raspberry Pi headers, width="40%"] -To flip the display, add the following line to the file `/boot/config.txt`: +Next, connect the other end of the black wire to the `GND` pin on the display and the other end of the red wire to the 5V pin on the display. Once all the connections are made, you should see the Touch Display turn on the next time you turn on your Raspberry Pi. -`lcd_rotate=2` +Use the other three pins on the Touch Display to connect the display to an original Raspberry Pi 1 Model A or B. Refer to our documentation on xref:display.adoc#legacy-support[legacy support] for more information. -This will vertically flip the LCD and the touch screen, compensating for the physical orientation of the display. +NOTE: To identify an original Raspberry Pi, check the GPIO header connector. Only the original model has a 26-pin GPIO header connector; subsequent models have 40 pins. -You can also rotate the display by adding the following to the `config.txt` file. +==== Power from a micro USB supply -* `display_lcd_rotate=x`, where `x` can be one of the folllowing: +If you don't want to use a Raspberry Pi to provide power to the Touch Display, you can use a micro USB power supply instead. We recommend using the https://www.raspberrypi.com/products/micro-usb-power-supply/[Raspberry Pi 12.5W power supply] to make sure the display runs as intended. -|=== -| display_lcd_rotate | result +Do not connect the GPIO pins on your Raspberry Pi to the display if you choose to use micro USB for power. The only connection between the two boards should be the Flat Flexible Cable. -| 0 -| no rotation +WARNING: When using a micro USB cable to power the display, mount it inside a chassis that blocks access to the display's PCB during usage. -| 1 -| rotate 90 degrees clockwise +=== Use an on-screen keyboard -| 2 -| rotate 180 degrees clockwise +Raspberry Pi OS _Bookworm_ and later include the Squeekboard on-screen keyboard by default. When a touch display is attached, the on-screen keyboard should automatically show when it is possible to enter text and automatically hide when it is not possible to enter text. -| 3 -| rotate 270 degrees clockwise +For applications which do not support text entry detection, use the keyboard icon at the right end of the taskbar to manually show and hide the keyboard. -| 0x10000 -| horizontal flip +You can also permanently show or hide the on-screen keyboard in the Display tab of Raspberry Pi Configuration or the `Display` section of `raspi-config`. -| 0x20000 -| vertical flip -|=== +TIP: In Raspberry Pi OS releases prior to _Bookworm_, use `matchbox-keyboard` instead. If you use the wayfire desktop compositor, use `wvkbd` instead. + +=== Change screen orientation + +If you want to physically rotate the display, or mount it in a specific position, select **Screen Configuration** from the **Preferences** menu. Right-click on the touch display rectangle (likely DSI-1) in the layout editor, select **Orientation**, then pick the best option to fit your needs. + +image::images/display-rotation.png[Screenshot of orientation options in screen configuration, width="80%"] + +==== Rotate screen without a desktop + +To set the screen orientation on a device that lacks a desktop environment, edit the `/boot/firmware/cmdline.txt` configuration file to pass an orientation to the system. Add the following line to `cmdline.txt`: + +[source,ini] +---- +video=DSI-1:800x480@60,rotate= +---- + +Replace the `` placeholder with one of the following values, which correspond to the degree of rotation relative to the default on your display: + +* `0` +* `90` +* `180` +* `270` -Note that the 90 and 270 degree rotation options require additional memory on the GPU, so these will not work with the 16MB GPU split. +For example, a rotation value of `90` rotates the display 90 degrees to the right. `180` rotates the display 180 degrees, or upside-down. -=== Touchscreen Orientation +NOTE: It is not possible to rotate the DSI display separately from the HDMI display with `cmdline.txt`. When you use DSI and HDMI simultaneously, they share the same rotation value. -Additionally, you have the option to change the rotation of the touchscreen independently of the display itself by adding a `dtoverlay` instruction in `config.txt`, for example: +==== Rotate touch input -`dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1,touchscreen-inverted-x=1` +WARNING: Rotating touch input via device tree can cause conflicts with your input library. Whenever possible, configure touch event rotation in your input library or desktop. -The options for the touchscreen are: +Rotation of touch input is independent of the orientation of the display itself. To change this you need to manually add a `dtoverlay` instruction in xref:../computers/config_txt.adoc[`/boot/firmware/config.txt`]. Add the following line at the end of `config.txt`: + +[source,ini] +---- +dtoverlay=vc4-kms-dsi-7inch,invx,invy +---- + +Then, disable automatic display detection by removing the following line from `config.txt`, if it exists: + +[source,ini] +---- +display_auto_detect=1 +---- + +==== Touch Display device tree option reference + +The `vc4-kms-dsi-7inch` overlay supports the following options: |=== | DT parameter | Action -| touchscreen-size-x +| `sizex` | Sets X resolution (default 800) -| touchscreen-size-y -| Sets Y resolution (default 600) +| `sizey` +| Sets Y resolution (default 480) -| touchscreen-inverted-x +| `invx` | Invert X coordinates -| touchscreen-inverted-y +| `invy` | Invert Y coordinates -| touchscreen-swapped-x-y -| Swap X and Y cordinates -|=== - -=== Troubleshooting - -Read our troubleshooting steps, tips, and tricks here: xref:display.adoc#troubleshooting-the-display[Raspberry Pi Touch Display troubleshooting]. - -=== Specifications +| `swapxy` +| Swap X and Y coordinates -* 800×480 RGB LCD display -* 24-bit colour -* Industrial quality: 140-degree viewing angle horizontal, 130-degree viewing angle vertical -* 10-point multi-touch touchscreen -* PWM backlight control and power control over I2C interface -* Metal-framed back with mounting points for Raspberry Pi display conversion board and Raspberry Pi -* Backlight lifetime: 20000 hours -* Operating temperature: -20 to +70 degrees centigrade -* Storage temperature: -30 to +80 degrees centigrade -* Contrast ratio: 500 -* Average brightness: 250 cd/m^2^ -* Viewing angle (degrees): - ** Top - 50 - ** Bottom - 70 - ** Left - 70 - ** Right - 70 -* Power requirements: 200mA at 5V typical, at maximum brightness. +| `disable_touch` +| Disables the touch overlay totally +|=== -==== Mechanical Specification +To specify these options, add them, separated by commas, to your `dtoverlay` line in `/boot/firmware/config.txt`. Boolean values default to true when present, but you can set them to false using the suffix "=0". Integer values require a value, e.g. `sizey=240`. For instance, to set the X resolution to 400 pixels and invert both X and Y coordinates, use the following line: -* Outer dimensions: 192.96 × 110.76mm -* Viewable area: 154.08 × 85.92mm -* https://datasheets.raspberrypi.org/display/7-inch-display-mechanical-drawing.pdf[Download mechanical drawing (PDF)] +[source,ini] +---- +dtoverlay=vc4-kms-dsi-7inch,sizex=400,invx,invy +---- -A drawing showing the radius and thickness of glass. +=== Installation on Compute Module based devices. -image::images/radius.png[Radius and thickness of glass] +All Raspberry Pi SBCs auto-detect the official Touch Displays as the circuitry connected to the DSI connector on the Raspberry Pi board is fixed; this autodetection ensures the correct Device Tree entries are passed to the kernel. However, Compute Modules are intended for industrial applications where the integrator can use any and all GPIOs and interfaces for whatever purposes they require. Autodetection is therefore not feasible, and hence is disabled on Compute Module devices. This means that the Device Tree fragments required to set up the display need to be loaded via some other mechanism, which can be either with a dtoverlay entry in config.txt as described above, via a custom base DT file, or if present, a HAT EEPROM. \ No newline at end of file diff --git a/documentation/asciidoc/accessories/display/images/display-rotation.png b/documentation/asciidoc/accessories/display/images/display-rotation.png new file mode 100755 index 0000000000..86eb3a10ba Binary files /dev/null and b/documentation/asciidoc/accessories/display/images/display-rotation.png differ diff --git a/documentation/asciidoc/accessories/display/images/display.png b/documentation/asciidoc/accessories/display/images/display.png new file mode 100644 index 0000000000..dd7ae33612 Binary files /dev/null and b/documentation/asciidoc/accessories/display/images/display.png differ diff --git a/documentation/asciidoc/accessories/display/images/display_plugs.png b/documentation/asciidoc/accessories/display/images/display_plugs.png new file mode 100644 index 0000000000..4e1fd5da90 Binary files /dev/null and b/documentation/asciidoc/accessories/display/images/display_plugs.png differ diff --git a/documentation/asciidoc/accessories/display/images/pi_plugs.png b/documentation/asciidoc/accessories/display/images/pi_plugs.png new file mode 100644 index 0000000000..44f607d74d Binary files /dev/null and b/documentation/asciidoc/accessories/display/images/pi_plugs.png differ diff --git a/documentation/asciidoc/accessories/display/legacy.adoc b/documentation/asciidoc/accessories/display/legacy.adoc index 4deace9469..eab11d275d 100644 --- a/documentation/asciidoc/accessories/display/legacy.adoc +++ b/documentation/asciidoc/accessories/display/legacy.adoc @@ -1,17 +1,14 @@ == Legacy Support -NOTE: These instructions are for the original Model A and B boards. +WARNING: These instructions are for the original Raspberry Pi, Model A, and B, boards only. To identify an original Raspberry Pi, check the GPIO header connector. Only the original model has a 26-pin GPIO header connector; subsequent models have 40 pins. -The DSI connector on the Model A/B boards does not have the I2C connections required to talk to the touchscreen controller and DSI controller. You can work around this by using the additional set of jumper cables provided with the display kit to wire up the I2C bus on the GPIO pins to the display controller board. +The DSI connector on both the Raspberry Pi 1 Model A and B boards does not have the I2C connections required to talk to the touchscreen controller and DSI controller. To work around this, use the additional set of jumper cables provided with the display kit. Connect SCL/SDA on the GPIO header to the horizontal pins marked SCL/SDA on the display board. Power the Model A/B via the GPIO pins using the jumper cables. -Using the jumper cables, connect SCL/SDA on the GPIO header to the horizontal pins marked SCL/SDA on the display board. We also recommend that you power the Model A/B via the GPIO pins using the jumper cables. +DSI display autodetection is disabled by default on these boards. To enable detection, add the following line to the xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] file: -For the GPIO header pinout, see http://pinout.xyz/[this diagram]. +[source,ini] +---- +ignore_lcd=0 +---- -DSI display autodetection is disabled by default on these boards. To enable detection, add the following line to `/boot/config.txt`: - -`ignore_lcd=0` - -Power the setup via the `PWR IN` micro-USB connector on the display board. Do not power the setup via the Pi's micro-USB port: the input polyfuse's maximum current rating will be exceeded as the display consumes approximately 400mA. - -NOTE: With the display connected to the GPIO I2C pins, the GPU will assume control of the respective I2C bus. The host operating system should not access this I2C bus, as simultaneous use of the bus by both the GPU and Linux will result in sporadic crashes. +Power the setup via the `PWR IN` micro-USB connector on the display board. Do not power the setup via the Raspberry Pi's micro-USB port. This will exceed the input polyfuse's maximum current rating, since the display consumes approximately 400mA. diff --git a/documentation/asciidoc/accessories/display/troubleshooting.adoc b/documentation/asciidoc/accessories/display/troubleshooting.adoc deleted file mode 100644 index 799e168498..0000000000 --- a/documentation/asciidoc/accessories/display/troubleshooting.adoc +++ /dev/null @@ -1,206 +0,0 @@ -== Troubleshooting the Display - -[discrete] -=== Have you got a good power supply? - -Having intermittent problems, or seeing a little rainbow square in the top right corner? It is likely that you need a better power supply. - -We recommend our official 2.5A adapter because we know it works, but any good 2.5A supply should work. - -[discrete] -=== Have you updated Raspberry Pi OS? - -If not, many problems will be solved by making sure your software is up-to date. - -You can undo any previous use of `rpi-update` and get your Pi back to the latest stable software by connecting -to a network and running: - -[,bash] ----- -sudo apt update -sudo apt install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} raspberrypi-bootloader -sudo reboot ----- - -[discrete] -=== My touchscreen doesn't work, or works intermittently - -* Make sure you've updated Raspberry Pi OS (see above for steps) -* Check the smaller ribbon cable is seated properly - -If you want to make sure your Pi has detected your touchscreen, try running: - -[,bash] ----- -dmesg | grep -i ft5406 ----- - -You should see a couple of lines that look like this: - -[,text] ----- -[ 5.224267] rpi-ft5406 rpi_ft5406: Probing device -[ 5.225960] input: FT5406 memory based driver as /devices/virtual/input/input3 ----- - -A detected touchscreen will also cause the `fbheight` and `fbwidth` parameters in `/proc/cmdline` to equal 480 and 800 respectively (the resolution of the screen). You can verify this by running: - ----- -cat /proc/cmdline | grep bcm2708_fb ----- - -[discrete] -=== My screen is upside-down! - -Depending on your display stand, you might find that the LCD display defaults to being upside-down. You can fix this by rotating it with `/boot/config.txt`. - -[,bash] ----- -sudo nano /boot/config.txt ----- - -Then add: - -[,bash] ----- -lcd_rotate=2 ----- - -Hit `CTRL+X` and `y` to save. And finally: - ----- -sudo reboot ----- - -[discrete] -=== My display fades out to weird patterns when I shutdown/reboot my Pi - -Don't panic! This is perfectly normal. - -[discrete] -=== My display is black - -* Make sure you've updated Raspberry Pi OS (see above for steps) -* Check the ribbon cable between your Pi and the LCD is properly seated -* Make sure you have a SD card properly inserted into your Pi - -[discrete] -=== My display is white - -* Check the larger ribbon cable between the display and driver board is properly seated - -[discrete] -=== Raspberry Pi OS says my screen is 752x448. Surely that's wrong? - -Yes, the screen should be 800x480. This is a result of overscan being enabled. - -Disable it by running raspi-config: - -[,bash] ----- -sudo raspi-config ----- - -And then navigating to *Advanced Options* > *Overscan* and picking *Disable*. - -[discrete] -=== My touchscreen isn't aligned correctly: my taps are slightly out - -This is probably also a side-effect of overscan being enabled, try the solution above. - -[discrete] -=== Some windows are cut off at the bottom of the screen so I can't use them - -If some windows in X are cut off at the side/bottom of the screen, this is unfortunately a side-effect of developers assuming a minimum screen resolution of 1024x768 pixels. - -You can usually reveal hidden buttons and fields by; - -* right clicking on the edge or top of the window, -* picking "move" -* using the up arrow key to nudge the window up off the top of the screen - -If you don't have a mouse, see the right click fix below. - -=== Tips and Tricks - -==== How do I use multiple monitors? - -At the moment you can't use HDMI and the LCD together in the X desktop, but you can send the output of certain applications to one screen or the other. - -Omxplayer is one example. It has been modified to enable secondary display output. - -To start displaying a video onto the LCD display (assuming it is the default display) just type: - -[,bash] ----- -omxplayer video.mkv ----- - -To start a second video onto the HDMI type: - -[,bash] ----- -omxplayer --display=5 video.mkv ----- - -*Please note: you may need to increase the amount of memory allocated to the GPU to 128MB if the videos are 1080P. Adjust the gpu_mem value in config.txt for this. The Raspberry Pi headline figures are 1080P30 decode, so if you are using two 1080P clips it may not play correctly depending on the complexity of the videos.* - -Display numbers are: - -* LCD: 4 -* TV/HDMI: 5 -* Auto select non-default display: 6 - -==== How do I enable right click? - -You can emulate a right click with a setting change. Just: - -[,bash] ----- -sudo nano /etc/X11/xorg.conf ----- - -Paste in: - ----- -Section "InputClass" - Identifier "calibration" - Driver "evdev" - MatchProduct "FT5406 memory based driver" - - Option "EmulateThirdButton" "1" - Option "EmulateThirdButtonTimeout" "750" - Option "EmulateThirdButtonMoveThreshold" "30" -EndSection ----- - -Hit `CTRL+X` and `y` to save. Then: - -[,bash] ----- -sudo reboot ----- - -Once enabled, right click works by pressing and holding the touchscreen and will be activated after a short delay. - -==== How do I get an on-screen keyboard? - -===== Florence Virtual Keyboard - -Install with: - -[,bash] ----- -sudo apt install florence ----- - -===== Matchbox Virtual Keyboard - -Install like so: - -[,bash] ----- -sudo apt install matchbox-keyboard ----- - -And then find in *Accessories* > *Keyboard*. diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse.adoc b/documentation/asciidoc/accessories/keyboard-and-mouse.adoc new file mode 100644 index 0000000000..4e34a87b2d --- /dev/null +++ b/documentation/asciidoc/accessories/keyboard-and-mouse.adoc @@ -0,0 +1,5 @@ +include::keyboard-and-mouse/getting-started-keyboard.adoc[] + +include::keyboard-and-mouse/getting-started-mouse.adoc[] + +include::keyboard-and-mouse/connecting-things.adoc[] diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/connecting-things.adoc b/documentation/asciidoc/accessories/keyboard-and-mouse/connecting-things.adoc new file mode 100644 index 0000000000..a23011f5c3 --- /dev/null +++ b/documentation/asciidoc/accessories/keyboard-and-mouse/connecting-things.adoc @@ -0,0 +1,8 @@ +== Connecting it all Together + +This is the configuration we recommend for using your Raspberry Pi, official keyboard and hub, and official mouse together. The hub on the keyboard ensures easy access to USB drives, and the mouse's cable is tidy, while being long enough to allow you to use the mouse left- or right-handed. + +image::images/everything.png[width="80%"] + +NOTE: It is important that the power supply is connected to the Raspberry Pi and the keyboard is connected to the Raspberry Pi. If the power supply were connected to the keyboard, with the Raspberry Pi powered via the keyboard, then the keyboard would not operate correctly. + diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-keyboard.adoc b/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-keyboard.adoc new file mode 100644 index 0000000000..3649738079 --- /dev/null +++ b/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-keyboard.adoc @@ -0,0 +1,19 @@ +== Getting Started with your Keyboard + +Our official keyboard includes three host USB ports for connecting external devices, such as USB mice, USB drives, and other USB- controlled devices. + +The product's micro USB port is for connection to the Raspberry Pi. Via the USB hub built into the keyboard, the Raspberry Pi controls, and provides power to, the three USB Type A ports. + +image::images/back-of-keyboard.png[width="80%"] + +=== Keyboard Features + +The Raspberry Pi keyboard has three lock keys: `Num Lock`, `Caps Lock`, and `Scroll Lock`. There are three LEDs in the top right-hand corner that indicate which locks are enabled. + +image::images/num-cap-scroll.png[width="80%"] + +`Num Lock`:: Allows use of the red number keys on the letter keys, effectively creating a numeric keypad. This mode is enabled and disabled by pressing the `Num Lock` key. + +`Caps Lock`:: Allows typing capital letters; press the `Shift` key to type lower-case letters in this mode. This mode is enabled and disabled by pressing the `Caps Lock` key. + +`Scroll Lock (ScrLk)`:: Allows use of the cursor keys for browsing web pages and spreadsheets without the mouse. This mode is enabled and disabled by pressing the `ScrLk` key while holding the Fn key. diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-mouse.adoc b/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-mouse.adoc new file mode 100644 index 0000000000..a9b58429a2 --- /dev/null +++ b/documentation/asciidoc/accessories/keyboard-and-mouse/getting-started-mouse.adoc @@ -0,0 +1,7 @@ +== Getting Started with your Mouse + +Our official mouse has three buttons, which activate high-quality micro-switches. The wheel is for quick scrolling when browsing documents and web pages. + +image::images/the-mouse.png[width="80%"] + +Always place the mouse on a flat, stable surface while using it. The mouse optically detects movement on the surface on which it is placed. On featureless surfaces, e.g. PVC or acrylic table tops, the mouse cannot detect movement. When you are working on such a surface, place the mouse on a mouse mat. diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/images/back-of-keyboard.png b/documentation/asciidoc/accessories/keyboard-and-mouse/images/back-of-keyboard.png new file mode 100644 index 0000000000..9439454fc5 Binary files /dev/null and b/documentation/asciidoc/accessories/keyboard-and-mouse/images/back-of-keyboard.png differ diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/images/everything.png b/documentation/asciidoc/accessories/keyboard-and-mouse/images/everything.png new file mode 100644 index 0000000000..596054c035 Binary files /dev/null and b/documentation/asciidoc/accessories/keyboard-and-mouse/images/everything.png differ diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/images/num-cap-scroll.png b/documentation/asciidoc/accessories/keyboard-and-mouse/images/num-cap-scroll.png new file mode 100644 index 0000000000..70031c3041 Binary files /dev/null and b/documentation/asciidoc/accessories/keyboard-and-mouse/images/num-cap-scroll.png differ diff --git a/documentation/asciidoc/accessories/keyboard-and-mouse/images/the-mouse.png b/documentation/asciidoc/accessories/keyboard-and-mouse/images/the-mouse.png new file mode 100644 index 0000000000..ab64447a2e Binary files /dev/null and b/documentation/asciidoc/accessories/keyboard-and-mouse/images/the-mouse.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus.adoc b/documentation/asciidoc/accessories/m2-hat-plus.adoc new file mode 100644 index 0000000000..b9501e9370 --- /dev/null +++ b/documentation/asciidoc/accessories/m2-hat-plus.adoc @@ -0,0 +1 @@ +include::m2-hat-plus/about.adoc[] diff --git a/documentation/asciidoc/accessories/m2-hat-plus/about.adoc b/documentation/asciidoc/accessories/m2-hat-plus/about.adoc new file mode 100644 index 0000000000..a3b033a28d --- /dev/null +++ b/documentation/asciidoc/accessories/m2-hat-plus/about.adoc @@ -0,0 +1,141 @@ +[[m2-hat-plus]] +== About + +.The Raspberry Pi M.2 HAT+ +image::images/m2-hat-plus.jpg[width="80%"] + +The Raspberry Pi M.2 HAT+ M Key enables you to connect M.2 peripherals such as NVMe drives and other PCIe accessories to Raspberry Pi 5's PCIe interface. + +The M.2 HAT+ adapter board converts between the PCIe connector on Raspberry Pi 5 and a single M.2 M key edge connector. You can connect any device that uses the 2230 or 2242 form factors. The M.2 HAT+ can supply up to 3A of power. + +The M.2 HAT+ uses Raspberry Pi's https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf[HAT+ specification], which allows Raspberry Pi OS to automatically detect the HAT+ and any connected devices. + +The included threaded spacers provide ample room to fit the Raspberry Pi Active Cooler beneath an M.2 HAT+. + +The M.2 HAT+ is _only_ compatible with the https://www.raspberrypi.com/products/raspberry-pi-5-case/[Raspberry Pi Case for Raspberry Pi 5] _if you remove the lid and the included fan_. + +== Features + +* Single-lane PCIe 2.0 interface (500 MB/s peak transfer rate) +* Supports devices that use the M.2 M key edge connector +* Supports devices with the 2230 or 2242 form factor +* Supplies up to 3A to connected M.2 devices +* Power and activity LEDs +* Conforms to the https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf[Raspberry Pi HAT+ specification] +* Includes: +** ribbon cable +** 16mm GPIO stacking header +** 4 threaded spacers +** 8 screws +** 1 knurled double-flanged drive attachment screw to secure and support the M.2 peripheral + +[[m2-hat-plus-installation]] +== Install + +To use the Raspberry Pi M.2 HAT+, you will need: + +* a Raspberry Pi 5 + +Each M.2 HAT+ comes with a ribbon cable, GPIO stacking header, and mounting hardware. Complete the following instructions to install your M.2 HAT+: + +. First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: ++ +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +. Next, xref:../computers/raspberry-pi.adoc#update-the-bootloader-configuration[ensure that your Raspberry Pi firmware is up-to-date]. Run the following command to see what firmware you're running: ++ +[source,console] +---- +$ sudo rpi-eeprom-update +---- ++ +If you see December 6, 2023 or a later date, proceed to the next step. If you see a date earlier than December 6, 2023, run the following command to open the Raspberry Pi Configuration CLI: ++ +[source,console] +---- +$ sudo raspi-config +---- ++ +Under `Advanced Options` > `Bootloader Version`, choose `Latest`. Then, exit `raspi-config` with `Finish` or the *Escape* key. ++ +Run the following command to update your firmware to the latest version: ++ +[source,console] +---- +$ sudo rpi-eeprom-update -a +---- ++ +Then, reboot with `sudo reboot`. + +. Disconnect the Raspberry Pi from power before beginning installation. + + +. The M.2 HAT+ is compatible with the Raspberry Pi 5 Active Cooler. If you have an Active Cooler, install it before installing the M.2 HAT+. ++ +-- +image::images/m2-hat-plus-installation-01.png[width="60%"] +-- +. Install the spacers using four of the provided screws. Firmly press the GPIO stacking header on top of the Raspberry Pi GPIO pins; orientation does not matter as long as all pins fit into place. Disconnect the ribbon cable from the M.2 HAT+, and insert the other end into the PCIe port of your Raspberry Pi. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing inward, towards the USB ports. With the ribbon cable fully and evenly inserted into the PCIe port, push the cable holder down from both sides to secure the ribbon cable firmly in place. ++ +-- +image::images/m2-hat-plus-installation-02.png[width="60%"] +-- +. Set the M.2 HAT+ on top of the spacers, and use the four remaining screws to secure it in place. ++ +-- +image::images/m2-hat-plus-installation-03.png[width="60%"] +-- +. Insert the ribbon cable into the slot on the M.2 HAT+. Lift the ribbon cable holder from both sides, then insert the cable with the copper contact points facing up. With the ribbon cable fully and evenly inserted into the port, push the cable holder down from both sides to secure the ribbon cable firmly in place. ++ +-- +image::images/m2-hat-plus-installation-04.png[width="60%"] +-- +. Remove the drive attachment screw by turning the screw counter-clockwise. Insert your M.2 SSD into the M.2 key edge connector, sliding the drive into the slot at a slight upward angle. Do not force the drive into the slot: it should slide in gently. ++ +-- +image::images/m2-hat-plus-installation-05.png[width="60%"] +-- +. Push the notch on the drive attachment screw into the slot at the end of your M.2 drive. Push the drive flat against the M.2 HAT+, and insert the SSD attachment screw by turning the screw clockwise until the SSD feels secure. Do not over-tighten the screw. ++ +-- +image::images/m2-hat-plus-installation-06.png[width="60%"] +-- +. Congratulations, you have successfully installed the M.2 HAT+. Connect your Raspberry Pi to power; Raspberry Pi OS will automatically detect the M.2 HAT+. If you use Raspberry Pi Desktop, you should see an icon representing the drive on your desktop. If you don't use a desktop, you can find the drive at `/dev/nvme0n1`. To make your drive automatically available for file access, consider xref:../computers/configuration.adoc#automatically-mount-a-storage-device[configuring automatic mounting]. ++ +-- +image::images/m2-hat-plus-installation-07.png[width="60%"] +-- + +WARNING: Always disconnect your Raspberry Pi from power before connecting or disconnecting a device from the M.2 slot. + +== Boot from NVMe + +To boot from an NVMe drive attached to the M.2 HAT+, complete the following steps: + +. xref:../computers/getting-started.adoc#raspberry-pi-imager[Format your NVMe drive using Raspberry Pi Imager]. You can do this from your Raspberry Pi if you already have an SD card with a Raspberry Pi OS image. +. Boot your Raspberry Pi into Raspberry Pi OS using an SD card or USB drive to alter the boot order in the persistent on-board EEPROM configuration. +. In a terminal on your Raspberry Pi, run `sudo raspi-config` to open the Raspberry Pi Configuration CLI. +. Under `Advanced Options` > `Boot Order`, choose `NVMe/USB boot`. Then, exit `raspi-config` with `Finish` or the *Escape* key. +. Reboot your Raspberry Pi with `sudo reboot`. + +For more information, see xref:../computers/raspberry-pi.adoc#nvme-ssd-boot[NVMe boot]. + +== Enable PCIe Gen 3 + +WARNING: The Raspberry Pi 5 is not certified for Gen 3.0 speeds. PCIe Gen 3.0 connections may be unstable. + +To enable PCIe Gen 3 speeds, follow the instructions at xref:../computers/raspberry-pi.adoc#pcie-gen-3-0[enable PCIe Gen 3.0]. + +== Schematics + +.Schematics for the Raspberry Pi M.2 HAT+ +image::images/m2-hat-plus-schematics.png[width="80%"] + +Schematics are also available as a https://datasheets.raspberrypi.com/m2-hat-plus/raspberry-pi-m2-hat-plus-schematics.pdf[PDF]. + +== Product brief + +For more information about the M.2 HAT+, including mechanical specifications and operating environment limitations, see the https://datasheets.raspberrypi.com/m2-hat-plus/raspberry-pi-m2-hat-plus-product-brief.pdf[product brief]. diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-01.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-01.png new file mode 100644 index 0000000000..89eda454cd Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-01.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-02.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-02.png new file mode 100644 index 0000000000..b11d07a459 Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-02.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-03.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-03.png new file mode 100644 index 0000000000..c11a504ee0 Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-03.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-04.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-04.png new file mode 100644 index 0000000000..ae6e321dce Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-04.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-05.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-05.png new file mode 100644 index 0000000000..0a93df849d Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-05.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-06.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-06.png new file mode 100644 index 0000000000..209ec6cbcd Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-06.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-07.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-07.png new file mode 100644 index 0000000000..238b75df86 Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-installation-07.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-schematics.png b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-schematics.png new file mode 100644 index 0000000000..5d0688fbd5 Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus-schematics.png differ diff --git a/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus.jpg b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus.jpg new file mode 100644 index 0000000000..30a05a30b2 Binary files /dev/null and b/documentation/asciidoc/accessories/m2-hat-plus/images/m2-hat-plus.jpg differ diff --git a/documentation/asciidoc/accessories/monitor.adoc b/documentation/asciidoc/accessories/monitor.adoc new file mode 100644 index 0000000000..b100eb439b --- /dev/null +++ b/documentation/asciidoc/accessories/monitor.adoc @@ -0,0 +1 @@ +include::monitor/monitor_intro.adoc[] diff --git a/documentation/asciidoc/accessories/monitor/images/drill-hole-template.pdf b/documentation/asciidoc/accessories/monitor/images/drill-hole-template.pdf new file mode 100644 index 0000000000..1d77318e3c Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/drill-hole-template.pdf differ diff --git a/documentation/asciidoc/accessories/monitor/images/drill-hole-template.png b/documentation/asciidoc/accessories/monitor/images/drill-hole-template.png new file mode 100644 index 0000000000..a1553774a8 Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/drill-hole-template.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.pdf b/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.pdf new file mode 100644 index 0000000000..d74544841f Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.pdf differ diff --git a/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.png b/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.png new file mode 100644 index 0000000000..41faee30b5 Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/mechanical-drawing.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/monitor-hero.png b/documentation/asciidoc/accessories/monitor/images/monitor-hero.png new file mode 100644 index 0000000000..dbaa5f56dc Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/monitor-hero.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/no-hdmi.png b/documentation/asciidoc/accessories/monitor/images/no-hdmi.png new file mode 100644 index 0000000000..408ad418ba Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/no-hdmi.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/no-valid-hdmi-signal-standby.png b/documentation/asciidoc/accessories/monitor/images/no-valid-hdmi-signal-standby.png new file mode 100644 index 0000000000..2c03121189 Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/no-valid-hdmi-signal-standby.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/not-supported-resolution.png b/documentation/asciidoc/accessories/monitor/images/not-supported-resolution.png new file mode 100644 index 0000000000..5334217389 Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/not-supported-resolution.png differ diff --git a/documentation/asciidoc/accessories/monitor/images/power-saving-mode.png b/documentation/asciidoc/accessories/monitor/images/power-saving-mode.png new file mode 100644 index 0000000000..106694ee18 Binary files /dev/null and b/documentation/asciidoc/accessories/monitor/images/power-saving-mode.png differ diff --git a/documentation/asciidoc/accessories/monitor/monitor_intro.adoc b/documentation/asciidoc/accessories/monitor/monitor_intro.adoc new file mode 100644 index 0000000000..ae747671ac --- /dev/null +++ b/documentation/asciidoc/accessories/monitor/monitor_intro.adoc @@ -0,0 +1,119 @@ +== Raspberry Pi Monitor + +The https://www.raspberrypi.com/products/raspberry-pi-monitor/[Raspberry Pi Monitor] is a 15.6" 1920 × 1080p IPS LCD display that connects to a computer using an HDMI cable. The Monitor also requires a USB-C power source. For full brightness and volume range, this must be a USB-PD source capable of at least 1.5A of current. + +.The Raspberry Pi Monitor +image::images/monitor-hero.png[The Raspberry Pi Monitor, width="100%"] + +The Monitor is compatible with all models of Raspberry Pi that support HDMI output. + +=== Controls + +The back of the Monitor includes the following controls: + +* a button that enters and exits Standby mode (indicated by the ⏻ (power) symbol) +* buttons that increase and decrease display brightness (indicated by the 🔆 (sun) symbol) +* buttons that increase and decrease speaker volume (indicated by the 🔈 (speaker) symbol) + +=== On screen display messages + +The on-screen display (OSD) may show the following messages: + +[cols="1a,6"] +|=== +| Message | Description + +| image::images/no-hdmi.png[No HDMI signal detected] +| No HDMI signal detected. + +| image::images/no-valid-hdmi-signal-standby.png[Standby mode] +| The monitor will soon enter standby mode to conserve power. + +| image::images/not-supported-resolution.png[Unsupported resolution] +| The output display resolution of the connected device is not supported. + +| image::images/power-saving-mode.png[Power saving mode] +| The monitor is operating in Power Saving mode, with reduced brightness and volume, because the monitor is not connected to a power supply capable of delivering 1.5A of current or greater. +|=== + +Additionally, the OSD shows information about display brightness changes using the 🔆 (sun) symbol, and speaker volume level changes using the 🔈 (speaker) symbol. Both brightness and volume use a scale that ranges from 0 to 100. + +TIP: If you attempt to exit Standby mode when the display cannot detect an HDMI signal, the red LED beneath the Standby button will briefly light, but the display will remain in Standby mode. + +=== Position the Monitor + +Use the following approaches to position the Monitor: + +* Angle the Monitor on the integrated stand. +* Mount the Monitor on an arm or stand using the four VESA mount holes on the back of the red rear plastic housing. ++ +IMPORTANT: Use spacers to ensure adequate space for display and power cable egress. +* Flip the integrated stand fully upwards, towards the top of the monitor. Use the drill hole template to create two mounting points spaced 55mm apart. Hang the Monitor using the slots on the back of the integrated stand. ++ +.Drill hole template +image::images/drill-hole-template.png[Drill hole template, width="40%"] + +=== Power the Monitor + +The Raspberry Pi Monitor draws power from a 5V https://en.wikipedia.org/wiki/USB_hardware#USB_Power_Delivery[USB Power Delivery] (USB-PD) power source. Many USB-C power supplies, including the official power supplies for the Raspberry Pi 4 and Raspberry Pi 5, support this standard. + +When using a power source that provides at least 1.5A of current over USB-PD, the Monitor operates in **Full Power mode**. In Full Power mode, you can use the full range (0%-100%) of display brightness and speaker volume. + +When using a power source that does _not_ supply at least 1.5A of current over USB-PD (including all USB-A power sources), the Monitor operates in **Power Saving mode**. Power Saving mode limits the maximum display brightness and the maximum speaker volume to ensure reliable operation. In Power Saving mode, you can use a limited range (0-50%) of display brightness and a limited range (0-60%) of speaker volume. When powered from a Raspberry Pi, the Monitor operates in Power Saving mode, since Raspberry Pi devices cannot provide 1.5A of current over a USB-A connection. + +To switch from Power Saving mode to Full Power mode, press and hold the *increase brightness* button for 3 seconds. + +[TIP] +==== +If the Monitor flashes on and off, your USB power supply is not capable of providing sufficient current to power the monitor. This can happen if you power the Monitor from a Raspberry Pi 5 or Pi 500 which is itself powered by a 5V/3A power supply. Try the following fixes to stop the Monitor from flashing on and off: + +* reduce the display brightness and volume (you may have to connect your monitor to another power supply to access the settings) +* switch to a different power source or cable + +==== + +=== Specification + +Diagonal: 15.6" + +Resolution: 1920 × 1080 + +Type: IPS LCD + +Colour gamut: 45% + +Contrast: 800:1 + +Brightness: 250cd/m^2^ + +Screen coating: Anti-glare 3H hardness + +Display area: 344 × 193mm + +Dimensions: 237 × 360 × 20mm + +Weight: 850g + +Supported resolutions: + +* 1920 × 1080p @ 50/60Hz +* 1280 × 720p @ 50/60Hz +* 720 × 576p @ 50/60Hz +* 720 × 480p @ 50/60Hz +* 640 × 480p @ 50/60Hz + +Input: HDMI 1.4; supports DDC-CI + +Power input: USB-C; requires 1.5A over USB-PD at 5V for full brightness and volume range + +Power consumption: 4.5-6.5W during use; < 0.1W at idle + +Speakers: 2 × 1.2W (stereo) + +Ports: 3.5mm audio jack + + +=== Mechanical drawing + +.Mechanical Drawing +image::images/mechanical-drawing.png[Mechanical drawing, width="80%"] diff --git a/documentation/asciidoc/accessories/sd-cards.adoc b/documentation/asciidoc/accessories/sd-cards.adoc new file mode 100644 index 0000000000..ffdb0161ae --- /dev/null +++ b/documentation/asciidoc/accessories/sd-cards.adoc @@ -0,0 +1 @@ +include::sd-cards/about.adoc[] diff --git a/documentation/asciidoc/accessories/sd-cards/about.adoc b/documentation/asciidoc/accessories/sd-cards/about.adoc new file mode 100644 index 0000000000..1d8f41170c --- /dev/null +++ b/documentation/asciidoc/accessories/sd-cards/about.adoc @@ -0,0 +1,37 @@ +== About + +.A Raspberry Pi SD Card inserted into a Raspberry Pi 5 +image::images/sd-hero.jpg[width="80%"] + +SD card quality is a critical factor in determining the overall user experience for a Raspberry Pi. Slow bus speeds and lack of command queueing can reduce the performance of even the most powerful Raspberry Pi models. + +Raspberry Pi's official microSD cards support DDR50 and SDR104 bus speeds. Additionally, Raspberry Pi SD cards support the command queueing (CQ) extension, which permits some pipelining of random read operations, ensuring optimal performance. + +You can even buy Raspberry Pi SD cards pre-programmed with the latest version of Raspberry Pi OS. + +Raspberry Pi SD cards are available in the following sizes: + +* 32GB +* 64GB +* 128GB + +== Specifications + +.A 128GB Raspberry Pi SD Card +image::images/sd-cards.png[width="80%"] + +Raspberry Pi SD cards use the SD6.1 SD specification. + +Raspberry Pi SD cards use the microSDHC/microSDXC form factor. + +Raspberry Pi SD cards have the following Speed Class ratings: C10, U3, V30, A2. + +The following table describes the read and write speeds of Raspberry Pi SD cards using 4KB of random data: + +|=== +| Raspberry Pi Model | Interface | Read Speed | Write Speed + +| 4 | DDR50 | 3,200 IOPS | 1,200 IOPS +| 5 | SDR104 | 5,000 IOPS | 2,000 IOPS +|=== + diff --git a/documentation/asciidoc/accessories/sd-cards/images/sd-cards.png b/documentation/asciidoc/accessories/sd-cards/images/sd-cards.png new file mode 100644 index 0000000000..9651ba9594 Binary files /dev/null and b/documentation/asciidoc/accessories/sd-cards/images/sd-cards.png differ diff --git a/documentation/asciidoc/accessories/sd-cards/images/sd-hero.jpg b/documentation/asciidoc/accessories/sd-cards/images/sd-hero.jpg new file mode 100644 index 0000000000..7597450399 Binary files /dev/null and b/documentation/asciidoc/accessories/sd-cards/images/sd-hero.jpg differ diff --git a/documentation/asciidoc/accessories/sense-hat.adoc b/documentation/asciidoc/accessories/sense-hat.adoc index 1c64f91492..c0db67f2bb 100644 --- a/documentation/asciidoc/accessories/sense-hat.adoc +++ b/documentation/asciidoc/accessories/sense-hat.adoc @@ -1,190 +1,5 @@ -== Installation -:pp: {plus}{plus} +include::sense-hat/intro.adoc[] -In order to work correctly, the Sense HAT requires an up-to-date kernel, I2C to be enabled, and a few libraries to get started. +include::sense-hat/hardware.adoc[] -. Ensure your APT package list is up-to-date: -+ -[,bash] ----- - sudo apt update ----- - -. Next, install the sense-hat package which will ensure the kernel is up-to-date, enable I2C, and install the necessary libraries and programs: -+ -[,bash] ----- - sudo apt install sense-hat ----- - -. Finally, a reboot may be required if I2C was disabled or the kernel was not up-to-date prior to the install: -+ -[,bash] ----- - sudo reboot ----- - -== Sense HAT Hardware - -* Raspberry Pi https://datasheets.raspberrypi.org/sense-hat/sense-hat-schematics.pdf[Sense HAT schematics]. - -== Sense HAT Software - -After installation, example code can be found under `/usr/src/sense-hat/examples`. - -These can be copied to the user's home directory by running `cp /usr/src/sense-hat/examples ~/ -a`. - -The C/C{pp} examples can be compiled by running `make` in the appropriate directory. - -The RTIMULibDrive11 example comes pre-compiled to help ensure everything works as intended. It can be launched by running `RTIMULibDrive11` and closed by pressing `Ctrl+c`. - -== Using the Sense HAT with Python - -`sense-hat` is the officially supported library for the Sense HAT; it provides access to all of the on-board sensors and the LED matrix. - -Complete documentation can be found at https://pythonhosted.org/sense-hat/[pythonhosted.org/sense-hat]. - -== Using the RTIMULib Library - -https://github.com/RPi-Distro/RTIMULib[RTIMULib] is a C{pp} and Python library that makes it easy to use 9-dof and 10-dof IMUs with embedded Linux systems. A pre-calibrated settings file is provided in `/etc/RTIMULib.ini`, which is also copied and used by `sense-hat`. The included examples look for `RTIMULib.ini` in the current working directory, so you may wish to copy the file there to get more accurate data. - -== Other Issues - -=== LED matrix - -The LED matrix is an RGB565 https://www.kernel.org/doc/Documentation/fb/framebuffer.txt[framebuffer] with the id "RPi-Sense FB". The appropriate device node can be written to as a standard file or mmap-ed. The included 'snake' example shows how to access the framebuffer. - -=== Joystick - -The joystick comes up as an input event device named "Raspberry Pi Sense HAT Joystick", mapped to the arrow keys and `Enter`. It should be supported by any library which is capable of handling inputs, or directly through the https://www.kernel.org/doc/Documentation/input/input.txt[evdev interface]. Suitable libraries include SDL, http://www.pygame.org/docs/[pygame] and https://python-evdev.readthedocs.org/en/latest/[python-evdev]. The included 'snake' example shows how to access the joystick directly. - -== Calibration - -Taken from this https://www.raspberrypi.org/forums/viewtopic.php?f=104&t=109064&p=750616#p810193[forum post]. - -Install the necessary software and run the calibration program as follows: - ----- -sudo apt update -sudo apt install octave -y -cd -cp /usr/share/librtimulib-utils/RTEllipsoidFit ./ -a -cd RTEllipsoidFit -RTIMULibCal ----- - -You will then see this menu: - -.... -Options are: - - m - calibrate magnetometer with min/max - e - calibrate magnetometer with ellipsoid (do min/max first) - a - calibrate accelerometers - x - exit - -Enter option: -.... - -Press lowercase `m`. The following message will then show; press any key to start. - ----- - Magnetometer min/max calibration - -------------------------------- - Waggle the IMU chip around, ensuring that all six axes - (+x, -x, +y, -y and +z, -z) go through their extrema. - When all extrema have been achieved, enter 's' to save, 'r' to reset - or 'x' to abort and discard the data. - - Press any key to start... ----- - -After it starts, you will see something similar to this scrolling up the screen: - - Min x: 51.60 min y: 69.39 min z: 65.91 - Max x: 53.15 max y: 70.97 max z: 67.97 - -Focus on the two lines at the very bottom of the screen, as these are the most recently posted measurements from the program. -Now you have to move the Astro Pi around in every possible way you can think of. It helps if you unplug all non-essential cables to avoid clutter. - -Try and get a complete circle in each of the pitch, roll and yaw axes. Take care not to accidentally eject the SD card while doing this. Spend a few minutes moving the Astro Pi, and stop when you find that the numbers are not changing anymore. - -Now press lowercase `s` then lowercase `x` to exit the program. If you run the `ls` command now, you'll see a new `RTIMULib.ini` file has been created. - -In addition to those steps, you can also do the ellipsoid fit by performing the steps above, but pressing `e` instead of `m`. - -When you're done, copy the resulting `RTIMULib.ini` to /etc/ and remove the local copy in `~/.config/sense_hat/`: - - rm ~/.config/sense_hat/RTIMULib.ini - sudo cp RTIMULib.ini /etc - -You are now done. - -== EEPROM Data - -NOTE: These steps may not work on Raspberry Pi 2 Model B Rev 1.0 and Raspberry Pi 3 Model B boards. The firmware will take control of I2C0, causing the ID pins to be configured as inputs. - -. Enable I2C0 and I2C1 by adding the following line to `/boot/config.txt`: -+ ----- - dtparam=i2c_vc=on - dtparam=i2c_arm=on ----- - -. Enter the following command to reboot: -+ -[,bash] ----- - sudo systemctl reboot ----- - -. Download and build the flash tool: -+ -[,bash] ----- - git clone https://github.com/raspberrypi/hats.git - cd hats/eepromutils - make ----- - -=== Reading - -. EEPROM data can be read with the following command: -+ -[,bash] ----- - sudo ./eepflash.sh -f=sense_read.eep -t=24c32 -r ----- - -=== Writing - -WARNING: Please note that this operation is potentially dangerous, and is not needed for the everyday user. The steps below are provided for debugging purposes only. If an error occurs, the HAT may no longer be automatically detected. - -. Download EEPROM settings and build the `.eep` binary: -+ -[,bash] ----- - wget https://github.com/raspberrypi/rpi-sense/raw/master/eeprom/eeprom_settings.txt -O sense_eeprom.txt - ./eepmake sense_eeprom.txt sense.eep /boot/overlays/rpi-sense-overlay.dtb ----- - -. Disable write protection: -+ -[,bash] ----- - i2cset -y -f 1 0x46 0xf3 1 ----- - -. Write the EEPROM data: -+ -[,bash] ----- - sudo ./eepflash.sh -f=sense.eep -t=24c32 -w ----- - -. Re-enable write protection: -+ -[,bash] ----- - i2cset -y -f 1 0x46 0xf3 0 ----- +include::sense-hat/software.adoc[] diff --git a/documentation/asciidoc/accessories/sense-hat/hardware.adoc b/documentation/asciidoc/accessories/sense-hat/hardware.adoc new file mode 100644 index 0000000000..735ce713aa --- /dev/null +++ b/documentation/asciidoc/accessories/sense-hat/hardware.adoc @@ -0,0 +1,25 @@ +== Features + +The Sense HAT has an 8×8 RGB LED matrix and a five-button joystick, and includes the following sensors: + +* Gyroscope +* Accelerometer +* Magnetometer +* Temperature +* Barometric pressure +* Humidity +* Colour and brightness + +Schematics and mechanical drawings for the Sense HAT and the Sense HAT V2 are available for download. + +* https://datasheets.raspberrypi.com/sense-hat/sense-hat-schematics.pdf[Sense HAT V1 schematics]. +* https://datasheets.raspberrypi.com/sense-hat/sense-hat-v2-schematics.pdf[Sense HAT V2 schematics]. +* https://datasheets.raspberrypi.com/sense-hat/sense-hat-mechanical-drawing.pdf[Sense HAT mechanical drawings]. + +=== LED matrix + +The LED matrix is an RGB565 https://www.kernel.org/doc/Documentation/fb/framebuffer.txt[framebuffer] with the id `RPi-Sense FB`. The appropriate device node can be written to as a standard file or mmap-ed. The included snake example shows how to access the framebuffer. + +=== Joystick + +The joystick comes up as an input event device named `Raspberry Pi Sense HAT Joystick`, mapped to the arrow keys and **Enter**. It should be supported by any library which is capable of handling inputs, or directly through the https://www.kernel.org/doc/Documentation/input/input.txt[evdev interface]. Suitable libraries include SDL, http://www.pygame.org/docs/[pygame] and https://python-evdev.readthedocs.org/en/latest/[python-evdev]. The included `snake` example shows how to access the joystick directly. diff --git a/documentation/asciidoc/accessories/sense-hat/images/Sense-HAT.jpg b/documentation/asciidoc/accessories/sense-hat/images/Sense-HAT.jpg new file mode 100644 index 0000000000..e1eebd815d Binary files /dev/null and b/documentation/asciidoc/accessories/sense-hat/images/Sense-HAT.jpg differ diff --git a/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.jpg b/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.jpg new file mode 100644 index 0000000000..01da626792 Binary files /dev/null and b/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.jpg differ diff --git a/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.png b/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.png new file mode 100644 index 0000000000..a16110ff22 Binary files /dev/null and b/documentation/asciidoc/accessories/sense-hat/images/experiment-with-the-sense-hat.png differ diff --git a/documentation/asciidoc/accessories/sense-hat/intro.adoc b/documentation/asciidoc/accessories/sense-hat/intro.adoc new file mode 100644 index 0000000000..01f8a2425a --- /dev/null +++ b/documentation/asciidoc/accessories/sense-hat/intro.adoc @@ -0,0 +1,9 @@ +== About + +The https://www.raspberrypi.com/products/sense-hat/[Raspberry Pi Sense HAT] is an add-on board that gives your Raspberry Pi an array of sensing capabilities. The on-board sensors allow you to monitor pressure, humidity, temperature, colour, orientation, and movement. The 8×8 RGB LED matrix allows you to visualise data from the sensors. The five-button joystick lets users interact with your projects. + +image::images/Sense-HAT.jpg[width="70%"] + +The Sense HAT was originally developed for use on the International Space Station as part of the educational https://astro-pi.org/[Astro Pi] programme run by the https://raspberrypi.org[Raspberry Pi Foundation] in partnership with the https://www.esa.int/[European Space Agency]. It can help with any project that requires position, motion, orientation, or environmental sensing. + +An officially supported xref:sense-hat.adoc#use-the-sense-hat-with-python[Python library] provides access to the on-board sensors, LED matrix, and joystick. The Sense HAT is compatible with any Raspberry Pi device with a 40-pin GPIO header. diff --git a/documentation/asciidoc/accessories/sense-hat/software.adoc b/documentation/asciidoc/accessories/sense-hat/software.adoc new file mode 100644 index 0000000000..33261939a2 --- /dev/null +++ b/documentation/asciidoc/accessories/sense-hat/software.adoc @@ -0,0 +1,191 @@ +== Install + +In order to work correctly, the Sense HAT requires: + +* an up-to-date kernel +* https://en.wikipedia.org/wiki/I%C2%B2C[I2C] enabled on your Raspberry Pi +* a few dependencies + +Complete the following steps to get your Raspberry Pi device ready to connect to the Sense HAT: + +. First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: ++ +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +. Next, install the `sense-hat` package, which will ensure the kernel is up to date, enable I2C, and install the necessary dependencies: ++ +[source,console] +---- +$ sudo apt install sense-hat +---- + +. Finally, reboot your Raspberry Pi to enable I2C and load the new kernel, if it changed: ++ +[source,console] +---- +$ sudo reboot +---- + +== Calibrate + +Install the necessary software and run the calibration program as follows: + +[source,console] +---- +$ sudo apt update +$ sudo apt install octave -y +$ cd +$ cp /usr/share/librtimulib-utils/RTEllipsoidFit ./ -a +$ cd RTEllipsoidFit +$ RTIMULibCal +---- + +The calibration program displays the following menu: + +---- +Options are: + + m - calibrate magnetometer with min/max + e - calibrate magnetometer with ellipsoid (do min/max first) + a - calibrate accelerometers + x - exit + +Enter option: +---- + +Press lowercase `m`. The following message will then show. Press any key to start. + +---- +Magnetometer min/max calibration +------------------------------- +Waggle the IMU chip around, ensuring that all six axes +(+x, -x, +y, -y and +z, -z) go through their extrema. +When all extrema have been achieved, enter 's' to save, 'r' to reset +or 'x' to abort and discard the data. + +Press any key to start... +---- + +After it starts, you should see output similar to the following scrolling up the screen: + +---- +Min x: 51.60 min y: 69.39 min z: 65.91 +Max x: 53.15 max y: 70.97 max z: 67.97 +---- + +Focus on the two lines at the very bottom of the screen, as these are the most recently posted measurements from the program. + +Now, pick up the Raspberry Pi and Sense HAT and move it around in every possible way you can think of. It helps if you unplug all non-essential cables to avoid clutter. + +Try and get a complete circle in each of the pitch, roll and yaw axes. Take care not to accidentally eject the SD card while doing this. Spend a few minutes moving the Sense HAT, and stop when you find that the numbers are not changing any more. + +Now press lowercase `s` then lowercase `x` to exit the program. If you run the `ls` command now, you'll see a new `RTIMULib.ini` file has been created. + +In addition to those steps, you can also do the ellipsoid fit by performing the steps above, but pressing `e` instead of `m`. + +When you're done, copy the resulting `RTIMULib.ini` to `/etc/` and remove the local copy in `~/.config/sense_hat/`: + +[source,console] +---- +$ rm ~/.config/sense_hat/RTIMULib.ini +$ sudo cp RTIMULib.ini /etc +---- + +== Getting started + +After installation, example code can be found under `/usr/src/sense-hat/examples`. + +=== Use the Sense HAT with Python + +`sense-hat` is the officially supported library for the Sense HAT; it provides access to all of the on-board sensors and the LED matrix. + +Complete documentation for the library can be found at https://sense-hat.readthedocs.io/en/latest/[sense-hat.readthedocs.io]. + +=== Use the Sense HAT with C++ + +https://github.com/RPi-Distro/RTIMULib[RTIMULib] is a {cpp} and Python library that makes it easy to use 9-dof and 10-dof IMUs with embedded Linux systems. A pre-calibrated settings file is provided in `/etc/RTIMULib.ini`, which is also copied and used by `sense-hat`. The included examples look for `RTIMULib.ini` in the current working directory, so you may wish to copy the file there to get more accurate data. + +The RTIMULibDrive11 example comes pre-compiled to help ensure everything works as intended. It can be launched by running `RTIMULibDrive11` and closed by pressing `Ctrl C`. + +NOTE: The C/{cpp} examples can be compiled by running `make` in the appropriate directory. + +== Troubleshooting + +=== Read and write EEPROM data + +These steps are provided for debugging purposes only. + +NOTE: On Raspberry Pi 2 Model B Rev 1.0 and Raspberry Pi 3 Model B boards, these steps may not work. The firmware will take control of I2C0, causing the ID pins to be configured as inputs. + +Before you can read and write EEPROM data to and from the Sense HAT, you must complete the following steps: + +. Enable I2C0 and I2C1 by adding the following line to the xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] file: ++ +[source,ini] +---- +dtparam=i2c_vc=on +dtparam=i2c_arm=on +---- + +. Run the following command to reboot: ++ +[source,console] +---- +$ sudo reboot +---- + +. Download and build the flash tool: ++ +[source,console] +---- +$ git clone https://github.com/raspberrypi/hats.git +$ cd hats/eepromutils +$ make +---- + +==== Read + +To read EEPROM data, run the following command: + +[source,console] +---- +$ sudo ./eepflash.sh -f=sense_read.eep -t=24c32 -r +---- + +==== Write + +NOTE: This operation will not damage your Raspberry Pi or Sense HAT, but if an error occurs, your Raspberry Pi may fail to automatically detect the HAT. + + +. First, download EEPROM settings and build the `.eep` binary: ++ +[source,console] +---- +$ wget https://github.com/raspberrypi/rpi-sense/raw/master/eeprom/eeprom_settings.txt -O sense_eeprom.txt +$ ./eepmake sense_eeprom.txt sense.eep /boot/firmware/overlays/rpi-sense-overlay.dtb +---- + +. Next, disable write protection: ++ +[source,console] +---- +$ i2cset -y -f 1 0x46 0xf3 1 +---- + +. Write the EEPROM data: ++ +[source,console] +---- +$ sudo ./eepflash.sh -f=sense.eep -t=24c32 -w +---- + +. Finally, re-enable write protection: ++ +[source,console] +---- +$ i2cset -y -f 1 0x46 0xf3 0 +---- + diff --git a/documentation/asciidoc/accessories/ssd-kit.adoc b/documentation/asciidoc/accessories/ssd-kit.adoc new file mode 100644 index 0000000000..2533220b5e --- /dev/null +++ b/documentation/asciidoc/accessories/ssd-kit.adoc @@ -0,0 +1 @@ +include::ssd-kit/about.adoc[] diff --git a/documentation/asciidoc/accessories/ssd-kit/about.adoc b/documentation/asciidoc/accessories/ssd-kit/about.adoc new file mode 100644 index 0000000000..390aef6d3f --- /dev/null +++ b/documentation/asciidoc/accessories/ssd-kit/about.adoc @@ -0,0 +1,13 @@ +== About + +.A 512GB Raspberry Pi SSD Kit +image::images/ssd-kit.png[width="80%"] + +The Raspberry Pi SSD Kit bundles a xref:../accessories/m2-hat-plus.adoc[Raspberry Pi M.2 HAT+] with a xref:../accessories/ssds.adoc[Raspberry Pi SSD]. + +The Raspberry Pi SSD Kit includes a 16mm stacking header, spacers, and +screws to enable fitting on Raspberry Pi 5 alongside a Raspberry Pi Active Cooler. + +== Install + +To install the Raspberry Pi SSD Kit, follow the xref:../accessories/m2-hat-plus.adoc#m2-hat-plus-installation[installation instructions for the Raspberry Pi M.2 HAT+]. diff --git a/documentation/asciidoc/accessories/ssd-kit/images/ssd-kit.png b/documentation/asciidoc/accessories/ssd-kit/images/ssd-kit.png new file mode 100644 index 0000000000..9381c5ca12 Binary files /dev/null and b/documentation/asciidoc/accessories/ssd-kit/images/ssd-kit.png differ diff --git a/documentation/asciidoc/accessories/ssds.adoc b/documentation/asciidoc/accessories/ssds.adoc new file mode 100644 index 0000000000..3934f0db66 --- /dev/null +++ b/documentation/asciidoc/accessories/ssds.adoc @@ -0,0 +1 @@ +include::ssds/about.adoc[] diff --git a/documentation/asciidoc/accessories/ssds/about.adoc b/documentation/asciidoc/accessories/ssds/about.adoc new file mode 100644 index 0000000000..abccf00e9e --- /dev/null +++ b/documentation/asciidoc/accessories/ssds/about.adoc @@ -0,0 +1,32 @@ +== About + +.A 512GB Raspberry Pi SSD +image::images/ssd.png[width="80%"] + +SSD quality is a critical factor in determining the overall user experience for a Raspberry Pi. +Raspberry Pi provides official SSDs that are tested to ensure compatibility with Raspberry Pi models and peripherals. + +Raspberry Pi SSDs are available in the following sizes: + +* 256GB +* 512GB + +To use an SSD with your Raspberry Pi, you need a Raspberry Pi 5-compatible M.2 adapter, such as the xref:../accessories/m2-hat-plus.adoc[Raspberry Pi M.2 HAT+]. + +== Specifications + +Raspberry Pi SSDs are PCIe Gen 3-compliant. + +Raspberry Pi SSDs use the NVMe 1.4 register interface and command set. + +Raspberry Pi SSDs use the M.2 2230 form factor. + +The following table describes the read and write speeds of Raspberry Pi SSDs using 4KB of random data: + +[cols="1,2,2"] +|=== +| Size | Read Speed | Write Speed + +| 256GB | 40,000 IOPS | 70,000 IOPS +| 512GB | 50,000 IOPS | 90,000 IOPS +|=== diff --git a/documentation/asciidoc/accessories/ssds/images/ssd.png b/documentation/asciidoc/accessories/ssds/images/ssd.png new file mode 100644 index 0000000000..25bbdc3a7f Binary files /dev/null and b/documentation/asciidoc/accessories/ssds/images/ssd.png differ diff --git a/documentation/asciidoc/accessories/touch-display-2.adoc b/documentation/asciidoc/accessories/touch-display-2.adoc new file mode 100644 index 0000000000..982c35d56a --- /dev/null +++ b/documentation/asciidoc/accessories/touch-display-2.adoc @@ -0,0 +1 @@ +include::touch-display-2/about.adoc[] diff --git a/documentation/asciidoc/accessories/touch-display-2/about.adoc b/documentation/asciidoc/accessories/touch-display-2/about.adoc new file mode 100644 index 0000000000..ed4014991b --- /dev/null +++ b/documentation/asciidoc/accessories/touch-display-2/about.adoc @@ -0,0 +1,136 @@ +== About + +The https://www.raspberrypi.com/products/touch-display-2/[Raspberry Pi Touch Display 2] is a portrait orientation touchscreen LCD display designed for interactive projects like tablets, entertainment systems, and information dashboards. + +.The Raspberry Pi Touch Display 2 +image::images/touch-display-2-hero.jpg[width="80%"] + +The Touch Display 2 connects to a Raspberry Pi using a DSI connector and GPIO connector. Raspberry Pi OS provides touchscreen drivers with support for five-finger multitouch and an on-screen keyboard, providing full functionality without the need to connect a keyboard or mouse. + +== Specifications + +* 1280×720px resolution, 24-bit RGB display +* 155×88mm active area +* 7" diagonal +* powered directly by the host Raspberry Pi, requiring no separate power supply +* supports up to five points of simultaneous multi-touch + +The Touch Display 2 is compatible with all models of Raspberry Pi from Raspberry Pi 1B+ onwards, except the Zero series and Keyboard series, which lack a DSI connector. + +The Touch Display 2 box contains the following parts (in left to right, top to bottom order in the image below): + +* Touch Display 2 +* eight M2.5 screws +* 15-way to 15-way FFC +* 22-way to 15-way FFC for Raspberry Pi 5 +* GPIO connector cable + +.Parts included in the Touch Display 2 box +image::images/touch-display-2-whats-in-the-booooox.jpg["Parts included in the Touch Display 2 box", width="80%"] + +== Install + +.A Raspberry Pi 5 connected and mounted to the Touch Display 2 +image::images/touch-display-2-installation-diagram.png["A Raspberry Pi 5 connected and mounted to the Touch Display 2", width="80%"] + +To connect a Touch Display 2 to a Raspberry Pi, use a Flat Flexible Cable (FFC) and a GPIO connector. The FFC you'll use depends upon your Raspberry Pi model: + +* for Raspberry Pi 5, use the included 22-way to 15-way FFC +* for any other Raspberry Pi model, use the included 15-way to 15-way FFC + +Once you have determined the correct FFC for your Raspberry Pi model, complete the following steps to connect your Touch Display 2 to your Raspberry Pi: + +. Disconnect your Raspberry Pi from power. +. Lift the retaining clips on either side of the FFC connector on the Touch Display 2. +. Insert one 15-way end of your FFC into the Touch Display 2 FFC connector, with the metal contacts facing upwards, away from the Touch Display 2. ++ +TIP: If you use the 22-way to 15-way FFC, the 22-way end is the _smaller_ end of the cable. Insert the _larger_ end of the cable into the Touch Display 2. +. While holding the FFC firmly in place, simultaneously push both retaining clips down on the FFC connector of the Touch Display 2. +. Lift the retaining clips on either side of the DSI connector of your Raspberry Pi. This port should be marked with some variation of the term `DISPLAY` or `DISP`. If your Raspberry Pi has multiple DSI connectors, prefer the port labelled `1`. +. Insert the other end of your FFC into the Raspberry Pi DSI connector, with the metal contacts facing towards the Ethernet and USB-A ports. +. While holding the FFC firmly in place, simultaneously push both retaining clips down on the DSI connector of the Raspberry Pi. +. Plug the GPIO connector cable into the port marked `J1` on the Touch Display 2. +. Connect the other (three-pin) end of the GPIO connector cable to pins 2, 4, and 6 of the xref:../computers/raspberry-pi.adoc#gpio[Raspberry Pi's GPIO]. Connect the red cable (5V power) to pin 2, and the black cable (ground) to pin 6. Viewed from above, with the Ethernet and USB-A ports facing down, these pins are located at the top right of the board, with pin 2 in the top right-most position. ++ +.The GPIO connection to the Touch Display 2 +image::images/touch-display-2-gpio-connection.png[The GPIO connection to the Touch Display 2, width="40%"] ++ +TIP: If pin 6 isn't available, you can use any other open `GND` pin to connect the black wire. If pin 2 isn't available, you can use any other 5V pin to connect the red wire, such as pin 4. +. Optionally, use the included M2.5 screws to mount your Raspberry Pi to the back of the Touch Display 2. +.. Align the four corner stand-offs of your Raspberry Pi with the four mount points that surround the FFC connector and `J1` port on the back of the Touch Display 2, taking special care not to pinch the FFC. +.. Insert the screws into the four corner stand-offs and tighten until your Raspberry Pi is secure. +. Reconnect your Raspberry Pi to power. It may take up to one minute to initialise the Touch Display 2 connection and begin displaying to the screen. + +=== Use an on-screen keyboard + +Raspberry Pi OS _Bookworm_ and later include the Squeekboard on-screen keyboard by default. When a touch display is attached, the on-screen keyboard should automatically show when it is possible to enter text and automatically hide when it is not possible to enter text. + +For applications which do not support text entry detection, use the keyboard icon at the right end of the taskbar to manually show and hide the keyboard. + +You can also permanently show or hide the on-screen keyboard in the Display tab of Raspberry Pi Configuration or the `Display` section of `raspi-config`. + +TIP: In Raspberry Pi OS releases prior to _Bookworm_, use `matchbox-keyboard` instead. If you use the wayfire desktop compositor, use `wvkbd` instead. + +=== Change screen orientation + +If you want to physically rotate the display, or mount it in a specific position, select **Screen Configuration** from the **Preferences** menu. Right-click on the touch display rectangle (likely DSI-1) in the layout editor, select **Orientation**, then pick the best option to fit your needs. + +==== Rotate screen without a desktop + +To set the screen orientation on a device that lacks a desktop environment, edit the `/boot/firmware/cmdline.txt` configuration file to pass an orientation to the system. Add the following entry to the end of `cmdline.txt`: + +[source,ini] +---- +video=DSI-1:720x1280@60,rotate= +---- + +Replace the `` placeholder with one of the following values, which correspond to the degree of rotation relative to the default on your display: + +* `0` +* `90` +* `180` +* `270` + +For example, a rotation value of `90` rotates the display 90 degrees to the right. `180` rotates the display 180 degrees, or upside-down. + +NOTE: It is not possible to rotate the DSI display separately from the HDMI display with `cmdline.txt`. When you use DSI and HDMI simultaneously, they share the same rotation value. + +==== Touch Display 2 device tree option reference + +The `vc4-kms-dsi-ili9881-7inch` overlay supports the following options: + +|=== +| DT parameter | Action + +| `sizex` +| Sets X resolution (default 720) + +| `sizey` +| Sets Y resolution (default 1280) + +| `invx` +| Invert X coordinates + +| `invy` +| Invert Y coordinates + +| `swapxy` +| Swap X and Y coordinates + +| `disable_touch` +| Disables the touch overlay totally +|=== + +To specify these options, add them, separated by commas, to your `dtoverlay` line in `/boot/firmware/config.txt`. Boolean values default to true when present, but you can set them to false using the suffix "=0". Integer values require a value, e.g. `sizey=240`. For instance, to set the X resolution to 400 pixels and invert both X and Y coordinates, use the following line: + +[source,ini] +---- +dtoverlay=vc4-kms-dsi-ili9881-7inch,sizex=400,invx,invy +---- + +=== Installation and software setup on Compute Module based devices. + +All Raspberry Pi SBCs auto-detect the official Touch Displays as the circuitry connected to the DSI connector on the Raspberry Pi board is fixed; this autodetection ensures the correct Device Tree entries are passed to the kernel. However, Compute Modules are intended for industrial applications where the integrator can use any and all GPIOs and interfaces for whatever purposes they require. Autodetection is therefore not feasible, and hence is disabled on Compute Module devices. This means that the Device Tree fragments required to set up the display need to be loaded via some other mechanism, which can be either with a dtoverlay entry in config.txt, via a custom base DT file, or if present, a HAT EEPROM. + +Creating a custom base Device tree file is beyond the scope of this documentation, however, it is simple to add an appropriate device tree entry via `config.txt`. See this xref:../computers/compute-module.adoc#attaching-the-touch-display-2-lcd-panel[page] for configuration details. + diff --git a/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-gpio-connection.png b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-gpio-connection.png new file mode 100644 index 0000000000..41e59bc42c Binary files /dev/null and b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-gpio-connection.png differ diff --git a/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-hero.jpg b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-hero.jpg new file mode 100644 index 0000000000..45779c6e24 Binary files /dev/null and b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-hero.jpg differ diff --git a/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-installation-diagram.png b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-installation-diagram.png new file mode 100644 index 0000000000..f3167f5e69 Binary files /dev/null and b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-installation-diagram.png differ diff --git a/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-whats-in-the-booooox.jpg b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-whats-in-the-booooox.jpg new file mode 100644 index 0000000000..e28fd789c4 Binary files /dev/null and b/documentation/asciidoc/accessories/touch-display-2/images/touch-display-2-whats-in-the-booooox.jpg differ diff --git a/documentation/asciidoc/accessories/tv-hat.adoc b/documentation/asciidoc/accessories/tv-hat.adoc index 71e6ada245..be04ece4cb 100644 --- a/documentation/asciidoc/accessories/tv-hat.adoc +++ b/documentation/asciidoc/accessories/tv-hat.adoc @@ -1,62 +1 @@ -== Getting Started - -The TV HAT has an on-board DVB-T2 tuner that allows you to receive and decode digital television streams on your Raspberry Pi. Then you can watch these streams on the Pi or on any computer connected to the same network as the Pi. - -The software we recommend to decode the streams (known as multiplexes, or muxes for short) and view content is called TVHeadend, and instructions for setting it up are below. The TV HAT can decode one mux at a time, and each mux can contain several channels to choose from. Content can either be viewed on the Raspberry Pi to which the TV-HAT is connected, or sent to another device on the same network. - -*You will need:* - -* A TV aerial -* A Raspberry Pi TV HAT with its stand-offs, screws, and aerial adaptor -* A Raspberry Pi that is connected to the internet (plus a mouse, keyboard, and display, if -you are not accessing the Pi remotely) -* Optional: another computer connected to the same network - -== Setup Instructions - -*On your Raspberry Pi:* - -* Connect the aerial adaptor to the TV HAT: - ** With the adaptor pointing away from the USB ports, press the HAT gently down over the Raspberry Pi's GPIO pins - ** Place the spacers at two or three of the corners of the HAT, and tighten the screws through the mounting -holes to hold them in place. -* Connect the TV HAT's aerial adaptor to the cable from your TV aerial. -* Set up the Raspberry Pi with the newest version of the Raspberry Pi OS operating system, which you can download from our https://www.raspberrypi.org/downloads/raspbian/[downloads page]. -* Start up your Pi, open a terminal window, and run the following two commands to install the `tvheadend` software: -+ ----- -sudo apt update -sudo apt install tvheadend ----- - -* During the `tvheadend` installation, you will be asked to choose an administrator account name and password. You'll need these later, so make sure to pick something you can remember. - -*In a web browser on a different computer:* - -* Type the following into the address bar: `+http://raspberrypi.local:9981/extjs.html+` -* This should connect to `tvheadend` running on the Raspberry Pi. - ** If the address above doesn't work, you'll need to find out the IP address of the Pi. Open a terminal window on your Pi, and run the command `hostname -I` - ** You'll see the IP address in one or two formats: a string of four numbers separated by dots, then, if you are on a IPv6 network, a space, then a long string of numbers and letters separated by colons. - ** Note down everything before the space (the four numbers and dots), and type this into the address bar instead of the raspberrypi.local part of the address. -* Once you have connected to `tvheadend` via the browser, you will be prompted to sign in. Use the account name and password you chose when you installed `tvheadend` on the Pi. A setup wizard should appear. -* First, set the language you want `tvheadend` to use (*English (GB)* worked for us; we have not yet tested other languages). -* Next, set up network, user, and administrator access. If you don't have specific preferences, leave *Allowed network* blank, and enter an asterisk (*) in the *username* and *password* fields. This will let anyone connected to your local network access `tvheadend`. -* You should see a window titled *Network settings*. Under *Network 2*, you should see `Tuner: Sony CDX2880 #0 : DVB-T #0`. For *Network type*, choose `DVB-T Network`. -* The next window is *Assign predefined muxes to networks*; here, you select the TV stream to receive and decode. Under Network 1, for predefined muxes, select your local TV transmitter. - ** Your local transmitter can be found using the https://www.freeview.co.uk/help[Freeview website]. Enter your postcode to see which transmitter should give you a good signal. -* When you click *Save & Next*, the software will start scanning for the selected mux, and will show a progress bar. After about two minutes, you should see something like: -+ ----- -Found muxes: 8 -Found services: 172 ----- - -* In the next window, titled *Service mapping*, tick all three boxes: *Map all services*, *Create provider tags*, and *Create network tags*. -* Next you should see a list of TV channels you can watch, along with the programmes they're currently showing. -* To watch a TV channel in the browser, click the little TV icon to the left of the channel -listing, just to the right of the *i* icon. This brings up an in-browser media player. Depending on the decoding facilities built into your browser and the type of stream being played, you may find that playback can be jerky. In these cases, we recommend using a local media player as the playback application. -* To watch a TV channel in a local media player, e.g. VLC https://www.videolan.org/vlc[www.videolan.org/vlc], you'll need to download it as a stream. Click the `i` icon to the left of a channel listing to bring up the information panel for that channel. Here you can see a stream file that you can download. - -`tvheadend` is supported by numerous apps, such as TvhClient for iOS, which will play TV from the Pi. OMXPlayer, supplied with Raspberry Pi OS, also supports viewing TV streams from `tvheadend`. Kodi, available in the Raspberry Pi OS repos, provides excellent facilities for playing live TV, along with previously recorded channels and timed series recording. - -To discuss other features or uses of the TV HAT, please visit our https://www.raspberrypi.org/forums[forums]. +include::tv-hat/about-tv-hat.adoc[] diff --git a/documentation/asciidoc/accessories/tv-hat/about-tv-hat.adoc b/documentation/asciidoc/accessories/tv-hat/about-tv-hat.adoc new file mode 100644 index 0000000000..e1cb7efa60 --- /dev/null +++ b/documentation/asciidoc/accessories/tv-hat/about-tv-hat.adoc @@ -0,0 +1,77 @@ +[[tv-hat]] +== About + +.The Raspberry Pi TV HAT +image::images/tv-hat.jpg[width="80%"] + +The Raspberry Pi TV HAT allows you to receive digital terrestrial TV broadcast systems, using an onboard DVB-T and DVB-T2 tuner, on a Raspberry Pi. With the board you can receive and view TV on a Raspberry Pi, or create a TV server that allows you to stream received TV over a network to other devices. The TV HAT can be used with any 40-pin Raspberry Pi board as a server for other devices on the network. Performance when receiving and viewing TV on the Pi itself can vary, and we recommend using a Raspberry Pi 2 or later for this purpose + +Key features: + +* Sony CXD2880 TV tuner +* Supported TV standards: DVB-T2, DVB-T +* Reception frequency: VHF III, UHF IV, UHF V +* Channel bandwidth: +** DVB-T2: 1.7MHz, 5MHz, 6MHz, 7MHz, 8MHz +** DVB-T: 5MHz, 6MHz, 7MHz, 8MHz + +== About DVB-T + +WARNING: The TV HAT does not support ATSC, the digital TV standard used in North America. + +Digital Video Broadcasting – Terrestrial (DVB-T) is the DVB European-based consortium standard for the broadcast transmission of digital terrestrial television. There are other digital TV standards used elsewhere in the world, e.g. ATSC which is used in North America. However the TV HAT only supports the DVB-T and DVB-T2 standards. + +.DTT system implemented or adopted (Source: DVB/EBU/BNE DTT Deployment Database, March 2023) +image::images/dvbt-map.png[width="80%"] + +[[tv-hat-installation]] +== Install + +Follow our xref:../computers/getting-started.adoc[getting started] documentation and set up the Raspberry Pi with the newest version of Raspberry Pi OS. + +Connect the aerial adaptor to the TV HAT and with the adaptor pointing away from the USB ports, press the HAT gently down over the Raspberry Pi's GPIO pins, and place the spacers at two or three of the corners of the HAT, and tighten the screws through the mounting holes to hold them in place. Then connect the TV HAT's aerial adaptor to the cable from your TV aerial. + +The software we recommend to decode the streams (known as multiplexes, or muxes for short) and view content is called TVHeadend. The TV HAT can decode one mux at a time, and each mux can contain several channels to choose from. Content can either be viewed on the Raspberry Pi to which the TV-HAT is connected, or sent to another device on the same network. + +Boot your Raspberry Pi and then go ahead open a terminal window, and run the following two commands to install the `tvheadend` software: + +[source,console] +---- +$ sudo apt update +$ sudo apt install tvheadend +---- + +During the `tvheadend` installation, you will be asked to choose an administrator account name and password. You'll need these later, so make sure to pick something you can remember. + +On another computer on your network, open up a web browser and type the following into the address bar: `http://raspberrypi.local:9981/extjs.html` + +This should connect to `tvheadend` running on the Raspberry Pi. Once you have connected to `tvheadend` via the browser, you will be prompted to sign in using the account name and password you chose when you installed `tvheadend` on the Raspberry Pi. + +A setup wizard should appear. + +You will be first ask to set the language you want `tvheadend` to use, and then to set up network, user, and administrator access. If you don't have specific preferences, leave *Allowed network* blank, and enter an asterisk (*) in the *username* and *password* fields. This will let anyone connected to your local network access `tvheadend`. + +You should see a window titled *Network settings*. Under *Network 2*, you should see `Tuner: Sony CDX2880 #0 : DVB-T #0`. For *Network type*, choose `DVB-T Network`. The next window is *Assign predefined muxes to networks*; here, you select the TV stream to receive and decode. Under Network 1, for predefined muxes, select your local TV transmitter. + +NOTE: Your local transmitter can be found using the https://www.freeview.co.uk/help[Freeview website]. Enter your postcode to see which transmitter should give you a good signal. + +When you click *Save & Next*, the software will start scanning for the selected mux, and will show a progress bar. After about two minutes, you should see something like: + +[source,console] +---- +Found muxes: 8 +Found services: 172 +---- + +In the next window, titled *Service mapping*, tick all three boxes: *Map all services*, *Create provider tags*, and *Create network tags*. You should see a list of TV channels you can watch, along with the programmes they're currently showing. + +To watch a TV channel in the browser, click the little TV icon to the left of the channel listing, just to the right of the *i* icon. This brings up an in-browser media player. Depending on the decoding facilities built into your browser and the type of stream being played, you may find that playback can be jerky. In these cases, we recommend using a local media player as the playback application. + +To watch a TV channel in a local media player, e.g. https://www.videolan.org/vlc[VLC], you'll need to download it as a stream. Click the `i` icon to the left of a channel listing to bring up the information panel for that channel. Here you can see a stream file that you can download. + +NOTE: `tvheadend` is supported by numerous apps, such as TvhClient for iOS, which will play TV from the Raspberry Pi. + +== Mechanical Drawing + +.The Raspberry Pi TV HAT +image::images/mechanical.png[] diff --git a/documentation/asciidoc/accessories/tv-hat/images/dvbt-map.png b/documentation/asciidoc/accessories/tv-hat/images/dvbt-map.png new file mode 100644 index 0000000000..f38d3f895b Binary files /dev/null and b/documentation/asciidoc/accessories/tv-hat/images/dvbt-map.png differ diff --git a/documentation/asciidoc/accessories/tv-hat/images/mechanical.png b/documentation/asciidoc/accessories/tv-hat/images/mechanical.png new file mode 100644 index 0000000000..1f4aac2063 Binary files /dev/null and b/documentation/asciidoc/accessories/tv-hat/images/mechanical.png differ diff --git a/documentation/asciidoc/accessories/tv-hat/images/tv-hat.jpg b/documentation/asciidoc/accessories/tv-hat/images/tv-hat.jpg new file mode 100644 index 0000000000..978db8980e Binary files /dev/null and b/documentation/asciidoc/accessories/tv-hat/images/tv-hat.jpg differ diff --git a/documentation/asciidoc/accessories/usb-3-hub.adoc b/documentation/asciidoc/accessories/usb-3-hub.adoc new file mode 100644 index 0000000000..44c1bec1ad --- /dev/null +++ b/documentation/asciidoc/accessories/usb-3-hub.adoc @@ -0,0 +1 @@ +include::usb-3-hub/about.adoc[] diff --git a/documentation/asciidoc/accessories/usb-3-hub/about.adoc b/documentation/asciidoc/accessories/usb-3-hub/about.adoc new file mode 100644 index 0000000000..c67d1f7708 --- /dev/null +++ b/documentation/asciidoc/accessories/usb-3-hub/about.adoc @@ -0,0 +1,17 @@ +== About + +The https://www.raspberrypi.com/products/usb-3-hub/[Raspberry Pi USB 3 Hub] provides extra connectivity for your devices, extending one USB-A port into four. An optional external USB-C power input supports high-power peripherals. You can use the USB 3 Hub to power low-power peripherals, such as most mice and keyboards, using no external power. + +.The Raspberry Pi USB 3.0 Hub +image::images/usb-3-hub-hero.png[width="80%"] + +== Specification + +* 1× upstream USB 3.0 Type-A male connector on 8cm captive cable +* 4× downstream USB 3.0 Type-A ports +* Data transfer speeds up to 5Gbps +* Power transfer up to 900 mA (4.5 W); optional external USB-C power input provides up to 5V @ 3A for high-power downstream peripherals +* Compatible with USB 3.0 and USB 2.0 Type-A host ports + +.Physical specification +image::images/usb-3-hub-physical-specification.png[] diff --git a/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-hero.png b/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-hero.png new file mode 100644 index 0000000000..7f3bc2b9a3 Binary files /dev/null and b/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-hero.png differ diff --git a/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-physical-specification.png b/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-physical-specification.png new file mode 100644 index 0000000000..7b469d14c2 Binary files /dev/null and b/documentation/asciidoc/accessories/usb-3-hub/images/usb-3-hub-physical-specification.png differ diff --git a/documentation/asciidoc/computers/ai.adoc b/documentation/asciidoc/computers/ai.adoc new file mode 100644 index 0000000000..af8f6182db --- /dev/null +++ b/documentation/asciidoc/computers/ai.adoc @@ -0,0 +1,2 @@ +include::ai/getting-started.adoc[] + diff --git a/documentation/asciidoc/computers/ai/getting-started.adoc b/documentation/asciidoc/computers/ai/getting-started.adoc new file mode 100644 index 0000000000..3a9b7263c0 --- /dev/null +++ b/documentation/asciidoc/computers/ai/getting-started.adoc @@ -0,0 +1,219 @@ +== Getting Started + +This guide will help you set up a Hailo NPU with your Raspberry Pi 5. This will enable you to run `rpicam-apps` camera demos using an AI neural network accelerator. + +=== Prerequisites + +For this guide, you will need the following: + +* a Raspberry Pi 5 +* one of the following NPUs: +** a xref:../accessories/ai-kit.adoc[Raspberry Pi AI Kit], which includes: +*** an M.2 HAT+ +*** a pre-installed Hailo-8L AI module +** a xref:../accessories/ai-hat-plus.adoc[Raspberry Pi AI HAT+] +* a 64-bit Raspberry Pi OS Bookworm install +* any official Raspberry Pi camera (e.g. Camera Module 3 or High Quality Camera) + +=== Hardware setup + +. Attach the camera to your Raspberry Pi 5 board following the instructions at xref:../accessories/camera.adoc#install-a-raspberry-pi-camera[Install a Raspberry Pi Camera]. You can skip reconnecting your Raspberry Pi to power, because you'll need to disconnect your Raspberry Pi from power for the next step. + +. Depending on your NPU, follow the installation instructions for the xref:../accessories/ai-kit.adoc#ai-kit-installation[AI Kit] or xref:../accessories/ai-hat-plus.adoc#ai-hat-plus-installation[AI HAT+], to get your hardware connected to your Raspberry Pi 5. + +. Follow the instructions to xref:raspberry-pi.adoc#pcie-gen-3-0[enable PCIe Gen 3.0]. This step is optional, but _highly recommended_ to achieve the best performance with your NPU. + +. Install the dependencies required to use the NPU. Run the following command from a terminal window: ++ +[source,console] +---- +$ sudo apt install hailo-all +---- ++ +This installs the following dependencies: ++ +* Hailo kernel device driver and firmware +* HailoRT middleware software +* Hailo Tappas core post-processing libraries +* The `rpicam-apps` Hailo post-processing software demo stages + +. Finally, reboot your Raspberry Pi with `sudo reboot` for these settings to take effect. + +. To ensure everything is running correctly, run the following command: ++ +[source,console] +---- +$ hailortcli fw-control identify +---- ++ +If you see output similar to the following, you've successfully installed the NPU and its software dependencies: ++ +---- +Executing on device: 0000:01:00.0 +Identifying board +Control Protocol Version: 2 +Firmware Version: 4.17.0 (release,app,extended context switch buffer) +Logger Version: 0 +Board Name: Hailo-8 +Device Architecture: HAILO8L +Serial Number: HLDDLBB234500054 +Part Number: HM21LB1C2LAE +Product Name: HAILO-8L AI ACC M.2 B+M KEY MODULE EXT TMP +---- ++ +NOTE: AI HAT+ devices may show `` for `Serial Number`, `Part Number` and `Product Name`. This is expected, and does not impact functionality. ++ +Additionally, you can run `dmesg | grep -i hailo` to check the kernel logs, which should yield output similar to the following: ++ +---- +[ 3.049657] hailo: Init module. driver version 4.17.0 +[ 3.051983] hailo 0000:01:00.0: Probing on: 1e60:2864... +[ 3.051989] hailo 0000:01:00.0: Probing: Allocate memory for device extension, 11600 +[ 3.052006] hailo 0000:01:00.0: enabling device (0000 -> 0002) +[ 3.052011] hailo 0000:01:00.0: Probing: Device enabled +[ 3.052028] hailo 0000:01:00.0: Probing: mapped bar 0 - 000000000d8baaf1 16384 +[ 3.052034] hailo 0000:01:00.0: Probing: mapped bar 2 - 000000009eeaa33c 4096 +[ 3.052039] hailo 0000:01:00.0: Probing: mapped bar 4 - 00000000b9b3d17d 16384 +[ 3.052044] hailo 0000:01:00.0: Probing: Force setting max_desc_page_size to 4096 (recommended value is 16384) +[ 3.052052] hailo 0000:01:00.0: Probing: Enabled 64 bit dma +[ 3.052055] hailo 0000:01:00.0: Probing: Using userspace allocated vdma buffers +[ 3.052059] hailo 0000:01:00.0: Disabling ASPM L0s +[ 3.052070] hailo 0000:01:00.0: Successfully disabled ASPM L0s +[ 3.221043] hailo 0000:01:00.0: Firmware was loaded successfully +[ 3.231845] hailo 0000:01:00.0: Probing: Added board 1e60-2864, /dev/hailo0 +---- + +. To ensure the camera is operating correctly, run the following command: ++ +[source,console] +---- +$ rpicam-hello -t 10s +---- ++ +This starts the camera and shows a preview window for ten seconds. Once you have verified everything is installed correctly, it's time to run some demos. + +=== Demos + +The `rpicam-apps` suite of camera applications implements a xref:camera_software.adoc#post-processing-with-rpicam-apps[post-processing framework]. This section contains a few demo post-processing stages that highlight some of the capabilities of the NPU. + +The following demos use xref:camera_software.adoc#rpicam-hello[`rpicam-hello`], which by default displays a preview window. However, you can use other `rpicam-apps` instead, including xref:camera_software.adoc#rpicam-vid[`rpicam-vid`] and xref:camera_software.adoc#rpicam-still[`rpicam-still`]. You may need to add or modify some command line options to make the demo commands compatible with alternative applications. + +To begin, run the following command to install the latest `rpicam-apps` software package: + +[source,console] +---- +$ sudo apt update && sudo apt install rpicam-apps +---- + +==== Object Detection + +This demo displays bounding boxes around objects detected by a neural network. To disable the viewfinder, use the xref:camera_software.adoc#nopreview[`-n`] flag. To return purely textual output describing the objects detected, add the `-v 2` option. Run the following command to try the demo on your Raspberry Pi: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov6_inference.json +---- + +Alternatively, you can try another model with different trade-offs in performance and efficiency. + +To run the demo with the Yolov8 model, run the following command: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov8_inference.json +---- + +To run the demo with the YoloX model, run the following command: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolox_inference.json +---- + +To run the demo with the Yolov5 Person and Face model, run the following command: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov5_personface.json +---- + +==== Image Segmentation + +This demo performs object detection and segments the object by drawing a colour mask on the viewfinder image. Run the following command to try the demo on your Raspberry Pi: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov5_segmentation.json --framerate 20 +---- + +==== Pose Estimation + +This demo performs 17-point human pose estimation, drawing lines connecting the detected points. Run the following command to try the demo on your Raspberry Pi: + +[source,console] +---- +$ rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov8_pose.json +---- + +=== Alternative Package Versions + +The AI Kit and AI HAT+ do not function if there is a version mismatch between the Hailo software packages and device drivers. In addition, Hailo's neural network tooling may require a particular version for generated model files. If you require a specific version, complete the following steps to install the proper versions of all of the dependencies: + +. If you have previously used `apt-mark` to hold any of the relevant packages, you may need to unhold them: ++ +[source,console] +---- +$ sudo apt-mark unhold hailo-tappas-core hailort hailo-dkms +---- + +. Install the required version of the software packages: + +[tabs] +====== +v4.19:: +To install version 4.19 of Hailo's neural network tooling, run the following commands: ++ +[source,console] +---- +sudo apt install hailo-tappas-core=3.30.0-1 hailort=4.19.0-3 hailo-dkms=4.19.0-1 python3-hailort=4.19.0-2 +---- ++ +[source,console] +---- +$ sudo apt-mark hold hailo-tappas-core hailort hailo-dkms python3-hailort +---- + +4.18:: +To install version 4.18 of Hailo's neural network tooling, run the following commands: ++ +[source,console] +---- +$ sudo apt install hailo-tappas-core=3.29.1 hailort=4.18.0 hailo-dkms=4.18.0-2 +---- ++ +[source,console] +---- +$ sudo apt-mark hold hailo-tappas-core hailort hailo-dkms +---- + +4.17:: +To install version 4.17 of Hailo's neural network tooling, run the following commands: ++ +[source,console] +---- +$ sudo apt install hailo-tappas-core=3.28.2 hailort=4.17.0 hailo-dkms=4.17.0-1 +---- ++ +[source,console] +---- +$ sudo apt-mark hold hailo-tappas-core hailort hailo-dkms +---- +====== + +=== Further Resources + +Hailo has also created a set of demos that you can run on a Raspberry Pi 5, available in the https://github.com/hailo-ai/hailo-rpi5-examples[hailo-ai/hailo-rpi5-examples GitHub repository]. + +You can find Hailo's extensive model zoo, which contains a large number of neural networks, in the https://github.com/hailo-ai/hailo_model_zoo/tree/master/docs/public_models/HAILO8L[hailo-ai/hailo_model_zoo GitHub repository]. + +Check out the https://community.hailo.ai/[Hailo community forums and developer zone] for further discussions on the Hailo hardware and tooling. diff --git a/documentation/asciidoc/computers/camera/camera_usage.adoc b/documentation/asciidoc/computers/camera/camera_usage.adoc new file mode 100644 index 0000000000..722f37c82b --- /dev/null +++ b/documentation/asciidoc/computers/camera/camera_usage.adoc @@ -0,0 +1,19 @@ +This documentation describes how to use supported camera modules with our software tools. All Raspberry Pi cameras can record high-resolution photographs and full HD 1080p video (or better) with our software tools. + +Raspberry Pi produces several official camera modules, including: + +* the original 5-megapixel Camera Module 1 (discontinued) +* the 8-megapixel https://www.raspberrypi.com/products/camera-module-v2/[Camera Module 2], with or without an infrared filter +* the 12-megapixel https://raspberrypi.com/products/camera-module-3/[Camera Module 3], with both standard and wide lenses, with or without an infrared filter +* the 12-megapixel https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/[High Quality Camera] with CS and M12 mount variants for use with external lenses +* the 1.6-megapixel https://www.raspberrypi.com/products/raspberry-pi-global-shutter-camera/[Global Shutter Camera] for fast motion photography +* the 12-megapixel https://www.raspberrypi.com/products/ai-camera/[AI Camera] uses the Sony IMX500 imaging sensor to provide low-latency, high-performance AI capabilities to any camera application + +For more information about camera hardware, see the xref:../accessories/camera.adoc#about-the-camera-modules[camera hardware documentation]. + +First, xref:../accessories/camera.adoc#install-a-raspberry-pi-camera[install your camera module]. Then, follow the guides in this section to put your camera module to use. + +[WARNING] +==== +This guide no longer covers the _legacy camera stack_ which was available in Bullseye and earlier Raspberry Pi OS releases. The legacy camera stack, using applications like `raspivid`, `raspistill` and the original `Picamera` (_not_ `Picamera2`) Python library, has been deprecated for many years, and is now unsupported. If you are using the legacy camera stack, it will only have support for the Camera Module 1, Camera Module 2 and the High Quality Camera, and will never support any newer camera modules. Nothing in this document is applicable to the legacy camera stack. +==== diff --git a/documentation/asciidoc/computers/camera/csi-2-usage.adoc b/documentation/asciidoc/computers/camera/csi-2-usage.adoc new file mode 100644 index 0000000000..f3515ae946 --- /dev/null +++ b/documentation/asciidoc/computers/camera/csi-2-usage.adoc @@ -0,0 +1,200 @@ +== Unicam + +Raspberry Pi SoCs all have two camera interfaces that support either CSI-2 D-PHY 1.1 or Compact Camera Port 2 (CCP2) sources. This interface is known by the codename Unicam. The first instance of Unicam supports two CSI-2 data lanes, while the second supports four. Each lane can run at up to 1Gbit/s (DDR, so the max link frequency is 500MHz). + +Compute Modules and Raspberry Pi 5 route out all lanes from both peripherals. Other models prior to Raspberry Pi 5 only expose the second instance, routing out only two of the data lanes to the camera connector. + +=== Software interfaces + +The V4L2 software interface is the only means of communicating with the Unicam peripheral. There used to also be firmware and MMAL rawcam component interfaces, but these are no longer supported. + +==== V4L2 + +NOTE: The V4L2 interface for Unicam is available only when using `libcamera`. + +There is a fully open-source kernel driver available for the Unicam block; this kernel module, called `bcm2835-unicam`, interfaces with V4L2 subdevice drivers to deliver raw frames. This `bcm2835-unicam` driver controls the sensor and configures the Camera Serial Interface 2 (CSI-2) receiver. Peripherals write raw frames (after Debayer) to SDRAM for V4L2 to deliver to applications. There is no image processing between the camera sensor capturing the image and the `bcm2835-unicam` driver placing the image data in SDRAM except for Bayer unpacking to 16bits/pixel. + +---- +|------------------------| +| bcm2835-unicam | +|------------------------| + ^ | + | |-------------| + img | | Subdevice | + | |-------------| + v -SW/HW- | +|---------| |-----------| +| Unicam | | I2C or SPI| +|---------| |-----------| +csi2/ ^ | +ccp2 | | + |-----------------| + | sensor | + |-----------------| +---- + +Mainline Linux contains a range of existing drivers. The Raspberry Pi kernel tree has some additional drivers and Device Tree overlays to configure them: + +|=== +| Device | Type | Notes + +| Omnivision OV5647 +| 5MP Camera +| Original Raspberry Pi Camera + +| Sony IMX219 +| 8MP Camera +| Revision 2 Raspberry Pi camera + +| Sony IMX477 +| 12MP Camera +| Raspberry Pi HQ camera + +| Sony IMX708 +| 12MP Camera +| Raspberry Pi Camera Module 3 + +| Sony IMX296 +| 1.6MP Camera +| Raspberry Pi Global Shutter Camera Module + +| Toshiba TC358743 +| HDMI to CSI-2 bridge +| + +| Analog Devices ADV728x-M +| Analog video to CSI-2 bridge +| No interlaced support + +| Infineon IRS1125 +| Time-of-flight depth sensor +| Supported by a third party +|=== + +As the subdevice driver is also a kernel driver with a standardised API, third parties are free to write their own for any source of their choosing. + +=== Write a third-party driver + +This is the recommended approach to interfacing via Unicam. + +When developing a driver for a new device intended to be used with the `bcm2835-unicam` module, you need the driver and corresponding device tree overlays. Ideally, the driver should be submitted to the http://vger.kernel.org/vger-lists.html#linux-media[linux-media] mailing list for code review and merging into mainline, then moved to the https://github.com/raspberrypi/linux[Raspberry Pi kernel tree]; but exceptions may be made for the driver to be reviewed and merged directly to the Raspberry Pi kernel. + +NOTE: All kernel drivers are licensed under the GPLv2 licence, therefore source code must be available. Shipping of binary modules only is a violation of the GPLv2 licence under which the Linux kernel is licensed. + +The `bcm2835-unicam` module has been written to try and accommodate all types of CSI-2 source driver that are currently found in the mainline Linux kernel. These can be split broadly into camera sensors and bridge chips. Bridge chips allow for conversion between some other format and CSI-2. + +==== Camera sensors + +The sensor driver for a camera sensor is responsible for all configuration of the device, usually via I2C or SPI. Rather than writing a driver from scratch, it is often easier to take an existing driver as a basis and modify it as appropriate. + +The https://github.com/raspberrypi/linux/blob/rpi-6.1.y/drivers/media/i2c/imx219.c[IMX219 driver] is a good starting point. This driver supports both 8bit and 10bit Bayer readout, so enumerating frame formats and frame sizes is slightly more involved. + +Sensors generally support https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html[V4L2 user controls]. Not all these controls need to be implemented in a driver. The IMX219 driver only implements a small subset, listed below, the implementation of which is handled by the `imx219_set_ctrl` function. + +* `V4L2_CID_PIXEL_RATE` / `V4L2_CID_VBLANK` / `V4L2_CID_HBLANK`: allows the application to set the frame rate +* `V4L2_CID_EXPOSURE`: sets the exposure time in lines; the application needs to use `V4L2_CID_PIXEL_RATE`, `V4L2_CID_HBLANK`, and the frame width to compute the line time +* `V4L2_CID_ANALOGUE_GAIN`: analogue gain in sensor specific units +* `V4L2_CID_DIGITAL_GAIN`: optional digital gain in sensor specific units +* `V4L2_CID_HFLIP / V4L2_CID_VFLIP`: flips the image either horizontally or vertically; this operation may change the Bayer order of the data in the frame, as is the case on the IMX219. +* `V4L2_CID_TEST_PATTERN` / `V4L2_CID_TEST_PATTERN_*`: enables output of various test patterns from the sensor; useful for debugging + +In the case of the IMX219, many of these controls map directly onto register writes to the sensor itself. + +Further guidance can be found in the `libcamera` https://git.linuxtv.org/libcamera.git/tree/Documentation/sensor_driver_requirements.rst[sensor driver requirements], and in chapter 3 of the https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf[Raspberry Pi Camera tuning guide]. + +===== Device Tree + +Device Tree is used to select the sensor driver and configure parameters such as number of CSI-2 lanes, continuous clock lane operation, and link frequency (often only one is supported). + +The IMX219 https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/imx219-overlay.dts[Device Tree overlay] for the 6.1 kernel is available on GitHub. + +==== Bridge chips + +These are devices that convert an incoming video stream, for example HDMI or composite, into a CSI-2 stream that can be accepted by the Raspberry Pi CSI-2 receiver. + +Handling bridge chips is more complicated. Unlike camera sensors, they have to respond to the incoming signal and report that to the application. + +The mechanisms for handling bridge chips can be split into two categories: either analogue or digital. + +When using `ioctls` in the sections below, an `_S_` in the `ioctl` name means it is a set function, while `_G_` is a get function and `_ENUM_` enumerates a set of permitted values. + +===== Analogue video sources + +Analogue video sources use the standard `ioctls` for detecting and setting video standards. https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-std.html[`VIDIOC_G_STD`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-std.html[`VIDIOC_S_STD`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enumstd.html[`VIDIOC_ENUMSTD`], and https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-querystd.html[`VIDIOC_QUERYSTD`] are available. + +Selecting the wrong standard will generally result in corrupt images. Setting the standard will typically also set the resolution on the V4L2 CAPTURE queue. It can not be set via `VIDIOC_S_FMT`. Generally, requesting the detected standard via `VIDIOC_QUERYSTD` and then setting it with `VIDIOC_S_STD` before streaming is a good idea. + +===== Digital video sources + +For digital video sources, such as HDMI, there is an alternate set of calls that allow specifying of all the digital timing parameters: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-dv-timings.html[`VIDIOC_G_DV_TIMINGS`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-dv-timings.html[`VIDIOC_S_DV_TIMINGS`], https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enum-dv-timings.html[`VIDIOC_ENUM_DV_TIMINGS`], and https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-query-dv-timings.html[`VIDIOC_QUERY_DV_TIMINGS`]. + +As with analogue bridges, the timings typically fix the V4L2 CAPTURE queue resolution, and calling `VIDIOC_S_DV_TIMINGS` with the result of `VIDIOC_QUERY_DV_TIMINGS` before streaming should ensure the format is correct. + +Depending on the bridge chip and the driver, it may be possible for changes in the input source to be reported to the application via `VIDIOC_SUBSCRIBE_EVENT` and `V4L2_EVENT_SOURCE_CHANGE`. + +===== Currently supported devices + +There are two bridge chips which are currently supported by the Raspberry Pi Linux kernel: the Analog Devices ADV728x-M for analogue video sources, and the Toshiba TC358743 for HDMI sources. + +Analog Devices ADV728x(A)-M analogue video to CSI2 bridge chips convert composite S-video (Y/C), or component (YPrPb) video into a single lane CSI-2 interface, and are supported by the https://github.com/raspberrypi/linux/blob/rpi-6.1.y/drivers/media/i2c/adv7180.c[ADV7180 kernel driver]. + +Product details for the various versions of this chip can be found on the Analog Devices website: https://www.analog.com/en/products/adv7280a.html[ADV7280A], https://www.analog.com/en/products/adv7281a.html[ADV7281A], and https://www.analog.com/en/products/adv7282a.html[ADV7282A]. + +Because of some missing code in the current core V4L2 implementation, selecting the source fails, so the Raspberry Pi kernel version adds a kernel module parameter called `dbg_input` to the ADV7180 kernel driver which sets the input source every time VIDIOC_S_STD is called. At some point mainstream will fix the underlying issue (a disjoin between the kernel API call s_routing, and the userspace call `VIDIOC_S_INPUT`) and this modification will be removed. + +Receiving interlaced video is not supported, therefore the ADV7281(A)-M version of the chip is of limited use as it doesn't have the necessary I2P deinterlacing block. Also ensure when selecting a device to specify the -M option. Without that you will get a parallel output bus which can not be interfaced to the Raspberry Pi. + +There are no known commercially available boards using these chips, but this driver has been tested via the Analog Devices https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/EVAL-ADV7282A-M.html[EVAL-ADV7282-M evaluation board]. + +This driver can be loaded using the `config.txt` dtoverlay `adv7282m` if you are using the `ADV7282-M` chip variant; or `adv728x-m` with a parameter of either `adv7280m=1`, `adv7281m=1`, or `adv7281ma=1` if you are using a different variant. + +---- +dtoverlay=adv728x-m,adv7280m=1 +---- + +The Toshiba TC358743 is an HDMI to CSI-2 bridge chip, capable of converting video data at up to 1080p60. + +Information on this bridge chip can be found on the https://toshiba.semicon-storage.com/ap-en/semiconductor/product/interface-bridge-ics-for-mobile-peripheral-devices/hdmir-interface-bridge-ics/detail.TC358743XBG.html[Toshiba website]. + +The TC358743 interfaces HDMI into CSI-2 and I2S outputs. It is supported by the https://github.com/raspberrypi/linux/blob/rpi-6.1.y/drivers/media/i2c/tc358743.c[TC358743 kernel module]. + +The chip supports incoming HDMI signals as either RGB888, YUV444, or YUV422, at up to 1080p60. It can forward RGB888, or convert it to YUV444 or YUV422, and convert either way between YUV444 and YUV422. Only RGB888 and YUV422 support has been tested. When using two CSI-2 lanes, the maximum rates that can be supported are 1080p30 as RGB888, or 1080p50 as YUV422. When using four lanes on a Compute Module, 1080p60 can be received in either format. + +HDMI negotiates the resolution by a receiving device advertising an https://en.wikipedia.org/wiki/Extended_Display_Identification_Data[EDID] of all the modes that it can support. The kernel driver has no knowledge of the resolutions, frame rates, or formats that you wish to receive, so it is up to the user to provide a suitable file via the VIDIOC_S_EDID ioctl, or more easily using `v4l2-ctl --fix-edid-checksums --set-edid=file=filename.txt` (adding the --fix-edid-checksums option means that you don't have to get the checksum values correct in the source file). Generating the required EDID file (a textual hexdump of a binary EDID file) is not too onerous, and there are tools available to generate them, but it is beyond the scope of this page. + +As described above, use the `DV_TIMINGS` ioctls to configure the driver to match the incoming video. The easiest approach for this is to use the command `v4l2-ctl --set-dv-bt-timings query`. The driver does support generating the `SOURCE_CHANGED` events, should you wish to write an application to handle a changing source. Changing the output pixel format is achieved by setting it via `VIDIOC_S_FMT`, but only the pixel format field will be updated as the resolution is configured by the DV timings. + +There are a couple of commercially available boards that connect this chip to the Raspberry Pi. The Auvidea B101 and B102 are the most widely obtainable, but other equivalent boards are available. + +This driver is loaded using the `config.txt` dtoverlay `tc358743`. + +The chip also supports capturing stereo HDMI audio via I2S. The Auvidea boards break the relevant signals out onto a header, which can be connected to the Raspberry Pi's 40-pin header. The required wiring is: + +[cols=",^,^,^"] +|=== +| Signal | B101 header | 40-pin header | BCM GPIO + +| LRCK/WFS +| 7 +| 35 +| 19 + +| BCK/SCK +| 6 +| 12 +| 18 + +| DATA/SD +| 5 +| 38 +| 20 + +| GND +| 8 +| 39 +| N/A +|=== + +The `tc358743-audio` overlay is required _in addition to_ the `tc358743` overlay. This should create an ALSA recording device for the HDMI audio. + +There is no resampling of the audio. The presence of audio is reflected in the V4L2 control `TC358743_CID_AUDIO_PRESENT` (audio-present), and the sample rate of the incoming audio is reflected in the V4L2 control `TC358743_CID_AUDIO_SAMPLING_RATE` (audio sampling-frequency). Recording when no audio is present or at a sample rate different from that reported emits a warning. diff --git a/documentation/asciidoc/computers/camera/images/annotate.jpg b/documentation/asciidoc/computers/camera/images/annotate.jpg new file mode 100644 index 0000000000..6a0e201515 Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/annotate.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/classify.jpg b/documentation/asciidoc/computers/camera/images/classify.jpg new file mode 100644 index 0000000000..ae9651da0a Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/classify.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/detection.jpg b/documentation/asciidoc/computers/camera/images/detection.jpg new file mode 100644 index 0000000000..7c650802dc Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/detection.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/drc.jpg b/documentation/asciidoc/computers/camera/images/drc.jpg new file mode 100644 index 0000000000..cd65315f50 Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/drc.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/face_detect.jpg b/documentation/asciidoc/computers/camera/images/face_detect.jpg new file mode 100644 index 0000000000..9507813c1e Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/face_detect.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/focus.jpg b/documentation/asciidoc/computers/camera/images/focus.jpg new file mode 100644 index 0000000000..e00586047e Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/focus.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/hdr.jpg b/documentation/asciidoc/computers/camera/images/hdr.jpg new file mode 100644 index 0000000000..c9ab3c918a Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/hdr.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/negate.jpg b/documentation/asciidoc/computers/camera/images/negate.jpg new file mode 100644 index 0000000000..9820aaab5d Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/negate.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/nodrc.jpg b/documentation/asciidoc/computers/camera/images/nodrc.jpg new file mode 100644 index 0000000000..f0c4a5843a Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/nodrc.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/nohdr.jpg b/documentation/asciidoc/computers/camera/images/nohdr.jpg new file mode 100644 index 0000000000..6c2587fda9 Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/nohdr.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/pose.jpg b/documentation/asciidoc/computers/camera/images/pose.jpg new file mode 100644 index 0000000000..2b0ee4974b Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/pose.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/preview_window.jpg b/documentation/asciidoc/computers/camera/images/preview_window.jpg new file mode 100644 index 0000000000..331358d385 Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/preview_window.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/segmentation.jpg b/documentation/asciidoc/computers/camera/images/segmentation.jpg new file mode 100644 index 0000000000..6790ef08cd Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/segmentation.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/sobel.jpg b/documentation/asciidoc/computers/camera/images/sobel.jpg new file mode 100644 index 0000000000..708f4413fe Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/sobel.jpg differ diff --git a/documentation/asciidoc/computers/camera/images/sobel_negate.jpg b/documentation/asciidoc/computers/camera/images/sobel_negate.jpg new file mode 100644 index 0000000000..4ee31424f4 Binary files /dev/null and b/documentation/asciidoc/computers/camera/images/sobel_negate.jpg differ diff --git a/documentation/asciidoc/computers/os/images/image2.jpg b/documentation/asciidoc/computers/camera/images/webcam-image-high-resolution.jpg similarity index 100% rename from documentation/asciidoc/computers/os/images/image2.jpg rename to documentation/asciidoc/computers/camera/images/webcam-image-high-resolution.jpg diff --git a/documentation/asciidoc/computers/os/images/image3.jpg b/documentation/asciidoc/computers/camera/images/webcam-image-no-banner.jpg similarity index 100% rename from documentation/asciidoc/computers/os/images/image3.jpg rename to documentation/asciidoc/computers/camera/images/webcam-image-no-banner.jpg diff --git a/documentation/asciidoc/computers/os/images/image.jpg b/documentation/asciidoc/computers/camera/images/webcam-image.jpg similarity index 100% rename from documentation/asciidoc/computers/os/images/image.jpg rename to documentation/asciidoc/computers/camera/images/webcam-image.jpg diff --git a/documentation/asciidoc/computers/camera/libcamera_differences.adoc b/documentation/asciidoc/computers/camera/libcamera_differences.adoc new file mode 100644 index 0000000000..1205db97eb --- /dev/null +++ b/documentation/asciidoc/computers/camera/libcamera_differences.adoc @@ -0,0 +1,42 @@ +=== Differences between `rpicam` and `raspicam` + +The `rpicam-apps` emulate most features of the legacy `raspicam` applications. However, users may notice the following differences: + +* Boost `program_options` don't allow multi-character short versions of options, so where these were present they have had to be dropped. The long form options are named the same way, and any single-character short forms are preserved. + +* `rpicam-still` and `rpicam-jpeg` do not show the captured image in the preview window. + +* `rpicam-apps` removed the following `raspicam` features: ++ +** opacity (`--opacity`) +** image effects (`--imxfx`) +** colour effects (`--colfx`) +** annotation (`--annotate`, `--annotateex`) +** dynamic range compression, or DRC (`--drc`) +** stereo (`--stereo`, `--decimate` and `--3dswap`) +** image stabilisation (`--vstab`) +** demo modes (`--demo`) ++ +xref:camera_software.adoc#post-processing-with-rpicam-apps[Post-processing] replaced many of these features. + +* `rpicam-apps` removed xref:camera_software.adoc#rotation[`rotation`] option support for 90° and 270° rotations. + +* `raspicam` conflated metering and exposure; `rpicam-apps` separates these options. +* To disable Auto White Balance (AWB) in `rpicam-apps`, set a pair of colour gains with xref:camera_software.adoc#awbgains[`awbgains`] (e.g. `1.0,1.0`). + +* `rpicam-apps` cannot set Auto White Balance (AWB) into greyworld mode for NoIR camera modules. Instead, pass the xref:camera_software.adoc#tuning-file[`tuning-file`] option a NoIR-specific tuning file like `imx219_noir.json`. + +* `rpicam-apps` does not provide explicit control of digital gain. Instead, the xref:camera_software.adoc#gain[`gain`] option sets it implicitly. + +* `rpicam-apps` removed the `--ISO` option. Instead, calculate the gain corresponding to the ISO value required. Vendors can provide mappings of gain to ISO. + +* `rpicam-apps` does not support setting a flicker period. + +* `rpicam-still` does not support burst capture. Instead, consider using `rpicam-vid` in MJPEG mode with `--segment 1` to force each frame into a separate file. + +* `rpicam-apps` uses open source drivers for all image sensors, so the mechanism for enabling or disabling on-sensor Defective Pixel Correction (DPC) is different. The imx477 driver on the Raspberry Pi HQ Camera enables on-sensor DPC by default. To disable on-sensor DPC on the HQ Camera, run the following command: ++ +[source,console] +---- +$ sudo echo 0 > /sys/module/imx477/parameters/dpc_enable +---- diff --git a/documentation/asciidoc/computers/camera/libcamera_python.adoc b/documentation/asciidoc/computers/camera/libcamera_python.adoc new file mode 100644 index 0000000000..d14a170684 --- /dev/null +++ b/documentation/asciidoc/computers/camera/libcamera_python.adoc @@ -0,0 +1,26 @@ +[[picamera2]] +=== Use `libcamera` from Python with Picamera2 + +The https://github.com/raspberrypi/picamera2[Picamera2 library] is a `rpicam`-based replacement for Picamera, which was a Python interface to Raspberry Pi's legacy camera stack. Picamera2 presents an easy-to-use Python API. + +Documentation about Picamera2 is available https://github.com/raspberrypi/picamera2[on GitHub] and in the https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf[Picamera2 manual]. + +==== Installation + +Recent Raspberry Pi OS images include Picamera2 with all the GUI (Qt and OpenGL) dependencies. Recent Raspberry Pi OS Lite images include Picamera2 without the GUI dependencies, although preview images can still be displayed using DRM/KMS. + +If your image did not include Picamera2, run the following command to install Picamera2 with all of the GUI dependencies: + +[source,console] +---- +$ sudo apt install -y python3-picamera2 +---- + +If you don't want the GUI dependencies, you can run the following command to install Picamera2 without the GUI dependencies: + +[source,console] +---- +$ sudo apt install -y python3-picamera2 --no-install-recommends +---- + +NOTE: If you previously installed Picamera2 with `pip`, uninstall it with: `pip3 uninstall picamera2`. diff --git a/documentation/asciidoc/computers/camera/qt.adoc b/documentation/asciidoc/computers/camera/qt.adoc new file mode 100644 index 0000000000..66aa9bb9e0 --- /dev/null +++ b/documentation/asciidoc/computers/camera/qt.adoc @@ -0,0 +1,22 @@ +=== Use `libcamera` with Qt + +Qt is a popular application framework and GUI toolkit. `rpicam-apps` includes an option to use Qt for a camera preview window. + +Unfortunately, Qt defines certain symbols (such as `slot` and `emit`) as macros in the global namespace. This causes errors when including `libcamera` files. The problem is common to all platforms that use both Qt and `libcamera`. Try the following workarounds to avoid these errors: + +* List `libcamera` include files, or files that include `libcamera` files (such as `rpicam-apps` files), _before_ any Qt header files whenever possible. + +* If you do need to mix your Qt application files with `libcamera` includes, replace `signals:` with `Q_SIGNALS:`, `slots:` with `Q_SLOTS:`, `emit` with `Q_EMIT` and `foreach` with `Q_FOREACH`. + +* Add the following at the top of any `libcamera` include files: ++ +[source,cpp] +---- +#undef signals +#undef slots +#undef emit +#undef foreach +---- + +* If your project uses `qmake`, add `CONFIG += no_keywords` to the project file. +* If your project uses `cmake`, add `SET(QT_NO_KEYWORDS ON)`. diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_building.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_building.adoc new file mode 100644 index 0000000000..306e9cfb84 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_building.adoc @@ -0,0 +1,293 @@ +== Advanced `rpicam-apps` + +=== Build `libcamera` and `rpicam-apps` + +Build `libcamera` and `rpicam-apps` for yourself for the following benefits: + +* You can pick up the latest enhancements and features. + +* `rpicam-apps` can be compiled with extra optimisation for Raspberry Pi 3 and Raspberry Pi 4 devices running a 32-bit OS. + +* You can include optional OpenCV and/or TFLite post-processing stages, or add your own. + +* You can customise or add your own applications derived from `rpicam-apps` + +==== Remove pre-installed `rpicam-apps` + +Raspberry Pi OS includes a pre-installed copy of `rpicam-apps`. Before building and installing your own version of `rpicam-apps`, you must first remove the pre-installed version. Run the following command to remove the `rpicam-apps` package from your Raspberry Pi: + +[source,console] +---- +$ sudo apt remove --purge rpicam-apps +---- + +==== Building `rpicam-apps` without building `libcamera` + +To build `rpicam-apps` without first rebuilding `libcamera` and `libepoxy`, install `libcamera`, `libepoxy` and their dependencies with `apt`: + +[source,console] +---- +$ sudo apt install -y libcamera-dev libepoxy-dev libjpeg-dev libtiff5-dev libpng-dev +---- + +TIP: If you do not need support for the GLES/EGL preview window, omit `libepoxy-dev`. + +To use the Qt preview window, install the following additional dependencies: + +[source,console] +---- +$ sudo apt install -y qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 +---- + +For xref:camera_software.adoc#libav-integration-with-rpicam-vid[`libav`] support in `rpicam-vid`, install the following additional dependencies: + +[source,console] +---- +$ sudo apt install libavcodec-dev libavdevice-dev libavformat-dev libswresample-dev +---- + +If you run Raspberry Pi OS Lite, install `git`: + +[source,console] +---- +$ sudo apt install -y git +---- + +Next, xref:camera_software.adoc#building-rpicam-apps[build `rpicam-apps`]. + +==== Building `libcamera` + +NOTE: Only build `libcamera` from scratch if you need custom behaviour or the latest features that have not yet reached `apt` repositories. + +[NOTE] +====== +If you run Raspberry Pi OS Lite, begin by installing the following packages: + +[source,console] +---- +$ sudo apt install -y python3-pip git python3-jinja2 +---- +====== + +First, install the following `libcamera` dependencies: + +[source,console] +---- +$ sudo apt install -y libboost-dev +$ sudo apt install -y libgnutls28-dev openssl libtiff5-dev pybind11-dev +$ sudo apt install -y qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 +$ sudo apt install -y meson cmake +$ sudo apt install -y python3-yaml python3-ply +$ sudo apt install -y libglib2.0-dev libgstreamer-plugins-base1.0-dev +---- + +Now we're ready to build `libcamera` itself. + +Download a local copy of Raspberry Pi's fork of `libcamera` from GitHub: + +[source,console] +---- +$ git clone https://github.com/raspberrypi/libcamera.git +---- + +Navigate into the root directory of the repository: + +[source,console] +---- +$ cd libcamera +---- + +Next, run `meson` to configure the build environment: + +[source,console] +---- +$ meson setup build --buildtype=release -Dpipelines=rpi/vc4,rpi/pisp -Dipas=rpi/vc4,rpi/pisp -Dv4l2=true -Dgstreamer=enabled -Dtest=false -Dlc-compliance=disabled -Dcam=disabled -Dqcam=disabled -Ddocumentation=disabled -Dpycamera=enabled +---- + +NOTE: You can disable the `gstreamer` plugin by replacing `-Dgstreamer=enabled` with `-Dgstreamer=disabled` during the `meson` build configuration. If you disable `gstreamer`, there is no need to install the `libglib2.0-dev` and `libgstreamer-plugins-base1.0-dev` dependencies. + +Now, you can build `libcamera` with `ninja`: + +[source,console] +---- +$ ninja -C build +---- + +Finally, run the following command to install your freshly-built `libcamera` binary: + +[source,console] +---- +$ sudo ninja -C build install +---- + +TIP: On devices with 1GB of memory or less, the build may exceed available memory. Append the `-j 1` flag to `ninja` commands to limit the build to a single process. This should prevent the build from exceeding available memory on devices like the Raspberry Pi Zero and the Raspberry Pi 3. + +`libcamera` does not yet have a stable binary interface. Always build `rpicam-apps` after you build `libcamera`. + +==== Building `rpicam-apps` + +First fetch the necessary dependencies for `rpicam-apps`. + +[source,console] +---- +$ sudo apt install -y cmake libboost-program-options-dev libdrm-dev libexif-dev +$ sudo apt install -y meson ninja-build +---- + +Download a local copy of Raspberry Pi's `rpicam-apps` GitHub repository: + +[source,console] +---- +$ git clone https://github.com/raspberrypi/rpicam-apps.git +---- + +Navigate into the root directory of the repository: + +[source,console] +---- +$ cd rpicam-apps +---- + +For desktop-based operating systems like Raspberry Pi OS, configure the `rpicam-apps` build with the following `meson` command: + +[source,console] +---- +$ meson setup build -Denable_libav=enabled -Denable_drm=enabled -Denable_egl=enabled -Denable_qt=enabled -Denable_opencv=disabled -Denable_tflite=disabled -Denable_hailo=disabled +---- + +For headless operating systems like Raspberry Pi OS Lite, configure the `rpicam-apps` build with the following `meson` command: + +[source,console] +---- +$ meson setup build -Denable_libav=disabled -Denable_drm=enabled -Denable_egl=disabled -Denable_qt=disabled -Denable_opencv=disabled -Denable_tflite=disabled -Denable_hailo=disabled +---- + +[TIP] +====== + +* Use `-Dneon_flags=armv8-neon` to enable optimisations for 32-bit OSes on Raspberry Pi 3 or Raspberry Pi 4. +* Use `-Denable_opencv=enabled` if you have installed OpenCV and wish to use OpenCV-based post-processing stages. +* Use `-Denable_tflite=enabled` if you have installed TensorFlow Lite and wish to use it in post-processing stages. +* Use `-Denable_hailo=enabled` if you have installed HailoRT and wish to use it in post-processing stages. + +====== + +You can now build `rpicam-apps` with the following command: + +[source,console] +---- +$ meson compile -C build +---- + +TIP: On devices with 1GB of memory or less, the build may exceed available memory. Append the `-j 1` flag to `meson` commands to limit the build to a single process. This should prevent the build from exceeding available memory on devices like the Raspberry Pi Zero and the Raspberry Pi 3. + +Finally, run the following command to install your freshly-built `rpicam-apps` binary: + +[source,console] +---- +$ sudo meson install -C build +---- + +[TIP] +==== +The command above should automatically update the `ldconfig` cache. If you have trouble accessing your new `rpicam-apps` build, run the following command to update the cache: + +[source,console] +---- +$ sudo ldconfig +---- +==== + +Run the following command to check that your device uses the new binary: + +[source,console] +---- +$ rpicam-still --version +---- + +The output should include the date and time of your local `rpicam-apps` build. + +Finally, follow the `dtoverlay` and display driver instructions in the xref:camera_software.adoc#configuration[Configuration section]. + +==== `rpicam-apps` meson flag reference + +The `meson` build configuration for `rpicam-apps` supports the following flags: + +`-Dneon_flags=armv8-neon`:: Speeds up certain post-processing features on Raspberry Pi 3 or Raspberry Pi 4 devices running a 32-bit OS. + +`-Denable_libav=enabled`:: Enables or disables `libav` encoder integration. + +`-Denable_drm=enabled`:: Enables or disables **DRM/KMS preview rendering**, a preview window used in the absence of a desktop environment. + +`-Denable_egl=enabled`:: Enables or disables the non-Qt desktop environment-based preview. Disable if your system lacks a desktop environment. + +`-Denable_qt=enabled`:: Enables or disables support for the Qt-based implementation of the preview window. Disable if you do not have a desktop environment installed or if you have no intention of using the Qt-based preview window. The Qt-based preview is normally not recommended because it is computationally very expensive, however it does work with X display forwarding. + +`-Denable_opencv=enabled`:: Forces OpenCV-based post-processing stages to link or not link. Requires OpenCV to enable. Defaults to `disabled`. + +`-Denable_tflite=enabled`:: Enables or disables TensorFlow Lite post-processing stages. Disabled by default. Requires Tensorflow Lite to enable. Depending on how you have built and/or installed TFLite, you may need to tweak the `meson.build` file in the `post_processing_stages` directory. + +`-Denable_hailo=enabled`:: Enables or disables HailoRT-based post-processing stages. Requires HailoRT to enable. Defaults to `auto`. + +`-Ddownload_hailo_models=true`:: Downloads and installs models for HailoRT post-processing stages. Requires `wget` to be installed. Defaults to `true`. + + +Each of the above options (except for `neon_flags`) supports the following values: + +* `enabled`: enables the option, fails the build if dependencies are not available +* `disabled`: disables the option +* `auto`: enables the option if dependencies are available + +==== Building `libepoxy` + +Rebuilding `libepoxy` should not normally be necessary as this library changes only very rarely. If you do want to build it from scratch, however, please follow the instructions below. + +Start by installing the necessary dependencies. + +[source,console] +---- +$ sudo apt install -y libegl1-mesa-dev +---- + +Next, download a local copy of the `libepoxy` repository from GitHub: + +[source,console] +---- +$ git clone https://github.com/anholt/libepoxy.git +---- + +Navigate into the root directory of the repository: + +[source,console] +---- +$ cd libepoxy +---- + +Create a build directory at the root level of the repository, then navigate into that directory: + +[source,console] +---- +$ mkdir _build +$ cd _build +---- + +Next, run `meson` to configure the build environment: + +[source,console] +---- +$ meson +---- + +Now, you can build `libexpoxy` with `ninja`: + +[source,console] +---- +$ ninja +---- + +Finally, run the following command to install your freshly-built `libepoxy` binary: + +[source,console] +---- +$ sudo ninja install +---- diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_getting_help.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_getting_help.adoc new file mode 100644 index 0000000000..8cf2367bc0 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_getting_help.adoc @@ -0,0 +1,17 @@ +== Getting help + +For further help with `libcamera` and the `rpicam-apps`, check the https://forums.raspberrypi.com/viewforum.php?f=43[Raspberry Pi Camera forum]. Before posting: + +* Make a note of your operating system version (`uname -a`). + +* Make a note of your `libcamera` and `rpicam-apps` versions (`rpicam-hello --version`). + +* Report the make and model of the camera module you are using. + +* Report the software you are trying to use. We don't support third-party camera module vendor software. + +* Report your Raspberry Pi model, including memory size. + +* Include any relevant excerpts from the application's console output. + +If there are specific problems in the camera software (such as crashes), consider https://github.com/raspberrypi/rpicam-apps[creating an issue in the `rpicam-apps` GitHub repository], including the same details listed above. diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_intro.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_intro.adoc new file mode 100644 index 0000000000..4accca0a8d --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_intro.adoc @@ -0,0 +1,47 @@ +== `rpicam-apps` + +[NOTE] +==== +Raspberry Pi OS _Bookworm_ renamed the camera capture applications from ``libcamera-\*`` to ``rpicam-*``. Symbolic links allow users to use the old names for now. **Adopt the new application names as soon as possible.** Raspberry Pi OS versions prior to _Bookworm_ still use the ``libcamera-*`` name. +==== + +Raspberry Pi supplies a small set of example `rpicam-apps`. These CLI applications, built on top of `libcamera`, capture images and video from a camera. These applications include: + +* `rpicam-hello`: A "hello world"-equivalent for cameras, which starts a camera preview stream and displays it on the screen. +* `rpicam-jpeg`: Runs a preview window, then captures high-resolution still images. +* `rpicam-still`: Emulates many of the features of the original `raspistill` application. +* `rpicam-vid`: Captures video. +* `rpicam-raw`: Captures raw (unprocessed Bayer) frames directly from the sensor. +* `rpicam-detect`: Not built by default, but users can build it if they have TensorFlow Lite installed on their Raspberry Pi. Captures JPEG images when certain objects are detected. + +Recent versions of Raspberry Pi OS include the five basic `rpicam-apps`, so you can record images and videos using a camera even on a fresh Raspberry Pi OS installation. + +Users can create their own `rpicam`-based applications with custom functionality to suit their own requirements. The https://github.com/raspberrypi/rpicam-apps[`rpicam-apps` source code] is freely available under a BSD-2-Clause licence. + +=== `libcamera` + +`libcamera` is an open-source software library aimed at supporting camera systems directly from the Linux operating system on Arm processors. Proprietary code running on the Broadcom GPU is minimised. For more information about `libcamera` see the https://libcamera.org[`libcamera` website]. + +`libcamera` provides a {cpp} API that configures the camera, then allows applications to request image frames. These image buffers reside in system memory and can be passed directly to still image encoders (such as JPEG) or to video encoders (such as H.264). `libcamera` doesn't encode or display images itself: that that functionality, use `rpicam-apps`. + +You can find the source code in the https://git.linuxtv.org/libcamera.git/[official libcamera repository]. The Raspberry Pi OS distribution uses a https://github.com/raspberrypi/libcamera.git[fork] to control updates. + +Underneath the `libcamera` core, we provide a custom pipeline handler. `libcamera` uses this layer to drive the sensor and image signal processor (ISP) on the Raspberry Pi. `libcamera` contains a collection of image-processing algorithms (IPAs) including auto exposure/gain control (AEC/AGC), auto white balance (AWB), and auto lens-shading correction (ALSC). + +Raspberry Pi's implementation of `libcamera` supports the following cameras: + +* Official cameras: +** OV5647 (V1) +** IMX219 (V2) +** IMX708 (V3) +** IMX477 (HQ) +** IMX500 (AI) +** IMX296 (GS) +* Third-party sensors: +** IMX290 +** IMX327 +** IMX378 +** IMX519 +** OV9281 + +To extend support to a new sensor, https://git.linuxtv.org/libcamera.git/[contribute to `libcamera`]. diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_multicam.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_multicam.adoc new file mode 100644 index 0000000000..fb387443ae --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_multicam.adoc @@ -0,0 +1,68 @@ +=== Use multiple cameras + +`rpicam-apps` has basic support for multiple cameras. You can attach multiple cameras to a Raspberry Pi in the following ways: + +* For Raspberry Pi Compute Modules, you can connect two cameras directly to a Raspberry Pi Compute Module I/O board. See the xref:../computers/compute-module.adoc#attach-a-camera-module[Compute Module documentation] for further details. With this method, you can _use both cameras simultaneously_. +* For Raspberry Pi 5, you can connect two cameras directly to the board using the dual MIPI connectors. +* For other Raspberry Pi devices with a camera port, you can attach two or more cameras with a Video Mux board such as https://www.arducam.com/product/multi-camera-v2-1-adapter-raspberry-pi/[this third-party product]. Since both cameras are attached to a single Unicam port, _only one camera may be used at a time_. + +To list all the cameras available on your platform, use the xref:camera_software.adoc#list-cameras[`list-cameras`] option. To choose which camera to use, pass the camera index to the xref:camera_software.adoc#camera[`camera`] option. + +NOTE: `libcamera` does not yet provide stereoscopic camera support. When running two cameras simultaneously, they must be run in separate processes, meaning there is no way to synchronise 3A operation between them. As a workaround, you could synchronise the cameras through an external sync signal for the HQ (IMX477) camera or use the software camera synchronisation support that is described below, switching the 3A to manual mode if necessary. + +==== Software Camera Synchronisation + +Raspberry Pi's _libcamera_ implementation has the ability to synchronise the frames of different cameras using only software. This will cause one camera to adjust it's frame timing so as to coincide as closely as possible with the frames of another camera. No soldering or hardware connections are required, and it will work with all of Raspberry Pi's camera modules, and even third party ones so long as their drivers implement frame duration control correctly. + +**How it works** + +The scheme works by designating one camera to be the _server_. The server will broadcast timing messages onto the network at regular intervals, such as once a second. Meanwhile other cameras, known as _clients_, can listen to these messages whereupon they may lengthen or shorten frame times slightly so as to pull them into sync with the server. This process is continual, though after the first adjustment, subsequent adjustments are normally small. + +The client cameras may be attached to the same Raspberry Pi device as the server, or they may be attached to different Raspberry Pis on the same network. The camera model on the clients may match the server, or they may be different. + +Clients and servers need to be set running at the same nominal framerate (such as 30fps). Note that there is no back-channel from the clients back to the server. It is solely the clients' responsibility to be up and running in time to match the server, and the server is completely unaware whether clients have synchronised successfully, or indeed whether there are any clients at all. + +In normal operation, running the same make of camera on the same Raspberry Pi, we would expect the frame start times of the camera images to match within "several tens of microseconds". When the camera models are different this could be significantly larger as the cameras will probably not be able to match framerates exactly and will therefore be continually drifting apart (and brought back together with every timing message). + +When cameras are on different devices, the system clocks should be synchronised using NTP (normally the case by default for Raspberry Pi OS), or if this is insufficiently precise, another protocol like PTP might be used. Any discrepancy between system clocks will feed directly into extra error in frame start times - even though the advertised timestamps on the frames will not tell you. + +**The Server** + +The server, as previously explained, broadcasts timing messages onto the network, by default every second. The server will run for a fixed number of frames, by default 100, after which it will inform the camera application on the device that the "synchronisation point" has been reached. At this moment, the application will start using the frames, so in the case of `rpicam-vid`, they will start being encoded and recorded. Recall that the behaviour and even existence of clients has no bearing on this. + +If required, there can be several servers on the same network so long as they are broadcasting timing messages to different network addresses. Clients, of course, will have to be configured to listen for the correct address. + +**Clients** + +Clients listen out for server timing messages and, when they receive one, will shorten or lengthen a camera frame duration by the required amount so that subsequent frames will start, as far as possible, at the same moment as the server's. + +The clients learn the correct "synchronisation point" from the server's messages, and just like the server, will signal the camera application at the same moment that it should start using the frames. So in the case of `rpicam-vid`, this is once again the moment at which frames will start being recorded. + +Normally it makes sense to start clients _before_ the server, as the clients will simply wait (the "synchronisation point" has not been reached) until a server is seen broadcasting onto the network. This obviously avoids timing problems where a server might reach its "synchronisation point" even before all the clients have been started! + +**Usage in `rpicam-vid`** + +We can use software camera synchronisation with `rpicam-vid` to record videos that are synchronised frame-by-frame. We're going to assume we have two cameras attached, and we're going to use camera 0 as the server, and camera 1 as the client. `rpicam-vid` defaults to a fixed 30 frames per second, which will be fine for us. + +First we should start the client: +[source,console] +---- +$ rpicam-vid -n -t 20s --camera 1 --codec libav -o client.mp4 --sync client +---- + +Note the `--sync client` parameter. This will record for 20 seconds but _only_ once the synchronisation point has been reached. If necessary, it will wait indefinitely for the first server message. + +To start the server: +[source,console] +---- +$ rpicam-vid -n -t 20s --camera 0 --codec libav -o server.mp4 --sync server +---- + +This too will run for 20 seconds counting from when the synchronisation point is reached and the recording starts. With the default synchronisation settings (100 frames at 30fps) this means there will be just over 3 seconds for clients to get synchronised. + +The server's broadcast address and port, the frequency of the timing messages and the number of frames to wait for clients to synchronise, can all be changed in the camera tuning file. Clients only pay attention to the broadcast address here which should match the server's; the other information will be ignored. Please refer to the https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf[Raspberry Pi Camera tuning guide] for more information. + +In practical operation there are a few final points to be aware of: + +* The fixed framerate needs to be below the maximum framerate at which the camera can operate (in the camera mode that is being used). This is because the synchronisation algorithm may need to _shorten_ camera frames so that clients can catch up with the server, and this will fail if it is already running as fast as it can. +* Whilst camera frames should be correctly synchronised, at higher framerates or depending on system load, it is possible for frames, either on the clients or server, to be dropped. In these cases the frame timestamps will help an application to work out what has happened, though it's usually simpler to try and avoid frame drops - perhaps by lowering the framerate, increasing the number of buffers being allocated to the camera queues (see the xref:camera_software.adoc#buffer-count[`--buffer-count` option]), or reducing system load. \ No newline at end of file diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_packages.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_packages.adoc new file mode 100644 index 0000000000..031fcc44e1 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_packages.adoc @@ -0,0 +1,15 @@ +=== Install `libcamera` and `rpicam-apps` + +Raspberry Pi provides two `rpicam-apps` packages: + +* `rpicam-apps` contains full applications with support for previews using a desktop environment. This package is pre-installed in Raspberry Pi OS. + +* `rpicam-apps-lite` omits desktop environment support, and only makes the DRM preview available. This package is pre-installed in Raspberry Pi OS Lite. + +==== Dependencies + +`rpicam-apps` depends on library packages named `library-name`, where `` is the ABI version. Your package manager should install these automatically. + +==== Dev packages + +You can rebuild `rpicam-apps` without building `libcamera` and `libepoxy` from scratch. For more information, see xref:camera_software.adoc#building-rpicam-apps-without-building-libcamera[Building `rpicam-apps` without rebuilding `libcamera`]. diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_post_processing.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing.adoc new file mode 100644 index 0000000000..339828d50f --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing.adoc @@ -0,0 +1,243 @@ +== Post-processing with `rpicam-apps` + +`rpicam-apps` share a common post-processing framework. This allows them to pass the images received from the camera system through a number of custom image-processing and image-analysis routines. Each such routine is known as a _stage_. To run post-processing stages, supply a JSON file instructing the application which stages and options to apply. You can find example JSON files that use the built-in post-processing stages in the https://github.com/raspberrypi/rpicam-apps/tree/main/assets[`assets` folder of the `rpicam-apps` repository]. + +For example, the **negate** stage turns light pixels dark and dark pixels light. Because the negate stage is basic, requiring no configuration, `negate.json` just names the stage: + +[source,json] +---- +{ + "negate": {} +} +---- + +To apply the negate stage to an image, pass `negate.json` to the `post-process-file` option: + +[source,console] +---- +$ rpicam-hello --post-process-file negate.json +---- + +To run multiple post-processing stages, create a JSON file that contains multiple stages as top-level keys. For example, to the following configuration runs the Sobel stage, then the negate stage: + +[source,json] +---- +{ + "sobel_cv": + { + "ksize": 5 + }, + "negate": {} +} +---- + +The xref:camera_software.adoc#sobel_cv-stage[Sobel stage] uses OpenCV, hence the `cv` suffix. It has a user-configurable parameter, `ksize`, that specifies the kernel size of the filter to be used. In this case, the Sobel filter produces bright edges on a black background, and the negate stage turns this into dark edges on a white background. + +.A negated Sobel filter. +image::images/sobel_negate.jpg[A negated Sobel filter] + +Some stages, such as `negate`, alter the image in some way. Other stages analyse the image to generate metadata. Post-processing stages can pass this metadata to other stages and even the application. + +To improve performance, image analysis often uses reduced resolution. `rpicam-apps` provide a dedicated low-resolution feed directly from the ISP. + +NOTE: The `rpicam-apps` supplied with Raspberry Pi OS do not include OpenCV and TensorFlow Lite. As a result, certain post-processing stages that rely on them are disabled. To use these stages, xref:camera_software.adoc#build-libcamera-and-rpicam-apps[re-compile `rpicam-apps`]. On a Raspberry Pi 3 or 4 running a 32-bit kernel, compile with the `-DENABLE_COMPILE_FLAGS_FOR_TARGET=armv8-neon` flag to speed up certain stages. + +=== Built-in stages + +==== `negate` stage + +This stage turns light pixels dark and dark pixels light. + +The `negate` stage has no user-configurable parameters. + +Default `negate.json` file: + +[source,json] +---- +{ + "negate" : {} +} +---- + +Run the following command to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --post-process-file negate.json +---- + +Example output: + +.A negated image. +image::images/negate.jpg[A negated image] + +==== `hdr` stage + +This stage emphasises details in images using High Dynamic Range (HDR) and Dynamic Range Compression (DRC). DRC uses a single image, while HDR combines multiple images for a similar result. + +Parameters fall into three groups: the LP filter, global tonemapping, and local contrast. + +This stage applies a smoothing filter to the fully-processed input images to generate a low pass (LP) image. It then generates the high pass (HP) image from the diff of the original and LP images. Then, it applies a global tonemap to the LP image and adds it back to the HP image. This process helps preserve local contrast. + +You can configure this stage with the following parameters: + +[cols="1,3a"] +|=== +| `num_frames` +| The number of frames to accumulate; for DRC, use 1; for HDR, try 8 +| `lp_filter_strength` +| The coefficient of the low pass IIR filter. +| `lp_filter_threshold` +| A piecewise linear function that relates pixel level to the threshold of meaningful detail +| `global_tonemap_points` +| Points in the input image histogram mapped to targets in the output range where we wish to move them. Uses the following sub-configuration: + +* an inter-quantile mean (`q` and `width`) +* a target as a proportion of the full output range (`target`) +* maximum (`max_up`) and minimum (`max_down`) gains to move the measured inter-quantile mean, to prevents the image from changing image too drastically +| `global_tonemap_strength` +| Strength of application of the global tonemap +| `local_pos_strength` +| A piecewise linear function that defines the gain applied to local contrast when added back to the tonemapped LP image, for positive (bright) detail +| `local_neg_strength` +| A piecewise linear function that defines the gain applied to local contrast when added back to the tonemapped LP image, for negative (dark) detail +| `local_tonemap_strength` +| An overall gain applied to all local contrast that is added back +| `local_colour_scale` +| A factor that allows the output colours to be affected more or less strongly +|=== + +To control processing strength, changing the `global_tonemap_strength` and `local_tonemap_strength` parameters. + +Processing a single image takes between two and three seconds for a 12MP image on a Raspberry Pi 4. When accumulating multiple frames, this stage sends only the processed image to the application. + +Default `drc.json` file for DRC: + +[source,json] +---- +{ + "hdr" : { + "num_frames" : 1, + "lp_filter_strength" : 0.2, + "lp_filter_threshold" : [ 0, 10.0 , 2048, 205.0, 4095, 205.0 ], + "global_tonemap_points" : + [ + { "q": 0.1, "width": 0.05, "target": 0.15, "max_up": 1.5, "max_down": 0.7 }, + { "q": 0.5, "width": 0.05, "target": 0.5, "max_up": 1.5, "max_down": 0.7 }, + { "q": 0.8, "width": 0.05, "target": 0.8, "max_up": 1.5, "max_down": 0.7 } + ], + "global_tonemap_strength" : 1.0, + "local_pos_strength" : [ 0, 6.0, 1024, 2.0, 4095, 2.0 ], + "local_neg_strength" : [ 0, 4.0, 1024, 1.5, 4095, 1.5 ], + "local_tonemap_strength" : 1.0, + "local_colour_scale" : 0.9 + } +} +---- + +Example: + +.Image without DRC processing +image::images/nodrc.jpg[Image without DRC processing] + +Run the following command to use this stage file with `rpicam-still`: + +[source,console] +---- +$ rpicam-still -o test.jpg --post-process-file drc.json +---- + +.Image with DRC processing +image::images/drc.jpg[Image with DRC processing] + +Default `hdr.json` file for HDR: + +[source,json] +---- +{ + "hdr" : { + "num_frames" : 8, + "lp_filter_strength" : 0.2, + "lp_filter_threshold" : [ 0, 10.0 , 2048, 205.0, 4095, 205.0 ], + "global_tonemap_points" : + [ + { "q": 0.1, "width": 0.05, "target": 0.15, "max_up": 5.0, "max_down": 0.5 }, + { "q": 0.5, "width": 0.05, "target": 0.45, "max_up": 5.0, "max_down": 0.5 }, + { "q": 0.8, "width": 0.05, "target": 0.7, "max_up": 5.0, "max_down": 0.5 } + ], + "global_tonemap_strength" : 1.0, + "local_pos_strength" : [ 0, 6.0, 1024, 2.0, 4095, 2.0 ], + "local_neg_strength" : [ 0, 4.0, 1024, 1.5, 4095, 1.5 ], + "local_tonemap_strength" : 1.0, + "local_colour_scale" : 0.8 + } +} +---- + +Example: + +.Image without HDR processing +image::images/nohdr.jpg[Image without HDR processing] + +Run the following command to use this stage file with `rpicam-still`: + +[source,console] +---- +$ rpicam-still -o test.jpg --ev -2 --denoise cdn_off --post-process-file hdr.json +---- + +.Image with HDR processing +image::images/hdr.jpg[Image with DRC processing] + +==== `motion_detect` stage + +The `motion_detect` stage analyses frames from the low-resolution image stream. You must configure the low-resolution stream to use this stage. The stage detects motion by comparing a region of interest (ROI) in the frame to the corresponding part of a previous frame. If enough pixels change between frames, this stage indicates the motion in metadata under the `motion_detect.result` key. + +This stage has no dependencies on third-party libraries. + +You can configure this stage with the following parameters, passing dimensions as a proportion of the low-resolution image size between 0 and 1: + +[cols="1,3"] +|=== +| `roi_x` | x-offset of the region of interest for the comparison (proportion between 0 and 1) +| `roi_y` | y-offset of the region of interest for the comparison (proportion between 0 and 1) +| `roi_width` | Width of the region of interest for the comparison (proportion between 0 and 1) +| `roi_height` | Height of the region of interest for the comparison (proportion between 0 and 1) +| `difference_m` | Linear coefficient used to construct the threshold for pixels being different +| `difference_c` | Constant coefficient used to construct the threshold for pixels being different according to `threshold = difference_m * pixel_value + difference_c` +| `frame_period` | The motion detector will run only this many frames +| `hskip` | The pixel subsampled by this amount horizontally +| `vksip` | The pixel subsampled by this amount vertically +| `region_threshold` | The proportion of pixels (regions) which must be categorised as different for them to count as motion +| `verbose` | Print messages to the console, including when the motion status changes +|=== + +Default `motion_detect.json` configuration file: + +[source,json] +---- +{ + "motion_detect" : { + "roi_x" : 0.1, + "roi_y" : 0.1, + "roi_width" : 0.8, + "roi_height" : 0.8, + "difference_m" : 0.1, + "difference_c" : 10, + "region_threshold" : 0.005, + "frame_period" : 5, + "hskip" : 2, + "vskip" : 2, + "verbose" : 0 + } +} +---- + +Adjust the differences and the threshold to make the algorithm more or less sensitive. To improve performance, use the `hskip` and `vskip` parameters. + +Run the following command to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --lores-width 128 --lores-height 96 --post-process-file motion_detect.json +---- diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_opencv.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_opencv.adoc new file mode 100644 index 0000000000..787393e966 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_opencv.adoc @@ -0,0 +1,120 @@ +=== Post-processing with OpenCV + +NOTE: These stages require an OpenCV installation. You may need to xref:camera_software.adoc#build-libcamera-and-rpicam-apps[rebuild `rpicam-apps` with OpenCV support]. + +==== `sobel_cv` stage + +This stage applies a https://en.wikipedia.org/wiki/Sobel_operator[Sobel filter] to an image to emphasise edges. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `ksize` | Kernel size of the Sobel filter +|=== + + +Default `sobel_cv.json` file: + +[source,json] +---- +{ + "sobel_cv" : { + "ksize": 5 + } +} +---- + +Example: + +.Using a Sobel filter to emphasise edges. +image::images/sobel.jpg[Using a Sobel filter to emphasise edges] + +==== `face_detect_cv` stage + +This stage uses the OpenCV Haar classifier to detect faces in an image. It returns face location metadata under the key `face_detect.results` and optionally draws the locations on the image. + +You can configure this stage with the following parameters: + +[cols=",3] +|=== +| `cascade_name` | Name of the file where the Haar cascade can be found +| `scaling_factor` | Determines range of scales at which the image is searched for faces +| `min_neighbors` | Minimum number of overlapping neighbours required to count as a face +| `min_size` | Minimum face size +| `max_size` | Maximum face size +| `refresh_rate` | How many frames to wait before trying to re-run the face detector +| `draw_features` | Whether to draw face locations on the returned image +|=== + +The `face_detect_cv` stage runs only during preview and video capture. It ignores still image capture. It runs on the low resolution stream with a resolution between 320×240 and 640×480 pixels. + +Default `face_detect_cv.json` file: + +[source,json] +---- +{ + "face_detect_cv" : { + "cascade_name" : "/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml", + "scaling_factor" : 1.1, + "min_neighbors" : 2, + "min_size" : 32, + "max_size" : 256, + "refresh_rate" : 1, + "draw_features" : 1 + } +} +---- + +Example: + +.Drawing detected faces onto an image. +image::images/face_detect.jpg[Drawing detected faces onto an image] + +==== `annotate_cv` stage + +This stage writes text into the top corner of images using the same `%` substitutions as the xref:camera_software.adoc#info-text[`info-text`] option. + +Interprets xref:camera_software.adoc#info-text[`info-text` directives] first, then passes any remaining tokens to https://www.man7.org/linux/man-pages/man3/strftime.3.html[`strftime`]. + +For example, to achieve a datetime stamp on the video, pass `%F %T %z`: + +* `%F` displays the ISO-8601 date (2023-03-07) +* `%T` displays 24h local time (e.g. "09:57:12") +* `%z` displays the timezone relative to UTC (e.g. "-0800") + +This stage does not output any metadata, but it writes metadata found in `annotate.text` in place of anything in the JSON configuration file. This allows other post-processing stages to write text onto images. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `text` | The text string to be written +| `fg` | Foreground colour +| `bg` | Background colour +| `scale` | A number proportional to the size of the text +| `thickness` | A number that determines the thickness of the text +| `alpha` | The amount of alpha to apply when overwriting background pixels +|=== + +Default `annotate_cv.json` file: + +[source,json] +---- +{ + "annotate_cv" : { + "text" : "Frame %frame exp %exp ag %ag dg %dg", + "fg" : 255, + "bg" : 0, + "scale" : 1.0, + "thickness" : 2, + "alpha" : 0.3 + } +} +---- + +Example: + +.Writing camera and date information onto an image with annotations. +image::images/annotate.jpg[Writing camera and date information onto an image with annotations] + diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_tflite.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_tflite.adoc new file mode 100644 index 0000000000..39d607f5e9 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_tflite.adoc @@ -0,0 +1,220 @@ +=== Post-Processing with TensorFlow Lite + +==== Prerequisites + +These stages require TensorFlow Lite (TFLite) libraries that export the {cpp} API. TFLite doesn't distribute libraries in this form, but you can download and install a version that exports the API from https://lindevs.com/install-precompiled-tensorflow-lite-on-raspberry-pi/[lindevs.com]. + +After installing, you must xref:camera_software.adoc#build-libcamera-and-rpicam-apps[recompile `rpicam-apps` with TensorFlow Lite support]. + +==== `object_classify_tf` stage + +Download: https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz[] + +`object_classify_tf` uses a Google MobileNet v1 model to classify objects in the camera image. This stage requires a https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz[`labels.txt` file]. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `top_n_results` | The number of results to show +| `refresh_rate` | The number of frames that must elapse between model runs +| `threshold_high` | Confidence threshold (between 0 and 1) where objects are considered as being present +| `threshold_low` | Confidence threshold which objects must drop below before being discarded as matches +| `model_file` | Filepath of the TFLite model file +| `labels_file` | Filepath of the file containing the object labels +| `display_labels` | Whether to display the object labels on the image; inserts `annotate.text` metadata for the `annotate_cv` stage to render +| `verbose` | Output more information to the console +|=== + +Example `object_classify_tf.json` file: + +[source,json] +---- +{ + "object_classify_tf" : { + "top_n_results" : 2, + "refresh_rate" : 30, + "threshold_high" : 0.6, + "threshold_low" : 0.4, + "model_file" : "/home//models/mobilenet_v1_1.0_224_quant.tflite", + "labels_file" : "/home//models/labels.txt", + "display_labels" : 1 + }, + "annotate_cv" : { + "text" : "", + "fg" : 255, + "bg" : 0, + "scale" : 1.0, + "thickness" : 2, + "alpha" : 0.3 + } +} +---- + +The stage operates on a low resolution stream image of size 224×224. +Run the following command to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --post-process-file object_classify_tf.json --lores-width 224 --lores-height 224 +---- + +.Object classification of a desktop computer and monitor. +image::images/classify.jpg[Object classification of a desktop computer and monitor] + +==== `pose_estimation_tf` stage + +Download: https://github.com/Qengineering/TensorFlow_Lite_Pose_RPi_32-bits[] + +`pose_estimation_tf` uses a Google MobileNet v1 model to detect pose information. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `refresh_rate` | The number of frames that must elapse between model runs +| `model_file` | Filepath of the TFLite model file +| `verbose` | Output extra information to the console +|=== + +Use the separate `plot_pose_cv` stage to draw the detected pose onto the main image. + +You can configure the `plot_pose_cv` stage with the following parameters: + +[cols="1,3"] +|=== +| `confidence_threshold` | Confidence threshold determining how much to draw; can be less than zero +|=== + +Example `pose_estimation_tf.json` file: + +[source,json] +---- +{ + "pose_estimation_tf" : { + "refresh_rate" : 5, + "model_file" : "posenet_mobilenet_v1_100_257x257_multi_kpt_stripped.tflite" + }, + "plot_pose_cv" : { + "confidence_threshold" : -0.5 + } +} +---- + +The stage operates on a low resolution stream image of size 257×257. **Because YUV420 images must have even dimensions, round up to 258×258 for YUV420 images.** + +Run the following command to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --post-process-file pose_estimation_tf.json --lores-width 258 --lores-height 258 +---- + +.Pose estimation of an adult human male. +image::images/pose.jpg[Pose estimation of an adult human male] + +==== `object_detect_tf` stage + +Download: https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip[] + +`object_detect_tf` uses a Google MobileNet v1 SSD (Single Shot Detector) model to detect and label objects. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `refresh_rate` | The number of frames that must elapse between model runs +| `model_file` | Filepath of the TFLite model file +| `labels_file` | Filepath of the file containing the list of labels +| `confidence_threshold` | Confidence threshold before accepting a match +| `overlap_threshold` | Determines the amount of overlap between matches for them to be merged as a single match. +| `verbose` | Output extra information to the console +|=== + +Use the separate `object_detect_draw_cv` stage to draw the detected objects onto the main image. + +You can configure the `object_detect_draw_cv` stage with the following parameters: + +[cols="1,3"] +|=== +| `line_thickness` | Thickness of the bounding box lines +| `font_size` | Size of the font used for the label +|=== + +Example `object_detect_tf.json` file: + +[source,json] +---- +{ + "object_detect_tf" : { + "number_of_threads" : 2, + "refresh_rate" : 10, + "confidence_threshold" : 0.5, + "overlap_threshold" : 0.5, + "model_file" : "/home//models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/detect.tflite", + "labels_file" : "/home//models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/labelmap.txt", + "verbose" : 1 + }, + "object_detect_draw_cv" : { + "line_thickness" : 2 + } +} +---- + +The stage operates on a low resolution stream image of size 300×300. Run the following command, which passes a 300×300 crop to the detector from the centre of the 400×300 low resolution image, to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --post-process-file object_detect_tf.json --lores-width 400 --lores-height 300 +---- + +.Detecting apple and cat objects. +image::images/detection.jpg[Detecting apple and cat objects] + +==== `segmentation_tf` stage + +Download: https://tfhub.dev/tensorflow/lite-model/deeplabv3/1/metadata/2?lite-format=tflite[] + +`segmentation_tf` uses a Google MobileNet v1 model. This stage requires a label file, found at the `assets/segmentation_labels.txt`. + +This stage runs on an image of size 257×257. Because YUV420 images must have even dimensions, the low resolution image should be at least 258 pixels in both width and height. The stage adds a vector of 257×257 values to the image metadata where each value indicates the categories a pixel belongs to. You can optionally draw a representation of the segmentation into the bottom right corner of the image. + +You can configure this stage with the following parameters: + +[cols="1,3"] +|=== +| `refresh_rate` | The number of frames that must elapse between model runs +| `model_file` | Filepath of the TFLite model file +| `labels_file` | Filepath of the file containing the list of labels +| `threshold` | When verbose is set, prints when the number of pixels with any label exceeds this number +| `draw` | Draws the segmentation map into the bottom right hand corner of the image +| `verbose` | Output extra information to the console +|=== + +Example `segmentation_tf.json` file: + +[source,json] +---- +{ + "segmentation_tf" : { + "number_of_threads" : 2, + "refresh_rate" : 10, + "model_file" : "/home//models/lite-model_deeplabv3_1_metadata_2.tflite", + "labels_file" : "/home//models/segmentation_labels.txt", + "draw" : 1, + "verbose" : 1 + } +} +---- + +This example takes a camera image and reduces it to 258×258 pixels in size. This stage even works when squashing a non-square image without cropping. This example enables the segmentation map in the bottom right hand corner. + +Run the following command to use this stage file with `rpicam-hello`: + +[source,console] +---- +$ rpicam-hello --post-process-file segmentation_tf.json --lores-width 258 --lores-height 258 --viewfinder-width 1024 --viewfinder-height 1024 +---- + +.Running segmentation and displaying the results on a map in the bottom right. +image::images/segmentation.jpg[Running segmentation and displaying the results on a map in the bottom right] diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_writing.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_writing.adoc new file mode 100644 index 0000000000..b010133f37 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_post_processing_writing.adoc @@ -0,0 +1,51 @@ +=== Write your own post-processing stages + +With the `rpicam-apps` post-processing framework, users can create their own custom post-processing stages. You can even include algorithms and routines from OpenCV and TensorFlow Lite. + +==== Basic post-processing stages + +To create your own post-processing stage, derive a new class from the `PostProcessingStage` class. +All post-processing stages must implement the following member functions: + +`char const *Name() const`:: Returns the name of the stage. Matched against stages listed in the JSON post-processing configuration file. +`void Read(boost::property_tree::ptree const ¶ms)`:: Reads the stage's configuration parameters from a provided JSON file. +`void AdjustConfig(std::string const &use_case, StreamConfiguration *config)`:: Gives stages a chance to influence the configuration of the camera. Frequently empty for stages with no need to configure the camera. +`void Configure()`:: Called just after the camera has been configured to allocate resources and check that the stage has access to necessary streams. +`void Start()`:: Called when the camera starts. Frequently empty for stages with no need to configure the camera. +`bool Process(CompletedRequest &completed_request)`:: Presents completed camera requests for post-processing. This is where you'll implement pixel manipulations and image analysis. Returns `true` if the post-processing framework should **not** deliver this request to the application. +`void Stop()`:: Called when the camera stops. Used to shut down any active processing on asynchronous threads. +`void Teardown()`:: Called when the camera configuration is destroyed. Use this as a deconstructor where you can de-allocate resources set up in the `Configure` method. + +In any stage implementation, call `RegisterStage` to register your stage with the system. + +Don't forget to add your stage to `meson.build` in the post-processing folder. +When writing your own stages, keep these tips in mind: + +* The `Process` method blocks the imaging pipeline. If it takes too long, the pipeline will stutter. **Always delegate time-consuming algorithms to an asynchronous thread.** + +* When delegating work to another thread, you must copy the image buffers. For applications like image analysis that don't require full resolution, try using a low-resolution image stream. + +* The post-processing framework _uses parallelism to process every frame_. This improves throughput. However, some OpenCV and TensorFlow Lite functions introduce another layer of parallelism _within_ each frame. Consider serialising calls within each frame since post-processing already takes advantage of multiple threads. + +* Most streams, including the low resolution stream, use the YUV420 format. You may need to convert this to another format for certain OpenCV or TFLite functions. + +* For the best performance, always alter images in-place. + +For a basic example, see https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/negate_stage.cpp[`negate_stage.cpp`]. This stage negates an image by turning light pixels dark and dark pixels light. This stage is mostly derived class boiler-plate, achieving the negation logic in barely half a dozen lines of code. + +For another example, see https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/sobel_cv_stage.cpp[`sobel_cv_stage.cpp`], which implements a Sobel filter in just a few lines of OpenCV functions. + +==== TensorFlow Lite stages + +For stages that use TensorFlow Lite (TFLite), derive a new class from the `TfStage` class. +This class delegates model execution to a separate thread to prevent camera stuttering. + +The `TfStage` class implements all the `PostProcessingStage` member functions post-processing stages must normally implement, _except for_ ``Name``. +All `TfStage`-derived stages must implement the ``Name`` function, and should implement some or all of the following virtual member functions: + +`void readExtras()`:: The base class reads the named model and certain other parameters like the `refresh_rate`. Use this function this to read extra parameters for the derived stage and check that the loaded model is correct (e.g. has right input and output dimensions). +`void checkConfiguration()`:: The base class fetches the low resolution stream that TFLite operates on and the full resolution stream in case the derived stage needs it. Use this function to check for the streams required by your stage. If your stage can't access one of the required streams, you might skip processing or throw an error. +`void interpretOutputs()`:: Use this function to read and interpret the model output. _Runs in the same thread as the model when the model completes_. +`void applyResults()`:: Use this function to apply results of the model (could be several frames old) to the current frame. Typically involves attaching metadata or drawing. _Runs in the main thread, before frames are delivered_. + +For an example implementation, see the https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/object_classify_tf_stage.cpp[`object_classify_tf_stage.cpp`] and https://github.com/raspberrypi/rpicam-apps/blob/main/post_processing_stages/pose_estimation_tf_stage.cpp[`pose_estimation_tf_stage.cpp`]. diff --git a/documentation/asciidoc/computers/camera/rpicam_apps_writing.adoc b/documentation/asciidoc/computers/camera/rpicam_apps_writing.adoc new file mode 100644 index 0000000000..fd5a9217bd --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_apps_writing.adoc @@ -0,0 +1,59 @@ +=== Write your own `rpicam` apps + +`rpicam-apps` does not provide all of the camera-related features that anyone could ever need. Instead, these applications are small and flexible. Users who require different behaviour can implement it themselves. + +All of the `rpicam-apps` use an event loop that receives messages when a new set of frames arrives from the camera system. This set of frames is called a `CompletedRequest`. The `CompletedRequest` contains: + +* all images derived from that single camera frame: often a low-resolution image and a full-size output +* metadata from the camera and post-processing systems + +==== `rpicam-hello` + +`rpicam-hello` is the smallest application, and the best place to start understanding `rpicam-apps` design. It extracts the `CompletedRequestPtr`, a shared pointer to the `CompletedRequest`, from the message, and forwards it to the preview window: + +[cpp] +---- +CompletedRequestPtr &completed_request = std::get(msg.payload); +app.ShowPreview(completed_request, app.ViewfinderStream()); +---- + +Every `CompletedRequest` must be recycled back to the camera system so that the buffers can be reused. Otherwise, the camera runs out of buffers for new camera frames. This recycling process happens automatically when no references to the `CompletedRequest` remain using {cpp}'s _shared pointer_ and _custom deleter_ mechanisms. + +As a result, `rpicam-hello` must complete the following actions to recycle the buffer space: + +* The event loop must finish a cycle so the message (`msg` in the code), which holds a reference to `CompletedRequest`, can be replaced with the next message. This discards the reference to the previous message. + +* When the event thread calls `ShowPreview`, it passes the preview thread a reference to the `CompletedRequest`. The preview thread discards the last `CompletedRequest` instance each time `ShowPreview` is called. + +==== `rpicam-vid` + +`rpicam-vid` is similar to `rpicam-hello` with encoding added to the event loop. Before the event loop starts, `rpicam-vid` configures the encoder with a callback. The callback handles the buffer containing the encoded image data. In the code below, we send the buffer to the `Output` object. `Output` could write it to a file or stream it, depending on the options specified. + +[cpp] +---- +app.SetEncodeOutputReadyCallback(std::bind(&Output::OutputReady, output.get(), _1, _2, _3, _4)); +---- + +Because this code passes the encoder a reference to the `CompletedRequest`, `rpicam-vid` can't recycle buffer data until the event loop, preview window, _and_ encoder all discard their references. + +==== `rpicam-raw` + +`rpicam-raw` is similar to `rpicam-vid`. It also encodes during the event loop. However, `rpicam-raw` uses a dummy encoder called the `NullEncoder`. This uses the input image as the output buffer instead of encoding it with a codec. `NullEncoder` only discards its reference to the buffer once the output callback completes. This guarantees that the buffer isn't recycled before the callback processes the image. + +`rpicam-raw` doesn't forward anything to the preview window. + +`NullEncoder` is possibly overkill in `rpicam-raw`. We could probably send images straight to the `Output` object, instead. However, `rpicam-apps` need to limit work in the event loop. `NullEncoder` demonstrates how you can handle most processes (even holding onto a reference) in other threads. + +==== `rpicam-jpeg` + +`rpicam-jpeg` starts the camera in preview mode in the usual way. When the timer completes, it stops the preview and switches to still capture: + +[cpp] +---- +app.StopCamera(); +app.Teardown(); +app.ConfigureStill(); +app.StartCamera(); +---- + +The event loop grabs the first frame returned from still mode and saves this as a JPEG. diff --git a/documentation/asciidoc/computers/camera/rpicam_configuration.adoc b/documentation/asciidoc/computers/camera/rpicam_configuration.adoc new file mode 100644 index 0000000000..c36db3f69d --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_configuration.adoc @@ -0,0 +1,57 @@ +=== Configuration + +Most use cases work automatically with no need to alter the camera configuration. However, some common use cases do require configuration tweaks, including: + +* Third-party cameras (the manufacturer's instructions should explain necessary configuration changes, if any) + +* Using a non-standard driver or overlay with an official Raspberry Pi camera + +Raspberry Pi OS recognises the following overlays in `/boot/firmware/config.txt`. + +|=== +| Camera Module | In `/boot/firmware/config.txt` + +| V1 camera (OV5647) +| `dtoverlay=ov5647` + +| V2 camera (IMX219) +| `dtoverlay=imx219` + +| HQ camera (IMX477) +| `dtoverlay=imx477` + +| GS camera (IMX296) +| `dtoverlay=imx296` + +| Camera Module 3 (IMX708) +| `dtoverlay=imx708` + +| IMX290 and IMX327 +| `dtoverlay=imx290,clock-frequency=74250000` or `dtoverlay=imx290,clock-frequency=37125000` (both modules share the imx290 kernel driver; refer to instructions from the module vendor for the correct frequency) + +| IMX378 +| `dtoverlay=imx378` + +| OV9281 +| `dtoverlay=ov9281` +|=== + +To use one of these overlays, you must disable automatic camera detection. To disable automatic detection, set `camera_auto_detect=0` in `/boot/firmware/config.txt`. If `config.txt` already contains a line assigning an `camera_auto_detect` value, change the value to `0`. Reboot your Raspberry Pi with `sudo reboot` to load your changes. + +If your Raspberry Pi has two camera connectors (Raspberry Pi 5 or one of the Compute Modules, for example), then you can specify the use of camera connector 0 by adding `,cam0` to the `dtoverlay` that you used from the table above. If you do not add this, it will default to checking camera connector 1. Note that for official Raspberry Pi camera modules connected to SBCs (not Compute Modules), auto-detection will correctly identify all the cameras connected to your device. + +[[tuning-files]] +==== Tweak camera behaviour with tuning files + +Raspberry Pi's `libcamera` implementation includes a **tuning file** for each camera. This file controls algorithms and hardware to produce the best image quality. `libcamera` can only determine the sensor in use, not the module. As a result, some modules require a tuning file override. Use the xref:camera_software.adoc#tuning-file[`tuning-file`] option to specify an override. You can also copy and alter existing tuning files to customise camera behaviour. + +For example, the no-IR-filter (NoIR) versions of sensors use Auto White Balance (AWB) settings different from the standard versions. On a Raspberry Pi 5 or later, you can specify the the NoIR tuning file for the IMX219 sensor with the following command: + +[source,console] +---- +$ rpicam-hello --tuning-file /usr/share/libcamera/ipa/rpi/pisp/imx219_noir.json +---- + +NOTE: Raspberry Pi models prior to Raspberry Pi 5 use different tuning files. On those devices, use the files stored in `/usr/share/libcamera/ipa/rpi/vc4/` instead. + +`libcamera` maintains tuning files for a number of cameras, including third-party models. For instance, you can find the tuning file for the Soho Enterprises SE327M12 in `se327m12.json`. diff --git a/documentation/asciidoc/computers/camera/rpicam_detect.adoc b/documentation/asciidoc/computers/camera/rpicam_detect.adoc new file mode 100644 index 0000000000..e75a4a630f --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_detect.adoc @@ -0,0 +1,14 @@ +=== `rpicam-detect` + +NOTE: Raspberry Pi OS does not include `rpicam-detect`. However, you can build `rpicam-detect` if you have xref:camera_software.adoc#post-processing-with-tensorflow-lite[installed TensorFlow Lite]. For more information, see the xref:camera_software.adoc#build-libcamera-and-rpicam-apps[`rpicam-apps` build instructions]. Don't forget to pass `-Denable_tflite=enabled` when you run `meson`. + +`rpicam-detect` displays a preview window and monitors the contents using a Google MobileNet v1 SSD (Single Shot Detector) neural network trained to identify about 80 classes of objects using the Coco dataset. `rpicam-detect` recognises people, cars, cats and many other objects. + +Whenever `rpicam-detect` detects a target object, it captures a full-resolution JPEG. Then it returns to monitoring preview mode. + +See the xref:camera_software.adoc#object_detect_tf-stage[TensorFlow Lite object detector] section for general information on model usage. For example, you might spy secretly on your cats while you are away with: + +[source,console] +---- +$ rpicam-detect -t 0 -o cat%04d.jpg --lores-width 400 --lores-height 300 --post-process-file object_detect_tf.json --object cat +---- diff --git a/documentation/asciidoc/computers/camera/rpicam_hello.adoc b/documentation/asciidoc/computers/camera/rpicam_hello.adoc new file mode 100644 index 0000000000..de7dae16f9 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_hello.adoc @@ -0,0 +1,41 @@ +=== `rpicam-hello` + +`rpicam-hello` briefly displays a preview window containing the video feed from a connected camera. To use `rpicam-hello` to display a preview window for five seconds, run the following command in a terminal: + +[source,console] +---- +$ rpicam-hello +---- + +You can pass an optional duration (in milliseconds) with the xref:camera_software.adoc#timeout[`timeout`] option. A value of `0` runs the preview indefinitely: + +[source,console] +---- +$ rpicam-hello --timeout 0 +---- + +Use `Ctrl+C` in the terminal or the close button on the preview window to stop `rpicam-hello`. + +==== Display an image sensor preview + +Most of the `rpicam-apps` display a preview image in a window. If there is no active desktop environment, the preview draws directly to the display using the Linux Direct Rendering Manager (DRM). Otherwise, `rpicam-apps` attempt to use the desktop environment. Both paths use zero-copy GPU buffer sharing: as a result, X forwarding is _not_ supported. + +If you run the X window server and want to use X forwarding, pass the xref:camera_software.adoc#qt-preview[`qt-preview`] flag to render the preview window in a https://en.wikipedia.org/wiki/Qt_(software)[Qt] window. The Qt preview window uses more resources than the alternatives. + +NOTE: Older systems using Gtk2 may, when linked with OpenCV, produce `Glib-GObject` errors and fail to show the Qt preview window. In this case edit the file `/etc/xdg/qt5ct/qt5ct.conf` as root and replace the line containing `style=gtk2` with `style=gtk3`. + +To suppress the preview window entirely, pass the xref:camera_software.adoc#nopreview[`nopreview`] flag: + +[source,console] +---- +$ rpicam-hello -n +---- + +The xref:camera_software.adoc#info-text[`info-text`] option displays image information on the window title bar using `%` directives. For example, the following command displays the current red and blue gain values: + +[source,console] +---- +$ rpicam-hello --info-text "red gain %rg, blue gain %bg" +---- + +For a full list of directives, see the xref:camera_software.adoc#info-text[`info-text` reference]. diff --git a/documentation/asciidoc/computers/camera/rpicam_jpeg.adoc b/documentation/asciidoc/computers/camera/rpicam_jpeg.adoc new file mode 100644 index 0000000000..2531487284 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_jpeg.adoc @@ -0,0 +1,19 @@ +=== `rpicam-jpeg` + +`rpicam-jpeg` helps you capture images on Raspberry Pi devices. + +To capture a full resolution JPEG image and save it to a file named `test.jpg`, run the following command: + +[source,console] +---- +$ rpicam-jpeg --output test.jpg +---- + +You should see a preview window for five seconds. Then, `rpicam-jpeg` captures a full resolution JPEG image and saves it. + +Use the xref:camera_software.adoc#timeout[`timeout`] option to alter display time of the preview window. The xref:camera_software.adoc#width-and-height[`width` and `height`] options change the resolution of the saved image. For example, the following command displays the preview window for 2 seconds, then captures and saves an image with a resolution of 640×480 pixels: + +[source,console] +---- +$ rpicam-jpeg --output test.jpg --timeout 2000 --width 640 --height 480 +---- diff --git a/documentation/asciidoc/computers/camera/rpicam_options_common.adoc b/documentation/asciidoc/computers/camera/rpicam_options_common.adoc new file mode 100644 index 0000000000..90e535ff8e --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_options_common.adoc @@ -0,0 +1,594 @@ +== `rpicam-apps` options reference + +=== Common options + +The following options apply across all the `rpicam-apps` with similar or identical semantics, unless otherwise noted. + +To pass one of the following options to an application, prefix the option name with `--`. If the option requires a value, pass the value immediately after the option name, separated by a single space. If the value contains a space, surround the value in quotes. + +Some options have shorthand aliases, for example `-h` instead of `--help`. Use these shorthand aliases instead of the full option name to save space and time at the expense of readability. + +==== `help` + +Alias: `-h` + +Prints the full set of options, along with a brief synopsis of each option. Does not accept a value. + +==== `version` + +Prints out version strings for `libcamera` and `rpicam-apps`. Does not accept a value. + +Example output: + +---- +rpicam-apps build: ca559f46a97a 27-09-2021 (14:10:24) +libcamera build: v0.0.0+3058-c29143f7 +---- + +==== `list-cameras` + +Lists the detected cameras attached to your Raspberry Pi and their available sensor modes. Does not accept a value. + +Sensor mode identifiers have the following form: `S_ : ` + +Crop is specified in native sensor pixels (even in pixel binning mode) as `(, )/×`. `(x, y)` specifies the location of the crop window of size `width × height` in the sensor array. + +For example, the following output displays information about an `IMX219` sensor at index 0 and an `IMX477` sensor at index 1: + +---- +Available cameras +----------------- +0 : imx219 [3280x2464] (/base/soc/i2c0mux/i2c@1/imx219@10) + Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop] + 1640x1232 [41.85 fps - (0, 0)/3280x2464 crop] + 1920x1080 [47.57 fps - (680, 692)/1920x1080 crop] + 3280x2464 [21.19 fps - (0, 0)/3280x2464 crop] + 'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop] + 1640x1232 [41.85 fps - (0, 0)/3280x2464 crop] + 1920x1080 [47.57 fps - (680, 692)/1920x1080 crop] + 3280x2464 [21.19 fps - (0, 0)/3280x2464 crop] +1 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a) + Modes: 'SRGGB10_CSI2P' : 1332x990 [120.05 fps - (696, 528)/2664x1980 crop] + 'SRGGB12_CSI2P' : 2028x1080 [50.03 fps - (0, 440)/4056x2160 crop] + 2028x1520 [40.01 fps - (0, 0)/4056x3040 crop] + 4056x3040 [10.00 fps - (0, 0)/4056x3040 crop] +---- + +For the IMX219 sensor in the above example: + +* all modes have an `RGGB` Bayer ordering +* all modes provide either 8-bit or 10-bit CSI2 packed readout at the listed resolutions + +==== `camera` + +Selects the camera to use. Specify an index from the xref:camera_software.adoc#list-cameras[list of available cameras]. + +==== `config` + +Alias: `-c` + +Specify a file containing CLI options and values. Consider a file named `example_configuration.txt` that contains the following text, specifying options and values as key-value pairs, one option per line, long (non-alias) option names only: + +---- +timeout=99000 +verbose= +---- + +TIP: Omit the leading `--` that you normally pass on the command line. For flags that lack a value, such as `verbose` in the above example, you must include a trailing `=`. + +You could then run the following command to specify a timeout of 99000 milliseconds and verbose output: + +[source,console] +---- +$ rpicam-hello --config example_configuration.txt +---- + +==== `timeout` + +Alias: `-t` + +Default value: 5000 milliseconds (5 seconds) + +Specify how long the application runs before closing. This value is interpreted as a number of milliseconds unless an optional suffix is used to change the unit. The suffix may be one of: + +* `min` - minutes +* `s` or `sec` - seconds +* `ms` - milliseconds (the default if no suffix used) +* `us` - microseconds +* `ns` - nanoseconds. + +This time applies to both video recording and preview windows. When capturing a still image, the application shows a preview window for the length of time specified by the `timeout` parameter before capturing the output image. + +To run the application indefinitely, specify a value of `0`. Floating point values are also permitted. + +Example: `rpicam-hello -t 0.5min` would run for 30 seconds. + +==== `preview` + +Alias: `-p` + +Sets the location (x,y coordinates) and size (w,h dimensions) of the desktop or DRM preview window. Does not affect the resolution or aspect ratio of images requested from the camera. Scales image size and pillar or letterboxes image aspect ratio to fit within the preview window. + +Pass the preview window dimensions in the following comma-separated form: `x,y,w,h` + +Example: `rpicam-hello --preview 100,100,500,500` + +image::images/preview_window.jpg[Letterboxed preview image] + +==== `fullscreen` + +Alias: `-f` + +Forces the preview window to use the entire screen with no border or title bar. Scales image size and pillar or letterboxes image aspect ratio to fit within the entire screen. Does not accept a value. + +==== `qt-preview` + +Uses the Qt preview window, which consumes more resources than the alternatives, but supports X window forwarding. Incompatible with the xref:camera_software.adoc#fullscreen[`fullscreen`] flag. Does not accept a value. + +==== `nopreview` + +Alias: `-n` + +Causes the application to _not_ display a preview window at all. Does not accept a value. + + +==== `info-text` + +Default value: `"#%frame (%fps fps) exp %exp ag %ag dg %dg"` + +Sets the supplied string as the title of the preview window when running in a desktop environment. Supports the following image metadata substitutions: + +|=== +| Directive | Substitution + +| `%frame` +| Sequence number of the frame. + +| `%fps` +| Instantaneous frame rate. + +| `%exp` +| Shutter speed used to capture the image, in microseconds. + +| `%ag` +| Analogue gain applied to the image in the sensor. + +| `%dg` +| Digital gain applied to the image by the ISP. + +| `%rg` +| Gain applied to the red component of each pixel. + +| `%bg` +| Gain applied to the blue component of each pixel. + +| `%focus` +| Focus metric for the image, where a larger value implies a sharper image. + +| `%lp` +| Current lens position in dioptres (1 / distance in metres). + +| `%afstate` +| Autofocus algorithm state (`idle`, `scanning`, `focused` or `failed`). +|=== + +image::images/focus.jpg[Image showing focus measure] + +==== `width` and `height` + +Each accepts a single number defining the dimensions, in pixels, of the captured image. + +For `rpicam-still`, `rpicam-jpeg` and `rpicam-vid`, specifies output resolution. + +For `rpicam-raw`, specifies raw frame resolution. For cameras with a 2×2 binned readout mode, specifying a resolution equal to or smaller than the binned mode captures 2×2 binned raw frames. + +For `rpicam-hello`, has no effect. + +Examples: + +* `rpicam-vid -o test.h264 --width 1920 --height 1080` captures 1080p video. + +* `rpicam-still -r -o test.jpg --width 2028 --height 1520` captures a 2028×1520 resolution JPEG. If used with the HQ camera, uses 2×2 binned mode, so the raw file (`test.dng`) contains a 2028×1520 raw Bayer image. + +==== `viewfinder-width` and `viewfinder-height` + +Each accepts a single number defining the dimensions, in pixels, of the image displayed in the preview window. Does not effect the preview window dimensions, since images are resized to fit. Does not affect captured still images or videos. + +==== `mode` + +Allows you to specify a camera mode in the following colon-separated format: `:::`. The system selects the closest available option for the sensor if there is not an exact match for a provided value. You can use the packed (`P`) or unpacked (`U`) packing formats. Impacts the format of stored videos and stills, but not the format of frames passed to the preview window. + +Bit-depth and packing are optional. +Bit-depth defaults to 12. +Packing defaults to `P` (packed). + +For information about the bit-depth, resolution, and packing options available for your sensor, see xref:camera_software.adoc#list-cameras[`list-cameras`]. + +Examples: + +* `4056:3040:12:P` - 4056×3040 resolution, 12 bits per pixel, packed. +* `1632:1224:10` - 1632×1224 resolution, 10 bits per pixel. +* `2592:1944:10:U` - 2592×1944 resolution, 10 bits per pixel, unpacked. +* `3264:2448` - 3264×2448 resolution. + +===== Packed format details + +The packed format uses less storage for pixel data. + +_On Raspberry Pi 4 and earlier devices_, the packed format packs pixels using the MIPI CSI-2 standard. This means: + +* 10-bit camera modes pack 4 pixels into 5 bytes. The first 4 bytes contain the 8 most significant bits (MSBs) of each pixel, and the final byte contains the 4 pairs of least significant bits (LSBs). +* 12-bit camera modes pack 2 pixels into 3 bytes. The first 2 bytes contain the 8 most significant bits (MSBs) of each pixel, and the final byte contains the 4 least significant bits (LSBs) of both pixels. + +_On Raspberry Pi 5 and later devices_, the packed format compresses pixel values with a visually lossless compression scheme into 8 bits (1 byte) per pixel. + +===== Unpacked format details + +The unpacked format provides pixel values that are much easier to manually manipulate, at the expense of using more storage for pixel data. + +On all devices, the unpacked format uses 2 bytes per pixel. + +_On Raspberry Pi 4 and earlier devices_, applications apply zero padding at the *most significant end*. In the unpacked format, a pixel from a 10-bit camera mode cannot exceed the value 1023. + +_On Raspberry Pi 5 and later devices_, applications apply zero padding at the *least significant end*, so images use the full 16-bit dynamic range of the pixel depth delivered by the sensor. + +==== `viewfinder-mode` + +Identical to the `mode` option, but it applies to the data passed to the preview window. For more information, see the xref:camera_software.adoc#mode[`mode` documentation]. + +==== `lores-width` and `lores-height` + +Delivers a second, lower-resolution image stream from the camera, scaled down to the specified dimensions. + +Each accepts a single number defining the dimensions, in pixels, of the lower-resolution stream. + +Available for preview and video modes. Not available for still captures. If you specify a aspect ratio different from the normal resolution stream, generates non-square pixels. + +For `rpicam-vid`, disables extra colour-denoise processing. + + +Useful for image analysis when combined with xref:camera_software.adoc#post-processing-with-rpicam-apps[image post-processing]. + +==== `hflip` + +Flips the image horizontally. Does not accept a value. + +==== `vflip` + +Flips the image vertically. Does not accept a value. + +==== `rotation` + +Rotates the image extracted from the sensor. Accepts only the values 0 or 180. + +==== `roi` + +Crops the image extracted from the full field of the sensor. Accepts four decimal values, _ranged 0 to 1_, in the following format: `,,,h>`. Each of these values represents a percentage of the available width and heights as a decimal between 0 and 1. + +These values define the following proportions: + +* ``: X coordinates to skip before extracting an image +* ``: Y coordinates to skip before extracting an image +* ``: image width to extract +* ``: image height to extract + +Defaults to `0,0,1,1` (starts at the first X coordinate and the first Y coordinate, uses 100% of the image width, uses 100% of the image height). + +Examples: + +* `rpicam-hello --roi 0.25,0.25,0.5,0.5` selects exactly a half of the total number of pixels cropped from the centre of the image (skips the first 25% of X coordinates, skips the first 25% of Y coordinates, uses 50% of the total image width, uses 50% of the total image height). +* `rpicam-hello --roi 0,0,0.25,0.25` selects exactly a quarter of the total number of pixels cropped from the top left of the image (skips the first 0% of X coordinates, skips the first 0% of Y coordinates, uses 25% of the image width, uses 25% of the image height). + +==== `hdr` + +Default value: `off` + +Runs the camera in HDR mode. If passed without a value, assumes `auto`. Accepts one of the following values: + +* `off` - Disables HDR. +* `auto` - Enables HDR on supported devices. Uses the sensor's built-in HDR mode if available. If the sensor lacks a built-in HDR mode, uses on-board HDR mode, if available. +* `single-exp` - Uses on-board HDR mode, if available, even if the sensor has a built-in HDR mode. If on-board HDR mode is not available, disables HDR. + +Raspberry Pi 5 and later devices have an on-board HDR mode. + +To check for built-in HDR modes in a sensor, pass this option in addition to xref:camera_software.adoc#list-cameras[`list-cameras`]. + +=== Camera control options + +The following options control image processing and algorithms that affect camera image quality. + +==== `sharpness` + +Sets image sharpness. Accepts a numeric value along the following spectrum: + +* `0.0` applies no sharpening +* values greater than `0.0`, but less than `1.0` apply less than the default amount of sharpening +* `1.0` applies the default amount of sharpening +* values greater than `1.0` apply extra sharpening + +==== `contrast` + +Specifies the image contrast. Accepts a numeric value along the following spectrum: + +* `0.0` applies minimum contrast +* values greater than `0.0`, but less than `1.0` apply less than the default amount of contrast +* `1.0` applies the default amount of contrast +* values greater than `1.0` apply extra contrast + + +==== `brightness` + +Specifies the image brightness, added as an offset to all pixels in the output image. Accepts a numeric value along the following spectrum: + +* `-1.0` applies minimum brightness (black) +* `0.0` applies standard brightness +* `1.0` applies maximum brightness (white) + +For many use cases, prefer xref:camera_software.adoc#ev[`ev`]. + +==== `saturation` + +Specifies the image colour saturation. Accepts a numeric value along the following spectrum: + +* `0.0` applies minimum saturation (grayscale) +* values greater than `0.0`, but less than `1.0` apply less than the default amount of saturation +* `1.0` applies the default amount of saturation +* values greater than `1.0` apply extra saturation + +==== `ev` + +Specifies the https://en.wikipedia.org/wiki/Exposure_value[exposure value (EV)] compensation of the image in stops. Accepts a numeric value that controls target values passed to the Automatic Exposure/Gain Control (AEC/AGC) processing algorithm along the following spectrum: + +* `-10.0` applies minimum target values +* `0.0` applies standard target values +* `10.0` applies maximum target values + +==== `shutter` + +Specifies the exposure time, using the shutter, in _microseconds_. Gain can still vary when you use this option. If the camera runs at a framerate so fast it does not allow for the specified exposure time (for instance, a framerate of 1fps and an exposure time of 10000 microseconds), the sensor will use the maximum exposure time allowed by the framerate. + +For a list of minimum and maximum shutter times for official cameras, see the xref:../accessories/camera.adoc#hardware-specification[camera hardware documentation]. Values above the maximum result in undefined behaviour. + +==== `gain` + +Alias: `--analoggain` + +Sets the combined analogue and digital gain. When the sensor driver can provide the requested gain, only uses analogue gain. When analogue gain reaches the maximum value, the ISP applies digital gain. Accepts a numeric value. + +For a list of analogue gain limits, for official cameras, see the xref:../accessories/camera.adoc#hardware-specification[camera hardware documentation]. + +Sometimes, digital gain can exceed 1.0 even when the analogue gain limit is not exceeded. This can occur in the following situations: + +* Either of the colour gains drops below 1.0, which will cause the digital gain to settle to 1.0/min(red_gain,blue_gain). This keeps the total digital gain applied to any colour channel above 1.0 to avoid discolouration artefacts. +* Slight variances during Automatic Exposure/Gain Control (AEC/AGC) changes. + +==== `metering` + +Default value: `centre` + +Sets the metering mode of the Automatic Exposure/Gain Control (AEC/AGC) algorithm. Accepts the following values: + +* `centre` - centre weighted metering +* `spot` - spot metering +* `average` - average or whole frame metering +* `custom` - custom metering mode defined in the camera tuning file + +For more information on defining a custom metering mode, and adjusting region weights in existing metering modes, see the https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf[Tuning guide for the Raspberry Pi cameras and libcamera]. + +==== `exposure` + +Sets the exposure profile. Changing the exposure profile should not affect the image exposure. Instead, different modes adjust gain settings to achieve the same net result. Accepts the following values: + +* `sport`: short exposure, larger gains +* `normal`: normal exposure, normal gains +* `long`: long exposure, smaller gains + +You can edit exposure profiles using tuning files. For more information, see the https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf[Tuning guide for the Raspberry Pi cameras and libcamera]. + +==== `awb` + +Sets the Auto White Balance (AWB) mode. Accepts the following values: + +|=== +| Mode name | Colour temperature range + +| `auto` +| 2500K to 8000K + +| `incandescent` +| 2500K to 3000K + +| `tungsten` +| 3000K to 3500K + +| `fluorescent` +| 4000K to 4700K + +| `indoor` +| 3000K to 5000K + +| `daylight` +| 5500K to 6500K + +| `cloudy` +| 7000K to 8500K + +| `custom` +| A custom range defined in the tuning file. +|=== + +These values are only approximate: values could vary according to the camera tuning. + +No mode fully disables AWB. Instead, you can fix colour gains with xref:camera_software.adoc#awbgains[`awbgains`]. + +For more information on AWB modes, including how to define a custom one, see the https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf[Tuning guide for the Raspberry Pi cameras and libcamera]. + +==== `awbgains` + +Sets a fixed red and blue gain value to be used instead of an Auto White Balance (AWB) algorithm. Set non-zero values to disable AWB. Accepts comma-separated numeric input in the following format: `,` + +==== `denoise` + +Default value: `auto` + +Sets the denoising mode. Accepts the following values: + +* `auto`: Enables standard spatial denoise. Uses extra-fast colour denoise for video, and high-quality colour denoise for images. Enables no extra colour denoise in the preview window. + +* `off`: Disables spatial and colour denoise. + +* `cdn_off`: Disables colour denoise. + +* `cdn_fast`: Uses fast colour denoise. + +* `cdn_hq`: Uses high-quality colour denoise. Not appropriate for video/viewfinder due to reduced throughput. + +Even fast colour denoise can lower framerates. High quality colour denoise _significantly_ lowers framerates. + +==== `tuning-file` + +Specifies the camera tuning file. The tuning file allows you to control many aspects of image processing, including the Automatic Exposure/Gain Control (AEC/AGC), Auto White Balance (AWB), colour shading correction, colour processing, denoising and more. Accepts a tuning file path as input. + +For more information about tuning files, see xref:camera_software.adoc#tuning-files[Tuning Files]. + +==== `autofocus-mode` + +Default value: `default` + +Specifies the autofocus mode. Accepts the following values: + +* `default`: puts the camera into continuous autofocus mode unless xref:camera_software.adoc#lens-position[`lens-position`] or xref:camera_software.adoc#autofocus-on-capture[`autofocus-on-capture`] override the mode to manual +* `manual`: does not move the lens at all unless manually configured with xref:camera_software.adoc#lens-position[`lens-position`] +* `auto`: only moves the lens for an autofocus sweep when the camera starts or just before capture if xref:camera_software.adoc#autofocus-on-capture[`autofocus-on-capture`] is also used +* `continuous`: adjusts the lens position automatically as the scene changes + +This option is only supported for certain camera modules. + +==== `autofocus-range` + +Default value: `normal` + +Specifies the autofocus range. Accepts the following values: + +* `normal`: focuses from reasonably close to infinity +* `macro`: focuses only on close objects, including the closest focal distances supported by the camera +* `full`: focus on the entire range, from the very closest objects to infinity + +This option is only supported for certain camera modules. + +==== `autofocus-speed` + +Default value: `normal` + +Specifies the autofocus speed. Accepts the following values: + +* `normal`: changes the lens position at normal speed +* `fast`: changes the lens position quickly + +This option is only supported for certain camera modules. + +==== `autofocus-window` + +Specifies the autofocus window within the full field of the sensor. Accepts four decimal values, _ranged 0 to 1_, in the following format: `,,,h>`. Each of these values represents a percentage of the available width and heights as a decimal between 0 and 1. + +These values define the following proportions: + +* ``: X coordinates to skip before applying autofocus +* ``: Y coordinates to skip before applying autofocus +* ``: autofocus area width +* ``: autofocus area height + +The default value uses the middle third of the output image in both dimensions (1/9 of the total image area). + +Examples: + +* `rpicam-hello --autofocus-window 0.25,0.25,0.5,0.5` selects exactly half of the total number of pixels cropped from the centre of the image (skips the first 25% of X coordinates, skips the first 25% of Y coordinates, uses 50% of the total image width, uses 50% of the total image height). +* `rpicam-hello --autofocus-window 0,0,0.25,0.25` selects exactly a quarter of the total number of pixels cropped from the top left of the image (skips the first 0% of X coordinates, skips the first 0% of Y coordinates, uses 25% of the image width, uses 25% of the image height). + +This option is only supported for certain camera modules. + +==== `lens-position` + +Default value: `default` + +Moves the lens to a fixed focal distance, normally given in dioptres (units of 1 / _distance in metres_). Accepts the following spectrum of values: + +* `0.0`: moves the lens to the "infinity" position +* Any other `number`: moves the lens to the 1 / `number` position. For example, the value `2.0` would focus at approximately 0.5m +* `default`: move the lens to a default position which corresponds to the hyperfocal position of the lens + +Lens calibration is imperfect, so different camera modules of the same model may vary. + +==== `verbose` + +Alias: `-v` + +Default value: `1` + +Sets the verbosity level. Accepts the following values: + +* `0`: no output +* `1`: normal output +* `2`: verbose output + +=== Output file options + +==== `output` + +Alias: `-o` + +Sets the name of the file used to record images or video. Besides plaintext file names, accepts the following special values: + +* `-`: write to stdout. +* `udp://` (prefix): a network address for UDP streaming. +* `tcp://` (prefix): a network address for TCP streaming. +* Include the `%d` directive in the file name to replace the directive with a count that increments for each opened file. This directive supports standard C format directive modifiers. + +Examples: + +* `rpicam-vid -t 100000 --segment 10000 -o chunk%04d.h264` records a 100 second file in 10 second segments, where each file includes an incrementing four-digit counter padded with leading zeros: e.g. `chunk0001.h264`, `chunk0002.h264`, etc. + +* `rpicam-vid -t 0 --inline -o udp://192.168.1.13:5000` streams H.264 video to network address 192.168.1.13 using UDP on port 5000. + +==== `wrap` + +Sets a maximum value for the counter used by the xref:camera_software.adoc#output[`output`] `%d` directive. The counter resets to zero after reaching this value. Accepts a numeric value. + +==== `flush` + +Flushes output files to disk as soon as a frame finishes writing, instead of waiting for the system to handle it. Does not accept a value. + +==== `post-process-file` + +Specifies a JSON file that configures the post-processing applied by the imaging pipeline. This applies to camera images _before_ they reach the application. This works similarly to the legacy `raspicam` "image effects". Accepts a file name path as input. + +Post-processing is a large topic and admits the use of third-party software like OpenCV and TensorFlowLite to analyse and manipulate images. For more information, see xref:camera_software.adoc#post-processing-with-rpicam-apps[post-processing]. + +==== `buffer-count` + +The number of buffers to allocate for still image capture or for video recording. The default value of zero lets each application choose a reasonable number for its own use case (1 for still image capture, and 6 for video recording). Increasing the number can sometimes help to reduce the number of frame drops, particularly at higher framerates. + +==== `viewfinder-buffer-count` + +As the `buffer-count` option, but applies when running in preview mode (that is `rpicam-hello` or the preview, not capture, phase of `rpicam-still`). + +==== `metadata` + +Save captured image metadata to a file or `-` for stdout. The fields in the metadata output will depend on the camera model in use. + +See also `metadata-format`. + +==== `metadata-format` + +Format to save the metadata in. Accepts the following values: + +* `txt` for text format +* `json` for JSON format + +In text format, each line will have the form + + key=value + +In JSON format, the output is a JSON object. + +This option does nothing unless `--metadata` is also specified. diff --git a/documentation/asciidoc/computers/camera/rpicam_options_detect.adoc b/documentation/asciidoc/computers/camera/rpicam_options_detect.adoc new file mode 100644 index 0000000000..298116505c --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_options_detect.adoc @@ -0,0 +1,15 @@ +=== Detection options + +The command line options specified in this section apply only to object detection using `rpicam-detect`. + +To pass one of the following options to `rpicam-detect`, prefix the option name with `--`. If the option requires a value, pass the value immediately after the option name, separated by a single space. If the value contains a space, surround the value in quotes. + +Some options have shorthand aliases, for example `-h` instead of `--help`. Use these shorthand aliases instead of the full option name to save space and time at the expense of readability. + +==== `object` + +Detects objects with the given name, sourced from the model's label file. Accepts a plaintext file name as input. + +==== `gap` + +Wait at least this many frames between captures. Accepts numeric values. diff --git a/documentation/asciidoc/computers/camera/rpicam_options_libav.adoc b/documentation/asciidoc/computers/camera/rpicam_options_libav.adoc new file mode 100644 index 0000000000..3b1f2ce199 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_options_libav.adoc @@ -0,0 +1,65 @@ +=== `libav` options + +The command line options specified in this section apply only to `libav` video backend. + +To enable the `libav` backend, pass the xref:camera_software.adoc#codec[`codec`] option the value `libav`. + +To pass one of the following options to an application, prefix the option name with `--`. If the option requires a value, pass the value immediately after the option name, separated by a single space. If the value contains a space, surround the value in quotes. + +Some options have shorthand aliases, for example `-h` instead of `--help`. Use these shorthand aliases instead of the full option name to save space and time at the expense of readability. + +==== `libav-format` + +Sets the `libav` output format. Accepts the following values: + +* `mkv` encoding +* `mp4` encoding +* `avi` encoding +* `h264` streaming +* `mpegts` streaming + +If you do not provide this option, the file extension passed to the xref:camera_software.adoc#output[`output`] option determines the file format. + +==== `libav-audio` + +Enables audio recording. When enabled, you must also specify an xref:camera_software.adoc#audio-codec[`audio-codec`]. Does not accept a value. + +==== `audio-codec` + +Default value: `aac` + +Selects an audio codec for output. For a list of available codecs, run `ffmpeg -codecs`. + +==== `audio-bitrate` + +Sets the bitrate for audio encoding in bits per second. Accepts numeric input. + +Example: `rpicam-vid --codec libav -o test.mp4 --audio_codec mp2 --audio-bitrate 16384` (Records audio at 16 kilobits/sec with the mp2 codec) + +==== `audio-samplerate` + +Default value: `0` + +Sets the audio sampling rate in Hz. Accepts numeric input. `0` uses the input sample rate. + +==== `audio-device` + +Select an ALSA input device for audio recording. For a list of available devices, run the following command: + +[source,console] +---- +$ pactl list | grep -A2 'Source #' | grep 'Name: ' +---- + +You should see output similar to the following: + +---- +Name: alsa_output.platform-bcm2835_audio.analog-stereo.monitor +Name: alsa_output.platform-fef00700.hdmi.hdmi-stereo.monitor +Name: alsa_output.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_000736B1214E0A-00.analog-stereo.monitor +Name: alsa_input.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_000736B1214E0A-00.mono-fallback +---- + +==== `av-sync` + +Shifts the audio sample timestamp by a value in microseconds. Accepts positive and negative numeric values. diff --git a/documentation/asciidoc/computers/camera/rpicam_options_still.adoc b/documentation/asciidoc/computers/camera/rpicam_options_still.adoc new file mode 100644 index 0000000000..4e20880dc7 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_options_still.adoc @@ -0,0 +1,126 @@ +=== Image options + +The command line options specified in this section apply only to still image output. + +To pass one of the following options to an application, prefix the option name with `--`. If the option requires a value, pass the value immediately after the option name, separated by a single space. If the value contains a space, surround the value in quotes. + +Some options have shorthand aliases, for example `-h` instead of `--help`. Use these shorthand aliases instead of the full option name to save space and time at the expense of readability. + +==== `quality` + +Alias: `-q` + +Default value: `93` + +Sets the JPEG quality. Accepts a value between `1` and `100`. + +==== `exif` + +Saves extra EXIF tags in the JPEG output file. Only applies to JPEG output. Because of limitations in the `libexif` library, many tags are currently (incorrectly) formatted as ASCII and print a warning in the terminal. + +This option is necessary to add certain EXIF tags related to camera settings. You can add tags unrelated to camera settings to the output JPEG after recording with https://exiftool.org/[ExifTool]. + +Example: `rpicam-still -o test.jpg --exif IDO0.Artist=Someone` + +==== `timelapse` + +Records images at the specified interval. Accepts an interval in milliseconds. Combine this setting with xref:camera_software.adoc#timeout[`timeout`] to capture repeated images over time. + +You can specify separate filenames for each output file using string formatting, e.g. `--output test%d.jpg`. + +Example: `rpicam-still -t 100000 -o test%d.jpg --timelapse 10000` captures an image every 10 seconds for 100 seconds. + +==== `framestart` + +Configures a starting value for the frame counter accessed in output file names as `%d`. Accepts an integer starting value. + +==== `datetime` + +Uses the current date and time in the output file name, in the form `MMDDhhmmss.jpg`: + +* `MM` = 2-digit month number +* `DD` = 2-digit day number +* `hh` = 2-digit 24-hour hour number +* `mm` = 2-digit minute number +* `ss` = 2-digit second number + +Does not accept a value. + +==== `timestamp` + +Uses the current system https://en.wikipedia.org/wiki/Unix_time[Unix time] as the output file name. Does not accept a value. + +==== `restart` + +Default value: `0` + +Configures the restart marker interval for JPEG output. JPEG restart markers can help limit the impact of corruption on JPEG images, and additionally enable the use of multi-threaded JPEG encoding and decoding. Accepts an integer value. + +==== `immediate` + +Captures the image immediately when the application runs. + +==== `keypress` + +Alias: `-k` + +Captures an image when the xref:camera_software.adoc#timeout[`timeout`] expires or on press of the *Enter* key, whichever comes first. Press the `x` key, then *Enter* to exit without capturing. Does not accept a value. + +==== `signal` + +Captures an image when the xref:camera_software.adoc#timeout[`timeout`] expires or when `SIGUSR1` is received. Use `SIGUSR2` to exit without capturing. Does not accept a value. + +==== `thumb` + +Default value: `320:240:70` + +Configure the dimensions and quality of the thumbnail with the following format: `` (or `none`, which omits the thumbnail). + +==== `encoding` + +Alias: `-e` + +Default value: `jpg` + +Sets the encoder to use for image output. Accepts the following values: + +* `jpg` - JPEG +* `png` - PNG +* `bmp` - BMP +* `rgb` - binary dump of uncompressed RGB pixels +* `yuv420` - binary dump of uncompressed YUV420 pixels + +This option always determines the encoding, overriding the extension passed to xref:camera_software.adoc#output[`output`]. + +When using the xref:camera_software.adoc#datetime[`datetime`] and xref:camera_software.adoc#timestamp[`timestamp`] options, this option determines the output file extension. + +==== `raw` + +Alias: `-r` + +Saves a raw Bayer file in DNG format in addition to the output image. Replaces the output file name extension with `.dng`. You can process these standard DNG files with tools like _dcraw_ or _RawTherapee_. Does not accept a value. + +The image data in the raw file is exactly what came out of the sensor, with no processing from the ISP or anything else. The EXIF data saved in the file, among other things, includes: + +* exposure time +* analogue gain (the ISO tag is 100 times the analogue gain used) +* white balance gains (which are the reciprocals of the "as shot neutral" values) +* the colour matrix used by the ISP + +==== `latest` + +Creates a symbolic link to the most recently saved file. Accepts a symbolic link name as input. + +==== `autofocus-on-capture` + +If set, runs an autofocus cycle _just before_ capturing an image. Interacts with the following xref:camera_software.adoc#autofocus-mode[`autofocus_mode`] values: + +* `default` or `manual`: only runs the capture-time autofocus cycle. + +* `auto`: runs an additional autofocus cycle when the preview window loads. + +* `continuous`: ignores this option, instead continually focusing throughout the preview. + +Does not require a value, but you can pass `1` to enable and `0` to disable. Not passing a value is equivalent to passing `1`. + +Only supported by some camera modules (such as the _Raspberry Pi Camera Module 3_). diff --git a/documentation/asciidoc/computers/camera/rpicam_options_vid.adoc b/documentation/asciidoc/computers/camera/rpicam_options_vid.adoc new file mode 100644 index 0000000000..00ac1a2589 --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_options_vid.adoc @@ -0,0 +1,141 @@ +=== Video options + +The command line options specified in this section apply only to video output. + +To pass one of the following options to an application, prefix the option name with `--`. If the option requires a value, pass the value immediately after the option name, separated by a single space. If the value contains a space, surround the value in quotes. + +Some options have shorthand aliases, for example `-h` instead of `--help`. Use these shorthand aliases instead of the full option name to save space and time at the expense of readability. + +==== `quality` + +Alias: `-q` + +Default value: `50` + +Accepts an MJPEG quality level between 1 and 100. Only applies to videos encoded in the MJPEG format. + +==== `bitrate` + +Alias: `-b` + +Controls the target bitrate used by the H.264 encoder in bits per second. Only applies to videos encoded in the H.264 format. Impacts the size of the output video. + + +Example: `rpicam-vid -b 10000000 --width 1920 --height 1080 -o test.h264` + +==== `intra` + +Alias: `-g` + +Default value: `60` + +Sets the frequency of Iframes (intra frames) in the H.264 bitstream. Accepts a number of frames. Only applies to videos encoded in the H.264 format. + +==== `profile` + +Sets the H.264 profile. Accepts the following values: + +* `baseline` +* `main` +* `high` + +Only applies to videos encoded in the H.264 format. + +==== `level` + +Sets the H.264 level. Accepts the following values: + +* `4` +* `4.1` +* `4.2` + +Only applies to videos encoded in the H.264 format. + +==== `codec` + +Sets the encoder to use for video output. Accepts the following values: + +* `h264` - use H.264 encoder (the default) +* `mjpeg` - use MJPEG encoder +* `yuv420` - output uncompressed YUV420 frames. +* `libav` - use the libav backend to encode audio and video (for more information, see xref:camera_software.adoc#libav-integration-with-rpicam-vid[`libav`]) + +==== `save-pts` + +WARNING: Raspberry Pi 5 does not support the `save-pts` option. Use `libav` to automatically generate timestamps for container formats instead. + +Enables frame timestamp output, which allow you to convert the bitstream into a container format using a tool like `mkvmerge`. Accepts a plaintext file name for the timestamp output file. + +Example: `rpicam-vid -o test.h264 --save-pts timestamps.txt` + +You can then use the following command to generate an MKV container file from the bitstream and timestamps file: + +[source,console] +---- +$ mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264 +---- + +==== `keypress` + +Alias: `-k` + +Allows the CLI to enable and disable video output using the *Enter* key. Always starts in the recording state unless specified otherwise with xref:camera_software.adoc#initial[`initial`]. Type the `x` key and press *Enter* to exit. Does not accept a value. + +==== `signal` + +Alias: `-s` + +Allows the CLI to enable and disable video output using `SIGUSR1`. Use `SIGUSR2` to exit. Always starts in the recording state unless specified otherwise with xref:camera_software.adoc#initial[`initial`]. Does not accept a value. + +==== `initial` + +Default value: `record` + +Specifies whether to start the application with video output enabled or disabled. Accepts the following values: + +* `record`: Starts with video output enabled. +* `pause`: Starts with video output disabled. + +Use this option with either xref:camera_software.adoc#keypress[`keypress`] or xref:camera_software.adoc#signal[`signal`] to toggle between the two states. + +==== `split` + +When toggling recording with xref:camera_software.adoc#keypress[`keypress`] or xref:camera_software.adoc#signal[`signal`], writes the video output from separate recording sessions into separate files. Does not accept a value. Unless combined with xref:camera_software.adoc#output[`output`] to specify unique names for each file, overwrites each time it writes a file. + +==== `segment` + +Cuts video output into multiple files of the passed duration. Accepts a duration in milliseconds. If passed a very small duration (for instance, `1`), records each frame to a separate output file to simulate burst capture. + +You can specify separate filenames for each file using string formatting, e.g. `--output test%04d.h264`. + +==== `circular` + +Default value: `4` + +Writes video recording into a circular buffer in memory. When the application quits, records the circular buffer to disk. Accepts an optional size in megabytes. + +==== `inline` + +Writes a sequence header in every Iframe (intra frame). This can help clients decode the video sequence from any point in the video, instead of just the beginning. Recommended with xref:camera_software.adoc#segment[`segment`], xref:camera_software.adoc#split[`split`], xref:camera_software.adoc#circular[`circular`], and streaming options. + +Only applies to videos encoded in the H.264 format. Does not accept a value. + +==== `listen` + +Waits for an incoming client connection before encoding video. Intended for network streaming over TCP/IP. Does not accept a value. + +==== `frames` + +Records exactly the specified number of frames. Any non-zero value overrides xref:camera_software.adoc#timeout[`timeout`]. Accepts a nonzero integer. + +==== `framerate` + +Records exactly the specified framerate. Accepts a nonzero integer. + +==== `low-latency` + +On a Pi 5, the `--low-latency` option will reduce the encoding latency, which may be beneficial for real-time streaming applications, in return for (slightly) less good coding efficiency (for example, B frames and arithmetic coding will no longer be used). + +==== `sync` + +Run the camera in software synchronisation mode, where multiple cameras synchronise frames to the same moment in time. The `sync` mode can be set to either `client` or `server`. For more information, please refer to the detailed explanation of xref:camera_software.adoc#software-camera-synchronisation[how software synchronisation works]. \ No newline at end of file diff --git a/documentation/asciidoc/computers/camera/rpicam_raw.adoc b/documentation/asciidoc/computers/camera/rpicam_raw.adoc new file mode 100644 index 0000000000..210e0e20ae --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_raw.adoc @@ -0,0 +1,26 @@ +=== `rpicam-raw` + +`rpicam-raw` records video as raw Bayer frames directly from the sensor. It does not show a preview window. To record a two second raw clip to a file named `test.raw`, run the following command: + +[source,console] +---- +$ rpicam-raw -t 2000 -o test.raw +---- + +`rpicam-raw` outputs raw frames with no formatting information at all, one directly after another. The application prints the pixel format and image dimensions to the terminal window to help the user interpret the pixel data. + +By default, `rpicam-raw` outputs raw frames in a single, potentially very large, file. Use the xref:camera_software.adoc#segment[`segment`] option to direct each raw frame to a separate file, using the `%05d` xref:camera_software.adoc#output[directive] to make each frame filename unique: + +[source,console] +---- +$ rpicam-raw -t 2000 --segment 1 -o test%05d.raw +---- + +With a fast storage device, `rpicam-raw` can write 18MB 12-megapixel HQ camera frames to disk at 10fps. `rpicam-raw` has no capability to format output frames as DNG files; for that functionality, use xref:camera_software.adoc#rpicam-still[`rpicam-still`]. Use the xref:camera_software.adoc#framerate[`framerate`] option at a level beneath 10 to avoid dropping frames: + +[source,console] +---- +$ rpicam-raw -t 5000 --width 4056 --height 3040 -o test.raw --framerate 8 +---- + +For more information on the raw formats, see the xref:camera_software.adoc#mode[`mode` documentation]. diff --git a/documentation/asciidoc/computers/camera/rpicam_still.adoc b/documentation/asciidoc/computers/camera/rpicam_still.adoc new file mode 100644 index 0000000000..08ec164e0a --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_still.adoc @@ -0,0 +1,206 @@ +=== `rpicam-still` + +`rpicam-still`, like `rpicam-jpeg`, helps you capture images on Raspberry Pi devices. +Unlike `rpicam-jpeg`, `rpicam-still` supports many options provided in the legacy `raspistill` application. + +To capture a full resolution JPEG image and save it to a file named `test.jpg`, run the following command: + +[source,console] +---- +$ rpicam-still --output test.jpg +---- + +==== Encoders + +`rpicam-still` can save images in multiple formats, including `png`, `bmp`, and both RGB and YUV binary pixel dumps. To read these binary dumps, any application reading the files must understand the pixel arrangement. + +Use the xref:camera_software.adoc#encoding[`encoding`] option to specify an output format. The file name passed to xref:camera_software.adoc#output[`output`] has no impact on the output file type. + +To capture a full resolution PNG image and save it to a file named `test.png`, run the following command: + +[source,console] +---- +$ rpicam-still --encoding png --output test.png +---- + +For more information about specifying an image format, see the xref:camera_software.adoc#encoding[`encoding` option reference]. + +==== Capture raw images + +Raw images are the images produced directly by the image sensor, before any processing is applied to them either by the Image Signal Processor (ISP) or CPU. Colour image sensors usually use the Bayer format. Use the xref:camera_software.adoc#raw[`raw`] option to capture raw images. + +To capture an image, save it to a file named `test.jpg`, and also save a raw version of the image to a file named `test.dng`, run the following command: + +[source,console] +---- +$ rpicam-still --raw --output test.jpg +---- + +`rpicam-still` saves raw images in the DNG (Adobe Digital Negative) format. To determine the filename of the raw images, `rpicam-still` uses the same name as the output file, with the extension changed to `.dng`. To work with DNG images, use an application like https://en.wikipedia.org/wiki/Dcraw[Dcraw] or https://en.wikipedia.org/wiki/RawTherapee[RawTherapee]. + +DNG files contain metadata about the image capture, including black levels, white balance information and the colour matrix used by the ISP to produce the JPEG. Use https://exiftool.org/[ExifTool] to view DNG metadata. The following output shows typical metadata stored in a raw image captured by a Raspberry Pi using the HQ camera: + +---- +File Name : test.dng +Directory : . +File Size : 24 MB +File Modification Date/Time : 2021:08:17 16:36:18+01:00 +File Access Date/Time : 2021:08:17 16:36:18+01:00 +File Inode Change Date/Time : 2021:08:17 16:36:18+01:00 +File Permissions : rw-r--r-- +File Type : DNG +File Type Extension : dng +MIME Type : image/x-adobe-dng +Exif Byte Order : Little-endian (Intel, II) +Make : Raspberry Pi +Camera Model Name : /base/soc/i2c0mux/i2c@1/imx477@1a +Orientation : Horizontal (normal) +Software : rpicam-still +Subfile Type : Full-resolution Image +Image Width : 4056 +Image Height : 3040 +Bits Per Sample : 16 +Compression : Uncompressed +Photometric Interpretation : Color Filter Array +Samples Per Pixel : 1 +Planar Configuration : Chunky +CFA Repeat Pattern Dim : 2 2 +CFA Pattern 2 : 2 1 1 0 +Black Level Repeat Dim : 2 2 +Black Level : 256 256 256 256 +White Level : 4095 +DNG Version : 1.1.0.0 +DNG Backward Version : 1.0.0.0 +Unique Camera Model : /base/soc/i2c0mux/i2c@1/imx477@1a +Color Matrix 1 : 0.8545269369 -0.2382823821 -0.09044229197 -0.1890484985 1.063961506 0.1062747385 -0.01334283455 0.1440163847 0.2593136724 +As Shot Neutral : 0.4754476844 1 0.413686484 +Calibration Illuminant 1 : D65 +Strip Offsets : 0 +Strip Byte Counts : 0 +Exposure Time : 1/20 +ISO : 400 +CFA Pattern : [Blue,Green][Green,Red] +Image Size : 4056x3040 +Megapixels : 12.3 +Shutter Speed : 1/20 +---- + +To find the analogue gain, divide the ISO number by 100. +The Auto White Balance (AWB) algorithm determines a single calibrated illuminant, which is always labelled `D65`. + +==== Capture long exposures + +To capture very long exposure images, disable the Automatic Exposure/Gain Control (AEC/AGC) and Auto White Balance (AWB). These algorithms will otherwise force the user to wait for a number of frames while they converge. + +To disable these algorithms, supply explicit values for gain and AWB. Because long exposures take plenty of time already, it often makes sense to skip the preview phase entirely with the xref:camera_software.adoc#immediate[`immediate`] option. + +To perform a 100 second exposure capture, run the following command: + +[source,console] +---- +$ rpicam-still -o long_exposure.jpg --shutter 100000000 --gain 1 --awbgains 1,1 --immediate +---- + +To find the maximum exposure times of official Raspberry Pi cameras, see xref:../accessories/camera.adoc#hardware-specification[the camera hardware specification]. + +==== Create a time lapse video + +To create a time lapse video, capture a still image at a regular interval, such as once a minute, then use an application to stitch the pictures together into a video. + +[tabs] +====== +`rpicam-still` time lapse mode:: ++ +To use the built-in time lapse mode of `rpicam-still`, use the xref:camera_software.adoc#timelapse[`timelapse`] option. This option accepts a value representing the period of time you want your Raspberry Pi to wait between captures, in milliseconds. ++ +First, create a directory where you can store your time lapse photos: ++ +[source,console] +---- +$ mkdir timelapse +---- ++ +Run the following command to create a time lapse over 30 seconds, recording a photo every two seconds, saving output into `image0000.jpg` through `image0013.jpg`: ++ +[source,console] +---- +$ rpicam-still --timeout 30000 --timelapse 2000 -o timelapse/image%04d.jpg +---- + +`cron`:: ++ +You can also automate time lapses with `cron`. First, create the script, named `timelapse.sh` containing the following commands. Replace the `` placeholder with the name of your user account on your Raspberry Pi: ++ +[source,bash] +---- +#!/bin/bash +DATE=$(date +"%Y-%m-%d_%H%M") +rpicam-still -o /home//timelapse/$DATE.jpg +---- ++ +Then, make the script executable: ++ +[source,console] +---- +$ chmod +x timelapse.sh +---- ++ +Create the `timelapse` directory into which you'll save time lapse pictures: ++ +[source,console] +---- +$ mkdir timelapse +---- ++ +Open your crontab for editing: ++ +[source,console] +---- +$ crontab -e +---- ++ +Once you have the file open in an editor, add the following line to schedule an image capture every minute, replacing the `` placeholder with the username of your primary user account: ++ +---- +* * * * * /home//timelapse.sh 2>&1 +---- ++ +Save and exit, and you should see this message: ++ +---- +crontab: installing new crontab +---- ++ +To stop recording images for the time lapse, run `crontab -e` again and remove the above line from your crontab. + +====== + +===== Stitch images together + +Once you have a series of time lapse photos, you probably want to combine them into a video. Use `ffmpeg` to do this on a Raspberry Pi. + +First, install `ffmpeg`: + +[source,console] +---- +$ sudo apt install ffmpeg +---- + +Run the following command from the directory that contains the `timelapse` directory to convert your JPEG files into an mp4 video: + +[source,console] +---- +$ ffmpeg -r 10 -f image2 -pattern_type glob -i 'timelapse/*.jpg' -s 1280x720 -vcodec libx264 timelapse.mp4 +---- + +The command above uses the following parameters: + +* `-r 10`: sets the frame rate (Hz value) to ten frames per second in the output video +* `-f image2`: sets `ffmpeg` to read from a list of image files specified by a pattern +* `-pattern_type glob`: use wildcard patterns (globbing) to interpret filename input with `-i` +* `-i 'timelapse/*.jpg'`: specifies input files to match JPG files in the `timelapse` directory +* `-s 1280x720`: scales to 720p +* `-vcodec libx264` use the software x264 encoder. +* `timelapse.mp4` The name of the output video file. + +For more information about `ffmpeg` options, run `ffmpeg --help` in a terminal. diff --git a/documentation/asciidoc/computers/camera/rpicam_vid.adoc b/documentation/asciidoc/computers/camera/rpicam_vid.adoc new file mode 100644 index 0000000000..e88c5b762a --- /dev/null +++ b/documentation/asciidoc/computers/camera/rpicam_vid.adoc @@ -0,0 +1,98 @@ +=== `rpicam-vid` + +`rpicam-vid` helps you capture video on Raspberry Pi devices. `rpicam-vid` displays a preview window and writes an encoded bitstream to the specified output. This produces an unpackaged video bitstream that is not wrapped in any kind of container (such as an mp4 file) format. + +NOTE: When available, `rpicam-vid` uses hardware H.264 encoding. + +For example, the following command writes a ten-second video to a file named `test.h264`: + +[source,console] +---- +$ rpicam-vid -t 10s -o test.h264 +---- + +You can play the resulting file with ffplay and other video players: + +[source,console] +---- +$ ffplay test.h264 +---- + +[WARNING] +==== +Older versions of vlc were able to play H.264 files correctly, but recent versions do not - displaying only a few, or possibly garbled, frames. You should either use a different media player, or save your files in a more widely supported container format - such as MP4 (see below). +==== + +On Raspberry Pi 5, you can output to the MP4 container format directly by specifying the `mp4` file extension for your output file: + +[source,console] +---- +$ rpicam-vid -t 10s -o test.mp4 +---- + +On Raspberry Pi 4, or earlier devices, you can save MP4 files using: + +[source,console] +---- +$ rpicam-vid -t 10s --codec libav -o test.mp4 +---- + +==== Encoders + +`rpicam-vid` supports motion JPEG as well as both uncompressed and unformatted YUV420: + +[source,console] +---- +$ rpicam-vid -t 10000 --codec mjpeg -o test.mjpeg +---- + +[source,console] +---- +$ rpicam-vid -t 10000 --codec yuv420 -o test.data +---- + +The xref:camera_software.adoc#codec[`codec`] option determines the output format, not the extension of the output file. + +The xref:camera_software.adoc#segment[`segment`] option breaks output files up into chunks of the segment size (given in milliseconds). This is handy for breaking a motion JPEG stream up into individual JPEG files by specifying very short (1 millisecond) segments. For example, the following command combines segments of 1 millisecond with a counter in the output file name to generate a new filename for each segment: + +[source,console] +---- +$ rpicam-vid -t 10000 --codec mjpeg --segment 1 -o test%05d.jpeg +---- + +==== Capture high framerate video + +To minimise frame drops for high framerate (> 60fps) video, try the following configuration tweaks: + +* Set the https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels[H.264 target level] to 4.2 with `--level 4.2`. +* Disable software colour denoise processing by setting the xref:camera_software.adoc#denoise[`denoise`] option to `cdn_off`. +* Disable the display window with xref:camera_software.adoc#nopreview[`nopreview`] to free up some additional CPU cycles. +* Set `force_turbo=1` in xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] to ensure that the CPU clock does not throttle during video capture. For more information, see xref:config_txt.adoc#force_turbo[the `force_turbo` documentation]. +* Adjust the ISP output resolution with `--width 1280 --height 720` or something even lower to achieve your framerate target. +* On Raspberry Pi 4, you can overclock the GPU to improve performance by adding `gpu_freq=550` or higher in `/boot/firmware/config.txt`. See xref:config_txt.adoc#overclocking[the overclocking documentation] for further details. + +The following command demonstrates how you might achieve 1280×720 120fps video: + +[source,console] +---- +$ rpicam-vid --level 4.2 --framerate 120 --width 1280 --height 720 --save-pts timestamp.pts -o video.264 -t 10000 --denoise cdn_off -n +---- + +==== `libav` integration with `rpicam-vid` + +`rpicam-vid` can use the `ffmpeg`/`libav` codec backend to encode audio and video streams. You can either save these streams to a file or stream them over the network. `libav` uses hardware H.264 video encoding when present. + +To enable the `libav` backend, pass `libav` to the xref:camera_software.adoc#codec[`codec`] option: + +[source,console] +---- +$ rpicam-vid --codec libav --libav-format avi --libav-audio --output example.avi +---- + +==== Low latency video with the Pi 5 + +Pi 5 uses software video encoders. These generally output frames with a longer latency than the old hardware encoders, and this can sometimes be an issue for real-time streaming applications. + +In this case, please add the option `--low-latency` to the `rpicam-vid` command. This will alter certain encoder options to output the encoded frame more quickly. + +The downside is that coding efficiency is (slightly) less good, and that the processor's multiple cores may be used (slightly) less efficiently. The maximum framerate that can be encoded may be slightly reduced (though it will still easily achieve 1080p30). diff --git a/documentation/asciidoc/computers/camera/streaming.adoc b/documentation/asciidoc/computers/camera/streaming.adoc new file mode 100644 index 0000000000..ffcf9a6569 --- /dev/null +++ b/documentation/asciidoc/computers/camera/streaming.adoc @@ -0,0 +1,206 @@ +== Stream video over a network with `rpicam-apps` + +This section describes how to stream video over a network using `rpicam-vid`. Whilst it's possible to stream very simple formats without using `libav`, for most applications we recommend using the xref:camera_software.adoc#libav-integration-with-rpicam-vid[`libav` backend]. + +=== UDP + +To stream video over UDP using a Raspberry Pi as a server, use the following command, replacing the `` placeholder with the IP address of the client or multicast address and replacing the `` placeholder with the port you would like to use for streaming: + +[source,console] +---- +$ rpicam-vid -t 0 -n --inline -o udp://: +---- + +To view video streamed over UDP using a Raspberry Pi as a client, use the following command, replacing the `` placeholder with the port you would like to stream from: + +[source,console] +---- +$ ffplay udp://@: -fflags nobuffer -flags low_delay -framedrop +---- +As noted previously, `vlc` no longer handles unencapsulated H.264 streams. + +In fact, support for unencapsulated H.264 can generally be quite poor so it is often better to send an MPEG-2 Transport Stream instead. Making use of `libav`, this can be accomplished with: + +[source,console] +---- +$ rpicam-vid -t 0 -n --codec libav --libav-format mpegts -o udp://: +---- + +In this case, we can also play the stream successfully with `vlc`: + +[source,console] +---- +$ vlc udp://@: +---- + +=== TCP + +You can also stream video over TCP. As before, we can send an unencapsulated H.264 stream over the network. To use a Raspberry Pi as a server: + +[source,console] +---- +$ rpicam-vid -t 0 -n --inline --listen -o tcp://0.0.0.0: +---- + +To view video streamed over TCP using a Raspberry Pi as a client, assuming the server is running at 30 frames per second, use the following command: + +[source,console] +---- +$ ffplay tcp://: -vf "setpts=N/30" -fflags nobuffer -flags low_delay -framedrop +---- + +But as with the UDP examples, it is often preferable to send an MPEG-2 Transport Stream as this is generally better supported. To do this, use: + +[source,console] +---- +$ rpicam-vid -t 0 -n --codec libav --libav-format mpegts -o tcp://0.0.0.0:?listen=1 +---- + +We can now play this back using a variety of media players, including `vlc`: + +[source,console] +---- +$ vlc tcp://: +---- + +=== RTSP + +We can use VLC as an RTSP server, however, we must send it an MPEG-2 Transport Stream as it no longer understands unencapsulated H.264: + +[source,console] +---- +$ rpicam-vid -t 0 -n --codec libav --libav-format mpegts -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' +---- + +To view video streamed over RTSP using a Raspberry Pi as a client, use the following command: + +[source,console] +---- +$ ffplay rtsp://:8554/stream1 -fflags nobuffer -flags low_delay -framedrop +---- + +Alternatively, use the following command on a client to stream using VLC: + +[source,console] +---- +$ vlc rtsp://:8554/stream1 +---- + +If you want to see a preview window on the server, just drop the `-n` option (see xref:camera_software.adoc#nopreview[`nopreview`]). + +=== `libav` and Audio + +We have already been using `libav` as the backend for network streaming. `libav` allows us to add an audio stream, so long as we're using a format - like the MPEG-2 Transport Stream - that permits audio data. + +We can take one of our previous commands, like the one for streaming an MPEG-2 Transport Stream over TCP, and simply add the `--libav-audio` option: + +[source,console] +---- +$ rpicam-vid -t 0 --codec libav --libav-format mpegts --libav-audio -o "tcp://:?listen=1" +---- + +You can stream over UDP with a similar command: + +[source,console] +---- +$ rpicam-vid -t 0 --codec libav --libav-format mpegts --libav-audio -o "udp://:" +---- + +=== GStreamer + +https://gstreamer.freedesktop.org/[GStreamer] is a Linux framework for reading, processing and playing multimedia files. We can also use it in conjunction with `rpicam-vid` for network streaming. + +This setup uses `rpicam-vid` to output an H.264 bitstream to stdout, though as we've done previously, we're going to encapsulate it in an MPEG-2 Transport Stream for better downstream compatibility. + +Then, we use the GStreamer `fdsrc` element to receive the bitstream, and extra GStreamer elements to send it over the network. On the server, run the following command to start the stream, replacing the `` placeholder with the IP address of the client or multicast address and replacing the `` placeholder with the port you would like to use for streaming: + +[source,console] +---- +$ rpicam-vid -t 0 -n --codec libav --libav-format mpegts -o - | gst-launch-1.0 fdsrc fd=0 ! udpsink host= port= +---- + +We could of course use anything (such as vlc) as the client, and the best GStreamer clients for playback are beyond the scope of this document. However, we note that the following pipeline (with the obvious substitutions) would work on a Pi 4 or earlier device: + +[source,console] +---- +$ gst-launch-1.0 udpsrc address= port= ! tsparse ! tsdemux ! h264parse ! queue ! v4l2h264dec ! autovideosink +---- + +For a Pi 5, replace `v4l2h264dec` by `avdec_h264`. + +TIP: To test this configuration, run the server and client commands in separate terminals on the same device, using `localhost` as the address. + +==== `libcamerasrc` GStreamer element + +`libcamera` provides a `libcamerasrc` GStreamer element which can be used directly instead of `rpicam-vid`. To use this element, run the following command on the server, replacing the `` placeholder with the IP address of the client or multicast address and replacing the `` placeholder with the port you would like to use for streaming. On a Pi 4 or earlier device, use: + +[source,console] +---- +$ gst-launch-1.0 libcamerasrc ! capsfilter caps=video/x-raw,width=640,height=360,format=NV12,interlace-mode=progressive ! v4l2h264enc extra-controls="controls,repeat_sequence_header=1" ! 'video/x-h264,level=(string)4' ! h264parse ! mpegtsmux ! udpsink host= port= +---- +On a Pi 5 you would have to replace `v4l2h264enc extra-controls="controls,repeat_sequence_header=1"` by `x264enc speed-preset=1 threads=1`. + +On the client we could use the same playback pipeline as we did just above, or other streaming media players. + +=== WebRTC + +Streaming over WebRTC (for example, to web browsers) is best accomplished using third party software. https://github.com/bluenviron/mediamtx[MediaMTX], for example, includes native Raspberry Pi camera support which makes it easy to use. + +To install it, download the latest version from the https://github.com/bluenviron/mediamtx/releases[releases] page. Raspberry Pi OS 64-bit users will want the "linux_arm64v8" compressed tar file (ending `.tar.gz`). Unpack it and you will get a `mediamtx` executable and a configuration file called `mediamtx.yml`. + +It's worth backing up the `mediamtx.yml` file because it documents many Raspberry Pi camera options that you may want to investigate later. + +To stream the camera, replace the contents of `mediamtx.yml` by: +---- +paths: + cam: + source: rpiCamera +---- +and start the `mediamtx` executable. On a browser, enter `http://:8889/cam` into the address bar. + +If you want MediaMTX to acquire the camera only when the stream is requested, add the following line to the previous `mediamtx.yml`: +---- + sourceOnDemand: yes +---- +Consult the original `mediamtx.yml` for additional configuration parameters that let you select the image size, the camera mode, the bitrate and so on - just search for `rpi`. + +==== Customised image streams with WebRTC + +MediaMTX is great if you want to stream just the camera images. But what if we want to add some extra information or overlay, or do some extra processing on the images? + +Before starting, ensure that you've built a version of `rpicam-apps` that includes OpenCV support. Check it by running + +[source,console] +---- +$ rpicam-hello --post-process-file rpicam-apps/assets/annotate_cv.json +---- +and looking for the overlaid text information at the top of the image. + +Next, paste the following into your `mediamtx.yml` file: +---- +paths: + cam: + source: udp://127.0.0.1:1234 +---- + +Now, start `mediamtx` and then, if you're using a Pi 5, in a new terminal window, enter: + +[source,console] +---- +$ rpicam-vid -t 0 -n --codec libav --libav-video-codec-opts "profile=baseline" --libav-format mpegts -o udp://127.0.0.1:1234?pkt_size=1316 --post-process-file rpicam-apps/assets/annotate_cv.json +---- +(On a Pi 4 or earlier device, leave out the `--libav-video-codec-opts "profile=baseline"` part of the command.) + +On another computer, you can now visit the same address as before, namely `http://:8889/cam`. + +The reason for specifying "baseline" profile on a Pi 5 is that MediaMTX doesn't support B frames, so we need to stop the encoder from producing them. On earlier devices, with hardware encoders, B frames are never generated so there is no issue. On a Pi 5 you could alternatively remove this option and replace it with `--low-latency` which will also prevent B frames, and produce a (slightly less well compressed) stream with reduced latency. + +[NOTE] +==== +If you notice occasional pauses in the video stream, this may be because the UDP receive buffers on the Pi (passing data from `rpicam-vid` to MediaMTX) are too small. To increase them permantently, add +---- +net.core.rmem_default=1000000 +net.core.rmem_max=1000000 +---- +to your `/etc/sysctl.conf` file (and reboot or run `sudo sysctl -p`). +==== \ No newline at end of file diff --git a/documentation/asciidoc/computers/camera/troubleshooting.adoc b/documentation/asciidoc/computers/camera/troubleshooting.adoc new file mode 100644 index 0000000000..4c94ce12f8 --- /dev/null +++ b/documentation/asciidoc/computers/camera/troubleshooting.adoc @@ -0,0 +1,16 @@ +== Troubleshooting + +If your Camera Module doesn't work like you expect, try some of the following fixes: + +* On Raspberry Pi 3 and earlier devices running Raspberry Pi OS _Bullseye_ or earlier: +** To enable hardware-accelerated camera previews, enable *Glamor*. To enable Glamor, enter `sudo raspi-config` in a terminal, select `Advanced Options` > `Glamor` > `Yes`. Then reboot your Raspberry Pi with `sudo reboot`. +** If you see an error related to the display driver, add `dtoverlay=vc4-fkms-v3d` or `dtoverlay=vc4-kms-v3d` to `/boot/config.txt`. Then reboot your Raspberry Pi with `sudo reboot`. +* On Raspberry Pi 3 and earlier, the graphics hardware can only support images up to 2048×2048 pixels, which places a limit on the camera images that can be resized into the preview window. As a result, video encoding of images larger than 2048 pixels wide produces corrupted or missing preview images. +* On Raspberry Pi 4, the graphics hardware can only support images up to 4096×4096 pixels, which places a limit on the camera images that can be resized into the preview window. As a result, video encoding of images larger than 4096 pixels wide produces corrupted or missing preview images. +* The preview window may show display tearing in a desktop environment. This is a known, unfixable issue. +* Check that the FFC (Flat Flexible Cable) is firmly seated, fully inserted, and that the contacts face the correct direction. The FFC should be evenly inserted, not angled. +* If you use a connector between the camera and your Raspberry Pi, check that the ports on the connector are firmly seated, fully inserted, and that the contacts face the correct direction. +* Check to make sure that the FFC (Flat Flexible Cable) is attached to the CSI (Camera Serial Interface), _not_ the DSI (Display Serial Interface). The connector fits into either port, but only the CSI port powers and controls the camera. Look for the `CSI` label printed on the board near the port. +* xref:os.adoc#update-software[Update to the latest software.] +* Try a different power supply. The Camera Module adds about 200-250mA to the power requirements of your Raspberry Pi. If your power supply is low quality, your Raspberry Pi may not be able to power the Camera module. +* If you've checked all the above issues and your Camera Module still doesn't work like you expect, try posting on our forums for more help. diff --git a/documentation/asciidoc/computers/camera/v4l2.adoc b/documentation/asciidoc/computers/camera/v4l2.adoc new file mode 100644 index 0000000000..7cc2ceabcc --- /dev/null +++ b/documentation/asciidoc/computers/camera/v4l2.adoc @@ -0,0 +1,44 @@ +== V4L2 drivers + +V4L2 drivers provide a standard Linux interface for accessing camera and codec features. Normally, Linux loads drivers automatically during boot. But in some situations you may need to xref:camera_software.adoc#configuration[load camera drivers explicitly]. + +=== Device nodes when using `libcamera` + +[cols="1,^3"] +|=== +| /dev/videoX | Default action + +| `video0` +| Unicam driver for the first CSI-2 receiver + +| `video1` +| Unicam driver for the second CSI-2 receiver + +| `video10` +| Video decode + +| `video11` +| Video encode + +| `video12` +| Simple ISP, can perform conversion and resizing between RGB/YUV formats in addition to Bayer to RGB/YUV conversion + +| `video13` +| Input to fully programmable ISP + +| `video14` +| High resolution output from fully programmable ISP + +| `video15` +| Low result output from fully programmable ISP + +| `video16` +| Image statistics from fully programmable ISP + +| `video19` +| HEVC decode +|=== + +=== Use the V4L2 drivers + +For more information on how to use the V4L2 drivers, see the https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/v4l2.html[V4L2 documentation]. diff --git a/documentation/asciidoc/computers/camera/webcams.adoc b/documentation/asciidoc/computers/camera/webcams.adoc new file mode 100644 index 0000000000..dbfe0c8e4c --- /dev/null +++ b/documentation/asciidoc/computers/camera/webcams.adoc @@ -0,0 +1,169 @@ +== Use a USB webcam + +Most Raspberry Pi devices have dedicated ports for camera modules. Camera modules are high-quality, highly-configurable cameras popular with Raspberry Pi users. + +However, for many purposes a USB webcam has everything you need to record pictures and videos from your Raspberry Pi. This section explains how to use a USB webcam with your Raspberry Pi. + +=== Install dependencies + +First, install the `fswebcam` package: + +[source,console] +---- +$ sudo apt install fswebcam +---- + +Next, add your username to the `video` group, otherwise you may see 'permission denied' errors: + +[source,console] +---- +$ sudo usermod -a -G video +---- + +To check that the user has been added to the group correctly, use the `groups` command. + +=== Take a photo + +Run the following command to take a picture using the webcam and save the image to a filename named `image.jpg`: + +[source,console] +---- +$ fswebcam image.jpg +---- + +You should see output similar to the following: + +---- +--- Opening /dev/video0... +Trying source module v4l2... +/dev/video0 opened. +No input was specified, using the first. +Adjusting resolution from 384x288 to 352x288. +--- Capturing frame... +Corrupt JPEG data: 2 extraneous bytes before marker 0xd4 +Captured frame in 0.00 seconds. +--- Processing captured image... +Writing JPEG image to 'image.jpg'. +---- + +.By default, `fswebcam` uses a low resolution and adds a banner displaying a timestamp. +image::images/webcam-image.jpg[By default, `fswebcam` uses a low resolution and adds a banner displaying a timestamp] + +To specify a different resolution for the captured image, use the `-r` flag, passing a width and height as two numbers separated by an `x`: + +[source,console] +---- +$ fswebcam -r 1280x720 image2.jpg +---- + +You should see output similar to the following: + +---- +--- Opening /dev/video0... +Trying source module v4l2... +/dev/video0 opened. +No input was specified, using the first. +--- Capturing frame... +Corrupt JPEG data: 1 extraneous bytes before marker 0xd5 +Captured frame in 0.00 seconds. +--- Processing captured image... +Writing JPEG image to 'image2.jpg'. +---- + +.Specify a resolution to capture a higher quality image. +image::images/webcam-image-high-resolution.jpg[Specify a resolution to capture a higher quality image] + +==== Remove the banner + +To remove the banner from the captured image, use the `--no-banner` flag: + +[source,console] +---- +$ fswebcam --no-banner image3.jpg +---- + +You should see output similar to the following: + +---- +--- Opening /dev/video0... +Trying source module v4l2... +/dev/video0 opened. +No input was specified, using the first. +--- Capturing frame... +Corrupt JPEG data: 2 extraneous bytes before marker 0xd6 +Captured frame in 0.00 seconds. +--- Processing captured image... +Disabling banner. +Writing JPEG image to 'image3.jpg'. +---- + +.Specify `--no-banner` to save the image without the timestamp banner. +image::images/webcam-image-no-banner.jpg[Specify `--no-banner` to save the image without the timestamp banner] + +=== Automate image capture + +Unlike xref:camera_software.adoc#rpicam-apps[`rpicam-apps`], `fswebcam` doesn't have any built-in functionality to substitute timestamps and numbers in output image names. This can be useful when capturing multiple images, since manually editing the file name every time you record an image can be tedious. Instead, use a Bash script to implement this functionality yourself. + +Create a new file named `webcam.sh` in your home folder. Add the following example code, which uses the `bash` programming language to save images to files with a file name containing the year, month, day, hour, minute, and second: + +[,bash] +---- +#!/bin/bash + +DATE=$(date +"%Y-%m-%d_%H-%M-%S") + +fswebcam -r 1280x720 --no-banner $DATE.jpg +---- + +Then, make the bash script executable by running the following command: + +[source,console] +---- +$ chmod +x webcam.sh +---- + +Run the script with the following command to capture an image and save it to a file with a timestamp for a name, similar to `2024-05-10_12-06-33.jpg`: + +[source,console] +---- +$ ./webcam.sh +---- + +You should see output similar to the following: + +---- +--- Opening /dev/video0... +Trying source module v4l2... +/dev/video0 opened. +No input was specified, using the first. +--- Capturing frame... +Corrupt JPEG data: 2 extraneous bytes before marker 0xd6 +Captured frame in 0.00 seconds. +--- Processing captured image... +Disabling banner. +Writing JPEG image to '2024-05-10_12-06-33.jpg'. +---- + +=== Capture a time lapse + +Use `cron` to schedule photo capture at a given interval. With the right interval, such as once a minute, you can capture a time lapse. + +First, open the cron table for editing: + +[source,console] +---- +$ crontab -e +---- + +Once you have the file open in an editor, add the following line to the schedule to take a picture every minute, replacing `` with your username: + +[,bash] +---- +* * * * * /home//webcam.sh 2>&1 +---- + +Save and exit, and you should see the following message: + +---- +crontab: installing new crontab +---- diff --git a/documentation/asciidoc/computers/camera_software.adoc b/documentation/asciidoc/computers/camera_software.adoc new file mode 100644 index 0000000000..a234811a7e --- /dev/null +++ b/documentation/asciidoc/computers/camera_software.adoc @@ -0,0 +1,61 @@ +include::camera/camera_usage.adoc[] + +include::camera/rpicam_apps_intro.adoc[] + +include::camera/rpicam_hello.adoc[] + +include::camera/rpicam_jpeg.adoc[] + +include::camera/rpicam_still.adoc[] + +include::camera/rpicam_vid.adoc[] + +include::camera/rpicam_raw.adoc[] + +include::camera/rpicam_detect.adoc[] + +include::camera/rpicam_configuration.adoc[] + +include::camera/rpicam_apps_multicam.adoc[] + +include::camera/rpicam_apps_packages.adoc[] + +include::camera/streaming.adoc[] + +include::camera/rpicam_options_common.adoc[] + +include::camera/rpicam_options_still.adoc[] + +include::camera/rpicam_options_vid.adoc[] + +include::camera/rpicam_options_libav.adoc[] + +include::camera/rpicam_options_detect.adoc[] + +include::camera/rpicam_apps_post_processing.adoc[] + +include::camera/rpicam_apps_post_processing_opencv.adoc[] + +include::camera/rpicam_apps_post_processing_tflite.adoc[] + +include::camera/rpicam_apps_post_processing_writing.adoc[] + +include::camera/rpicam_apps_building.adoc[] + +include::camera/rpicam_apps_writing.adoc[] + +include::camera/qt.adoc[] + +include::camera/libcamera_python.adoc[] + +include::camera/webcams.adoc[] + +include::camera/v4l2.adoc[] + +include::camera/csi-2-usage.adoc[] + +include::camera/libcamera_differences.adoc[] + +include::camera/troubleshooting.adoc[] + +include::camera/rpicam_apps_getting_help.adoc[] diff --git a/documentation/asciidoc/computers/compute-module.adoc b/documentation/asciidoc/computers/compute-module.adoc index 05c090516d..97810c8bc8 100644 --- a/documentation/asciidoc/computers/compute-module.adoc +++ b/documentation/asciidoc/computers/compute-module.adoc @@ -1,15 +1,13 @@ -include::compute-module/datasheet.adoc[] - -include::compute-module/designfiles.adoc[] +include::compute-module/introduction.adoc[] include::compute-module/cm-emmc-flashing.adoc[] +include::compute-module/cm-bootloader.adoc[] + include::compute-module/cm-peri-sw-guide.adoc[] include::compute-module/cmio-camera.adoc[] include::compute-module/cmio-display.adoc[] - - - +include::compute-module/datasheet.adoc[] diff --git a/documentation/asciidoc/computers/compute-module/cm-bootloader.adoc b/documentation/asciidoc/computers/compute-module/cm-bootloader.adoc new file mode 100644 index 0000000000..aea936e1a3 --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/cm-bootloader.adoc @@ -0,0 +1,55 @@ +== Compute Module EEPROM bootloader + +Since Compute Module 4, Compute Modules use an EEPROM bootloader. This bootloader lives in a small segment of on-board storage instead of the boot partition. As a result, it requires different procedures to update. Before using a Compute Module with an EEPROM bootloader in production, always follow these best practices: + +* Select a specific bootloader release. Verify that every Compute Module you use has that release. The version in the `usbboot` repo is always a recent stable release. +* Configure the boot device by xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[setting the `BOOT_ORDER` ]. +* Enable hardware write-protection on the bootloader EEPROM to ensure that the bootloader can't be modified on inaccessible products (such as remote or embedded devices). + +=== Flash Compute Module bootloader EEPROM + +To flash the bootloader EEPROM: + +. Set up the hardware as you would when xref:../computers/compute-module.adoc#flash-compute-module-emmc[flashing the eMMC], but ensure `EEPROM_nWP` is _not_ pulled low. +. Run the following command to write `recovery/pieeprom.bin` to the bootloader EEPROM: ++ +[source,console] +---- +$ ./rpiboot -d recovery +---- +. Once complete, `EEPROM_nWP` may be pulled low again. + +=== Flash storage devices other than SD cards + +The Linux-based https://github.com/raspberrypi/usbboot/blob/master/mass-storage-gadget/README.md[`mass-storage-gadget`] supports flashing of NVMe, eMMC and USB block devices. `mass-storage-gadget` writes devices faster than the firmware-based `rpiboot` mechanism, and also provides a UART console to the device for debugging. + +`usbboot` also includes a number of https://github.com/raspberrypi/usbboot/blob/master/Readme.md#compute-module-4-extensions[extensions] that enable you to interact with the EEPROM bootloader on a Compute Module. + +=== Update the Compute Module bootloader + +On Compute Modules with an EEPROM bootloader, ROM never runs `recovery.bin` from SD/eMMC. These Compute Modules disable the `rpi-eeprom-update` service by default, because eMMC is not removable and an invalid `recovery.bin` file could prevent the system from booting. + +You can override this behaviour with `self-update` mode. In `self-update` mode, you can update the bootloader from USB MSD or network boot. + +WARNING: `self-update` mode does not update the bootloader atomically. If a power failure occurs during an EEPROM update, you could corrupt the EEPROM. + +=== Modify the bootloader configuration + +To modify the Compute Module EEPROM bootloader configuration: + +. Navigate to the `usbboot/recovery` directory. +. If you require a specific bootloader release, replace `pieeprom.original.bin` with the equivalent from your bootloader release. +. Edit the default `boot.conf` bootloader configuration file to define a xref:../computers/raspberry-pi.adoc#BOOT_ORDER[`BOOT_ORDER`]: + * For network boot, use `BOOT_ORDER=0xf2`. + * For SD/eMMC boot, use `BOOT_ORDER=0xf1`. + * For USB boot failing over to eMMC, use `BOOT_ORDER=0xf15`. + * For NVMe boot, use `BOOT_ORDER=0xf6`. +. Run `./update-pieeprom.sh` to generate a new EEPROM image `pieeprom.bin` image file. +. If you require EEPROM write-protection, add `eeprom_write_protect=1` to `/boot/firmware/config.txt`. + * Once enabled in software, you can lock hardware write-protection by pulling the `EEPROM_nWP` pin low. +. Run the following command to write the updated `pieeprom.bin` image to EEPROM: ++ +[source,console] +---- +$ ../rpiboot -d . +---- diff --git a/documentation/asciidoc/computers/compute-module/cm-emmc-flashing.adoc b/documentation/asciidoc/computers/compute-module/cm-emmc-flashing.adoc index dc0c8ed799..664dd97c0d 100644 --- a/documentation/asciidoc/computers/compute-module/cm-emmc-flashing.adoc +++ b/documentation/asciidoc/computers/compute-module/cm-emmc-flashing.adoc @@ -1,174 +1,158 @@ -== Flashing the Compute Module eMMC +[[flash-compute-module-emmc]] +== Flash an image to a Compute Module -The Compute Module has an on-board eMMC device connected to the primary SD card interface. This guide explains how to write data to the eMMC storage using a Compute Module IO board. +TIP: To flash the same image to multiple Compute Modules, use the https://github.com/raspberrypi/rpi-sb-provisioner[Raspberry Pi Secure Boot Provisioner]. To customise an OS image to flash onto those devices, use https://github.com/RPi-Distro/pi-gen[pi-gen]. -Please also read the section in the xref:compute-module.adoc#datasheets-and-schematics[Compute Module Datasheets] +[[flashing-the-compute-module-emmc]] -=== Steps to Flash the eMMC +The Compute Module has an on-board eMMC device connected to the primary SD card interface. This guide explains how to flash (write) an operating system image to the eMMC storage of a single Compute Module. -To flash the Compute Module eMMC, you either need a Linux system (a Raspberry Pi is recommended, or Ubuntu on a PC) or a Windows system (Windows 10 is recommended). For BCM2837 (CM3), a bug which affected the Mac has been fixed, so this will also work. +**Lite** variants of Compute Modules do not have on-board eMMC. Instead, follow the procedure to flash a storage device for other Raspberry Pi devices at xref:../computers/getting-started.adoc#installing-the-operating-system[Install an operating system]. -NOTE: There is a bug in the BCM2835 (CM1) bootloader which returns a slightly incorrect USB packet to the host. Most USB hosts seem to ignore this benign bug and work fine; we do, however, see some USB ports that don't work due to this bug. We don't quite understand why some ports fail, as it doesn't seem to be correlated with whether they are USB2 or USB3 (we have seen both types working), but it's likely to be specific to the host controller and driver. This bug has been fixed in BCM2837. +=== Prerequisites -==== For Windows Users +To flash the Compute Module eMMC, you need the following: -Under Windows, an installer is available to install the required drivers and boot tool automatically. Alternatively, a user can compile and run it using Cygwin and/or install the drivers manually. +* Another computer, referred to in this guide as the *host device*. You can use Linux (we recommend Raspberry Pi OS or Ubuntu), Windows 11, or macOS. +* The Compute Module IO Board xref:compute-module.adoc#io-board-compatibility[that corresponds to your Compute Module model]. +* A micro USB cable, or a USB-C cable for Compute Module models since CM5IO. -==== Windows Installer +TIP: In some cases, USB hubs can prevent the host device from recognising the Compute Module. If your host device does not recognise the Compute Module, try connecting the Compute Module directly to the host device. For more diagnostic tips, see https://github.com/raspberrypi/usbboot?tab=readme-ov-file#troubleshooting[the usbboot troubleshooting guide]. -For those who just want to enable the Compute Module eMMC as a mass storage device under Windows, the stand-alone installer is the recommended option. This installer has been tested on Windows 10 32-bit and 64-bit, and Windows XP 32-bit. +=== Set up the IO Board -Please ensure you are not writing to any USB devices whilst the installer is running. +To begin, physically set up your IO Board. This includes connecting the Compute Module and host device to the IO Board. -. Download and run the https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe[Windows installer] to install the drivers and boot tool. -. Plug your host PC USB into the CMIO USB SLAVE port, making sure J4 is set to the EN position. -. Apply power to the CMIO board; Windows should now find the hardware and install the driver. -. Once the driver installation is complete, run the `RPiBoot.exe` tool that was previously installed. -. After a few seconds, the Compute Module eMMC will pop up under Windows as a disk (USB mass storage device). +[tabs] +====== +Compute Module 5 IO Board:: ++ +To set up the Compute Module 5 IO Board: ++ +. Connect the Compute Module to the IO board. When connected, the Compute Module should lie flat. +. Fit `nRPI_BOOT` to J2 (`disable eMMC Boot`) on the IO board jumper. +. Connect a cable from USB-C slave port J11 on the IO board to the host device. -=== Setting up the CMIO board +Compute Module 4 IO Board:: ++ +To set up the Compute Module 4 IO Board: ++ +. Connect the Compute Module to the IO board. When connected, the Compute Module should lie flat. +. Fit `nRPI_BOOT` to J2 (`disable eMMC Boot`) on the IO board jumper. +. Connect a cable from micro USB slave port J11 on the IO board to the host device. -==== Compute Module 4 +Compute Module IO Board:: ++ +To set up the Compute Module IO Board: ++ +. Connect the Compute Module to the IO board. When connected, the Compute Module should lie parallel to the board, with the engagement clips firmly clicked into place. +. Set J4 (`USB SLAVE BOOT ENABLE`) to 1-2 = (`USB BOOT ENABLED`) +. Connect a cable from micro USB slave port J15 on the IO board to the host device. +====== -Ensure the Compute Module is fitted correctly installed on the IO board. It should lie flat on the IO board. +=== Set up the host device -* Make sure that `nRPI_BOOT` which is J2 (`disable eMMC Boot`) on the IO board is set to the 'EN' position. -* Use a micro USB cable to connect the micro USB slave port J11 on IO board to the host device. -* Do not power up yet. +Next, let's set up software on the host device. -==== Compute Module 1 and 3 +TIP: For a host device, we recommend a Raspberry Pi 4 or newer running 64-bit Raspberry Pi OS. -Ensure the Compute Module itself is correctly installed on the IO board. It should lie parallel with the board, with the engagement clips clicked into place. - -* Make sure that J4 (USB SLAVE BOOT ENABLE) is set to the 'EN' position. -* Use a micro USB cable to connect the micro USB slave port J15 on IO board to the host device. -* Do not power up yet. - -==== Building `rpiboot` on your host system (Cygwin/Linux) - -We will be using Git to get the rpiboot source code, so ensure Git is installed. In Cygwin, use the Cygwin installer. On a Pi or other Debian-based Linux machine, use the following command: - -[,bash] +[tabs] +====== +Linux:: ++ +To set up software on a Linux host device: ++ +. Run the following command to install `rpiboot` (or, alternatively, https://github.com/raspberrypi/usbboot[build `rpiboot` from source]): ++ +[source,console] ---- -sudo apt install git +$ sudo apt install rpiboot ---- - -Git may produce an error if the date is not set correctly. On a Raspberry Pi, enter the following to correct this: - -[,bash] ----- -sudo date MMDDhhmm ----- - -where `MM` is the month, `DD` is the date, and `hh` and `mm` are hours and minutes respectively. - -Clone the `usbboot` tool repository: - -[,bash] +. Connect the IO Board to power. +. Then, run `rpiboot`: ++ +[source,console] ---- -git clone --depth=1 https://github.com/raspberrypi/usbboot -cd usbboot +$ sudo rpiboot ---- +. After a few seconds, the Compute Module should appear as a mass storage device. Check the `/dev/` directory, likely `/dev/sda` or `/dev/sdb`, for the device. Alternatively, run `lsblk` and search for a device with a storage capacity that matches the capacity of your Compute Module. -`libusb` must be installed. If you are using Cygwin, please make sure `libusb` is installed as previously described. On Raspberry Pi OS or other Debian-based Linux, enter the following command: - -[,bash] +macOS:: ++ +To set up software on a macOS host device: ++ +. First, https://github.com/raspberrypi/usbboot?tab=readme-ov-file#macos[build `rpiboot` from source]. +. Connect the IO Board to power. +. Then, run the `rpiboot` executable with the following command: ++ +[source,console] ---- -sudo apt install libusb-1.0-0-dev +$ rpiboot -d mass-storage-gadget64 ---- +. When the command finishes running, you should see a message stating "The disk you inserted was not readable by this computer." Click **Ignore**. Your Compute Module should now appear as a mass storage device. -Now build and install the `usbboot` tool: +Windows:: ++ +To set up software on a Windows 11 host device: ++ +. Download the https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe[Windows installer] or https://github.com/raspberrypi/usbboot[build `rpiboot` from source]. +. Double-click on the installer to run it. This installs the drivers and boot tool. Do not close any driver installation windows which appear during the installation process. +. Reboot +. Connect the IO Board to power. Windows should discover the hardware and configure the required drivers. +. On CM4 and later devices, select **Raspberry Pi - Mass Storage Gadget - 64-bit** from the start menu. After a few seconds, the Compute Module eMMC or NVMe will appear as USB mass storage devices. This also provides a debug console as a serial port gadget. +. On CM3 and older devices, select **rpiboot**. Double-click on `RPiBoot.exe` to run it. After a few seconds, the Compute Module eMMC should appear as a USB mass storage device. -[,bash] ----- -make ----- +====== -Run the `usbboot` tool and it will wait for a connection: -[,bash] ----- -sudo ./rpiboot ----- +=== Flash the eMMC -Now plug the host machine into the Compute Module IO board USB slave port and power the CMIO board on. The `rpiboot` tool will discover the Compute Module and send boot code to allow access to the eMMC. +You can use xref:../computers/getting-started.adoc#raspberry-pi-imager[Raspberry Pi Imager] to flash an operating system image to a Compute Module. -For more information run +Alternatively, use `dd` to write a raw OS image (such as xref:../computers/os.adoc#introduction[Raspberry Pi OS]) to your Compute Module. Run the following command, replacing `/dev/sdX` with the path to the mass storage device representation of your Compute Module and `raw_os_image.img` with the path to your raw OS image: +[source,console] ---- -./rpiboot -h +$ sudo dd if=raw_os_image.img of=/dev/sdX bs=4MiB ---- -==== Writing to the eMMC (Windows) - -After `rpiboot` completes, a new USB mass storage drive will appear in Windows. We recommend following this xref:getting-started.adoc#installing-images-on-windows[guide] and using Win32DiskImager to write images to the drive, rather than trying to use `/dev/sda` etc. from Cygwin. - -Make sure J4 (USB SLAVE BOOT ENABLE) / J2 (nRPI_BOOT) is set to the disabled position and/or nothing is plugged into the USB slave port. Power cycling the IO board should now result in the Compute Module booting from eMMC. +Once the image has been written, disconnect and reconnect the Compute Module. You should now see two partitions (for Raspberry Pi OS): -==== Writing to the eMMC (Linux) - -After `rpiboot` completes, you will see a new device appear; this is commonly `/dev/sda` on a Pi but it could be another location such as `/dev/sdb`, so check in `/dev/` or run `lsblk` before running `rpiboot` so you can see what changes. - -You now need to write a raw OS image (such as https://www.raspberrypi.org/downloads/raspbian/[Raspberry Pi OS]) to the device. Note the following command may take some time to complete, depending on the size of the image: (Change `/dev/sdX` to the appropriate device.) - -[,bash] ----- -sudo dd if=raw_os_image_of_your_choice.img of=/dev/sdX bs=4MiB ----- - -Once the image has been written, unplug and re-plug the USB; you should see two partitions appear (for Raspberry Pi OS) in `/dev`. In total, you should see something similar to this: - -[,bash] +[source,console] ---- /dev/sdX <- Device /dev/sdX1 <- First partition (FAT) /dev/sdX2 <- Second partition (Linux filesystem) ---- -The `/dev/sdX1` and `/dev/sdX2` partitions can now be mounted normally. - -Make sure J4 (USB SLAVE BOOT ENABLE) / J2 (nRPI_BOOT) is set to the disabled position and/or nothing is plugged into the USB slave port. Power cycling the IO board should now result in the Compute Module booting from eMMC. - -[[cm4bootloader]] -=== Compute Module 4 Bootloader +You can mount the `/dev/sdX1` and `/dev/sdX2` partitions normally. -The default bootloader configuration on CM4 is designed to support bringup and development on a https://www.raspberrypi.org/products/compute-module-4-io-board[Compute Module 4 IO board] and the software version flashed at manufacture may be older than the latest release. For final products please consider:- +=== Boot from eMMC -* Selecting and verifying a specific bootloader release. The version in the `usbboot` repo is always a recent stable release. -* Configuring the boot device (e.g. network boot). See `BOOT_ORDER` section in the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[bootloader configuration] guide. -* Enabling hardware write protection on the bootloader EEPROM to ensure that the bootloader can't be modified on remote/inaccessible products. +[tabs] +====== +Compute Module 5 IO Board:: ++ +Disconnect `nRPI_BOOT` from J2 (`disable eMMC Boot`) on the IO board jumper. -N.B. The Compute Module 4 ROM never runs `recovery.bin` from SD/EMMC and the `rpi-eeprom-update` service is not enabled by default. This is necessary because the EMMC is not removable and an invalid `recovery.bin` file would prevent the system from booting. This can be overridden and used with `self-update` mode where the bootloader can be updated from USB MSD or Network boot. However, `self-update` mode is not an atomic update and therefore not safe in the event of a power failure whilst the EEPROM was being updated. +Compute Module 4 IO Board:: ++ +Disconnect `nRPI_BOOT` from J2 (`disable eMMC Boot`) on the IO board jumper. -==== Modifying the bootloader configuration +Compute Module IO Board:: ++ +Set J4 (`USB SLAVE BOOT ENABLE`) to 2-3 (`USB BOOT DISABLED`). +====== -To modify the CM4 bootloader configuration:- +==== Boot -* Replace `recovery/pieeprom.original.bin` if a specific bootloader release is required. -* Edit the default `recovery/boot.conf` bootloader configuration file. Typically, at least the BOOT_ORDER must be updated:- - ** For network boot `BOOT_ORDER=0xf2` - ** For SD/EMMC boot `BOOT_ORDER=0xf1` - ** For USB boot failing over to EMMC `BOOT_ORDER=0xf15` -* Run `recovery/update-pieeprom.sh` to update the EEPROM image `pieeprom.bin` image file. -* If EEPROM write protection is required then edit `recovery/config.txt` and add `eeprom_write_protect=1`. Hardware write-protection must be enabled via software and then locked by pulling the `EEPROM_nWP` pin low. +Disconnect the USB slave port. Power-cycle the IO board to boot the Compute Module from the new image you just wrote to eMMC. -The pieeprom.bin file is now ready to be flashed to the Compute Module 4. +=== Known issues -==== Flashing the bootloader EEPROM - Compute Module 4 - -To flash the bootloader EEPROM follow the same hardware setup as for flashing the EMMC but also ensure EEPROM_nWP is NOT pulled low. Once complete `EEPROM_nWP` may be pulled low again. - -[,bash] ----- -# Writes recovery/pieeprom.bin to the bootloader EEPROM. -./rpiboot -d recovery ----- - -=== Troubleshooting - -For a small percentage of Raspberry Pi Compute Module 3s, booting problems have been reported. We have traced these back to the method used to create the FAT32 partition; we believe the problem is due to a difference in timing between the BCM2835/6/7 and the newer eMMC devices. The following method of creating the partition is a reliable solution in our hands. - -[,bash] +* A small percentage of CM3 devices may experience problems booting. We have traced these back to the method used to create the FAT32 partition; we believe the problem is due to a difference in timing between the CPU and eMMC. If you have trouble booting your CM3, create the partitions manually with the following commands: ++ +[source,console] ---- $ sudo parted /dev/ (parted) mkpart primary fat32 4MiB 64MiB @@ -176,3 +160,5 @@ $ sudo parted /dev/ $ sudo mkfs.vfat -F32 /dev/ $ sudo cp -r /* ---- + +* The CM1 bootloader returns a slightly incorrect USB packet to the host. Most USB hosts ignore it, but some USB ports don't work due to this bug. CM3 fixed this bug. diff --git a/documentation/asciidoc/computers/compute-module/cm-peri-sw-guide.adoc b/documentation/asciidoc/computers/compute-module/cm-peri-sw-guide.adoc index c47c30d8e2..cb1beac887 100644 --- a/documentation/asciidoc/computers/compute-module/cm-peri-sw-guide.adoc +++ b/documentation/asciidoc/computers/compute-module/cm-peri-sw-guide.adoc @@ -1,269 +1,235 @@ -== Attaching and Enabling Peripherals +== Wire peripherals -NOTE: Unless explicitly stated otherwise, these instructions will work identically on Compute Module and Compute Module 3 Module+IO board(s). +This guide helps developers wire up peripherals to the Compute Module pins, and explains how to enable these peripherals in software. -This guide is designed to help developers using the Compute Module (and Compute Module 3) get to grips with how to wire up peripherals to the Compute Module pins, and how to make changes to the software to enable these peripherals to work correctly. +Most of the pins of the SoC, including the GPIO, two CSI camera interfaces, two DSI display interfaces, and HDMI are available for wiring. You can can usually leave unused pins disconnected. -The Compute Module (CM) and Compute Module 3 (CM3) contain the Raspberry Pi BCM2835 (or BCM2837 for CM3) system on a chip (SoC) or 'processor', memory, and eMMC. The eMMC is similar to an SD card but is soldered onto the board. Unlike SD cards, the eMMC is specifically designed to be used as a disk and has extra features that make it more reliable in this use case. Most of the pins of the SoC (GPIO, two CSI camera interfaces, two DSI display interfaces, HDMI etc) are freely available and can be wired up as the user sees fit (or, if unused, can usually be left unconnected). The Compute Module is a DDR2 SODIMM form-factor-compatible module, so any DDR2 SODIMM socket should be able to be used +Compute Modules that come in the DDR2 SODIMM form factor are physically compatible with any DDR2 SODIMM socket. However, the pinout is **not** the same as SODIMM memory modules. -NOTE: The pinout is NOT the same as an actual SODIMM memory module. +To use a Compute Module, a user must design a motherboard that: -To use the Compute Module, a user needs to design a (relatively simple) 'motherboard' which can provide power to the Compute Module (3.3V and 1.8V at minimum), and which connects the pins to the required peripherals for the user's application. +* provides power to the Compute Module (3.3V and 1.8V at minimum) +* connects the pins to the required peripherals for the user's application -Raspberry Pi provides a minimal motherboard for the Compute Module (called the Compute Module IO Board, or CMIO Board) which powers the module, brings out the GPIO to pin headers, and brings the camera and display interfaces out to FFC connectors. It also provides HDMI, USB, and an 'ACT' LED, as well as the ability to program the eMMC of a module via USB from a PC or Raspberry Pi. +This guide first explains the boot process and how Device Tree describes attached hardware. -This guide first explains the boot process and how Device Tree is used to describe attached hardware; these are essential things to understand when designing with the Compute Module. It then provides a worked example of attaching an I2C and an SPI peripheral to a CMIO (or CMIO V3 for CM3) Board and creating the Device Tree files necessary to make both peripherals work under Linux, starting from a vanilla Raspberry Pi OS image. +Then, we'll explain how to attach an I2C and an SPI peripheral to an IO Board. Finally, we'll create the Device Tree files necessary to use both peripherals with Raspberry Pi OS. === BCM283x GPIOs -BCM283x has three banks of General-Purpose Input/Output (GPIO) pins: 28 pins on Bank 0, 18 pins on Bank 1, and 8 pins on Bank 2, making 54 pins in total. These pins can be used as true GPIO pins, i.e. software can set them as inputs or outputs, read and/or set state, and use them as interrupts. They also can be set to 'alternate functions' such as I2C, SPI, I2S, UART, SD card, and others. +BCM283x has three banks of general-purpose input/output (GPIO) pins: 28 pins on Bank 0, 18 pins on Bank 1, and 8 pins on Bank 2, for a total of 54 pins. These pins can be used as true GPIO pins: software can set them as inputs or outputs, read and/or set state, and use them as interrupts. They also can run alternate functions such as I2C, SPI, I2S, UART, SD card, and others. -On a Compute Module, both Bank 0 and Bank 1 are free to use. Bank 2 is used for eMMC and HDMI hot plug detect and ACT LED / USB boot control. +You can use Bank 0 or Bank 1 on any Compute Module. Don't use Bank 2: it controls eMMC, HDMI hot plug detect, and ACT LED/USB boot control. -It is useful on a running system to look at the state of each of the GPIO pins (what function they are set to, and the voltage level at the pin) so that you can see if the system is set up as expected. This is particularly helpful if you want to see if a Device Tree is working as expected, or to get a look at the pin states during hardware debug. +Use `pinctrl` to check the voltage and function of the GPIO pins to see if your Device Tree is working as expected. -Raspberry Pi provides the `raspi-gpio` package which is a tool for hacking and debugging GPIO +=== BCM283x boot process -NOTE: You need to run `raspi-gpio` as root. +BCM283x devices have a VideoCore GPU and Arm CPU cores. The GPU consists of a DSP processor and hardware accelerators for imaging, video encode and decode, 3D graphics, and image compositing. -To install `raspi-gpio`: +In BCM283x devices, the DSP core in the GPU boots first. It handles setup before booting up the main Arm processors. ----- -sudo apt install raspi-gpio ----- - -If `apt` can't find the `raspi-gpio` package, you will need to do an update first: - ----- -sudo apt update ----- - -To get help on `raspi-gpio`, run it with the `help` argument: - ----- -sudo raspi-gpio help ----- - -For example, to see the current function and level of all GPIO pins use: +Raspberry Pi BCM283x devices have a three-stage boot process: ----- -sudo raspi-gpio get ----- - -NOTE: `raspi-gpio` can be used with the `funcs` argument to get a list of all supported GPIO functions per pin. It will print out a table in CSV format. The idea is to pipe the table to a `.csv` file and then load this file using e.g. Excel: - ----- -sudo raspi-gpio funcs > gpio-funcs.csv ----- +* The GPU DSP comes out of reset and executes code from the small internal boot ROM. This code loads a second-stage bootloader via an external interface. This code first looks for a second-stage boot loader on the boot device called `bootcode.bin` on the boot partition. If no boot device is found or `bootcode.bin` is not found, the boot ROM waits in USB boot mode for a host to provide a second-stage boot loader (`usbbootcode.bin`). +* The second-stage boot loader is responsible for setting up the LPDDR2 SDRAM interface and other critical system functions. Once set up, the second-stage boot loader loads and executes the main GPU firmware (`start.elf`). +* `start.elf` handles additional system setup and boots up the Arm processor subsystem. It contains the GPU firmware. The GPU firmware first reads `dt-blob.bin` to determine initial GPIO pin states and GPU-specific interfaces and clocks, then parses `config.txt`. It then loads a model-specific Arm device tree file and any Device Tree overlays specified in `config.txt` before starting the Arm subsystem and passing the Device Tree data to the booting Linux kernel. -=== BCM283x Boot Process - -BCM283x devices consist of a VideoCore GPU and ARM CPU cores. The GPU is in fact a system consisting of a DSP processor and hardware accelerators for imaging, video encode and decode, 3D graphics, and image compositing. +=== Device Tree -In BCM283x devices, it is the DSP core in the GPU that boots first. It is responsible for general setup and housekeeping before booting up the main ARM processor(s). +xref:configuration.adoc#device-trees-overlays-and-parameters[Linux Device Tree for Raspberry Pi] encodes information about hardware attached to a system as well as the drivers used to communicate with that hardware. -The BCM283x devices as used on Raspberry Pi and Compute Module boards have a three-stage boot process: +The boot partition contains several binary Device Tree (`.dtb`) files. The Device Tree compiler creates these binary files using human-readable Device Tree descriptions (`.dts`). -. The GPU DSP comes out of reset and executes code from a small internal ROM (the boot ROM). The sole purpose of this code is to load a second stage boot loader via one of the external interfaces. On a Raspberry Pi or Compute Module, this code first looks for a second stage boot loader on the SD card (eMMC); it expects this to be called `bootcode.bin` and to be on the first partition (which must be FAT32). If no SD card is found or `bootcode.bin` is not found, the Boot ROM sits and waits in 'USB boot' mode, waiting for a host to give it a second stage boot loader via the USB interface. -. The second stage boot loader (`bootcode.bin` on the sdcard or `usbbootcode.bin` for usb boot) is responsible for setting up the LPDDR2 SDRAM interface and various other critical system functions and then loading and executing the main GPU firmware (called `start.elf`, again on the primary SD card partition). -. `start.elf` takes over and is responsible for further system setup and booting up the ARM processor subsystem, and contains the firmware that runs on the various parts of the GPU. It first reads `dt-blob.bin` to determine initial GPIO pin states and GPU-specific interfaces and clocks, then parses `config.txt`. It then loads an ARM device tree file (e.g. `bcm2708-rpi-cm.dtb` for a Compute Module) and any device tree overlays specified in `config.txt` before starting the ARM subsystem and passing the device tree data to the booting Linux kernel. +The boot partition contains two different types of Device Tree files. One is used by the GPU only; the rest are standard Arm Device Tree files for each of the BCM283x-based Raspberry Pi products: -=== Device Tree +* `dt-blob.bin` (used by the GPU) +* `bcm2708-rpi-b.dtb` (Used for Raspberry Pi 1 Models A and B) +* `bcm2708-rpi-b-plus.dtb` (Used for Raspberry Pi 1 Models B+ and A+) +* `bcm2709-rpi-2-b.dtb` (Used for Raspberry Pi 2 Model B) +* `bcm2710-rpi-3-b.dtb` (Used for Raspberry Pi 3 Model B) +* `bcm2708-rpi-cm.dtb` (Used for Raspberry Pi Compute Module 1) +* `bcm2710-rpi-cm3.dtb` (Used for Raspberry Pi Compute Module 3) -http://www.devicetree.org/[Device Tree] is a special way of encoding all the information about the hardware attached to a system (and consequently required drivers). +During boot, the user can specify a specific Arm Device Tree to use via the `device_tree` parameter in `config.txt`. For example, the line `device_tree=mydt.dtb` in `config.txt` specifies an Arm Device Tree in a file named `mydt.dtb`. -On a Pi or Compute Module there are several files in the first FAT partition of the SD/eMMC that are binary 'Device Tree' files. These binary files (usually with extension `.dtb`) are compiled from human readable text descriptions (usually files with extension `.dts`) by the Device Tree compiler. +You can create a full Device Tree for a Compute Module product, but we recommend using **overlays** instead. Overlays add descriptions of non-board-specific hardware to the base Device Tree. This includes GPIO pins used and their function, as well as the devices attached, so that the correct drivers can be loaded. The bootloader merges overlays with the base Device Tree before passing the Device Tree to the Linux kernel. Occasionally the base Device Tree changes, usually in a way that will not break overlays. -On a standard Raspberry Pi OS image in the first (FAT) partition you will find two different types of device tree files, one is used by the GPU only and the rest are standard ARM device tree files for each of the BCM283x based Pi products: +Use the `dtoverlay` parameter in `config.txt` to load Device Tree overlays. Raspberry Pi OS assumes that all overlays are located in the `/overlays` directory and use the suffix `-overlay.dtb`. For example, the line `dtoverlay=myoverlay` loads the overlay `/overlays/myoverlay-overlay.dtb`. -* `dt-blob.bin` (used by the GPU) -* `bcm2708-rpi-b.dtb` (Used for Pi model A and B) -* `bcm2708-rpi-b-plus.dtb` (Used for Pi model B+ and A+) -* `bcm2709-rpi-2-b.dtb` (Used for Pi 2 model B) -* `bcm2710-rpi-3-b.dtb` (Used for Pi 3 model B) -* `bcm2708-rpi-cm.dtb` (Used for Pi Compute Module) -* `bcm2710-rpi-cm3.dtb` (Used for Pi Compute Module 3) +To wire peripherals to a Compute Module, describe all hardware attached to the Bank 0 and Bank 1 GPIOs in an overlay. This allows you to use standard Raspberry Pi OS images, since the overlay is merged into the standard base Device Tree. Alternatively, you can define a custom Device Tree for your application, but you won't be able to use standard Raspberry Pi OS images. Instead, you must create a modified Raspberry Pi OS image that includes your custom device tree for every OS update you wish to distribute. If the base overlay changes, you might need to update your customised Device Tree. -NOTE: `dt-blob.bin` by default does not exist as there is a 'default' version compiled into `start.elf`, but for Compute Module projects it will often be necessary to provide a `dt-blob.bin` (which overrides the default built-in file). +=== `dt-blob.bin` -NOTE: `dt-blob.bin` is in compiled device tree format, but is only read by the GPU firmware to set up functions exclusive to the GPU - see below. +When `start.elf` runs, it first reads `dt-blob.bin`. This is a special form of Device Tree blob which tells the GPU how to set up the GPIO pin states. -* A guide to xref:configuration.adoc#changing-the-default-pin-configuration[creating `dt-blob.bin`]. -* A guide to the xref:configuration.adoc#device-trees-overlays-and-parameters[Linux Device Tree for Raspberry Pi]. +`dt-blob.bin` contains information about GPIOs and peripherals controlled by the GPU, instead of the SoC. For example, the GPU manages Camera Modules. The GPU needs exclusive access to an I2C interface and a couple of pins to talk to a Camera Module. -During boot, the user can specify a specific ARM device tree to use via the `device_tree` parameter in `config.txt`, for example adding the line `device_tree=mydt.dtb` to `config.txt` where `mydt.dtb` is the dtb file to load instead of one of the standard ARM dtb files. While a user can create a full device tree for their Compute Module product, the recommended way to add hardware is to use overlays (see next section). +On most Raspberry Pi models, I2C0 is reserved for exclusive GPU use. `dt-blob.bin` defines the GPIO pins used for I2C0. -In addition to loading an ARM dtb, `start.elf` supports loading additional Device Tree 'overlays' via the `dtoverlay` parameter in `config.txt`, for example adding as many `dtoverlay=myoverlay` lines as required as overlays to `config.txt`, noting that overlays live in `/overlays` and are suffixed `-overlay.dtb` e.g. `/overlays/myoverlay-overlay.dtb`. Overlays are merged with the base dtb file before the data is passed to the Linux kernel when it starts. +By default, `dt-blob.bin` does not exist. Instead, `start.elf` includes a built-in version of the file. Many Compute Module projects provide a custom `dt-blob.bin` which overrides the default built-in file. -Overlays are used to add data to the base dtb that (nominally) describes non board-specific hardware. This includes GPIO pins used and their function, as well as the device(s) attached, so that the correct drivers can be loaded. The convention is that on a Raspberry Pi, all hardware attached to the Bank0 GPIOs (the GPIO header) should be described using an overlay. On a Compute Module all hardware attached to the Bank0 and Bank1 GPIOs should be described in an overlay file. You don't have to follow these conventions: you can roll all the information into one single dtb file, as previously described, replacing `bcm2708-rpi-cm.dtb`. However, following the conventions means that you can use a 'standard' Raspberry Pi OS release, with its standard base dtb and all the product-specific information contained in a separate overlay. Occasionally the base dtb might change - usually in a way that will not break overlays - which is why using an overlay is suggested. +`dt-blob.bin` specifies: -=== dt-blob.bin +* the pin used for HDMI hot plug detect +* GPIO pins used as a GPCLK output +* an ACT LED that the GPU can use while booting -When `start.elf` runs, it first reads something called `dt-blob.bin`. This is a special form of Device Tree blob which tells the GPU how to (initially) set up the GPIO pin states, and also any information about GPIOs/peripherals that are controlled (owned) by the GPU, rather than being used via Linux on the ARM. For example, the Raspberry Pi Camera peripheral is managed by the GPU, and the GPU needs exclusive access to an I2C interface to talk to it, as well as a couple of control pins. I2C0 on most Pi Boards and Compute Modules is nominally reserved for exclusive GPU use. The information on which GPIO pins the GPU should use for I2C0, and to control the camera functions, comes from `dt-blob.bin`. +https://datasheets.raspberrypi.com/cm/minimal-cm-dt-blob.dts[`minimal-cm-dt-blob.dts`] is an example `.dts` device tree file. It sets up HDMI hot plug detection, an ACT LED, and sets all other GPIOs as inputs with default pulls. -NOTE: the `start.elf` firmware has a xref:configuration.adoc#changing-the-default-pin-configuration['built-in' default] `dt-blob.bin` which is used if no `dt-blob.bin` is found on the root of the first FAT partition. Most Compute Module projects will want to provide their own custom `dt-blob.bin`. Note that `dt-blob.bin` specifies which pin is for HDMI hot plug detect, although this should never change on Compute Module. It can also be used to set up a GPIO as a GPCLK output, and specify an ACT LED that the GPU can use while booting. Other functions may be added in future. +To compile `minimal-cm-dt-blob.dts` to `dt-blob.bin`, use the xref:configuration.adoc#device-trees-overlays-and-parameters[Device Tree compiler] `dtc`. +To install `dtc` on a Raspberry Pi, run the following command: -https://datasheets.raspberrypi.org/cm/minimal-cm-dt-blob.dts[minimal-cm-dt-blob.dts] is an example `.dts` device tree file that sets up the HDMI hot plug detect and ACT LED and sets all other GPIOs to be inputs with default pulls. +[source,console] +---- +$ sudo apt install device-tree-compiler +---- -To compile the `minimal-cm-dt-blob.dts` to `dt-blob.bin` use the Device Tree Compiler `dtc`: +Then, run the follow command to compile `minimal-cm-dt-blob.dts` into `dt-blob.bin`: +[source,console] ---- -dtc -I dts -O dtb -o dt-blob.bin minimal-cm-dt-blob.dts +$ dtc -I dts -O dtb -o dt-blob.bin minimal-cm-dt-blob.dts ---- -=== ARM Linux Device Tree +For more information, see our xref:configuration.adoc#change-the-default-pin-configuration[guide to creating `dt-blob.bin`]. -After `start.elf` has read `dt-blob.bin` and set up the initial pin states and clocks, it reads xref:config_txt.adoc[`config.txt`] which contains many other options for system setup. +=== Arm Linux Device Tree -After reading `config.txt` another device tree file specific to the board the hardware is running on is read: this is `bcm2708-rpi-cm.dtb` for a Compute Module, or `bcm2710-rpi-cm.dtb` for CM3. This file is a standard ARM Linux device tree file, which details how hardware is attached to the processor: what peripheral devices exist in the SoC and where, which GPIOs are used, what functions those GPIOs have, and what physical devices are connected. This file will set up the GPIOs appropriately, overwriting the pin state set up in `dt-blob.bin` if it is different. It will also try to load driver(s) for the specific device(s). +After `start.elf` reads `dt-blob.bin` and sets up the initial pin states and clocks, it reads xref:config_txt.adoc[`config.txt`], which contains many other options for system setup. -Although the `bcm2708-rpi-cm.dtb` file can be used to load all attached devices, the recommendation for Compute Module users is to leave this file alone. Instead, use the one supplied in the standard Raspberry Pi OS software image, and add devices using a custom 'overlay' file as previously described. The `bcm2708-rpi-cm.dtb` file contains (disabled) entries for the various peripherals (I2C, SPI, I2S etc.) and no GPIO pin definitions, apart from the eMMC/SD Card peripheral which has GPIO defs and is enabled, because it is always on the same pins. The idea is that the separate overlay file will enable the required interfaces, describe the pins used, and also describe the required drivers. The `start.elf` firmware will read and merge the `bcm2708-rpi-cm.dtb` with the overlay data before giving the merged device tree to the Linux kernel as it boots up. +After reading `config.txt`, `start.elf` reads a model-specific Device Tree file. For instance, Compute Module 3 uses `bcm2710-rpi-cm.dtb`. This file is a standard Arm Linux Device Tree file that details hardware attached to the processor. It enumerates: -=== Device Tree Source and Compilation +* what and where peripheral devices exist +* which GPIOs are used +* what functions those GPIOs have +* what physical devices are connected -The Raspberry Pi OS image provides compiled dtb files, but where are the source dts files? They live in the Raspberry Pi Linux kernel branch, on https://github.com/raspberrypi/linux[GitHub]. Look in the `arch/arm/boot/dts` folder. +This file sets up the GPIOs by overwriting the pin state in `dt-blob.bin` if it is different. It will also try to load drivers for the specific devices. -Some default overlay dts files live in `arch/arm/boot/dts/overlays`. Corresponding overlays for standard hardware that can be attached to a *Raspberry Pi* in the Raspberry Pi OS image are on the FAT partition in the `/overlays` directory. Note that these assume certain pins on BANK0, as they are for use on a Raspberry Pi. In general, use the source of these standard overlays as a guide to creating your own, unless you are using the same GPIO pins as you would be using if the hardware was plugged into the GPIO header of a Raspberry Pi. +The model-specific Device Tree file contains disabled entries for peripherals. It contains no GPIO pin definitions other than the eMMC/SD Card peripheral which has GPIO defs and always uses the same pins. -Compiling these dts files to dtb files requires an up-to-date version of the xref:configuration.adoc#device-trees-overlays-and-parameters[Device Tree compiler] `dtc`. The way to install an appropriate version on Raspberry Pi is to run: +=== Device Tree source and compilation ----- -sudo apt install device-tree-compiler ----- +The Raspberry Pi OS image provides compiled `dtb` files, but the source `dts` files live in the https://github.com/raspberrypi/linux/tree/rpi-6.6.y/arch/arm/boot/dts/broadcom[Raspberry Pi Linux kernel branch]. Look for `rpi` in the file names. -If you are building your own kernel then the build host also gets a version in `scripts/dtc`. You can arrange for your overlays to be built automatically by adding them to `Makefile` in `arch/arm/boot/dts/overlays`, and using the 'dtbs' make target. +Default overlay `dts` files live at https://github.com/raspberrypi/linux/tree/rpi-6.6.y/arch/arm/boot/dts/overlays[`arch/arm/boot/dts/overlays`]. These overlay files are a good starting point for creating your own overlays. To compile these `dts` files to `dtb` files, use the xref:configuration.adoc#device-trees-overlays-and-parameters[Device Tree compiler] `dtc`. -=== Device Tree Debugging +When building your own kernel, the build host requires the Device Tree compiler in `scripts/dtc`. To build your overlays automatically, add them to the `dtbs` make target in `arch/arm/boot/dts/overlays/Makefile`. -When the Linux kernel is booted on the ARM core(s), the GPU provides it with a fully assembled device tree, assembled from the base dts and any overlays. This full tree is available via the Linux proc interface in `/proc/device-tree`, where nodes become directories and properties become files. +=== Device Tree debugging -You can use `dtc` to write this out as a human readable dts file for debugging. You can see the fully assembled device tree, which is often very useful: +When booting the Linux kernel, the GPU provides a fully assembled Device Tree created using the base `dts` and any overlays. This full tree is available via the Linux `proc` interface in `/proc/device-tree`. Nodes become directories and properties become files. ----- -dtc -I fs -O dts -o proc-dt.dts /proc/device-tree ----- - -As previously explained in the GPIO section, it is also very useful to use `raspi-gpio` to look at the setup of the GPIO pins to check that they are as you expect: +You can use `dtc` to write this out as a human readable `dts` file for debugging. To see the fully assembled device tree, run the following command: +[source,console] ---- -raspi-gpio get +$ dtc -I fs -O dts -o proc-dt.dts /proc/device-tree ---- -If something seems to be going awry, useful information can also be found by dumping the GPU log messages: +`pinctrl` provides the status of the GPIO pins. If something seems to be going awry, try dumping the GPU log messages: +[source,console] ---- -sudo vcdbg log msg +$ sudo vclog --msg ---- -You can include more diagnostics in the output by adding `dtdebug=1` to `config.txt`. - -=== Examples - -NOTE: Please use the https://www.raspberrypi.org/forums/viewforum.php?f=107[Device Tree subforum] on the Raspberry Pi forums to ask Device Tree related questions. - -For these simple examples I used a CMIO board with peripherals attached via jumper wires. +TIP: To include even more diagnostics in the output, add `dtdebug=1` to `config.txt`. -For each of the examples we assume a CM+CMIO or CM3+CMIO3 board with a clean install of the latest Raspberry Pi OS Lite version on the CM. +Use the https://forums.raspberrypi.com/viewforum.php?f=107[Device Tree Raspberry Pi forum] to ask Device Tree-related questions or report an issue. -The examples here require internet connectivity, so a USB hub plus keyboard plus wireless LAN or Ethernet dongle plugged into the CMIO USB port is recommended. +=== Examples -Please post any issues, bugs or questions on the Raspberry Pi https://www.raspberrypi.org/forums/viewforum.php?f=107[Device Tree subforum]. +The following examples use an IO Board with peripherals attached via jumper wires. We assume a CM1+CMIO or CM3+CMIO3, running a clean install of Raspberry Pi OS Lite. The examples here require internet connectivity, so we recommend a USB hub, keyboard, and wireless LAN or Ethernet dongle plugged into the IO Board USB port. -[discrete] -=== Example 1 - attaching an I2C RTC to BANK1 pins +==== Attach an I2C RTC to Bank 1 pins -In this simple example we wire an NXP PCF8523 real time clock (RTC) to the CMIO board BANK1 GPIO pins: 3V3, GND, I2C1_SDA on GPIO44 and I2C1_SCL on GPIO45. +In this example, we wire an NXP PCF8523 real time clock (RTC) to the IO Board Bank 1 GPIO pins: 3V3, GND, I2C1_SDA on GPIO44 and I2C1_SCL on GPIO45. -Download https://datasheets.raspberrypi.org/cm/minimal-cm-dt-blob.dts[minimal-cm-dt-blob.dts] and copy it to the SD card FAT partition, located in `/boot` when the CM has booted. +Download https://datasheets.raspberrypi.com/cm/minimal-cm-dt-blob.dts[`minimal-cm-dt-blob.dts`] and copy it to the boot partition in `/boot/firmware/`. Edit `minimal-cm-dt-blob.dts` and change the pin states of GPIO44 and 45 to be I2C1 with pull-ups: +[source,console] ---- -sudo nano /boot/minimal-cm-dt-blob.dts +$ sudo nano /boot/firmware/minimal-cm-dt-blob.dts ---- -Change lines: +Replace the following lines: +[source,kotlin] ---- pin@p44 { function = "input"; termination = "pull_down"; }; // DEFAULT STATE WAS INPUT NO PULL pin@p45 { function = "input"; termination = "pull_down"; }; // DEFAULT STATE WAS INPUT NO PULL ---- -to: +With the following pull-up definitions: +[source,kotlin] ---- pin@p44 { function = "i2c1"; termination = "pull_up"; }; // SDA1 pin@p45 { function = "i2c1"; termination = "pull_up"; }; // SCL1 ---- -NOTE: We could use this `dt-blob.dts` with no changes The Linux Device Tree will (re)configure these pins during Linux kernel boot when the specific drivers are loaded, so it is up to you whether you modify `dt-blob.dts`. I like to configure `dt-blob.dts` to what I expect the final GPIOs to be, as they are then set to their final state as soon as possible during the GPU boot stage, but this is not strictly necessary. You may find that in some cases you do need pins to be configured at GPU boot time, so they are in a specific state when Linux drivers are loaded. For example, a reset line may need to be held in the correct orientation. +We could use this `dt-blob.dts` with no changes, because the Linux Device Tree re-configures these pins during Linux kernel boot when the specific drivers load. However, if you configure `dt-blob.dts`, the GPIOs reach their final state as soon as possible during the GPU boot stage. In some cases, pins must be configured at GPU boot time so they are in a specific state when Linux drivers are loaded. For example, a reset line may need to be held in the correct orientation. -Compile `dt-blob.bin`: +Run the following command to compile `dt-blob.bin`: +[source,console] ---- -sudo dtc -I dts -O dtb -o /boot/dt-blob.bin /boot/minimal-cm-dt-blob.dts +$ sudo dtc -I dts -O dtb -o /boot/firmware/dt-blob.bin /boot/firmware/minimal-cm-dt-blob.dts ---- -Grab https://datasheets.raspberrypi.org/cm/example1-overlay.dts[example1-overlay.dts] and put it in `/boot` then compile it: +Download https://datasheets.raspberrypi.com/cm/example1-overlay.dts[`example1-overlay.dts`], copy it to the boot partition in `/boot/firmware/`, then compile it with the following command: +[source,console] ---- -sudo dtc -@ -I dts -O dtb -o /boot/overlays/example1.dtbo /boot/example1-overlay.dts +$ sudo dtc -@ -I dts -O dtb -o /boot/firmware/overlays/example1.dtbo /boot/firmware/example1-overlay.dts ---- -NOTE: The '-@' in the `dtc` command line. This is necessary if you are compiling dts files with external references, as overlays tend to be. +The `-@` flag compiles `dts` files with external references. It is usually necessary. -Edit `/boot/config.txt` and add the line: +Add the following line to xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]: +[source,ini] ---- dtoverlay=example1 ---- -Now save and reboot. +Finally, reboot with `sudo reboot`. -Once rebooted, you should see an rtc0 entry in /dev. Running: +Once rebooted, you should see an `rtc0` entry in `/dev`. Run the following command to view the hardware clock time: +[source,console] ---- -sudo hwclock +$ sudo hwclock ---- -will return with the hardware clock time, and not an error. - -[discrete] -=== Example 2 - Attaching an ENC28J60 SPI Ethernet Controller on BANK0 - -In this example we use one of the already available overlays in /boot/overlays to add an ENC28J60 SPI Ethernet controller to BANK0. The Ethernet controller is connected to SPI pins CE0, MISO, MOSI and SCLK (GPIO8-11 respectively), as well as GPIO25 for a falling edge interrupt, and of course GND and 3V3. +==== Attach an ENC28J60 SPI Ethernet controller on Bank 0 -In this example we won't change `dt-blob.bin`, although of course you can if you wish. We should see that Linux Device Tree correctly sets up the pins. +In this example, we use an overlay already defined in `/boot/firmware/overlays` to add an ENC28J60 SPI Ethernet controller to Bank 0. The Ethernet controller uses SPI pins CE0, MISO, MOSI and SCLK (GPIO8-11 respectively), GPIO25 for a falling edge interrupt, in addition to GND and 3.3V. -Edit `/boot/config.txt` and add the line: +In this example, we won't change `dt-blob.bin`. Instead, add the following line to `/boot/firmware/config.txt`: +[source,ini] ---- dtoverlay=enc28j60 ---- -Now save and reboot. - -Once rebooted you should see, as before, an rtc0 entry in /dev. Running: - ----- -sudo hwclock ----- - -will return with the hardware clock time, and not an error. +Reboot with `sudo reboot`. -You should also have Ethernet connectivity: +If you now run `ifconfig` you should see an aditional `eth` entry for the ENC28J60 NIC. You should also have Ethernet connectivity. Run the following command to test your connectivity: +[source,console] ---- -ping 8.8.8.8 +$ ping 8.8.8.8 ---- -should work. - -finally running: +Run the following command to show GPIO functions; GPIO8-11 should now provide ALT0 (SPI) functions: +[source,console] ---- -sudo raspi-gpio get +$ pinctrl ---- -should show that GPIO8-11 have changed to ALT0 (SPI) functions. - diff --git a/documentation/asciidoc/computers/compute-module/cmio-camera.adoc b/documentation/asciidoc/computers/compute-module/cmio-camera.adoc index 0544a417b6..a29dbbd82b 100644 --- a/documentation/asciidoc/computers/compute-module/cmio-camera.adoc +++ b/documentation/asciidoc/computers/compute-module/cmio-camera.adoc @@ -1,165 +1,294 @@ -== Attaching a Raspberry Pi Camera Module +== Attach a Camera Module -[NOTE] -====== -These instructions are intended for advanced users, if anything is unclear please use the https://www.raspberrypi.org/forums/viewforum.php?f=43[Raspberry Pi Camera forums] for technical help. +The Compute Module has two CSI-2 camera interfaces: CAM1 and CAM0. This section explains how to connect one or two Raspberry Pi Cameras to a Compute Module using the CAM1 and CAM0 interfaces with a Compute Module I/O Board. -Unless explicitly stated otherwise, these instructions will work identically on both the Compute Module and Compute Module 3, attached to a Compute Module IO Board. Compute Module 4 is slightly different, so please refer to the appropriate section. -====== +=== Update your system -The Compute Module has two CSI-2 camera interfaces. CAM0 has two CSI-2 data lanes, whilst CAM1 has four data lanes. The Compute Module IO board exposes both of these interfaces. Note that the standard Raspberry Pi devices uses CAM1, but only exposes two lanes. - -Please note that the camera modules are *not* designed to be hot pluggable. They should always be connected or disconnected with the power off. - -=== Updating your System - -The camera software is under constant development. Please ensure your system is up to date prior to using these instructions. +Before configuring a camera, xref:../computers/raspberry-pi.adoc#update-the-bootloader-configuration[ensure that your Raspberry Pi firmware is up-to-date].: +[source,console] ---- -sudo apt update -sudp apt full-upgrade +$ sudo apt update +$ sudo apt full-upgrade ---- -=== Crypto Chip +=== Connect one camera + +To connect a single camera to a Compute Module, complete the following steps: -When using the Compute Module to drive cameras, it is NOT necessary to incorporate the crypto chip used on the Raspberry Pi--designed camera boards when attaching the OM5647, IMX219 or HQ Camera Modules directly to the Compute Module carrier board. The Raspberry Pi firmware will automatically detect the CM and allow communications with the Camera Module to proceed without the crypto chip being present. +. Disconnect the Compute Module from power. +. Connect the Camera Module to the CAM1 port using a RPI-CAMERA board or a Raspberry Pi Zero camera cable. ++ +image::images/CMIO-Cam-Adapter.jpg[alt="Connecting the adapter board", width="60%"] + +. _(CM1, CM3, CM3+, and CM4S only)_: Connect the following GPIO pins with jumper cables: + * `0` to `CD1_SDA` + * `1` to `CD1_SCL` + * `2` to `CAM1_I01` + * `3` to `CAM1_I00` ++ +image::images/CMIO-Cam-GPIO.jpg[alt="GPIO connection for a single camera", width="60%"] -=== Quickstart Guide +. Reconnect the Compute Module to power. -To connect a single camera: +. Remove (or comment out with the prefix `#`) the following lines, if they exist, in `/boot/firmware/config.txt`: ++ +[source,ini] +---- +camera_auto_detect=1 +---- ++ +[source,ini] +---- +dtparam=i2c_arm=on +---- -. Power the CM down. -. On the compute module, run `sudo raspi-config` and enable the camera. -. Connect the RPI-CAMERA board and Camera Module to the CAM1 port. As an alternative, the Pi Zero camera cable can be used. +. _(CM1, CM3, CM3+, and CM4S only)_: Add the following directive to `/boot/firmware/config.txt` to accommodate the swapped GPIO pin assignment on the I/O board: + -image::images/CMIO-Cam-Adapter.jpg[Connecting the adapter board] +[source,ini] +---- +dtoverlay=cm-swap-i2c0 +---- -. (CM1 & CM3 only) Connect GPIO pins together as shown below. +. _(CM1, CM3, CM3+, and CM4S only)_: Add the following directive to `/boot/firmware/config.txt` to assign GPIO 3 as the CAM1 regulator: + -image::images/CMIO-Cam-GPIO.jpg[GPIO connection for a single camera] +[source,ini] +---- +dtparam=cam1_reg +---- -. Power the CM up and run `+sudo wget https://datasheets.raspberrypi.org/cmio/dt-blob-cam1.bin -O /boot/dt-blob.bin+` -. Finally, reboot for the dt-blob.bin file to be read. +. Add the appropriate directive to `/boot/firmware/config.txt` to manually configure the driver for your camera model: ++ +[%header,cols="1,1"] +|=== +| camera model +| directive -To connect two cameras, follow the steps as for a single camera and then also: +| v1 camera +| `dtoverlay=ov5647` -. Whilst powered down, repeat step 3 with CAM0. -. (CM1 and CM3 only) Connect the GPIO pins for the second camera. - image:images/CMIO-Cam-GPIO2.jpg[GPIO connection with additional camera] -. (CM4 only) Add jumpers to J6. -. Power up and run `+sudo wget https://datasheets.raspberrypi.org/cmio/dt-blob-dualcam.bin -O /boot/dt-blob.bin+` -. Reboot for the dt-blob.bin file to be read. +| v2 camera +| `dtoverlay=imx219` -NOTE: The default wiring uses GPIOs 2&3 to control the primary camera. These GPIOs can also be used for I2C, but doing so will result in a conflict, and the camera is unlikely to work. -*Do not enable I2C via `dtparam=i2c_arm=on` if you wish to use the camera with the default wiring* +| v3 camera +| `dtoverlay=imx708` -==== Software Support +| HQ camera +| `dtoverlay=imx477` -The supplied camera applications `raspivid` and `raspistill` have the -cs (--camselect) option to specify which camera should be used. +| GS camera +| `dtoverlay=imx296` +|=== -If you are writing your own camera application based on the MMAL API you can use the MMAL_PARAMETER_CAMERA_NUM parameter to set the current camera. E.g. +. Reboot your Compute Module with `sudo reboot`. +. Run the following command to check the list of detected cameras: ++ +[source,console] ---- -MMAL_PARAMETER_INT32_T camera_num = {{MMAL_PARAMETER_CAMERA_NUM, sizeof(camera_num)}, CAMERA_NUMBER}; -status = mmal_port_parameter_set(camera->control, &camera_num.hdr); +$ rpicam-hello --list ---- +You should see your camera model, referred to by the driver directive in the table above, in the output. + +=== Connect two cameras -=== Advanced Issues +To connect two cameras to a Compute Module, complete the following steps: -The Compute Module IO board has a 22-way 0.5mm FFC for each camera port, with CAM0 being a two-lane interface and CAM1 being the full four-lane interface. The standard Raspberry Pi uses a 15-way 1mm FFC cable, so you will need either an adapter (part# RPI-CAMERA) or a Pi Zero camera cable. +. Follow the single camera instructions above. +. Disconnect the Compute Module from power. +. Connect the Camera Module to the CAM0 port using a RPI-CAMERA board or a Raspberry Pi Zero camera cable. ++ +image::images/CMIO-Cam-Adapter.jpg[alt="Connect the adapter board", width="60%"] +. _(CM1, CM3, CM3+, and CM4S only)_: Connect the following GPIO pins with jumper cables: + * `28` to `CD0_SDA` + * `29` to `CD0_SCL` + * `30` to `CAM0_I01` + * `31` to `CAM0_I00` ++ +image:images/CMIO-Cam-GPIO2.jpg[alt="GPIO connection with additional camera", width="60%"] -The CMIO board for Compute Modules 1&3 differ slightly in approach to that for Compute Module 4. They will be considered separately. +. _(CM4 and CM5)_: Connect the J6 GPIO pins with two vertical-orientation jumpers. ++ +image:images/j6_vertical.jpg[alt="Connect the J6 GPIO pins in vertical orientation", width="60%"] -==== Compute Module 1 & 3 +. Reconnect the Compute Module to power. -On the Compute Module IO board it is necessary to bridge the GPIOs and I2C interface required by the Raspberry Pi OS to the CAM1 connector. This is done by connecting the GPIOs from the J6 GPIO connector to the CD1_SDA/SCL and CAM1_IO0/1 pins on the J5 connector using jumper wires. +. _(CM1, CM3, CM3+, and CM4S only)_: Add the following directive to `/boot/firmware/config.txt` to assign GPIO 31 as the CAM0 regulator: ++ +[source,ini] +---- +dtparam=cam0_reg +---- -NOTE: The pin numbers below are provided only as an example. LED and SHUTDOWN pins can be shared by both cameras, if required. +. Add the appropriate directive to `/boot/firmware/config.txt` to manually configure the driver for your camera model: ++ +[%header,cols="1,1"] +|=== +| camera model +| directive -The SDA and SCL pins must be either GPIOs 0 and 1, GPIOs 28 and 29, or GPIOs 44 and 45, and must be individual to each camera. +| v1 camera +| `dtoverlay=ov5647,cam0` -===== Steps to attach a Raspberry Pi Camera (to CAM1) +| v2 camera +| `dtoverlay=imx219,cam0` -. Attach the 0.5mm 22W FFC flexi (included with the RPI-CAMERA board) to the CAM1 connector (flex contacts face down). As an alternative, the Pi Zero camera cable can be used. -. Attach the RPI-CAMERA adaptor board to the other end of the 0.5mm flex (flex contacts face down). -. Attach a Raspberry Pi Camera to the other, larger 15W 1mm FFC on the RPI-CAMERA adaptor board (*contacts on the Raspberry Pi Camera flex must face up*). -. Attach CD1_SDA (J6 pin 37) to GPIO0 (J5 pin 1). -. Attach CD1_SCL (J6 pin 39) to GPIO1 (J5 pin 3). -. Attach CAM1_IO1 (J6 pin 41) to GPIO2 (J5 pin 5). -. Attach CAM1_IO0 (J6 pin 43) to GPIO3 (J5 pin 7). +| v3 camera +| `dtoverlay=imx708,cam0` -Note, the numbers in brackets are conventional, physical pin numbers, numbered from left to right, top to bottom. The numbers on the silkscreen correspond to the Broadcom SoC GPIO numbers. +| HQ camera +| `dtoverlay=imx477,cam0` -===== Steps to attach a second Raspberry Pi Camera (to CAM0) +| GS camera +| `dtoverlay=imx296,cam0` +|=== -Attach the second camera to the (CAM0) connector as before. +. Reboot your Compute Module with `sudo reboot`. -Connect up the I2C and GPIO lines. +. Run the following command to check the list of detected cameras: ++ +[source,console] +---- +$ rpicam-hello --list +---- ++ +You should see both camera models, referred to by the driver directives in the table above, in the output. -. Attach CD0_SDA (J6 pin 45) to GPIO28 (J6 pin 1). -. Attach CD0_SCL (J6 pin 47) to GPIO29 (J6 pin 3). -. Attach CAM0_IO1 (J6 pin 49) to GPIO30 (J6 pin 5). -. Attach CAM0_IO0 (J6 pin 51) to GPIO31 (J6 pin 7). +=== Software -==== Compute Module 4 +Raspberry Pi OS includes the `libcamera` library to help you take images with your Raspberry Pi. -On the Compute Module 4 IO board the CAM1 connector is already wired to the I2C on GPIOs 44 & 45, and the shutdown line is connected to GPIO 5 on the GPIO expander. There is no LED signal wired through. No hardware changes are required to use CAM1 other than connecting the 22pin FFC to the CAM1 connector (flex contacts face down). +==== Take a picture -To connect a second Raspberry Pi camera (to CAM0), two jumpers must be added to J6 in a vertical orienation. The CAM0 connector shares the shutdown line with CAM1. +Use the following command to immediately take a picture and save it to a file in PNG encoding using the `MMDDhhmmss` date format as a filename: -==== Configuring default pin states (all CM variants) +[source,console] +---- +$ rpicam-still --datetime -e png +---- -The GPIOs that we are using for the camera default to input mode on the Compute Module. To xref:configuration.adoc#changing-the-default-pin-configuration[override these default settings] and also tell the system that these are the pins to be used by the camera, we need to create a `dt-blob.bin` that is loaded by the firmware when the system boots up. This file is built from a source dts file that contains the requried settings, and placed on the boot partition. +Use the `-t` option to add a delay in milliseconds. +Use the `--width` and `--height` options to specify a width and height for the image. -<> are provided at the bottom of this document. These use the default wiring as described in this page. +==== Take a video -The `pin_config` section in the `pins_cm { }` (compute module), `pins_cm3 { }` (compute module3), or `pins_cm4 { }` (compute module 4) section of the source dts needs the camera's LED and power enable pins set to outputs: +Use the following command to immediately start recording a ten-second long video and save it to a file with the h264 codec named `video.h264`: +[source,console] ---- -pin@p2 { function = "output"; termination = "no_pulling"; }; -pin@p3 { function = "output"; termination = "no_pulling"; }; +$ rpicam-vid -t 10000 -o video.h264 ---- -To tell the firmware which pins to use and how many cameras to look for, add the following to the `pin_defines` section: +==== Specify which camera to use + +By default, `libcamera` always uses the camera with index `0` in the `--list-cameras` list. +To specify a camera option, get an index value for each camera from the following command: +[source,console] ---- -pin_define@CAMERA_0_LED { type = "internal"; number = <2>; }; -pin_define@CAMERA_0_SHUTDOWN { type = "internal"; number = <3>; }; -pin_define@CAMERA_0_UNICAM_PORT { type = "internal"; number = <1>; }; -pin_define@CAMERA_0_I2C_PORT { type = "internal"; number = <0>; }; -pin_define@CAMERA_0_SDA_PIN { type = "internal"; number = <0>; }; -pin_define@CAMERA_0_SCL_PIN { type = "internal"; number = <1>; }; +$ rpicam-hello --list-cameras +Available cameras +----------------- +0 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a) + Modes: 'SRGGB10_CSI2P' : 1332x990 [120.05 fps - (696, 528)/2664x1980 crop] + 'SRGGB12_CSI2P' : 2028x1080 [50.03 fps - (0, 440)/4056x2160 crop] + 2028x1520 [40.01 fps - (0, 0)/4056x3040 crop] + 4056x3040 [10.00 fps - (0, 0)/4056x3040 crop] + +1 : imx708 [4608x2592] (/base/soc/i2c0mux/i2c@0/imx708@1a) + Modes: 'SRGGB10_CSI2P' : 1536x864 [120.13 fps - (768, 432)/3072x1728 crop] + 2304x1296 [56.03 fps - (0, 0)/4608x2592 crop] + 4608x2592 [14.35 fps - (0, 0)/4608x2592 crop] ---- -Indentation and line breaks are not critical, so the example files expand these blocks out for readability. +In the above output: + +* `imx477` refers to a HQ camera with an index of `0` +* `imx708` refers to a v3 camera with an index of `1` -The Compute Module's *pin_config* section needs the second camera's LED and power enable pins configured: +To use the HQ camera, pass its index (`0`) to the `--camera` `libcamera` option: +[source,console] ---- -pin@p30 { function = "output"; termination = "no_pulling"; }; -pin@p31 { function = "output"; termination = "no_pulling"; }; +$ rpicam-hello --camera 0 ---- -In the Compute Module's *pin_defines* section of the dts file, change the *NUM_CAMERAS* parameter to 2 and add the following: +To use the v3 camera, pass its index (`1`) to the `--camera` `libcamera` option: + +[source,console] +---- +$ rpicam-hello --camera 1 +---- + + +=== I2C mapping of GPIO pins + +By default, the supplied camera drivers assume that CAM1 uses `i2c-10` and CAM0 uses `i2c-0`. Compute module I/O boards map the following GPIO pins to `i2c-10` and `i2c-0`: + +[%header,cols="1,1,1"] +|=== +| I/O Board Model +| `i2c-10` pins +| `i2c-0` pins +| CM4 I/O Board +| GPIOs 44,45 +| GPIOs 0,1 + +| CM1, CM3, CM3+, CM4S I/O Board +| GPIOs 0,1 +| GPIOs 28,29 +|=== + +To connect a camera to the CM1, CM3, CM3+ and CM4S I/O Board, add the following directive to `/boot/firmware/config.txt` to accommodate the swapped pin assignment: + +[source,ini] ---- -pin_define@CAMERA_1_LED { type = "internal"; number = <30>; }; -pin_define@CAMERA_1_SHUTDOWN { type = "internal"; number = <31>; }; -pin_define@CAMERA_1_UNICAM_PORT { type = "internal"; number = <0>; }; -pin_define@CAMERA_1_I2C_PORT { type = "internal"; number = <0>; }; -pin_define@CAMERA_1_SDA_PIN { type = "internal"; number = <28>; }; -pin_define@CAMERA_1_SCL_PIN { type = "internal"; number = <29>; }; +dtoverlay=cm-swap-i2c0 ---- -[[sample-device-tree-source-files]] -==== Sample device tree source files +Alternative boards may use other pin assignments. Check the documentation for your board and use the following alternate overrides depending on your layout: + +[%header,cols="1,1"] +|=== +| Swap +| Override + +| Use GPIOs 0,1 for i2c0 +| `i2c0-gpio0` + +| Use GPIOs 28,29 for i2c0 (default) +| `i2c0-gpio28` + +| Use GPIOs 44&45 for i2c0 +| `i2c0-gpio44` + +| Use GPIOs 0&1 for i2c10 (default) +| `i2c10-gpio0` + +| Use GPIOs 28&29 for i2c10 +| `i2c10-gpio28` + +| Use GPIOs 44&45 for i2c10 +| `i2c10-gpio44` +|=== + +==== GPIO pins for shutdown + +For camera shutdown, Device Tree uses the pins assigned by the `cam1_reg` and `cam0_reg` overlays. + +The CM4 IO board provides a single GPIO pin for both aliases, so both cameras share the same regulator. + +The CM1, CM3, CM3+, and CM4S I/O boards provides no GPIO pin for `cam1_reg` and `cam0_reg`, so the regulators are disabled on those boards. However, you can enable them with the following directives in `/boot/firmware/config.txt`: -https://datasheets.raspberrypi.org/cmio/dt-blob-cam1.dts[Enable CAM1 only] +* `dtparam=cam1_reg` +* `dtparam=cam0_reg` -https://datasheets.raspberrypi.org/cmio/dt-blob-dualcam.dts[Enable CAM1 and CAM0] +To assign `cam1_reg` and `cam0_reg` to a specific pin on a custom board, use the following directives in `/boot/firmware/config.txt`: -==== Compiling a DTS file to a device tree blob +* `dtparam=cam1_reg_gpio=` +* `dtparam=cam0_reg_gpio=` -Once all the required changes have been made to the `dts` file, it needs to be compiled and placed on the boot partition of the device. +For example, to use pin 42 as the regulator for CAM1, add the directive `dtparam=cam1_reg_gpio=42` to `/boot/firmware/config.txt`. -Instructions for doing this can be found on the xref:configuration.adoc#changing-the-default-pin-configuration[Pin Configuration] page. +These directives only work for GPIO pins connected directly to the SoC, not for expander GPIO pins. diff --git a/documentation/asciidoc/computers/compute-module/cmio-display.adoc b/documentation/asciidoc/computers/compute-module/cmio-display.adoc index 2541da290b..747eb41bf2 100644 --- a/documentation/asciidoc/computers/compute-module/cmio-display.adoc +++ b/documentation/asciidoc/computers/compute-module/cmio-display.adoc @@ -1,106 +1,83 @@ -== Attaching the Official 7-inch Display +== Attaching the Touch Display LCD panel -NOTE: These instructions are intended for advanced users, if anything is unclear please use the https://www.raspberrypi.org/forums/viewforum.php?f=98[Raspberry Pi Compute Module forums] for technical help. +Update your system software and firmware to the latest version before starting. +Compute Modules mostly use the same process, but sometimes physical differences force changes for a particular model. -Please ensure your system software is updated before starting. Largely speaking the approach taken for Compute Modules 1, 3, and 4 is the same, but there are minor differences in physical setup required. It will be indicated where a step applies only to a specific platform. +=== Connect a display to DISP1/DSI1 -WARNING: The Raspberry Pi Zero camera cable cannot be used as an alternative to the RPI-DISPLAY adaptor, because its wiring is different. +NOTE: The Raspberry Pi Zero camera cable cannot be used as an alternative to the RPI-DISPLAY adapter. The two cables have distinct wiring. -WARNING: Please note that the display is *not* designed to be hot pluggable. It (and camera modules) should always be connected or disconnected with the power off. +To connect a display to DISP1/DSI1: -=== Quickstart Guide (Display Only) - -. Connect the display to the DISP1 port on the Compute Module IO board through the 22W to 15W display adaptor. -. (CM1 and 3 only) Connect these pins together with jumper wires: +. Disconnect the Compute Module from power. +. Connect the display to the DISP1/DSI1 port on the Compute Module IO board through the 22W to 15W display adapter. +. _(CM1, CM3, CM3+, and CM4S only)_: Connect the following GPIO pins with jumper cables: + * `0` to `CD1_SDA` + * `1` to `CD1_SCL` +. _(CM5)_ On the Compute Module 5 IO board, add the appropriate jumpers to J6, as indicated on the silkscreen. +. Reconnect the Compute Module to power. +. Add the following line to xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]: + +[source,ini] ---- - GPIO0 - CD1_SDA - GPIO1 - CD1_SCL +dtoverlay=vc4-kms-dsi-7inch ---- +. Reboot your Compute Module with `sudo reboot`. Your device should detect and begin displaying output to your display. -. Power up the Compute Module and run: -+ -`+sudo wget https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-only.bin -O /boot/dt-blob.bin+` +=== Connect a display to DISP0/DSI0 -. Reboot for the `dt-blob.bin` file to be read. +To connect a display to DISP0/DSI0 on CM1, CM3 and CM4 IO boards: -=== Quickstart Guide (Display and Cameras) +. Connect the display to the DISP0/DSI0 port on the Compute Module IO board through the 22W to 15W display adapter. +. _(CM1, CM3, CM3+, and CM4S only)_: Connect the following GPIO pins with jumper cables: + * `28` to `CD0_SDA` + * `29` to `CD0_SCL` -==== To enable the display and one camera:* + . _(CM4 only)_ On the Compute Module 4 IO board, add the appropriate jumpers to J6, as indicated on the silkscreen. -. Connect the display to the DISP1 port on the Compute Module IO board through the 22W to 15W display adaptor, called RPI-DISPLAY. -. Connect the Camera Module to the CAM1 port on the Compute Module IO board through the 22W to 15W adaptor called RPI-CAMERA. Alternatively, the Raspberry Pi Zero camera cable can be used. -. (CM 1 and 3 only) Connect these pins together with jumper wires: +. Reconnect the Compute Module to power. +. Add the following line to `/boot/firmware/config.txt`: + +[source,ini] ---- - GPIO0 - CD1_SDA - GPIO1 - CD1_SCL - GPIO2 - CAM1_IO1 - GPIO3 - CAM1_IO0 +dtoverlay=vc4-kms-dsi-7inch ---- -+ -image:images/CMIO-Cam-Disp-GPIO.jpg[GPIO connection for a single display and Camera Modules] - (Please note this image needs to be updated to have the extra jumper leads removed and use the standard wiring (2&3 not 4&5)) +. Reboot your Compute Module with `sudo reboot`. Your device should detect and begin displaying output to your display. -. Power up the Compute Module and run: -+ -`+sudo wget https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam1.bin -O /boot/dt-blob.bin+` +=== Disable touchscreen -. Reboot for the `dt-blob.bin` file to be read. +The touchscreen requires no additional configuration. Connect it to your Compute Module, and both the touchscreen element and display should work once successfully detected. -==== To enable the display and both cameras:* +To disable the touchscreen element, but still use the display, add the following line to `/boot/firmware/config.txt`: -. Follow the steps for connecting the display and one camera above. -. Connect the Camera Module to the CAM0 port on the Compute Module IO board through the 22W to 15W adaptor called RPI-CAMERA. Alternatively, the Raspberry Pi Zero camera cable can be used. -. (CM1 & 3 only) Add links: -+ +[source,ini] ---- - GPIO28 - CD0_SDA - GPIO29 - CD0_SCL - GPIO30 - CAM0_IO1 - GPIO31 - CAM0_IO0 +disable_touchscreen=1 ---- -. (CM4 only) Add jumpers to J6. -. Power up the Compute Module and run: -+ -`+sudo wget https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam2.bin -O /boot/dt-blob.bin+` - -. Reboot for the `dt-blob.bin` file to be read. -+ -image:images/CMIO-Cam-Disp-Example.jpg[Camera Preview on the 7 inch display] - (Please note this image needs to be updated to show two Camera Modules and the standard wiring) - -=== Software Support +=== Disable display -There is no additional configuration required to enable the touchscreen. The touch interface should work out of the box once the screen is successfully detected. +To entirely ignore the display when connected, add the following line to `/boot/firmware/config.txt`: -If you wish to disable the touchscreen element and only use the display side, you can add the command `disable_touchscreen=1` to /boot/config.txt to do so. +[source,ini] +---- +ignore_lcd=1 +---- -To make the firmware to ignore the display even if connected, then add `ignore_lcd=1` to /boot/config.txt. +== Attaching the Touch Display 2 LCD panel -=== Firmware Configuration +Touch Display 2 is a 720x1280 7" LCD display designed specifically for Raspberry Pi devices (see https://www.raspberrypi.com/products/touch-display-2/). It connects in the same way as the original touch display, but the software setup on Compute Modules is slightly different as it uses a different display driver. See xref:../accessories/touch-display-2.adoc[Touch Display 2] for connection details. -The firmware looks at the dt-blob.bin file for the relevant configuration to use -for the screen. It looks at the pin_number@ defines for +Edit the /boot/firmware/config.txt file and add the following to enable Touch Display 2 on DISP1/DSI1. You will also need to add jumpers to J6 as indicated on the silkscreen. +[source,ini] ---- -DISPLAY_I2C_PORT -DISPLAY_SDA -DISPLAY_SCL -DISPLAY_DSI_PORT +dtoverlay=vc4-kms-dsi-ili9881-7inch ---- -The I2C port, SDA and SCL pin numbers are self explanatory. DISPLAY_DSI_PORT -selects between DSI1 (the default) and DSI0. - -Once all the required changes have been made to the `dts` file, it needs to be compiled and placed on the boot partition of the device. +To use DISP0/DSI0, use the following: -Instructions for doing this can be found on the xref:configuration.adoc#changing-the-default-pin-configuration[Pin Configuration] page. - -==== Sources - -* https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-only.dts[dt-blob-disp1-only.dts] -* https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam1.dts[dt-blob-disp1-cam1.dts] -* https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam2.dts[dt-blob-disp1-cam2.dts] -* https://datasheets.raspberrypi.org/cmio/dt-blob-disp0-only.dts[dt-blob-disp0-only.dts] (Uses wiring as for CAM0) +[source,ini] +---- +dtoverlay=vc4-kms-dsi-ili9881-7inch,dsi0 +---- diff --git a/documentation/asciidoc/computers/compute-module/datasheet.adoc b/documentation/asciidoc/computers/compute-module/datasheet.adoc index 8b8cf45724..11d52ccb82 100644 --- a/documentation/asciidoc/computers/compute-module/datasheet.adoc +++ b/documentation/asciidoc/computers/compute-module/datasheet.adoc @@ -1,47 +1,84 @@ -== Datasheets and Schematics +== Specifications -=== Compute Module 4 +=== Compute Module 5 datasheet -The latest version of the Compute Module is the Compute Module 4 (CM4). It is the recommended Compute Module for all current and future development. +To learn more about Compute Module 5 (CM5) and its corresponding IO Board, see the following documents: -* https://datasheets.raspberrypi.org/cm4/cm4-datasheet.pdf[Compute Module 4 Datasheet] -* https://datasheets.raspberrypi.org/cm4io/cm4io-datasheet.pdf[Compute Module 4 IO Board Datasheet] +* https://datasheets.raspberrypi.com/cm5/cm5-datasheet.pdf[CM5 datasheet] +* https://rpltd.co/cm5-design-files[CM5 design files] -NOTE: Schematics are not available for the Compute Module 4, but are available for the IO board. +=== Compute Module 5 IO Board datasheet -Schematics for the CMIO4 board are included in the datasheet, +Design data for the Compute Module 5 IO Board (CM5IO) can be found in its datasheet: -* https://datasheets.raspberrypi.org/cm4io/cm4io-datasheet.pdf[Compute Module 4 IO Board Datasheet] (including schematics) +* https://datasheets.raspberrypi.com/cm5/cm5io-datasheet.pdf[CM5IO datasheet] +* https://rpltd.co/cm5io-design-files[CM5IO design files] -There is also a KiCAD PCB design set available: +=== Compute Module 4 datasheet -* https://datasheets.raspberrypi.org/cm4io/CM4IO-KiCAD.zip[Compute Module 4 IO Board KiCAD files] +To learn more about Compute Module 4 (CM4) and its corresponding IO Board, see the following documents: -==== Under Voltage Detection +* https://datasheets.raspberrypi.com/cm4/cm4-datasheet.pdf[CM4 datasheet] -Schematic for an under-voltage detection circuit, as used in most models of Raspberry Pi: +[.whitepaper, title="Configure the Compute Module 4", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003470-WP/Configuring-the-Compute-Module-4.pdf] +**** +The Compute Module 4 is available in a number of different hardware configurations. Some use cases disable certain features that aren't required. -image::images/under_voltage_detect.png[Under-voltage detect] +This document describes how to disable various hardware and software interfaces. +**** + +=== Compute Module 4 IO Board datasheet + +Design data for the Compute Module 4 IO Board (CM4IO) can be found in its datasheet: + +* https://datasheets.raspberrypi.com/cm4io/cm4io-datasheet.pdf[CM4IO datasheet] + +We also provide a KiCad PCB design set for the CM4 IO Board: + +* https://datasheets.raspberrypi.com/cm4io/CM4IO-KiCAD.zip[CM4IO KiCad files] + +=== Compute Module 4S datasheet + +Compute Module 4S (CM4S) offers the internals of CM4 in the DDR2-SODIMM form factor of CM1, CM3, and CM3+. To learn more about CM4S, see the following documents: -=== Older Products +* https://datasheets.raspberrypi.com/cm4s/cm4s-datasheet.pdf[CM4S datasheet] -Raspberry Pi CM1, CM3 and CM3L are supported products with an End-of-Life (EOL) date no earlier than January 2026. For customers embarking on new designs, Raspberry Pi recommends using the newer Compute Module 3+, which offers improved thermal performance, and a wider range of Flash memory options. +=== Compute Module 3+ datasheet -* https://datasheets.raspberrypi.org/cm/cm1-and-cm3-datasheet.pdf[Compute Module and Compute Module 3] +Compute Module 3+ (CM3+) is a supported product with an end-of-life (EOL) date no earlier than January 2028. To learn more about CM3+ and its corresponding IO Board, see the following documents: -Raspberry Pi CM3+ and CM3+ Lite are supported prodicts with an End-of-Life (EOL) date no earlier than January 2026. +* https://datasheets.raspberrypi.com/cm/cm3-plus-datasheet.pdf[CM3+ datasheet] -* https://datasheets.raspberrypi.org/cm/cm3-plus-datasheet.pdf[Compute Module 3+] +=== Compute Module 1 and Compute Module 3 datasheet -Schematics for the Compute Module 1, 3 and 3L +Raspberry Pi Compute Module 1 (CM1) and Compute Module 3 (CM3) are supported products with an end-of-life (EOL) date no earlier than January 2026. To learn more about CM1 and CM3, see the following documents: -* https://datasheets.raspberrypi.org/cm/cm1-schematics.pdf[CM Rev 1.1] -* https://datasheets.raspberrypi.org/cm/cm3-schematics.pdf[CM3 and CM3L Rev 1.0] +* https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf[CM1 and CM3 datasheet] +* https://datasheets.raspberrypi.com/cm/cm1-schematics.pdf[Schematics for CM1] +* https://datasheets.raspberrypi.com/cm/cm3-schematics.pdf[Schematics for CM3] -Schematics for the Compute Module IO board (CMIO): +[.whitepaper, title="Transition from Compute Module 1 or Compute Module 3 to Compute Module 4", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003469-WP/Transitioning-from-CM3-to-CM4.pdf] +**** +This white paper helps developers migrate from Compute Module 1 or Compute Module 3 to Compute Module 4. +**** -* https://datasheets.raspberrypi.org/cmio/cmio-schematics.pdf[CMIO Rev 3.0] (Supports CM1, CM3, CM3L, CM3+ and CM3+L) +=== Compute Module IO Board schematics -Schematics for the Compute Module camera/display adapter board (CMCDA): +The Compute Module IO Board (CMIO) provides a variety of interfaces for CM1, CM3, CM3+, and CM4S. The Compute Module IO Board comes in two variants: Version 1 and Version 3. Version 1 is only compatible with CM1. Version 3 is compatible with CM1, CM3, CM3+, and CM4S. Compute Module IO Board Version 3 is sometimes written as the shorthand CMIO3. To learn more about CMIO1 and CMIO3, see the following documents: -* https://datasheets.raspberrypi.org/cmcda/cmcda-schematics.pdf[CMCDA Rev 1.1] \ No newline at end of file +* https://datasheets.raspberrypi.com/cmio/cmio-schematics.pdf[Schematics for CMIO] +* https://datasheets.raspberrypi.com/cmio/RPi-CMIO-R1P2.zip[Design documents for CMIO Version 1.2 (CMIO/CMIO1)] +* https://datasheets.raspberrypi.com/cmio/RPi-CMIO-R3P0.zip[Design documents for CMIO Version 3.0 (CMIO3)] + +=== Compute Module Camera/Display Adapter Board schematics + +The Compute Module Camera/Display Adapter Board (CMCDA) provides camera and display interfaces for Compute Modules. To learn more about the CMCDA, see the following documents: + +* https://datasheets.raspberrypi.com/cmcda/cmcda-schematics.pdf[Schematics for the CMCDA] +* https://datasheets.raspberrypi.com/cmcda/RPi-CMCDA-1P1.zip[Design documents for CMCDA Version 1.1] + +=== Under-voltage detection + +The following schematic describes an under-voltage detection circuit, as used in older models of Raspberry Pi: + +image::images/under_voltage_detect.png[Under-voltage detect] diff --git a/documentation/asciidoc/computers/compute-module/designfiles.adoc b/documentation/asciidoc/computers/compute-module/designfiles.adoc deleted file mode 100644 index 57a293147d..0000000000 --- a/documentation/asciidoc/computers/compute-module/designfiles.adoc +++ /dev/null @@ -1,22 +0,0 @@ -== Design Files for CMIO Boards - -[discrete] -=== Compute Module IO board for CM4 - -Design data for the Compute Module 4 IO board can be found in its datasheet: - -* https://datasheets.raspberrypi.org/cm4io/cm4io-datasheet.pdf[Compute Module 4 IO Board datasheet] - -There is also a KiCAD PCB design set available: - -* https://datasheets.raspberrypi.org/cm4io/CM4IO-KiCAD.zip[Compute Module 4 IO Board KiCAD files] - -[discrete] -=== Older Products - -* https://datasheets.raspberrypi.org/cmio/RPi-CMIO-R1P2.zip[CMIO Rev 1.2] -* https://datasheets.raspberrypi.org/cmio/RPi-CMIO-R3P0.zip[CMIO Rev 3.0] - -Design data for the Compute Module camera/display adapter board (CMCDA): - -* https://datasheets.raspberrypi.org/cmcda/RPi-CMCDA-1P1.zip[CMCDA Rev 1.1] diff --git a/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-Example.jpg b/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-Example.jpg deleted file mode 100644 index c7c8a60c2c..0000000000 Binary files a/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-Example.jpg and /dev/null differ diff --git a/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-GPIO.jpg b/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-GPIO.jpg deleted file mode 100644 index e5cbdd81f9..0000000000 Binary files a/documentation/asciidoc/computers/compute-module/images/CMIO-Cam-Disp-GPIO.jpg and /dev/null differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm1.jpg b/documentation/asciidoc/computers/compute-module/images/cm1.jpg new file mode 100644 index 0000000000..caa01fec3a Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm1.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm3-plus.jpg b/documentation/asciidoc/computers/compute-module/images/cm3-plus.jpg new file mode 100644 index 0000000000..dc266211b8 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm3-plus.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm3.jpg b/documentation/asciidoc/computers/compute-module/images/cm3.jpg new file mode 100644 index 0000000000..c82500604a Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm3.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-assembly.svg b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-assembly.svg new file mode 100644 index 0000000000..596cda0127 --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-assembly.svg @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + 3 + + + + + + 1 + + + + + + 2 + + + + + 4 + \ No newline at end of file diff --git a/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.png b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.png new file mode 100644 index 0000000000..7fcd0da44e Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.svg b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.svg new file mode 100644 index 0000000000..232dc6e76b --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna-physical.svg @@ -0,0 +1,4711 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 87.5 ± 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1/4–36UNS–2B + 1/4–36UNS–2A + 11 + + Milling unilateral 5.85 ± 0.02 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2.0 + 205 ± 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + S=8 + + + 6.25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Note:All dimensions in mmAll dimensions are approximate and for reference purposes only. The dimensions shown should not be used for producing production dataThe dimensions are subject to part and manufacturing tolerancesDimensions may be subject to change + diff --git a/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna.jpg b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna.jpg new file mode 100644 index 0000000000..2dd3fbcd74 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm4-cm5-antenna.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm4.jpg b/documentation/asciidoc/computers/compute-module/images/cm4.jpg new file mode 100644 index 0000000000..a60f5b73bf Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm4.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm4io.jpg b/documentation/asciidoc/computers/compute-module/images/cm4io.jpg new file mode 100644 index 0000000000..fe4ccab2bc Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm4io.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm4s.jpg b/documentation/asciidoc/computers/compute-module/images/cm4s.jpg new file mode 100644 index 0000000000..7119617d8e Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm4s.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.png b/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.png new file mode 100644 index 0000000000..05323596a7 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.svg b/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.svg new file mode 100644 index 0000000000..4ddf6308f6 --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/images/cm5-case-physical.svg @@ -0,0 +1,12074 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SSD + + + + + + + + + + + + + + + + + +Power In + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +STATUS +Power +HDMI0 +HDMI1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +94 + +170 + + + + + + + + + + + + + + + +28 + + + + + + + + + + + + + + + + + +Note:All dimensions in mmAll dimensions are approximate and for reference purposes only. The dimensions shown should not be used for producing production dataThe dimensions are subject to part and manufacturing tolerancesDimensions may be subject to change + diff --git a/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.png b/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.png new file mode 100644 index 0000000000..5214101780 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.svg b/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.svg new file mode 100644 index 0000000000..5abb017d82 --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/images/cm5-cooler-physical.svg @@ -0,0 +1,9616 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 41 + 56 + + + + + + + + + + + 33 + 4 × M2.5 + + + + + + + + + + + + + + + + + + + 10 + 2.7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 48 + + + + + + + + + + + Note: + All dimensions in mm + All dimensions are app + ro + ximate and for + reference purposes only. + + The dimensions + shown should not be used for p + r + oducing + p + r + oduction data + The dimensions are subject + t + o pa + r + t and + manufacturing + t + ole + r + ances + Dimensions may be subject + t + o change + + diff --git a/documentation/asciidoc/computers/compute-module/images/cm5-cooler.jpg b/documentation/asciidoc/computers/compute-module/images/cm5-cooler.jpg new file mode 100644 index 0000000000..d4781a5cd4 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5-cooler.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5.png b/documentation/asciidoc/computers/compute-module/images/cm5.png new file mode 100644 index 0000000000..0431e3e2d1 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5io-case-front.png b/documentation/asciidoc/computers/compute-module/images/cm5io-case-front.png new file mode 100644 index 0000000000..055875438a Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5io-case-front.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5io-case.png b/documentation/asciidoc/computers/compute-module/images/cm5io-case.png new file mode 100644 index 0000000000..074e802b66 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5io-case.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cm5io.png b/documentation/asciidoc/computers/compute-module/images/cm5io.png new file mode 100644 index 0000000000..382ae0b2c0 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cm5io.png differ diff --git a/documentation/asciidoc/computers/compute-module/images/cmio.jpg b/documentation/asciidoc/computers/compute-module/images/cmio.jpg new file mode 100644 index 0000000000..347f27f286 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/cmio.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/images/j6_vertical.jpg b/documentation/asciidoc/computers/compute-module/images/j6_vertical.jpg new file mode 100644 index 0000000000..90858661a4 Binary files /dev/null and b/documentation/asciidoc/computers/compute-module/images/j6_vertical.jpg differ diff --git a/documentation/asciidoc/computers/compute-module/introduction.adoc b/documentation/asciidoc/computers/compute-module/introduction.adoc new file mode 100644 index 0000000000..aa74d7bd58 --- /dev/null +++ b/documentation/asciidoc/computers/compute-module/introduction.adoc @@ -0,0 +1,232 @@ +== Compute Modules + +Raspberry Pi Compute Modules are **system-on-module** variants of the flagship Raspberry Pi models. Compute Modules are especially popular for industrial and commercial applications, including digital signage, thin clients, and process automation. Some of these applications use the flagship Raspberry Pi design, but many users want a more compact design or on-board eMMC storage. + +Compute Modules come in multiple variants, varying both in memory and soldered-on Multi-Media Card (eMMC) flash storage capacity. Like SD cards, eMMC provides persistent storage with minimal energy impact. Unlike SD cards, eMMC is specifically designed to be used as a disk and includes extra features to improve reliability. **Lite** models have no on-board storage, and are sometimes referred to with the shorthand suffix **L**, e.g. "CM3L". + +Compute Modules use the following Raspberry Pi SoCs: + +* BCM2835 for CM1 +* BCM2837 for CM3, CM3+ +* BCM2711 for CM4, CM4S +* BCM2712 for CM5 + +=== Compute Module 5 + +.Compute Module 5 +image::images/cm5.png[alt="Compute Module 5", width="60%"] + +The Compute Module 5 (CM5) combines the internals of a Raspberry Pi 5 (the BCM2712 processor and 2GB, 4GB, 8GB, or 16GB of RAM) with optional 0GB (Lite), 16GB, 32GB or 64GB of eMMC flash storage. + +CM5 uses the same form factor as CM4, featuring two 100-pin high density connectors. + +=== Compute Module 4 + +.Compute Module 4 +image::images/cm4.jpg[alt="Compute Module 4", width="60%"] + +The Compute Module 4 (CM4) combines the internals of a Raspberry Pi 4 (the BCM2711 processor and 1GB, 2GB, 4GB, or 8GB of RAM) with an optional 0GB (Lite), 8GB, 16GB or 32GB of eMMC flash storage. + +Unlike CM1, CM3, and CM3+, CM4 does not use the DDR2 SO-DIMM form factor. Instead, CM4 uses two 100-pin high density connectors in a smaller physical footprint. This change helped add the following interfaces: + +* an additional second HDMI port +* PCIe +* Ethernet + +The previous form factor could not have supported these interfaces. + +=== Compute Module 4S + +.Compute Module 4S +image::images/cm4s.jpg[alt="Compute Module 4S", width="60%"] + +The Compute Module 4S (CM4S) combines the internals of a Raspberry Pi 4 (the BCM2711 processor and 1GB, 2GB, 4GB, or 8GB of RAM) with an optional 0GB (Lite), 8GB, 16GB or 32GB of eMMC flash storage. Unlike CM4, CM4S comes in the same DDR2 SO-DIMM form factor as CM1, CM3, and CM3+. + +[[compute-module-3-plus]] +=== Compute Module 3+ + +.Compute Module 3+ +image::images/cm3-plus.jpg[alt="Compute Module 3+", width="60%"] + +The Compute Module 3+ (CM3+) combines the internals of a Raspberry Pi 3 Model B+ (the BCM2837 processor and 1GB of RAM) with an optional 0GB (Lite), 8GB, 16GB or 32GB of eMMC flash storage. CM3+ comes in the DDR2 SO-DIMM form factor. + +=== Compute Module 3 + +.Compute Module 3 +image::images/cm3.jpg[alt="Compute Module 3", width="60%"] + +The Compute Module 3 (CM3) combines the internals of a Raspberry Pi 3 (the BCM2837 processor and 1GB of RAM) with an optional 4GB of eMMC flash storage. CM3 comes in the DDR2 SO-DIMM form factor. + +=== Compute Module 1 + +.Compute Module 1 +image::images/cm1.jpg[alt="Compute Module 1", width="60%"] + +The Compute Module 1 (CM1) contains the internals of a Raspberry Pi (the BCM2835 processor and 512MB of RAM) as well as an optional 4GB of eMMC flash storage. CM1 comes in the DDR2 SO-DIMM form factor. + +== IO Boards + +Raspberry Pi IO Boards provide a way to connect a single Compute Module to a variety of I/O (input/output) interfaces. Compute Modules are small, lacking ports and connectors. IO Boards provide a way to connect Compute Modules to a variety of peripherals. + +Raspberry Pi IO Boards provide the following functionality: + +* power the module +* connects the GPIO to pin headers +* connects the camera and display interfaces to FFC connectors +* connects HDMI to HDMI ports +* connects USB to USB ports +* connects activity monitoring to LEDs +* eMMC programming over USB +* connects PCIe to connectors used to physically connect storage or peripherals + +IO Boards are breakout boards intended for development or personal use; in production, you should use a smaller, potentially custom board that provides only the ports and peripherals required for your use-case. + +=== Compute Module 5 IO Board + +.Compute Module 5 IO Board +image::images/cm5io.png[alt="Compute Module 5 IO Board", width="60%"] + +Compute Module 5 IO Board provides the following interfaces: + +* HAT footprint with 40-pin GPIO connector +* PoE header +* 2× HDMI ports +* 2× USB 3.0 ports +* Gigabit Ethernet RJ45 with PoE support +* M.2 M key PCIe socket compatible with the 2230, 2242, 2260, and 2280 form factors +* microSD card slot (only for use with Lite variants with no eMMC; other variants ignore the slot) +* 2× MIPI DSI/CSI-2 combined display/camera FPC connectors (22-pin 0.5 mm pitch cable) +* Real-time clock with battery socket +* four-pin JST-SH PWM fan connector +* USB-C power using the same standard as Raspberry Pi 5 (5V, 5A (25W) or 5V, 3A (15W) with a 600mA peripheral limit) +* Jumpers to disable features such as eMMC boot, EEPROM write, and the USB OTG connection + +=== Compute Module 4 IO Board + +.Compute Module 4 IO Board +image::images/cm4io.jpg[alt="Compute Module 4 IO Board", width="60%"] + +Compute Module 4 IO Board provides the following interfaces: + +* HAT footprint with 40-pin GPIO connector and PoE header +* 2× HDMI ports +* 2× USB 2.0 ports +* Gigabit Ethernet RJ45 with PoE support +* microSD card slot (only for use with Lite variants with no eMMC; other variants ignore the slot) +* PCIe Gen 2 socket +* micro USB upstream port +* 2× MIPI DSI display FPC connectors (22-pin 0.5 mm pitch cable) +* 2× MIPI CSI-2 camera FPC connectors (22-pin 0.5 mm pitch cable) +* Real-time clock with battery socket +* 12V input via barrel jack (supports up to 26V if PCIe unused) + +=== Compute Module IO Board + +.Compute Module IO Board +image::images/cmio.jpg[alt="Compute Module IO Board", width="60%"] + +Compute Module IO Board provides the following interfaces: + +* 120 GPIO pins +* HDMI port +* USB-A port +* 2× MIPI DSI display FPC connectors (22-pin 0.5 mm pitch cable) +* 2× MIPI CSI-2 camera FPC connectors (22-pin 0.5 mm pitch cable) + +The Compute Module IO Board comes in two variants: Version 1 and Version 3. Version 1 is only compatible with CM1. Version 3 is compatible with CM1, CM3, CM3+, and CM4S. Compute Module IO Board Version 3 is sometimes written as the shorthand CMIO3. + +Compute Module IO Board Version 3 added a microSD card slot that did not exist in Compute Module IO Board Version 1. + +=== IO Board compatibility + +Not all Compute Module IO Boards work with all Compute Module models. The following table shows which Compute Modules work with each IO Board: + +[cols="1,1"] +|=== +| IO Board | Compatible Compute Modules + +| Compute Module IO Board Version 1 (CMIO)/(CMIO1) +a| +* CM1 +| Compute Module IO Board Version 3 (CMIO)/(CMIO3) +a| +* CM1 +* CM3 +* CM3+ +* CM4S +| Compute Module 4 IO Board (CM4IO) +a| +* CM4 +* CM5 (with reduced functionality) +| Compute Module 5 IO Board (CM5IO) +a| +* CM5 +* CM4 (with reduced functionality) +|=== + +== CM5 Accessories + +=== IO Case + +The world can be a dangerous place. The Compute Module 5 IO Board Case provides physical protection for a CM5IO Board. + +.Compute Module 5 IO Board Case +image::images/cm5io-case.png[alt="Compute Module 5 IO Board Case", width="60%"] + +The Case provides cut-outs for all externally-facing ports and LEDs on the CM5IO Board, and an attachment point for a Raspberry Pi Antenna Kit. + +.Compute Module 5 IO Board Case ports +image::images/cm5io-case-front.png[alt="the port selection on the Compute Module 5 IO Board Case", width="60%"] + +To mount a CM5IO Board within your Case, position your Board in the bottom section of the case, aligning the four mounting points inset slightly from each corner of the Board. Fasten four screws into the mounting points. Take care not to over-tighten the screws. + +To use the Case fan, connect the fan cable to the FAN (J14) port on the Board. + +To close the case, put the top section of the case on top of the bottom section of the case. Facing the front of the case, which has port pass-throughs, carefully align the screw holes on the left and right side of the case and the power button on the back of the case. Tighten four screws into the screw holes. Take care not to over-tighten the screws. + +TIP: The Case comes with a fan pre-installed. To close the case with the passive Cooler attached to your Compute Module, remove the fan. To remove the fan, remove the four screws positioned in the corners of the fan from the bottom of the top case. + +.CM5 Case physical specification +image::images/cm5-case-physical.png[alt="CM5 Case physical specification", width="80%"] + +=== Antenna + +The Raspberry Pi Antenna Kit provides a certified external antenna to boost wireless reception on a CM4 or CM5. + +.CM4 and CM5 Antenna +image::images/cm4-cm5-antenna.jpg[alt="The Antenna, connected to CM4", width="60%"] + +To attach the Antenna to your Compute Module and Case, complete the following steps: + +. Connect the https://en.wikipedia.org/wiki/Hirose_U.FL[U.FL connector] on the cable to the U.FL-compatible connector on your Compute Module. +. Secure the toothed washer onto the male SMA connector at the end of the cable, then insert the SMA connector, with the antenna facing outward, through the hole in the Case. +. Fasten the SMA connector into place with the retaining hexagonal nut and washer. +. Tighten the female SMA connector on the Antenna onto the male SMA connector. +. Adjust the Antenna to its final position by turning it up to 90°. + +.CM4 and CM5 Antenna assembly diagram +image::images/cm4-cm5-antenna-assembly.svg[alt="CM4 and CM5 antenna assembly diagram", width="60%"] + +To **use** the Antenna with your Compute Module, add a `dtoverlay` instruction in xref:../computers/config_txt.adoc[`/boot/firmware/config.txt`]. Add the following line to the end of `config.txt`: + +[source,ini] +---- +dtparam=ant2 +---- + +.CM4 and CM5 Antenna physical specification +image::images/cm4-cm5-antenna-physical.png[alt="CM4 and CM5 antenna physical specification", width="80%"] + +=== Cooler + +The CM5 Cooler helps dissipate heat from your CM5, improving CPU performance, longevity, and bumpiness. + +.CM5 Cooler +image::images/cm5-cooler.jpg[alt="CM5 Cooler", width="60%"] + +To mount the Cooler to your CM5, attach the thermally conductive silicone at the bottom of the Cooler to the top of your CM5. Align the cut-out in the heatsink with the antenna https://en.wikipedia.org/wiki/Hirose_U.FL[U.FL connector]. Optionally, fasten screws in the mounting points found in each corner to secure the Cooler. If you omit the screws, the bond between your Cooler and your Compute Module will improve through time, use, and trust. + +.CM5 Cooler physical specification +image::images/cm5-cooler-physical.png[alt="CM5 Cooler physical specification", width="80%"] + +NOTE: The CM5 Cooler is only compatible with the CM5IO Case if you remove the fan from the case. diff --git a/documentation/asciidoc/computers/config_txt.adoc b/documentation/asciidoc/computers/config_txt.adoc index 88c3157b40..500831113e 100644 --- a/documentation/asciidoc/computers/config_txt.adoc +++ b/documentation/asciidoc/computers/config_txt.adoc @@ -1,17 +1,11 @@ include::config_txt/what_is_config_txt.adoc[] -include::config_txt/memory.adoc[] - -include::config_txt/codeclicence.adoc[] +include::config_txt/autoboot.adoc[] -include::config_txt/video.adoc[] - -include::config_txt/pi4-hdmi.adoc[] +include::config_txt/common.adoc[] include::config_txt/audio.adoc[] -include::config_txt/camera.adoc[] - include::config_txt/boot.adoc[] include::config_txt/gpio.adoc[] @@ -20,5 +14,11 @@ include::config_txt/overclocking.adoc[] include::config_txt/conditional.adoc[] -include::config_txt/misc.adoc[] +include::config_txt/memory.adoc[] + +include::config_txt/codeclicence.adoc[] + +include::config_txt/video.adoc[] + +include::config_txt/camera.adoc[] diff --git a/documentation/asciidoc/computers/config_txt/audio.adoc b/documentation/asciidoc/computers/config_txt/audio.adoc index e2e1bf43f4..7ba0b541de 100644 --- a/documentation/asciidoc/computers/config_txt/audio.adoc +++ b/documentation/asciidoc/computers/config_txt/audio.adoc @@ -1,10 +1,18 @@ -== Onboard Analogue Audio (3.5mm Jack) +== Onboard analogue audio (3.5mm jack) The onboard audio output uses config options to change the way the analogue audio is driven, and whether some firmware features are enabled or not. +=== `audio_pwm_mode` + +`audio_pwm_mode=1` selects legacy low-quality analogue audio from the 3.5mm AV jack. + +`audio_pwm_mode=2` (the default) selects high quality analogue audio using an advanced modulation scheme. + +NOTE: This option uses more GPU compute resources and can interfere with some use cases on some models. + === `disable_audio_dither` -By default, a 1.0LSB dither is applied to the audio stream if it is routed to the analogue audio output. This can create audible background "hiss" in some situations, for example when the ALSA volume is set to a low level. Set `disable_audio_dither` to `1` to disable dither application. +By default, a 1.0LSB dither is applied to the audio stream if it is routed to the analogue audio output. This can create audible background hiss in some situations, for example when the ALSA volume is set to a low level. Set `disable_audio_dither` to `1` to disable dither application. === `enable_audio_dither` @@ -13,3 +21,15 @@ Audio dither (see disable_audio_dither above) is normally disabled when the audi === `pwm_sample_bits` The `pwm_sample_bits` command adjusts the bit depth of the analogue audio output. The default bit depth is `11`. Selecting bit depths below `8` will result in nonfunctional audio, as settings below `8` result in a PLL frequency too low to support. This is generally only useful as a demonstration of how bit depth affects quantisation noise. + +== HDMI audio + +By default, HDMI audio output is enabled on all Raspberry Pi models with HDMI output. + +To disable HDMI audio output, append `,noaudio` to the end of the `dtoverlay=vc4-kms-v3d` line in xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]: + +[source,ini] +---- +dtoverlay=vc4-kms-v3d,noaudio +---- + diff --git a/documentation/asciidoc/computers/config_txt/autoboot.adoc b/documentation/asciidoc/computers/config_txt/autoboot.adoc new file mode 100644 index 0000000000..fa37c855e4 --- /dev/null +++ b/documentation/asciidoc/computers/config_txt/autoboot.adoc @@ -0,0 +1,82 @@ +== `autoboot.txt` + +`autoboot.txt` is an optional configuration file that can be used to specify the `boot_partition` number. + +This can also be used in conjunction with the `tryboot` feature to implement A/B booting for OS upgrades. + +`autoboot.txt` is limited to 512 bytes and supports the `[all]`, `[none]` and `[tryboot]` xref:config_txt.adoc#conditional-filters[conditional] filters. + +See also xref:raspberry-pi.adoc#fail-safe-os-updates-tryboot[TRYBOOT] boot flow. + +=== `boot_partition` +Specifies the partition number for booting unless the partition number was already specified as a parameter to the `reboot` command (e.g. `sudo reboot 2`). + +Partition numbers start at `1` and the MBR partitions are `1` to `4`. Specifying partition `0` means boot from the `default` partition which is the first bootable FAT partition. + +Bootable partitions must be formatted as FAT12, FAT16 or FAT32 and contain a `start.elf` file (or `config.txt` file on Raspberry Pi 5) in order to be classed as be bootable by the bootloader. + +=== The `[tryboot]` filter +This filter passes if the system was booted with the `tryboot` flag set. + +[source,console] +---- +$ sudo reboot "0 tryboot" +---- + +=== `tryboot_a_b` +Set this property to `1` to load the normal `config.txt` and `boot.img` files instead of `tryboot.txt` and `tryboot.img` when the `tryboot` flag is set. + +This enables the `tryboot` switch to be made at the partition level rather than the file-level without having to modify configuration files in the A/B partitions. + +=== Example update flow for A/B booting + +The following pseudo-code shows how a hypothetical OS `Update service` could use `tryboot` in `autoboot.txt` to perform a fail-safe OS upgrade. + +Initial `autoboot.txt`: + +[source,ini] +---- +[all] +tryboot_a_b=1 +boot_partition=2 +[tryboot] +boot_partition=3 +---- + +**Installing the update** + +* System is powered on and boots to partition 2 by default +* An `Update service` downloads the next version of the OS to partition 3 +* The update is tested by rebooting to `tryboot` mode `reboot "0 tryboot"` where `0` means the default partition + +**Committing or cancelling the update** + +* System boots from partition 3 because the `[tryboot]` filter evaluates to true in `tryboot mode` +* If tryboot is active (`/proc/device-tree/chosen/bootloader/tryboot == 1`) + ** If the current boot partition (`/proc/device-tree/chosen/bootloader/partition`) matches the `boot_partition` in the `[tryboot]` section of `autoboot.txt` + *** The `Update Service` validates the system to verify that the update was successful + *** If the update was successful + **** Replace `autoboot.txt` swapping the `boot_partition` configuration + **** Normal reboot - partition 3 is now the default boot partition + *** Else + **** `Update Service` marks the update as failed e.g. it removes the update files. + **** Normal reboot - partition 2 is still the default boot partition because the `tryboot` flag is automatically cleared + *** End if + ** End If +* End If + +Updated `autoboot.txt`: + +[source,ini] +---- +[all] +tryboot_a_b=1 +boot_partition=3 +[tryboot] +boot_partition=2 +---- + +[NOTE] +====== +It's not mandatory to reboot after updating `autoboot.txt`. However, the `Update Service` must be careful to avoid overwriting the current partition since `autoboot.txt` has already been modified to commit the last update. For more information, see xref:configuration.adoc#device-trees-overlays-and-parameters[Device Tree parameters]. +====== diff --git a/documentation/asciidoc/computers/config_txt/boot.adoc b/documentation/asciidoc/computers/config_txt/boot.adoc index 2adb08ff0e..b87ef830d3 100644 --- a/documentation/asciidoc/computers/config_txt/boot.adoc +++ b/documentation/asciidoc/computers/config_txt/boot.adoc @@ -5,29 +5,13 @@ These options specify the firmware files transferred to the VideoCore GPU prior to booting. `start_file` specifies the VideoCore firmware file to use. -`fixup_file` specifies the file used to fix up memory locations used in the `start_file` to match the GPU memory split. Note that the `start_file` and the `fixup_file` are a matched pair - using unmatched files will stop the board from booting. This is an advanced option, so we advise that you use `start_x` and `start_debug` rather than this option. +`fixup_file` specifies the file used to fix up memory locations used in the `start_file` to match the GPU memory split. -=== `start_x`, `start_debug` +The `start_file` and the `fixup_file` are a matched pair - using unmatched files will stop the board from booting. This is an advanced option, so we advise that you use `start_x` and `start_debug` rather than this option. -These provide a shortcut to some alternative `start_file` and `fixup_file` settings, and are the recommended methods for selecting firmware configurations. +NOTE: Cut-down firmware (`start*cd.elf` and `fixup*cd.dat`) cannot be selected this way - the system will fail to boot. The only way to enable the cut-down firmware is to specify `gpu_mem=16`. The cut-down firmware removes support for codecs, 3D and debug logging as well as limiting the initial early-boot framebuffer to 1080p @16bpp - although KMS can replace this with up to 32bpp 4K framebuffer(s) at a later stage as with any firmware. -`start_x=1` implies - `start_file=start_x.elf` - `fixup_file=fixup_x.dat` - -On the Pi 4, if the files `start4x.elf` and `fixup4x.dat` are present, these files will be used instead. - -`start_debug=1` implies - `start_file=start_db.elf` - `fixup_file=fixup_db.dat` - -There is no specific handling for the Pi 4, so if you wish to use the Pi 4 debug firmware files, you need to manually specify `start_file` and `fixup_file`. - -`start_x=1` should be specified when using the camera module. Enabling the camera via `raspi-config` will set this automatically. - -=== `disable_commandline_tags` - -Set the `disable_commandline_tags` command to `1` to stop `start.elf` from filling in ATAGS (memory from `0x100`) before launching the kernel. +NOTE: The Raspberry Pi 5, Compute Module 5, and Raspberry Pi 500 firmware is self-contained in the bootloader EEPROM. === `cmdline` @@ -35,85 +19,75 @@ Set the `disable_commandline_tags` command to `1` to stop `start.elf` from filli === `kernel` -`kernel` is the alternative filename on the boot partition to use when loading the kernel. The default value on the Pi 1, Pi Zero, and Compute Module is `kernel.img`, and on the Pi 2, Pi 3, and Compute Module 3 it is `kernel7.img`. On the Pi4, it is `kernel7l.img`. +`kernel` is the alternative filename on the boot partition for loading the kernel. The default value on the Raspberry Pi 1, Zero and Zero W, and Raspberry Pi Compute Module 1 is `kernel.img`. The default value on the Raspberry Pi 2, 3, 3+ and Zero 2 W, and Raspberry Pi Compute Modules 3 and 3+ is `kernel7.img`. The default value on the Raspberry Pi 4 and 400, and Raspberry Pi Compute Module 4 is `kernel8.img`, or `kernel7l.img` if `arm_64bit` is set to 0. -=== `arm_64bit` +The Raspberry Pi 5, Compute Module 5, and Raspberry Pi 500 firmware defaults to loading `kernel_2712.img` because this image contains optimisations specific to those models (e.g. 16K page-size). If this file is not present, then the common 64-bit kernel (`kernel8.img`) will be loaded instead. -If set to non-zero, forces the kernel loading system to assume a 64-bit kernel, starts the processors up in 64-bit mode, and sets `kernel8.img` to be the kernel image loaded, unless there is an explicit `kernel` option defined in which case that is used instead. Defaults to 0 on all platforms. *NOTE*: 64-bit kernels may be uncompressed image files or a gzip archive of an image (which can still be called kernel8.img; the bootloader will recognize the archive from the signature bytes at the beginning). - -Note that the 64-bit kernel will only work on the Pi4, Pi3, and Pi2B rev1.2 boards with latest firmware. - -=== `arm_control` - -WARNING: This setting is *DEPRECATED*, use `arm_64bit` instead to enable 64-bit kernels. - -Sets board-specific control bits. - -=== `armstub` +=== `arm_64bit` -`armstub` is the filename on the boot partition from which to load the ARM stub. The default ARM stub is stored in firmware and is selected automatically based on the Pi model and various settings. +If set to 1, the kernel will be started in 64-bit mode. Setting to 0 selects 32-bit mode. -The stub is a small piece of ARM code that is run before the kernel. Its job is to set up low-level hardware like the interrupt controller before passing control to the kernel. +In 64-bit mode, the firmware will choose an appropriate kernel (e.g. `kernel8.img`), unless there is an explicit `kernel` option defined, in which case that is used instead. -=== `arm_peri_high` +Defaults to 1 on Raspberry Pi 4, 400 and Compute Module 4, 4S platforms. Defaults to 0 on all other platforms. However, if the name given in an explicit `kernel` option matches one of the known kernels then `arm_64bit` will be set accordingly. -Set `arm_peri_high` to `1` to enable "High Peripheral" mode on the Pi 4. It is set automatically if a suitable DTB is loaded. +64-bit kernels come in the following forms: -NOTE: Enabling "High Peripheral" mode without a compatible device tree will make your system fail to boot. Currently ARM stub support is missing, so you will also need to load a suitable file using `armstub`. +* uncompressed image files +* gzip archives of an image -=== `kernel_address` +Both forms may use the `img` file extension; the bootloader recognizes archives using signature bytes at the start of the file. -`kernel_address` is the memory address to which the kernel image should be loaded. 32-bit kernels are loaded to address `0x8000` by default, and 64-bit kernels to address `0x80000`. If `kernel_old` is set, kernels are loaded to the address `0x0`. +The following Raspberry Pi models support this flag: -=== `kernel_old` +* 2B rev 1.2 +* 3B +* 3A+ +* 3B+ +* 4B +* 400 +* Zero 2 W +* Compute Module 3 +* Compute Module 3+ +* Compute Module 4 +* Compute Module 4S -Set `kernel_old` to `1` to load the kernel to the memory address `0x0`. +Flagship models since Raspberry Pi 5, Compute Modules since CM5, and Keyboard models since Pi 500 _only_ support the 64-bit kernel. Models that only support a 64-bit kernel ignore this flag. === `ramfsfile` `ramfsfile` is the optional filename on the boot partition of a `ramfs` to load. -NOTE: Newer firmware supports the loading of multiple `ramfs` files. You should separate the multiple file names with commas, taking care not to exceed the 80-character line length limit. All the loaded files are concatenated in memory and treated as a single `ramfs` blob. More information is available https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=10532[on the forums]. +NOTE: Newer firmware supports the loading of multiple `ramfs` files. You should separate the multiple file names with commas, taking care not to exceed the 80-character line length limit. All the loaded files are concatenated in memory and treated as a single `ramfs` blob. More information is available https://forums.raspberrypi.com/viewtopic.php?f=63&t=10532[on the forums]. === `ramfsaddr` `ramfsaddr` is the memory address to which the `ramfsfile` should be loaded. +[[initramfs]] === `initramfs` The `initramfs` command specifies both the ramfs filename *and* the memory address to which to load it. It performs the actions of both `ramfsfile` and `ramfsaddr` in one parameter. The address can also be `followkernel` (or `0`) to place it in memory after the kernel image. Example values are: `initramfs initramf.gz 0x00800000` or `initramfs init.gz followkernel`. As with `ramfsfile`, newer firmwares allow the loading of multiple files by comma-separating their names. -NOTE: This option uses different syntax from all the other options, and you should not use a `=` character here. +NOTE: This option uses different syntax from all the other options, and you should not use the `=` character here. -=== `init_uart_baud` +[[auto_initramfs]] +=== `auto_initramfs` -`init_uart_baud` is the initial UART baud rate. The default value is `115200`. +If `auto_initramfs` is set to `1`, the firmware looks for an `initramfs` file to match the kernel. The file must be in the same location as the kernel image, and the name is derived from the name of the kernel by replacing the `kernel` prefix with `initramfs`, and removing any extension such as `.img`, e.g. `kernel8.img` requires `initramfs8`. You can make use of `auto_initramfs` with custom kernel names provided the names begin with `kernel` and `initramfs` respectively and everything else matches (except for the absence of the file extension on the initramfs). Otherwise, an explicit xref:config_txt.adoc#initramfs[`initramfs`] statement is required. -=== `init_uart_clock` +[[disable_poe_fan]] +=== `disable_poe_fan` -`init_uart_clock` is the initial UART clock frequency. The default value is `48000000` (48MHz). Note that this clock only applies to UART0 (ttyAMA0 in Linux), and that the maximum baudrate for the UART is limited to 1/16th of the clock. The default UART on the Pi 3 and Pi Zero is UART1 (ttyS0 in Linux), and its clock is the core VPU clock - at least 250MHz. - -=== `bootcode_delay` - -The `bootcode_delay` command delays for a given number of seconds in `bootcode.bin` before loading `start.elf`: the default value is `0`. - -This is particularly useful to insert a delay before reading the EDID of the monitor, for example if the Pi and monitor are powered from the same source, but the monitor takes longer to start up than the Pi. Try setting this value if the display detection is wrong on initial boot, but is correct if you soft-reboot the Pi without removing power from the monitor. - -=== `boot_delay` - -The `boot_delay` command instructs to wait for a given number of seconds in `start.elf` before loading the kernel: the default value is `1`. The total delay in milliseconds is calculated as `(1000 x boot_delay) + boot_delay_ms`. This can be useful if your SD card needs a while to get ready before Linux is able to boot from it. - -=== `boot_delay_ms` - -The `boot_delay_ms` command means wait for a given number of milliseconds in `start.elf`, together with `boot_delay`, before loading the kernel. The default value is `0`. +By default, a probe on the I2C bus will happen at startup, even when a PoE HAT is not attached. Setting this option to 1 disables control of a PoE HAT fan through I2C (on pins ID_SD & ID_SC). If you are not intending to use a PoE HAT, this is a helpful way to minimise boot time. === `disable_splash` If `disable_splash` is set to `1`, the rainbow splash screen will not be shown on boot. The default value is `0`. -=== `enable_gic` (Raspberry Pi 4 Only) +=== `enable_uart` -On the Raspberry Pi 4B, if this value is set to `0` then the interrupts will be routed to the ARM cores using the legacy interrupt controller, rather than via the GIC-400. The default value is `1`. +`enable_uart=1` (in conjunction with `console=serial0,115200` in `cmdline.txt`) requests that the kernel creates a serial console, accessible using GPIOs 14 and 15 (pins 8 and 10 on the 40-pin header). Editing `cmdline.txt` to remove the line `quiet` enables boot messages from the kernel to also appear there. See also `uart_2ndstage`. === `force_eeprom_read` @@ -122,33 +96,220 @@ Set this option to `0` to prevent the firmware from trying to read an I2C HAT EE [[os_prefix]] === `os_prefix` -`os_prefix` is an optional setting that allows you to choose between multiple versions of the kernel and Device Tree files installed on the same card. Any value in `os_prefix` is prepended to (stuck in front of) the name of any operating system files loaded by the firmware, where "operating system files" is defined to mean kernels, initramfs, cmdline.txt, .dtbs and overlays. The prefix would commonly be a directory name, but it could also be part of the filename such as "test-". For this reason, directory prefixes must include the trailing `/` character. +`os_prefix` is an optional setting that allows you to choose between multiple versions of the kernel and Device Tree files installed on the same card. Any value in `os_prefix` is prepended to the name of any operating system files loaded by the firmware, where "operating system files" is defined to mean kernels, `initramfs`, `cmdline.txt`, `.dtbs` and overlays. The prefix would commonly be a directory name, but it could also be part of the filename such as "test-". For this reason, directory prefixes must include the trailing `/` character. In an attempt to reduce the chance of a non-bootable system, the firmware first tests the supplied prefix value for viability - unless the expected kernel and .dtb can be found at the new location/name, the prefix is ignored (set to ""). A special case of this viability test is applied to overlays, which will only be loaded from `+${os_prefix}${overlay_prefix}+` (where the default value of <> is "overlays/") if `+${os_prefix}${overlay_prefix}README+` exists, otherwise it ignores `os_prefix` and treats overlays as shared. -(The reason the firmware checks for the existence of key files rather than directories when checking prefixes is twofold - the prefix may not be a directory, and not all boot methods support testing for the existence of a directory.) +(The reason the firmware checks for the existence of key files rather than directories when checking prefixes is twofold: the prefix may not be a directory, and not all boot methods support testing for the existence of a directory.) NOTE: Any user-specified OS file can bypass all prefixes by using an absolute path (with respect to the boot partition) - just start the file path with a `/`, e.g. `kernel=/my_common_kernel.img`. -See also <> and <>. +See also <> and xref:legacy_config_txt.adoc#upstream_kernel[`upstream_kernel`]. + +=== `otg_mode` (Raspberry Pi 4 only) + +USB On-The-Go (often abbreviated to OTG) is a feature that allows supporting USB devices with an appropriate OTG cable to configure themselves as USB hosts. On older Raspberry Pis, a single USB 2 controller was used in both USB host and device mode. + +Flagship models since Raspberry Pi 4B and Keyboard models since Pi 400 add a high-performance USB 3 controller, attached via PCIe, to drive the main USB ports. The legacy USB 2 controller is still available on the USB-C power connector for use as a device (`otg_mode=0`, the default). Compute Modules before CM5 do not include this high-performance USB 3 controller. + +`otg_mode=1` requests that a more capable XHCI USB 2 controller is used as an alternative host controller on that USB-C connector. + +NOTE: By default, Raspberry Pi OS includes a line in `/boot/firmware/config.txt` that enables this setting on Compute Module 4. + [[overlay_prefix]] === `overlay_prefix` -Specifies a subdirectory/prefix from which to load overlays - defaults to `overlays/` (note the trailing `/`). If used in conjunction with <>, the `os_prefix` comes before the `overlay_prefix`, i.e. `dtoverlay=disable-bt` will attempt to load `+${os_prefix}${overlay_prefix}disable-bt.dtbo+`. +Specifies a subdirectory/prefix from which to load overlays, and defaults to `overlays/` (note the trailing `/`). If used in conjunction with <>, the `os_prefix` comes before the `overlay_prefix`, i.e. `dtoverlay=disable-bt` will attempt to load `+${os_prefix}${overlay_prefix}disable-bt.dtbo+`. NOTE: Unless `+${os_prefix}${overlay_prefix}README+` exists, overlays are shared with the main OS (i.e. `os_prefix` is ignored). -=== `uart_2ndstage` +=== Configuration Properties + +Raspberry Pi 5 requires a `config.txt` file to be present to indicate that the partition is bootable. + +[[boot_ramdisk]] +==== `boot_ramdisk` + +If this property is set to `1` then the bootloader will attempt load a ramdisk file called `boot.img` containing the xref:configuration.adoc#boot-folder-contents[boot filesystem]. Subsequent files (e.g. `start4.elf`) are read from the ramdisk instead of the original boot file system. + +The primary purpose of `boot_ramdisk` is to support `secure-boot`, however, unsigned `boot.img` files can also be useful to Network Boot or `RPIBOOT` configurations. + +* The maximum size for a ramdisk file is 96MB. +* `boot.img` files are raw disk `.img` files. The recommended format is a plain FAT32 partition with no MBR. +* The memory for the ramdisk filesystem is released before the operating system is started. +* If xref:raspberry-pi.adoc#fail-safe-os-updates-tryboot[TRYBOOT] is selected then the bootloader will search for `tryboot.img` instead of `boot.img`. +* See also xref:config_txt.adoc#autoboot-txt[autoboot.txt]. + +For more information about `secure-boot` and creating `boot.img` files please see https://github.com/raspberrypi/usbboot/blob/master/Readme.md[USBBOOT]. + +Default: `0` + +[[boot_load_flags]] +==== `boot_load_flags` + +Experimental property for custom firmware (bare metal). + +Bit 0 (0x1) indicates that the .elf file is custom firmware. This disables any compatibility checks (e.g. is USB MSD boot supported) and resets PCIe before starting the executable. + +Not relevant on Raspberry Pi 5 because there is no `start.elf` file. + +Default: `0x0` + +[[enable_rp1_uart]] +==== `enable_rp1_uart` + +When set to `1`, firmware initialises RP1 UART0 to 115200bps and doesn't reset RP1 before starting the OS (separately configurable using `pciex4_reset=1`). +This makes it easier to get UART output on the 40-pin header in early boot-code, for instance during bare-metal debug. + +Default: `0x0` + +[[pciex4_reset]] +==== `pciex4_reset` + +Raspberry Pi 5 only. + +By default, the PCIe x4 controller used by `RP1` is reset before starting the operating system. If this parameter is set to `0` then the reset is disabled allowing operating system or bare metal code to inherit the PCIe configuration setup from the bootloader. + +Default: `1` + +[[uart_2ndstage]] +==== `uart_2ndstage` + +If `uart_2ndstage` is `1` then enable debug logging to the UART. This option also automatically enables UART logging in `start.elf`. This is also described on the xref:config_txt.adoc#boot-options[Boot options] page. + +The `BOOT_UART` property also enables bootloader UART logging but does not enable UART logging in `start.elf` unless `uart_2ndstage=1` is also set. + +Default: `0` + +[[erase_eeprom]] +==== `erase_eeprom` + +If `erase_eeprom` is set to `1` then `recovery.bin` will erase the entire SPI EEPROM instead of flashing the bootloader image. This property has no effect during a normal boot. + +Default: `0` + +[[set_reboot_arg1]] +==== `set_reboot_arg1` +Raspberry Pi 5 only. + +Sets the value of `boot_arg1` to be passed via a reset-safe register to the bootloader after a reboot. +See xref:config_txt.adoc#boot_arg1[`boot_arg1`] for more details. +Default: `` + +[[set_reboot_order]] +==== `set_reboot_order` + +Raspberry Pi 5 only. + +Sets the value of xref:raspberry-pi.adoc#BOOT_ORDER[BOOT_ORDER] to be passed via a reset-safe register to the bootloader after a reboot. As with `tryboot`, this is a one-time setting and is automatically cleared after use. + +This property could be used to debug different xref:raspberry-pi.adoc#BOOT_ORDER[BOOT_ORDER] settings. Alternatively, it could be used in a provisioning system which has control over power and the `nRPIBOOT` GPIO to override the boot mode without specifying xref:config_txt.adoc#conditional-filters[conditional filter] statements in the EEPROM config. + +Default: `` + + +[[eeprom_write_protect]] +==== `eeprom_write_protect` + +Configures the EEPROM `write status register`. This can be set either to mark the entire EEPROM as write-protected, or to clear write-protection. + +This option must be used in conjunction with the EEPROM `/WP` pin which controls updates to the EEPROM `Write Status Register`. Pulling `/WP` low (CM4 `EEPROM_nWP` or on a Raspberry Pi 4 `TP5`) does NOT write-protect the EEPROM unless the `Write Status Register` has also been configured. + +See the https://www.winbond.com/resource-files/w25x40cl_f%2020140325.pdf[Winbond W25x40cl] or https://www.winbond.com/hq/product/code-storage-flash-memory/serial-nor-flash/?__locale=en&partNo=W25Q16JV[Winbond W25Q16JV] datasheets for further details. + +`eeprom_write_protect` settings in `config.txt` for `recovery.bin`. + +|=== +| Value | Description + +| 1 +| Configures the write protect regions to cover the entire EEPROM. + +| 0 +| Clears the write protect regions. + +| -1 +| Do nothing. +|=== + +NOTE: `flashrom` does not support clearing of the write-protect regions and will fail to update the EEPROM if write-protect regions are defined. + +On Raspberry Pi 5 `/WP` is pulled low by default and consequently write-protect is enabled as soon as the `Write Status Register` is configured. To clear write-protect pull `/WP` high by connecting `TP14` and `TP1`. + +Default: `-1` + +[[os_check]] +==== `os_check` + +On Raspberry Pi 5 the firmware automatically checks for a compatible Device Tree file before attempting to boot from the current partition. Otherwise, older non-compatible kernels would be loaded and then hang. +To disable this check (e.g. for bare-metal development), set `os_check=0` in config.txt + +Default: `1` + +[[bootloader_update]] +==== `bootloader_update` + +This option may be set to 0 to block self-update without requiring the EEPROM configuration to be updated. This is sometimes useful when updating multiple Raspberry Pis via network boot because this option can be controlled per Raspberry Pi (e.g. via a serial number filter in `config.txt`). + +Default: `1` + +=== Secure Boot configuration properties + +[.whitepaper, title="How to use Raspberry Pi Secure Boot", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003466-WP/Boot-Security-Howto.pdf] +**** +This whitepaper describes how to implement secure boot on devices based on Raspberry Pi 4. For an overview of our approach to implementing secure boot implementation, please see the https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-004651-WP/Raspberry-Pi-4-Boot-Security.pdf[Raspberry Pi 4 Boot Security] whitepaper. The secure boot system is intended for use with `buildroot`-based OS images; using it with Raspberry Pi OS is not recommended or supported. +**** + +The following `config.txt` properties are used to program the `secure-boot` OTP settings. These changes are irreversible and can only be programmed via `RPIBOOT` when flashing the bootloader EEPROM image. This ensures that `secure-boot` cannot be set remotely or by accidentally inserting a stale SD card image. + +For more information about enabling `secure-boot` please see the https://github.com/raspberrypi/usbboot/blob/master/Readme.md#secure-boot[Secure Boot readme] and the https://github.com/raspberrypi/usbboot/blob/master/secure-boot-example/README.md[Secure Boot tutorial] in the https://github.com/raspberrypi/usbboot[USBBOOT] repo. + +[[program_pubkey]] +==== `program_pubkey` + +If this property is set to `1` then `recovery.bin` will write the hash of the public key in the EEPROM image to OTP. Once set, the bootloader will reject EEPROM images signed with different RSA keys or unsigned images. + +Default: `0` + +[[revoke_devkey]] +==== `revoke_devkey` + +Raspberry Pi 4 only. + +If this property is set to `1` then `recovery.bin` will write a value to OTP that prevents the ROM from loading old versions of the second stage bootloader which do not support `secure-boot`. This prevents `secure-boot` from being turned off by reverting to an older release of the bootloader. Therefore, this property must be set if `secure-boot` is enabled on production devices. + +This property is automatically is set by `recovery.bin` `2025/05/16` and newer if `program_pubkey=1`. + + +Default: `0` + +[[program_rpiboot_gpio]] +==== `program_rpiboot_gpio` + +Raspberry Pi 4B and Raspberry Pi 400 only. + +Compute Module 4 and 4S have a dedicated `nRPIBOOT` jumper to select `RPIBOOT` mode. Raspberry Pi 4B and Raspberry Pi 400 lack a dedicated `nRPIBOOT` jumper so one of the following GPIOs must be selected for use as `nRPIBOOT`. + +* `2` +* `4` +* `5` +* `6` +* `7` +* `8` + +The GPIO may be used as a general-purpose I/O pin after the OS has started. However, you should verify that this GPIO configuration does not conflict with any HATs which might pull the GPIO low during boot. + +Although `secure-boot` requires this property to be set on Raspberry Pi 4B and Raspberry Pi 400, it does not depend on `secure-boot`. For example, `RPIBOOT` can be useful for automated testing. -Setting `uart_2ndstage=1` causes the second-stage loader (`bootcode.bin` on devices prior to the Raspberry Pi 4, or the boot code in the EEPROM for Raspberry Pi 4 devices) and the main firmware (`start*.elf`) to output diagnostic information to UART0. +For safety, this OTP value can _only_ be programmed via `RPIBOOT`. As a result, you must first clear the bootloader EEPROM using `erase_eeprom`. The blank EEPROM causes the ROM to failover to `RPIBOOT` mode, which then allows this option to be set. -Be aware that output is likely to interfere with Bluetooth operation unless it is disabled (`dtoverlay=disable-bt`) or switched to the other UART (`dtoverlay=miniuart-bt`), and if the UART is accessed simultaneously to output from Linux then data loss can occur leading to corrupted output. This feature should only be required when trying to diagnose an early boot loading problem. +Default: `{nbsp}` -[[upstream_kernel]] -=== `upstream_kernel` +[[program_jtag_lock]] +==== `program_jtag_lock` -If `upstream_kernel=1` is used, the firmware sets <> to "upstream/", unless it has been explicitly set to something else, but like other `os_prefix` values it will be ignored if the required kernel and .dtb file can't be found when using the prefix. +If this property is set to `1` then `recovery.bin` will program an OTP value that prevents VideoCore JTAG from being used. This option requires that `program_pubkey` and `revoke_devkey` are also set. This option can prevent failure analysis, and should only be set after the device has been fully tested. -The firmware will also prefer upstream Linux names for DTBs (`bcm2837-rpi-3-b.dtb` instead of `bcm2710-rpi-3-b.dtb`, for example). If the upstream file isn't found the firmware will load the downstream variant instead and automatically apply the "upstream" overlay to make some adjustments. Note that this process happens _after_ the `os_prefix` has been finalised. +Default: `0` diff --git a/documentation/asciidoc/computers/config_txt/camera.adoc b/documentation/asciidoc/computers/config_txt/camera.adoc index e8dc2def95..a3caa01349 100644 --- a/documentation/asciidoc/computers/config_txt/camera.adoc +++ b/documentation/asciidoc/computers/config_txt/camera.adoc @@ -1,9 +1,9 @@ -== Camera Settings +== Camera settings === `disable_camera_led` -Setting `disable_camera_led` to `1` prevents the red camera LED from turning on when recording video or taking a still picture. This is useful for preventing reflections when the camera is facing a window, for example. +Setting `disable_camera_led` to `1` prevents the red camera LED from turning on when recording video or taking a still picture. This is useful for preventing reflections, for example when the camera is facing a window. === `awb_auto_is_greyworld` -Setting `awb_auto_is_greyworld` to `1` allows libraries or applications that do not support the greyworld option internally to capture valid images and videos with NoIR cameras. It switches "auto" awb mode to use the "greyworld" algorithm. This should only be be needed for NoIR cameras, or when the High Quality camera has had its xref:../accessories/camera.adoc#raspberry-pi-hq-camera-filter-removal[IR filter removed]. +Setting `awb_auto_is_greyworld` to `1` allows libraries or applications that do not support the greyworld option internally to capture valid images and videos with NoIR cameras. It switches auto awb mode to use the greyworld algorithm. This should only be needed for NoIR cameras, or when the High Quality camera has had its xref:../accessories/camera.adoc#filter-removal[IR filter removed]. diff --git a/documentation/asciidoc/computers/config_txt/codeclicence.adoc b/documentation/asciidoc/computers/config_txt/codeclicence.adoc index 872f31e5cc..688591a12f 100644 --- a/documentation/asciidoc/computers/config_txt/codeclicence.adoc +++ b/documentation/asciidoc/computers/config_txt/codeclicence.adoc @@ -1,8 +1,10 @@ -== Licence Key and Codec Options +== Licence key and codec options -Hardware decoding of additional codecs on the Pi 3 and earlier models can be enabled by http://codecs.raspberrypi.org/license-keys/[purchasing a licence] that is locked to the CPU serial number of your Raspberry Pi. +Hardware decoding of additional codecs on the Raspberry Pi 3 and earlier models can be enabled by https://codecs.raspberrypi.com/license-keys/[purchasing a licence] that is locked to the CPU serial number of your Raspberry Pi. -On the Raspberry Pi 4, the hardware codecs for MPEG2 or VC1 are permanently disabled and cannot be enabled even with a licence key; on the Pi 4, thanks to its increased processing power compared to earlier models, MPEG2 and VC1 can be decoded in software via applications such as VLC. Therefore, a hardware codec licence key is not needed if you're using a Pi 4. +The Raspberry Pi 4 has permanently disabled hardware decoders for MPEG2 and VC1. These codecs cannot be enabled, so a hardware codec licence key is not needed. Software decoding of MPEG2 and VC1 files performs well enough for typical use cases. + +The Raspberry Pi 5 has H.265 (HEVC) hardware decoding. This decoding is enabled by default, so a hardware codec licence key is not needed. === `decode_MPG2` @@ -12,4 +14,4 @@ On the Raspberry Pi 4, the hardware codecs for MPEG2 or VC1 are permanently disa `decode_WVC1` is a licence key to allow hardware VC-1 decoding, e.g. `decode_WVC1=0x12345678`. -If you have multiple Raspberry Pis and you've bought a codec licence for each of them, you can list up to eight licence keys in a single `config.txt`, for example `decode_MPG2=0x12345678,0xabcdabcd,0x87654321`. This enables you to swap the same SD card between the different Pis without having to edit `config.txt` each time. +If you have multiple Raspberry Pis and you've bought a codec licence for each of them, you can list up to eight licence keys in a single `config.txt`, for example `decode_MPG2=0x12345678,0xabcdabcd,0x87654321`. This enables you to swap the same SD card between the different Raspberry Pis without having to edit `config.txt` each time. diff --git a/documentation/asciidoc/computers/config_txt/common.adoc b/documentation/asciidoc/computers/config_txt/common.adoc new file mode 100644 index 0000000000..7f4f89708e --- /dev/null +++ b/documentation/asciidoc/computers/config_txt/common.adoc @@ -0,0 +1,59 @@ +== Common options + +=== Common display options + +==== `hdmi_enable_4kp60` + +NOTE: This option applies only to Raspberry Pi 4, Compute Module 4, Compute Module 4S, and Pi 400. + +By default, when connected to a 4K monitor, certain models select a 30Hz refresh rate. Use this option to allow selection of 60Hz refresh rates. Models impacted by this setting do _not_ support 4Kp60 output on both micro HDMI ports simultaneously. Enabling this setting increases power consumption and temperature. + +=== Common hardware configuration options + +==== `camera_auto_detect` + +By default, Raspberry Pi OS includes a line in `/boot/firmware/config.txt` that enables this setting. + +When enabled, the firmware will automatically load overlays for recognised CSI cameras. + +To disable, set `camera_auto_detect=0` (or remove `camera_auto_detect=1`). + +==== `display_auto_detect` + +By default, Raspberry Pi OS includes a line in `/boot/firmware/config.txt` that enables this setting. + +When enabled, the firmware will automatically load overlays for recognised DSI displays. + +To disable, set `display_auto_detect=0` (or remove `display_auto_detect=1`). + +==== `dtoverlay` + +The `dtoverlay` option requests the firmware to load a named Device Tree overlay - a configuration file that can enable kernel support for built-in and external hardware. For example, `dtoverlay=vc4-kms-v3d` loads an overlay that enables the kernel graphics driver. + +As a special case, if called with no value - `dtoverlay=` - the option marks the end of a list of overlay parameters. If used before any other `dtoverlay` or `dtparam` setting, it prevents the loading of any HAT overlay. + +For more details, see xref:configuration.adoc#part3.1[DTBs, overlays and config.txt]. + +==== `dtparam` + +Device Tree configuration files for Raspberry Pi devices support various parameters for such things as enabling I2C and SPI interfaces. Many DT overlays are configurable via the use of parameters. Both types of parameters can be supplied using the `dtparam` setting. In addition, overlay parameters can be appended to the `dtoverlay` option, separated by commas, but keep in mind the line length limit of 98 characters. + +For more details, see xref:configuration.adoc#part3.1[DTBs, overlays and config.txt]. + +==== `arm_boost` + +NOTE: This option applies only to later Raspberry Pi 4B revisions which include two-phase power delivery, and all revisions of Pi 400. + +By default, Raspberry Pi OS includes a line in `/boot/firmware/config.txt` that enables this setting on supported devices. + +Some Raspberry Pi devices have a second switch-mode power supply for the SoC voltage rail. When enabled, increases the default turbo-mode clock from 1.5GHz to 1.8GHz. + +To disable, set `arm_boost=0`. + +==== `power_force_3v3_pwm` + +NOTE: This option applies only to Raspberry Pi 5, Compute Module 5, and Pi 500. + +Forces PWM on 3.3V output from the GPIO header or CSI connector. + +To disable, set `power_force_3v3_pwm=0`. diff --git a/documentation/asciidoc/computers/config_txt/conditional.adoc b/documentation/asciidoc/computers/config_txt/conditional.adoc index 515496d96d..f905c870e7 100644 --- a/documentation/asciidoc/computers/config_txt/conditional.adoc +++ b/documentation/asciidoc/computers/config_txt/conditional.adoc @@ -1,6 +1,7 @@ -== Conditional Filters +[[conditional-filters]] +== Conditional filters -When a single SD Card (or card image) is being used with one Raspberry Pi and one monitor, it is easy to set `config.txt` as required for that specific combination and keep it that way, amending it only when something changes. +When a single SD card (or card image) is being used with one Raspberry Pi and one monitor, it is easy to set `config.txt` as required for that specific combination and keep it that way, amending it only when something changes. However, if one Raspberry Pi is swapped between different monitors, or if the SD card (or card image) is being swapped between multiple boards, a single set of settings may no longer be sufficient. Conditional filters allow you to define certain sections of the config file to be used only in specific cases, allowing a single `config.txt` to create different configurations when read by different hardware. @@ -8,176 +9,341 @@ However, if one Raspberry Pi is swapped between different monitors, or if the SD The `[all]` filter is the most basic filter. It resets all previously set filters and allows any settings listed below it to be applied to all hardware. It is usually a good idea to add an `[all]` filter at the end of groups of filtered settings to avoid unintentionally combining filters (see below). -=== Model Filters +=== Model filters -The conditional model filters are applied according to the following table. +The conditional model filters apply according to the following table. |=== | Filter | Applicable model(s) -| [pi1] -| Model A, Model B, Compute Module +| `[pi1]` +| Model 1A, Model 1B, Model 1A+, Model 1B+, Compute Module 1 -| [pi2] +| `[pi2]` | Model 2B (BCM2836- or BCM2837-based) -| [pi3] -| Model 3B, Model 3B+, Model 3A+, Compute Module 3 +| `[pi3]` +| Model 3B, Model 3B+, Model 3A+, Compute Module 3, Compute Module 3+ -| [pi3+] -| Model 3A+, Model 3B+ +| `[pi3+]` +| Model 3A+, Model 3B+ (also sees `[pi3]` contents) -| [pi4] -| Model 4B, Pi 400, Compute Module 4 +| `[pi4]` +| Model 4B, Pi 400, Compute Module 4, Compute Module 4S -| [pi400] -| Pi 400 +| `[pi5]` +| Raspberry Pi 5, Compute Module 5, Pi 500 -| [cm4] -| Compute Module 4 +| `[pi400]` +| Pi 400 (also sees `[pi4]` contents) -| [pi0] -| Zero, Zero W, Zero WH +| `[pi500]` +| Pi 500 (also sees `[pi5]` contents) + +| `[cm1]` +| Compute Module 1 (also sees `[pi1]` contents) + +| `[cm3]` +| Compute Module 3 (also sees `[pi3]` contents) + +| `[cm3+]` +| Compute Module 3+ (also sees `[pi3+]` contents) + +| `[cm4]` +| Compute Module 4 (also sees `[pi4]` contents) + +| `[cm4s]` +| Compute Module 4S (also sees `[pi4]` contents) + +| `[cm5]` +| Compute Module 5 (also sees `[pi5]` contents) + +| `[pi0]` +| Zero, Zero W, Zero 2 W + +| `[pi0w]` +| Zero W (also sees `[pi0]` contents) + +| `[pi02]` +| Zero 2 W (also sees `[pi0w]` and `[pi0]` contents) + +| `[board-type=Type]` +| Filter by `Type` number - see xref:raspberry-pi.adoc#raspberry-pi-revision-codes[Raspberry Pi Revision Codes] E.g `[board-type=0x14]` would match CM4. -| [pi0w] -| Zero W, Zero WH |=== -These are particularly useful for defining different `kernel`, `initramfs`, and `cmdline` settings, as the Pi 1 and Pi 2 require different kernels. They can also be useful to define different overclocking settings, as the Pi 1 and Pi 2 have different default speeds. For example, to define separate `initramfs` images for each: +These are particularly useful for defining different `kernel`, `initramfs`, and `cmdline` settings, as the Raspberry Pi 1 and Raspberry Pi 2 require different kernels. They can also be useful to define different overclocking settings, as the Raspberry Pi 1 and Raspberry Pi 2 have different default speeds. For example, to define separate `initramfs` images for each: - [pi1] - initramfs initrd.img-3.18.7+ followkernel - [pi2] - initramfs initrd.img-3.18.7-v7+ followkernel - [all] +---- +[pi1] +initramfs initrd.img-3.18.7+ followkernel +[pi2] +initramfs initrd.img-3.18.7-v7+ followkernel +[all] +---- + +Remember to use the `[all]` filter at the end, so that any subsequent settings aren't limited to Raspberry Pi 2 hardware only. -Remember to use the `[all]` filter at the end, so that any subsequent settings aren't limited to Pi 2 hardware only. +[NOTE] +==== +Some models of Raspberry Pi, including Zero, Compute Module, and Keyboard models, read settings from multiple filters. To apply a setting to only one model: -It is important to note that the Raspberry Pi Zero W will see the contents of [pi0w] AND [pi0]. Likewise, a Raspberry Pi 3B Plus sees [pi3+] AND [pi3], and a Raspberry Pi 400 sees [pi400] AND [pi4]. If you want a setting to apply only to Pi Zero, Pi 3B or Pi 4B, you need to follow it (order is important) with a setting in the [pi0w], [pi3+] or [pi400] section that reverts it. +* apply the setting to the base model (e.g. `[pi4]`), then revert the setting for all models that read the base model's filters (e.g. `[pi400]`, `[cm4]`, `[cm4s]`) +* use the `board-type` filter with a revision code to target a single model (e.g. `[board-type=0x11]`) +==== === The `[none]` filter The `[none]` filter prevents any settings that follow from being applied to any hardware. Although there is nothing that you can't do without `[none]`, it can be a useful way to keep groups of unused settings in config.txt without having to comment out every line. -=== The `[EDID=*]` filter +[source,ini] +---- +# Bootloader EEPROM config. +# If PM_RSTS is partition 62 then set bootloader properties to disable +# SD high speed and show HDMI diagnostics +# Boot from partition 2 with debug option. +[partition=62] +# Only high (>31) partition can be remapped. +PARTITION=2 +SD_QUIRKS=0x1 +HDMI_DELAY=0 +---- -When switching between multiple monitors while using a single SD card in your Pi, and where a blank config isn't sufficient to automatically select the desired resolution for each one, this allows specific settings to be chosen based on the monitors' EDID names. +Example `config.txt` - (Currently Raspberry Pi 5 onwards) +[source,ini] +---- +# config.txt - If the original requested partition number in PM_RSTS was a +# special number then use an alternate cmdline.txt +[partition=62] +cmdline=cmdline-recovery.txt +---- + +The raw value of the `PM_RSTS` register at bootup is available via `/proc/device-tree/chosen/bootloader/rsts` and the final partition number used for booting is available via `/proc/device-tree/chosen/bootloader/partition`. These are big-endian binary values. + +=== The expression filter -To view the EDID name of an attached monitor, run the following command: +The expression filter provides support for comparing unsigned integer "boot variables" to constants using a simple set of operators. It is intended to support OTA update mechanisms, debug and test. -[source] +* The "boot variables" are `boot_arg1`, `boot_count`, `boot_partition` and `partition`. +* Boot variables are always lower case. +* Integer constants may either be written as decimal or as hex. +* Expression conditional filters have no side-effects e.g. no assignment operators. +* As with other filter types the expression filter cannot be nested. +* Use the `[all]` filter to reset expressions and all other conditional filter types. + +Syntax: +[source,ini] ---- -tvservice -n +# ARG is a boot-variable +# VALUE and MASK are unsigned integer constants +[ARG=VALUE] # selected if (ARG == VALUE) +[ARG&MASK] # selected if ((ARG & VALUE) != 0) +[ARG&MASK=VALUE] # selected if ((ARG & MASK) == VALUE) +[ARGVALUE] # selected if (ARG > VALUE) + ---- - -This will print something like this: -[source] +==== `boot_arg1` +Raspberry Pi 5 and newer devices only. + +The `boot_arg1` variable is a 32-bit user defined value which is stored in a reset-safe register allowing parameters to be passed accross a reboot. + +Setting `boot_arg1` to 42 via `config.txt`: +[source,ini] ---- -device_name=VSC-TD2220 +set_reboot_arg1=42 ---- - -You can then specify settings that apply only to this monitor: +The `set_reboot_arg1` property sets the value for the next boot. It does not change the current value as seen by the config parser. -[source] +Setting `boot_arg1` to 42 via vcmailbox: +[source,console] ---- -[EDID=VSC-TD2220] -hdmi_group=2 -hdmi_mode=82 -[all] +sudo vcmailbox 0x0003808c 8 8 1 42 ---- -This forces 1920x1080 DVT mode for the specified monitor, without affecting any other monitors. +Reading `boot_arg1` via vcmailbox: +[source,console] +---- +sudo vcmailbox 0x0003008c 8 8 1 0 +# Example output - boot_arg1 is 42 +# 0x00000020 0x80000000 0x0003008c 0x00000008 0x80000008 0x00000001 0x0000002a 0x0000000 +---- +The value of the `boot_arg1` variable when the OS was started can be read via xref:configuration.adoc#part4[device-tree] at `/proc/device-tree/chosen/bootloader/arg1` + +==== `boot_count` +Raspberry Pi 5 and newer devices only. -Note that these settings apply only at boot, so the monitor must be connected at boot time and the Pi must be able to read its EDID information to find the correct name. Hotplugging a different monitor into the Pi after boot will not select different settings. +The `boot_count` variable is an 8-bit value stored in a reset-safe register that is incremented at boot (wrapping back to zero at 256). It is cleared if power is disconnected. -On the Raspberry Pi 4, if both HDMI ports are in use, then the EDID will be checked against both of them, and subsequent configuration applied only to the first matching device. You can determine the EDID names for both ports by first running `tvservice -l` in a terminal window to list all attached devices and then using the returned numerical IDs in `tvservice -v -n` to find the EDID name for a specific display ID. +To read `boot_count` via vcmailbox: +[source,console] +---- +sudo vcmailbox 0x0003008d 4 4 0 +# Example - boot count is 3 +# 0x0000001c 0x80000000 0x0003008d 0x00000004 0x80000004 0x00000003 0x00000000 +---- -=== The Serial Number Filter +Setting/clearing `boot_count` via vcmailbox: +[source,console] +---- +# Clear boot_count by setting it to zero. +sudo vcmailbox 0x0003808d 4 4 0 +---- +The value of `boot_count` when the OS was started can be read via xref:configuration.adoc#part4[device-tree] at `/proc/device-tree/chosen/bootloader/count` -Sometimes settings should only be applied to a single specific Pi, even if you swap the SD card to a different one. Examples include licence keys and overclocking settings (although the licence keys already support SD card swapping in a different way). You can also use this to select different display settings, even if the EDID identification above is not possible, provided that you don't swap monitors between your Pis. For example, if your monitor doesn't supply a usable EDID name, or if you are using composite output (for which EDID cannot be read). +==== `boot_partition` +The `boot_partition` variable can be used to select alternate OS files (e.g. `cmdline.txt`) to be loaded, depending on which partition `config.txt` was loaded from after processing xref:config_txt.adoc#autoboot-txt[autoboot.txt]. This is intended for use with an `A/B` boot-system with `autoboot.txt` where it is desirable to be able to have identical files installed to the boot partition for both the `A` and `B` images. -To view the serial number of your Pi, run the following command: +The value of the `boot_partition` can be different to the requested `partition` variable if it was overriden by setting `boot_partition` in xref:config_txt.adoc#autoboot-txt[autoboot.txt] or if the specified partion was not bootable and xref:raspberry-pi.adoc#PARTITION_WALK[PARTITION_WALK] was enabled in the EEPROM config. -[source] +Example `config.txt` - select the matching root filesystem for the `A/B` boot file-system: +[source,ini] ---- -cat /proc/cpuinfo +# Use different cmdline files to point to different root filesystems based on which partition the system booted from. +[boot_partition=1] +cmdline=cmdline_rootfs_a.txt # Points to root filesystem A + +[boot_partition=2] +cmdline=cmdline_rootfs_b.txt # Points to root filesystem B ---- -The serial will be shown as a 16-digit hex value at the bottom. For example, if you see: +The value of `boot_partition` i.e. the partition used to boot the OS can be read from xref:configuration.adoc#part4[device-tree] at `/proc/device-tree/chosen/bootloader/partition` + +==== `partition` +The `partition` variable can be used to select alternate boot flows according to the requested partition number (`sudo reboot N`) or via direct usage of the `PM_RSTS` watchdog register. + + +=== The `[tryboot]` filter + +This filter succeeds if the `tryboot` reboot flag was set. + +It is intended for use in xref:config_txt.adoc#autoboot-txt[autoboot.txt] to select a different `boot_partition` in `tryboot` mode for fail-safe OS updates. + +The value of `tryboot` at the start of boot can be read via xref:configuration.adoc#part4[device-tree] at `/proc/device-tree/chosen/bootloader/tryboot` + +=== The `[EDID=*]` filter -[source] +When switching between multiple monitors while using a single SD card in your Raspberry Pi, and where a blank config isn't sufficient to automatically select the desired resolution for each one, this allows specific settings to be chosen based on the monitors' EDID names. + +To view the EDID name of an attached monitor, you need to follow a few steps. Run the following command to see which output devices you have on your Raspberry Pi: + +[source,console] ---- -Serial : 0000000012345678 +$ ls -1 /sys/class/drm/card?-HDMI-A-?/edid ---- -then you can define settings that will only be applied to this specific Pi: +On a Raspberry Pi 4, this will print something like: -[source] ---- -[0x12345678] -# settings here are applied only to the Pi with this serial -[all] -# settings here are applied to all hardware +/sys/class/drm/card1-HDMI-A-1/edid +/sys/class/drm/card1-HDMI-A-2/edid ---- -=== The GPIO Filter +You then need to run `edid-decode` against each of these filenames, for example: -You can also filter depending on the state of a GPIO. For example +[source,console] +---- +$ edid-decode /sys/class/drm/card1-HDMI-A-1/edid +---- + +If there's no monitor connected to that particular output device, it'll tell you the EDID was empty; otherwise it will serve you *lots* of information about your monitor's capabilities. You need to look for the lines specifying the `Manufacturer` and the `Display Product Name`. The "EDID name" is then `-`, with any spaces in either string replaced by underscores. For example, if your `edid-decode` output included: -[source] ---- -[gpio4=1] -# Settings here are applied if GPIO 4 is high +.... + Vendor & Product Identification: + Manufacturer: DEL +.... + Display Product Name: 'DELL U2422H' +.... +---- -[gpio2=0] -# Settings here are applied if GPIO 2 is low +The EDID name for this monitor would be `DEL-DELL_U2422H`. +You can then use this as a conditional-filter to specify settings that only apply when this particular monitor is connected: + +[source,ini] +---- +[EDID=DEL-DELL_U2422H] +cmdline=cmdline_U2422H.txt [all] -# settings here are applied to all hardware ---- -=== The `[HDMI:*]` Filter +These settings apply only at boot. The monitor must be connected at boot time, and the Raspberry Pi must be able to read its EDID information to find the correct name. Hotplugging a different monitor into the Raspberry Pi after boot will not select different settings. + +On the Raspberry Pi 4, if both HDMI ports are in use, then the EDID filter will be checked against both of them, and configuration from all matching conditional filters will be applied. + +NOTE: This setting is not available on Raspberry Pi 5. + +=== The serial number filter + +Sometimes settings should only be applied to a single specific Raspberry Pi, even if you swap the SD card to a different one. Examples include licence keys and overclocking settings (although the licence keys already support SD card swapping in a different way). You can also use this to select different display settings, even if the EDID identification above is not possible, provided that you don't swap monitors between your Raspberry Pis. For example, if your monitor doesn't supply a usable EDID name, or if you are using composite output (from which EDID cannot be read). + +To view the serial number of your Raspberry Pi, run the following command: + +[source,console] +---- +$ cat /proc/cpuinfo +---- + +A 16-digit hex value will be displayed near the bottom of the output. Your Raspberry Pi's serial number is the last eight hex-digits. For example, if you see: -NOTE: This filter is for the Raspberry Pi 4 only. +---- +Serial : 0000000012345678 +---- -The Raspberry Pi 4 has two HDMI ports, and for many `config.txt` commands related to HDMI, it is necessary to specify which HDMI port is being referred to. The HDMI conditional filters subsequent HDMI configurations to the specific port. +The serial number is `12345678`. -[source] +NOTE: On some Raspberry Pi models, the first 8 hex-digits contain values other than `0`. Even in this case, only use the last eight hex-digits as the serial number. + +You can define settings that will only be applied to this specific Raspberry Pi: + +[source,ini] ---- - [HDMI:0] - hdmi_group=2 - hdmi_mode=45 - [HDMI:1] - hdmi_group=2 - hdmi_mode=67 +[0x12345678] +# settings here apply only to the Raspberry Pi with this serial + +[all] +# settings here apply to all hardware + ---- -An alternative `variable:index` syntax is available on all port-specific HDMI commands. You could use the following, which is the same as the previous example: +=== The GPIO filter -[source] +You can also filter depending on the state of a GPIO. For example: + +[source,ini] ---- - hdmi_group:0=2 - hdmi_mode:0=45 - hdmi_group:1=2 - hdmi_mode:1=67 +[gpio4=1] +# Settings here apply if GPIO 4 is high + +[gpio2=0] +# Settings here apply if GPIO 2 is low + +[all] +# settings here apply to all hardware + ---- -=== Combining Conditional Filters +=== Combine conditional filters Filters of the same type replace each other, so `[pi2]` overrides `[pi1]`, because it is not possible for both to be true at once. -Filters of different types can be combined simply by listing them one after the other, for example: +Filters of different types can be combined by listing them one after the other, for example: -[source] +[source,ini] ---- - # settings here are applied to all hardware - [EDID=VSC-TD2220] - # settings here are applied only if monitor VSC-TD2220 is connected - [pi2] - # settings here are applied only if monitor VSC-TD2220 is connected *and* on a Pi 2 - [all] - # settings here are applied to all hardware +# settings here apply to all hardware + +[EDID=VSC-TD2220] +# settings here apply only if monitor VSC-TD2220 is connected + +[pi2] +# settings here apply only if monitor VSC-TD2220 is connected *and* on a Raspberry Pi 2 + +[all] +# settings here apply to all hardware + ---- Use the `[all]` filter to reset all previous filters and avoid unintentionally combining different filter types. diff --git a/documentation/asciidoc/computers/config_txt/gpio.adoc b/documentation/asciidoc/computers/config_txt/gpio.adoc index afec7e221f..2508cbd06a 100644 --- a/documentation/asciidoc/computers/config_txt/gpio.adoc +++ b/documentation/asciidoc/computers/config_txt/gpio.adoc @@ -1,10 +1,9 @@ -== GPIO Control +== GPIO control === `gpio` -The `gpio` directive allows GPIO pins to be set to specific modes and values at boot time in a way that would -previously have needed a custom `dt-blob.bin` file. Each line applies the same settings (or at least makes the same -changes) to a set of pins, either a single pin (`3`), a range of pins (`3-4`), or a comma-separated list of either (`3-4,6,8`). +The `gpio` directive allows GPIO pins to be set to specific modes and values at boot time in a way that would previously have needed a custom `dt-blob.bin` file. Each line applies the same settings (or at least makes the same changes) to a set of pins, addressing either a single pin (`3`), a range of pins (`3-4`), or a comma-separated list of either (`3-4,6,8`). + The pin set is followed by an `=` and one or more comma-separated attributes from this list: * `ip` - Input @@ -16,10 +15,11 @@ The pin set is followed by an `=` and one or more comma-separated attributes fro * `pd` - Pull down * `pn/np` - No pull -`gpio` settings are applied in order, so those appearing later override those appearing earlier. +`gpio` settings apply in order, so those appearing later override those appearing earlier. Examples: +[source,ini] ---- # Select Alt2 for GPIO pins 0 to 27 (for DPI24) gpio=0-27=a2 @@ -34,38 +34,9 @@ gpio=18,20=pu gpio=17-21=ip ---- -The `gpio` directive respects the "[...]" section headers in `config.txt`, so it is possible to use different settings -based on the model, serial number, and EDID. - -GPIO changes made through this mechanism do not have any direct effect on the kernel -- they don't cause GPIO pins to -be exported to the sysfs interface, and they can be overridden by pinctrl entries in the Device Tree as well as -utilities like `raspi-gpio`. - -Note also that there is a delay of a few seconds between power being applied and the changes taking effect -- longer -if booting over the network or from a USB mass storage device. - -=== `enable_jtag_gpio` - -Setting `enable_jtag_gpio=1` selects Alt4 mode for GPIO pins 22-27, and sets up some internal SoC connections, thus enabling the JTAG interface for the ARM CPU. It works on all models of Raspberry Pi. - -|=== -| Pin # | Function - -| GPIO22 -| ARM_TRST - -| GPIO23 -| ARM_RTCK - -| GPIO24 -| ARM_TDO +The `gpio` directive respects the "[...]" conditional filters in `config.txt`, so it is possible to use different settings based on the model, serial number, and EDID. -| GPIO25 -| ARM_TCK +GPIO changes made through this mechanism do not have any direct effect on the kernel. They don't cause GPIO pins to be exported to the `sysfs` interface, and they can be overridden by `pinctrl` entries in the Device Tree as well as utilities like `pinctrl`. -| GPIO26 -| ARM_TDI +Note also that there is a delay of a few seconds between power being applied and the changes taking effect - longer if booting over the network or from a USB mass storage device. -| GPIO27 -| ARM_TMS -|=== diff --git a/documentation/asciidoc/computers/config_txt/memory.adoc b/documentation/asciidoc/computers/config_txt/memory.adoc index 616956f322..8c6d907310 100644 --- a/documentation/asciidoc/computers/config_txt/memory.adoc +++ b/documentation/asciidoc/computers/config_txt/memory.adoc @@ -1,58 +1,13 @@ -== Memory Options - -=== `gpu_mem` - -Specifies how much memory, in megabytes, to reserve for the exclusive use of the GPU: the remaining memory is allocated to the ARM CPU for use by the OS. For Pis with less than 1GB of memory, the default is `64`; for Pis with 1GB or more of memory the default is `76`. - -The memory allocated to the GPU is used for display, 3D, Codec and camera purposes as well as some basic firmware housekeeping. The maximums specified below assume you are using all these features. If you are not, then smaller values of gpu_mem can be used. - -To ensure the best performance of Linux, you should set `gpu_mem` to the lowest possible value. If a particular graphics feature is not working correctly, try increasing the value of `gpu_mem`, being mindful of the recommended maximums shown below. - -IMPORTANT: Unlike GPU's found on x86 machines, where increasing memory can improve 3D performance, the architecture of the VideoCore means *there is no performance advantage from specifying values larger than is necessary*, and in fact it can harm performance. - -On the Raspberry Pi 4 the 3D component of the GPU has its own memory management unit (MMU), and does not use memory from the `gpu_mem` allocation. Instead memory is allocated dynamically within Linux. This allows a smaller value to be specified for `gpu_mem` on the Pi 4, compared to previous models. - -The recommended maximum values are as follows: - -|=== -| total RAM | `gpu_mem` recommended maximum - -| 256MB -| `128` - -| 512MB -| `384` - -| 1GB or greater -| `512`, `256` on the Pi4 -|=== - -It is possible to set `gpu_mem` to larger values, however this should be avoided since it can cause problems, such as preventing Linux from booting. The minimum value is `16`, however this disables certain GPU features. - -You can also use `gpu_mem_256`, `gpu_mem_512`, and `gpu_mem_1024` to allow swapping the same SD card between Pis with different amounts of RAM without having to edit `config.txt` each time: - -=== `gpu_mem_256` - -The `gpu_mem_256` command sets the GPU memory in megabytes for Raspberry Pis with 256MB of memory. (It is ignored if memory size is not 256MB). This overrides `gpu_mem`. - -=== `gpu_mem_512` - -The `gpu_mem_512` command sets the GPU memory in megabytes for Raspberry Pis with 512MB of memory. (It is ignored if memory size is not 512MB). This overrides `gpu_mem`. - -=== `gpu_mem_1024` - -The `gpu_mem_1024` command sets the GPU memory in megabytes for Raspberry Pis with 1GB or more of memory. (It is ignored if memory size is smaller than 1GB). This overrides `gpu_mem`. +== Memory options === `total_mem` This parameter can be used to force a Raspberry Pi to limit its memory capacity: specify the total amount of RAM, in megabytes, you wish the Raspberry Pi to use. For example, to make a 4GB Raspberry Pi 4B behave as though it were a 1GB model, use the following: +[source,ini] ---- total_mem=1024 ---- This value will be clamped between a minimum of 128MB, and a maximum of the total memory installed on the board. -=== `disable_l2cache` - -Setting this to `1` disables the CPU's access to the GPU's L2 cache and requires a corresponding L2 disabled kernel. Default value on BCM2835 is `0`. On BCM2836, BCM2837, and BCM2711, the ARMs have their own L2 cache and therefore the default is `1`. The standard Pi `kernel.img` and `kernel7.img` builds reflect this difference in cache setting. diff --git a/documentation/asciidoc/computers/config_txt/misc.adoc b/documentation/asciidoc/computers/config_txt/misc.adoc deleted file mode 100644 index cfb36688d3..0000000000 --- a/documentation/asciidoc/computers/config_txt/misc.adoc +++ /dev/null @@ -1,31 +0,0 @@ -== Miscellaneous Options - -=== `avoid_warnings` - -The xref:configuration.adoc#firmware-warning-icons[warning symbols] can be disabled using this option, although this is not advised. - -`avoid_warnings=1` disables the warning overlays. -`avoid_warnings=2` disables the warning overlays, but additionally allows turbo mode even when low-voltage is present. - -=== `logging_level` - -Sets the VideoCore logging level. The value is a VideoCore-specific bitmask. - -=== `include` - -Causes the content of the specified file to be inserted into the current file. - -For example, adding the line `include extraconfig.txt` to `config.txt` will include the content of `extraconfig.txt` file in the `config.txt` file. - -*Include directives are not supported by bootcode.bin or the EEPROM bootloader* - -=== `max_usb_current` - -WARNING: This command is now deprecated and has no effect. - -Originally certain models of Raspberry Pi limited the USB ports to a maximum of 600mA. Setting `max_usb_current=1` changed this default to 1200mA. However, all firmware now has this flag set by default, so it is no longer necessary to use this option. - -[[disable_poe_fan]] -=== `disable_poe_fan` - -Set this option to `1` to prevent control of the PoE HAT fan through I2C (on pins ID_SD & ID_SC). Without this, a probe on the I2C bus will happen at startup, even when not using the PoE HAT. diff --git a/documentation/asciidoc/computers/config_txt/overclocking.adoc b/documentation/asciidoc/computers/config_txt/overclocking.adoc index 38d4de66de..b76a8ac8a5 100644 --- a/documentation/asciidoc/computers/config_txt/overclocking.adoc +++ b/documentation/asciidoc/computers/config_txt/overclocking.adoc @@ -1,65 +1,73 @@ -== Overclocking Options +== Overclocking options -The kernel has a https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html[CPUFreq] driver with the "powersave" governor enabled by default, switched to "ondemand" during boot, when xref:configuration.adoc#raspi-config[raspi-config] is installed. With "ondemand" governor, CPU frequency will vary with processor load. You can adjust the minimum values with the `*_min` config options or disable dynamic clocking by applying a static scaling governor ("powersave" or "performance") or with `force_turbo=1`. +The kernel has a https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html[CPUFreq] driver with the powersave governor enabled by default, switched to ondemand during boot, when xref:configuration.adoc#raspi-config[raspi-config] is installed. With the ondemand governor, CPU frequency will vary with processor load. You can adjust the minimum values with the `*_min` config options, or disable dynamic clocking by applying a static scaling governor (powersave or performance) or with `force_turbo=1`. -Overclocking and overvoltage will be disabled at runtime when the SoC reaches `temp_limit` (see below), which defaults to 85°C, in order to cool down the SoC. You should not hit this limit with Raspberry Pi Models 1 and 2, but you are more likely to with Raspberry Pi 3 and Raspberry Pi 4B. Overclocking and overvoltage are also disabled when an undervoltage situation is detected. +Overclocking and overvoltage will be disabled at runtime when the SoC reaches `temp_limit` (see below), which defaults to 85°C, in order to cool down the SoC. You should not hit this limit with Raspberry Pi 1 and Raspberry Pi 2, but you are more likely to with Raspberry Pi 3 and newer. Overclocking and overvoltage are also disabled when an undervoltage situation is detected. -NOTE: For more information xref:raspberry-pi.adoc#frequency-management-and-thermal-control[see the section on frequency managment and thermal control]. +NOTE: For more information xref:raspberry-pi.adoc#frequency-management-and-thermal-control[see the section on frequency management and thermal control]. -WARNING: Setting any overclocking parameters to values other than those used by xref:configuration.adoc#overclock[raspi-config] may set a permanent bit within the SoC, making it possible to detect that your Raspberry Pi has been overclocked. The specific circumstances where the overclock bit is set are if `force_turbo` is set to `1` and any of the `over_voltage_*` options are set to a value > `0`. See the https://www.raspberrypi.org/blog/introducing-turbo-mode-up-to-50-more-performance-for-free/[blog post on Turbo Mode] for more information. +WARNING: Setting any overclocking parameters to values other than those used by xref:configuration.adoc#overclock[`raspi-config`] may set a permanent bit within the SoC. This makes it possible to detect that your Raspberry Pi was once overclocked. The overclock bit sets when `force_turbo` is set to `1` and any of the `over_voltage_*` options are set to a value of more than `0`. See the https://www.raspberrypi.com/news/introducing-turbo-mode-up-to-50-more-performance-for-free/[blog post on Turbo mode] for more information. === Overclocking +[cols="1m,3"] |=== | Option | Description | arm_freq | Frequency of the ARM CPU in MHz. +| arm_boost +| Increases `arm_freq` to the highest supported frequency for the board-type and firmware. Set to `1` to enable. + | gpu_freq -| Sets `core_freq`, `h264_freq`, `isp_freq`, `v3d_freq` and `hevc_freq` together +| Sets `core_freq`, `h264_freq`, `isp_freq`, `v3d_freq` and `hevc_freq` together. | core_freq -| Frequency of the GPU processor core in MHz, influences CPU performance because it drives the L2 cache and memory bus; the L2 cache benefits only Pi Zero/Pi Zero W/ Pi 1, there is a small benefit for SDRAM on Pi 2/Pi 3. See section below for use on the Pi 4. +| Frequency of the GPU processor core in MHz. Influences CPU performance because it drives the L2 cache and memory bus; the L2 cache benefits only Raspberry Pi Zero/Raspberry Pi Zero W/Raspberry Pi 1; and there is a small benefit for SDRAM on Raspberry Pi 2 and Raspberry Pi 3. See section below for use on Raspberry Pi 4. | h264_freq -| Frequency of the hardware video block in MHz; individual override of the `gpu_freq` setting +| Frequency of the hardware video block in MHz; individual override of the `gpu_freq` setting. | isp_freq -| Frequency of the image sensor pipeline block in MHz; individual override of the `gpu_freq` setting +| Frequency of the image sensor pipeline block in MHz; individual override of the `gpu_freq` setting. | v3d_freq -| Frequency of the 3D block in MHz; individual override of the `gpu_freq` setting +| Frequency of the 3D block in MHz; individual override of the `gpu_freq` setting. On Raspberry Pi 5, V3D is independent of `core_freq`, `isp_freq` and `hevc_freq`. | hevc_freq -| Frequency of the High Efficiency Video Codec block in MHz; individual override of the `gpu_freq` setting. Pi 4 only. +| Frequency of the High Efficiency Video Codec block in MHz; individual override of the `gpu_freq` setting. Raspberry Pi 4 only. | sdram_freq -| Frequency of the SDRAM in MHz. SDRAM overclocking on Pi 4B is not currently supported +| Frequency of the SDRAM in MHz. SDRAM overclocking on Raspberry Pi 4 or newer is not supported. | over_voltage -| CPU/GPU core upper voltage limit. The value should be in the range [-16,8] which equates to the range [0.95V,1.55V] ([0.8,1.4V] on RPi 1) with 0.025V steps. In other words, specifying -16 will give 0.95V (0.8V on RPi 1) as the maximum CPU/GPU core voltage, and specifying 8 will allow up to 1.55V (1.4V on RPi 1). For defaults see table below. Values above 6 are only allowed when `force_turbo=1` is specified: this sets the warranty bit if `over_voltage_*` > `0` is also set. +| CPU/GPU core upper voltage limit. The value should be in the range [-16,8] which equates to the range [0.95V,1.55V] ([0.8,1.4V] on Raspberry Pi 1) with 0.025V steps. In other words, specifying -16 will give 0.95V (0.8V on Raspberry Pi 1) as the maximum CPU/GPU core voltage, and specifying 8 will allow up to 1.55V (1.4V on Raspberry Pi 1). For defaults, see the table below. Values above 6 are only allowed when `force_turbo=1` is specified: this sets the warranty bit if `over_voltage_*` > `0` is also set. | over_voltage_sdram | Sets `over_voltage_sdram_c`, `over_voltage_sdram_i`, and `over_voltage_sdram_p` together. | over_voltage_sdram_c -| SDRAM controller voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. +| SDRAM controller voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. Not supported on Raspberry Pi 4 or later devices. | over_voltage_sdram_i -| SDRAM I/O voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. +| SDRAM I/O voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. Not supported on Raspberry Pi 4 or later devices. | over_voltage_sdram_p -| SDRAM phy voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. - +| SDRAM phy voltage adjustment. [-16,8] equates to [0.8V,1.4V] with 0.025V steps. Not supported on Raspberry Pi 4 or later devices. + | force_turbo | Forces turbo mode frequencies even when the ARM cores are not busy. Enabling this may set the warranty bit if `over_voltage_*` is also set. | initial_turbo -| Enables https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=6201&start=425#p180099[turbo mode from boot] for the given value in seconds, or until cpufreq sets a frequency. The maximum value is `60`. +| Enables https://forums.raspberrypi.com/viewtopic.php?f=29&t=6201&start=425#p180099[turbo mode from boot] for the given value in seconds, or until `cpufreq` sets a frequency. The maximum value is `60`. The November 2024 firmware update made the following changes: + +* changed the default from `0` to `60` to reduce boot time +* switched the kernel CPU performance governor from `powersave` to `ondemand` + | arm_freq_min -| Minimum value of `arm_freq` used for dynamic frequency clocking. Note that reducing this value below the default does not result in any significant power savings and is not currently supported. +| Minimum value of `arm_freq` used for dynamic frequency clocking. Note that reducing this value below the default does not result in any significant power savings, and is not currently supported. | core_freq_min | Minimum value of `core_freq` used for dynamic frequency clocking. @@ -83,20 +91,27 @@ WARNING: Setting any overclocking parameters to values other than those used by | Minimum value of `sdram_freq` used for dynamic frequency clocking. | over_voltage_min -| Minimum value of `over_voltage` used for dynamic frequency clocking. The value should be in the range [-16,8] which equates to the range [0.8V,1.4V] with 0.025V steps. In other words, specifying -16 will give 0.8V as the CPU/GPU core idle voltage, and specifying 8 will give a minimum of 1.4V. +| Minimum value of `over_voltage` used for dynamic frequency clocking. The value should be in the range [-16,8] which equates to the range [0.8V,1.4V] with 0.025V steps. In other words, specifying -16 will give 0.8V as the CPU/GPU core idle voltage, and specifying 8 will give a minimum of 1.4V. This setting is deprecated on Raspberry Pi 4 and Raspberry Pi 5. + +| over_voltage_delta +| On Raspberry Pi 4 and Raspberry Pi 5 the over_voltage_delta parameter adds the given offset in microvolts to the number calculated by the DVFS algorithm. | temp_limit | Overheat protection. This sets the clocks and voltages to default when the SoC reaches this value in degree Celsius. Values over 85 are clamped to 85. | temp_soft_limit | *3A+/3B+ only*. CPU speed throttle control. This sets the temperature at which the CPU clock speed throttling system activates. At this temperature, the clock speed is reduced from 1400MHz to 1200MHz. Defaults to `60`, can be raised to a maximum of `70`, but this may cause instability. + +| core_freq_fixed +| Setting to 1 disables active scaling of the core clock frequency and ensures that any peripherals that use the core clock will maintain a consistent speed. The fixed clock speed is the higher/turbo frequency for the platform in use. Use this in preference to setting specific core_clock frequencies as it provides portability of config files between platforms. + |=== -This table gives the default values for the options on various Raspberry Pi Models, all frequencies are stated in MHz. +This table gives the default values for the options on various Raspberry Pi models, all frequencies are stated in MHz. -[cols=",^,^,^,^,^,^,^"] +[cols="m,^,^,^,^,^,^,^,^,^,^"] |=== -| Option | Pi 0/W | Pi1 | Pi2 | Pi3 | Pi3A+/Pi3B+ | Pi4/CM4 | Pi 400 +| Option | Pi 0/W | Pi1 | Pi2 | Pi3 | Pi3A+/Pi3B+ | CM4 & Pi4B <= R1.3 | Pi4B R1.4 | Pi 400 | Pi Zero 2 W | Pi 5 | arm_freq | 1000 @@ -105,7 +120,10 @@ This table gives the default values for the options on various Raspberry Pi Mode | 1200 | 1400 | 1500 +| 1500 or 1800 if `arm_boost`=1 | 1800 +| 1000 +| 2400 | core_freq | 400 @@ -115,6 +133,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 400 | 500 | 500 +| 500 +| 400 +| 910 | h264_freq | 300 @@ -124,6 +145,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 400 | 500 | 500 +| 500 +| 300 +| N/A | isp_freq | 300 @@ -133,6 +157,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 400 | 500 | 500 +| 500 +| 300 +| 910 | v3d_freq | 300 @@ -142,6 +169,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 400 | 500 | 500 +| 500 +| 300 +| 910 | hevc_freq | N/A @@ -151,6 +181,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | N/A | 500 | 500 +| 500 +| N/A +| 910 | sdram_freq | 450 @@ -160,6 +193,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 500 | 3200 | 3200 +| 3200 +| 450 +| 4267 | arm_freq_min | 700 @@ -169,6 +205,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 600 | 600 | 600 +| 600 +| 600 +| 1500 | core_freq_min | 250 @@ -178,6 +217,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 250 | 200 | 200 +| 200 +| 250 +| 500 | gpu_freq_min | 250 @@ -187,6 +229,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 250 | 250 | 250 +| 250 +| 250 +| 500 | h264_freq_min | 250 @@ -196,6 +241,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 250 | 250 | 250 +| 250 +| 250 +| N/A | isp_freq_min | 250 @@ -205,6 +253,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 250 | 250 | 250 +| 250 +| 250 +| 500 | v3d_freq_min | 250 @@ -214,6 +265,9 @@ This table gives the default values for the options on various Raspberry Pi Mode | 250 | 250 | 250 +| 250 +| 250 +| 500 | sdram_freq_min | 400 @@ -223,11 +277,14 @@ This table gives the default values for the options on various Raspberry Pi Mode | 400 | 3200 | 3200 +| 3200 +| 400 +| 4267 |=== -This table gives defaults for options that are the same across all models. +This table gives defaults for options which are the same across all models. -[cols=",^"] +[cols="m,^"] |=== | Option | Default @@ -238,7 +295,7 @@ This table gives defaults for options that are the same across all models. | 85 (°C) | over_voltage -| 0 (1.35V, 1.2V on RPi 1) +| 0 (1.35V, 1.2V on Raspberry Pi 1) | over_voltage_min | 0 (1.2V) @@ -258,32 +315,8 @@ This table gives defaults for options that are the same across all models. The firmware uses Adaptive Voltage Scaling (AVS) to determine the optimum CPU/GPU core voltage in the range defined by `over_voltage` and `over_voltage_min`. -|=== -| Model | Default | Resulting voltage - -| Pi 1 -| 0 -| 1.2V - -| Pi 2 -| 0 -| 1.2-1.3125V - -| Pi 3 -| 0 -| 1.2-1.3125V - -| Pi 4, Pi400, CM4 -| 0 -| 0.88V - -| Pi Zero -| 6 -| 1.35V -|=== - [discrete] -===== Specific to Raspberry Pi 4, Raspberry Pi 400 and CM4 +==== Specific to Raspberry Pi 4, Raspberry Pi 400 and CM4 The minimum core frequency when the system is idle must be fast enough to support the highest pixel clock (ignoring blanking) of the display(s). Consequently, `core_freq` will be boosted above 500 MHz if the display mode is 4Kp60. @@ -293,57 +326,72 @@ The minimum core frequency when the system is idle must be fast enough to suppor | Default | 500 -| hdmi_enable_4kp60 +| `hdmi_enable_4kp60` | 550 |=== +NOTE: There is no need to use `hdmi_enable_4kp60` on Flagship models since Raspberry Pi 5, Compute Modules since CM5, and Keyboard models since Pi 500; they support dual-4Kp60 displays by default. + * Overclocking requires the latest firmware release. * The latest firmware automatically scales up the voltage if the system is overclocked. Manually setting `over_voltage` disables automatic voltage scaling for overclocking. -* It is recommended when overclocking to use the individual frequency settings (`isp_freq`, `v3d_freq` etc) rather than `gpu_freq` because the maximum stable frequency will be different for ISP, V3D, HEVC etc. -* The SDRAM frequency is not configurable on Raspberry Pi 4. +* It is recommended when overclocking to use the individual frequency settings (`isp_freq`, `v3d_freq` etc) rather than `gpu_freq`, because the maximum stable frequency will be different for ISP, V3D, HEVC etc. +* The SDRAM frequency is not configurable on Raspberry Pi 4 or later devices. ==== `force_turbo` -By default (`force_turbo=0`) the "On Demand" CPU frequency driver will raise clocks to their maximum frequencies when the ARM cores are busy and will lower them to the minimum frequencies when the ARM cores are idle. +By default (`force_turbo=0`) the on-demand CPU frequency driver will raise clocks to their maximum frequencies when the ARM cores are busy, and will lower them to the minimum frequencies when the ARM cores are idle. `force_turbo=1` overrides this behaviour and forces maximum frequencies even when the ARM cores are not busy. -==== `never_over_voltage` +=== Clocks relationship -Sets a bit in the OTP memory (one time programmable) that prevents the device from being overvoltaged. This is intended to lock the device down so the warranty bit cannot be set either inadvertently or maliciously by using an invalid overvoltage. +==== Raspberry Pi 4 -==== `disable_auto_turbo` +The GPU core, CPU, SDRAM and GPU each have their own PLLs and can have unrelated frequencies. The h264, v3d and ISP blocks share a PLL. -On Pi 2/Pi 3, setting this flag will disable the GPU from moving into turbo mode, which it can do in particular load cases. +To view the Raspberry Pi's current frequency in KHz, type: `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`. Divide the result by 1000 to find the value in MHz. Note that this frequency is the kernel _requested_ frequency, and it is possible that any throttling (for example at high temperatures) may mean the CPU is actually running more slowly than reported. An instantaneous measurement of the actual ARM CPU frequency can be retrieved using the vcgencmd `vcgencmd measure_clock arm`. This is displayed in Hertz. -=== Clocks Relationship +=== Monitoring core temperature +[.whitepaper, title="Cooling a Raspberry Pi device", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003608-WP/Cooling-a-Raspberry-Pi-device.pdf] +**** +This white paper goes through the reasons why your Raspberry Pi may get hot and why you might want to cool it back down, offering options on the cooling process. +**** -The GPU core, CPU, SDRAM and GPU each have their own PLLs and https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=6201&start=275#p168042[can have unrelated frequencies]. The h264, v3d and ISP blocks share a PLL. +To view the temperature of a Raspberry Pi, run the following command: -To view the Pi's current frequency in KHz, type: `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`. Divide the result by 1000 to find the value in MHz. Note that this frequency is the kernel _requested_ frequency, and it is possible that any throttling (for example at high temperatures) may mean the CPU is actually running more slowly than reported. An instantaneous measurement of the actual ARM CPU frequency can be retrieved using the vcgencmd `vcgencmd measure_clock arm`. This is displayed in Hertz. +[source,console] +---- +$ cat /sys/class/thermal/thermal_zone0/temp +---- -=== Monitoring Core Temperature +Divide the result by 1000 to find the value in degrees Celsius. Alternatively, you can use `vcgencmd measure_temp` to report the GPU temperature. -To view the Raspberry Pi's temperature, type `cat /sys/class/thermal/thermal_zone0/temp`. Divide the result by 1000 to find the value in degrees Celsius. Alternatively, there is a vcgencmd, `vcgencmd measure_temp` that interrogates the GPU directly for its temperature. +Hitting the temperature limit is not harmful to the SoC, but it will cause the CPU to throttle. A heat sink can help to control the core temperature, and therefore performance. This is especially useful if the Raspberry Pi is running inside a case. Airflow over the heat sink will make cooling more efficient. -Whilst hitting the temperature limit is not harmful to the SoC, it will cause CPU throttling. A heatsink can help to control the core temperature and therefore performance. This is especially useful if the Pi is running inside a case. Airflow over the heatsink will make cooling more efficient. +When the core temperature is between 80°C and 85°C, the ARM cores will be throttled back. If the temperature exceeds 85°C, the ARM cores and the GPU will be throttled back. -With firmware from 12th September 2016 or later, when the core temperature is between 80'C and 85'C, a warning icon showing a red half-filled thermometer will be displayed, and the ARM cores will be throttled back. If the temperature exceeds 85'C, an icon showing a fully-filled thermometer will be displayed, and both the ARM cores and the GPU will be throttled back. +For the Raspberry Pi 3 Model B+, the PCB technology has been changed to provide better heat dissipation and increased thermal mass. In addition, a soft temperature limit has been introduced, with the goal of maximising the time for which a device can "sprint" before reaching the hard limit at 85°C. When the soft limit is reached, the clock speed is reduced from 1.4GHz to 1.2GHz, and the operating voltage is reduced slightly. This reduces the rate of temperature increase: we trade a short period at 1.4GHz for a longer period at 1.2GHz. By default, the soft limit is 60°C. This can be changed via the `temp_soft_limit` setting in `config.txt`. -For the Raspberry Pi 3 Model B+, the PCB technology has been changed to provide better heat dissipation and increased thermal mass. In addition, a soft temperature limit has been introduced, with the goal of maximising the time for which a device can "sprint" before reaching the hard limit at 85°C. When the soft limit is reached, the clock speed is reduced from 1.4GHz to 1.2GHz, and the operating voltage is reduced slightly. This reduces the rate of temperature increase: we trade a short period at 1.4GHz for a longer period at 1.2GHz. By default, the soft limit is 60°C, and this can be changed via the `temp_soft_limit` setting in config.txt. +=== Monitoring voltage -See the page on xref:configuration.adoc#firmware-warning-icons[warning icons] for more details. +It is essential to keep the supply voltage above 4.8V for reliable performance. Note that the voltage from some USB chargers/power supplies can fall as low as 4.2V. This is because they are usually designed to charge a 3.7V LiPo battery, not to supply 5V to a computer. -=== Monitoring Voltage +To monitor the Raspberry Pi's PSU voltage, you will need to use a multimeter to measure between the VCC and GND pins on the GPIO. More information is available in the xref:raspberry-pi.adoc#power-supply[power] section of the documentation. -It is essential to keep the supply voltage above 4.8V for reliable performance. Note that the voltage from some USB chargers/power supplies can fall as low as 4.2V. This is because they are usually designed to charge a 3.7V LiPo battery, not to supply 5V to a computer. +If the voltage drops below 4.63V (±5%), the ARM cores and the GPU will be throttled back, and a message indicating the low voltage state will be added to the kernel log. + +The Raspberry Pi 5 PMIC has built in ADCs that allow the supply voltage to be measured. To view the current supply voltage, run the following command: -To monitor the Pi's PSU voltage, you will need to use a multimeter to measure between the VCC and GND pins on the GPIO. More information is available in xref:raspberry-pi.adoc#power-supply[power]. +[source,console] +---- +$ vcgencmd pmic_read_adc EXT5V_V +---- -If the voltage drops below 4.63V (+-5%), recent versions of the firmware will show a yellow lightning bolt symbol on the display to indicate a lack of power, and a message indicating the low voltage state will be added to the kernel log. +=== Overclocking problems -See the page on xref:configuration.adoc#firmware-warning-icons[warning icons] for more details. +Most overclocking issues show up immediately, when the device fails to boot. If your device fails to boot due to an overclocking configuration change, use the following steps to return your device to a bootable state: -=== Overclocking Problems +. Remove any clock frequency overrides from `config.txt`. +. Increase the core voltage using `over_voltage_delta`. +. Re-apply overclocking parameters, taking care to avoid the previous known-bad overclocking parameters. -Most overclocking issues show up immediately with a failure to boot. If this occurs, hold down the `shift` key during the next boot. This will temporarily disable all overclocking, allowing you to boot successfully and then edit your settings. \ No newline at end of file diff --git a/documentation/asciidoc/computers/config_txt/pi4-hdmi.adoc b/documentation/asciidoc/computers/config_txt/pi4-hdmi.adoc deleted file mode 100644 index 2d35bf0760..0000000000 --- a/documentation/asciidoc/computers/config_txt/pi4-hdmi.adoc +++ /dev/null @@ -1,26 +0,0 @@ -== Raspberry Pi 4 HDMI Pipeline - -In order to support dual displays, and modes up to 4k60, the Raspberry Pi 4 has updated the HDMI composition pipeline hardware in a number of ways. One of the major changes is that it generates 2 output pixels for every clock cycle. - -Every HDMI mode has a list of timings that control all the parameters around sync pulse durations. These are typically defined via a pixel clock, and then a number of active pixels, a front porch, sync pulse, and back porch for each of the horizontal and vertical directions. - -Running everything at 2 pixels per clock means that the Pi4 can not support a timing where _any_ of the horizontal timings are not divisible by 2. The firmware and Linux kernel will filter out any mode that does not fulfill this criteria. - -There is only one mode in the CEA and DMT standards that falls into this category - DMT mode 81, which is 1366x768 @ 60Hz. This mode has odd values for the horizontal sync and back porch timings. It's also an unusual mode for having a width that isn't divisible by 8. - -If your monitor is of this resolution, then the Pi4 will automatically drop down to the next mode that is advertised by the monitor; this is typically 1280x720. - -On some monitors it is possible to configure them to use 1360x768 @ 60Hz. They typically do not advertise this mode via their EDID so the selection can't be made automatically, but it can be manually chosen by adding - -[source] ----- -hdmi_group=2 -hdmi_mode=87 -hdmi_cvt=1360 768 60 ----- - -to xref:config_txt.adoc#video-options[config.txt]. - -Timings specified manually via a `hdmi_timings=` line in `config.txt` will also need to comply with the restriction of all horizontal timing parameters being divisible by 2. - -`dpi_timings=` are not restricted in the same way as that pipeline still only runs at a single pixel per clock cycle. diff --git a/documentation/asciidoc/computers/config_txt/video.adoc b/documentation/asciidoc/computers/config_txt/video.adoc index 5aa10c73ed..eac9fba9fc 100644 --- a/documentation/asciidoc/computers/config_txt/video.adoc +++ b/documentation/asciidoc/computers/config_txt/video.adoc @@ -1,1777 +1,111 @@ -== Video Options +== Video options -=== Composite Video Mode +=== HDMI mode -==== `sdtv_mode` +To control HDMI settings, use the xref:configuration.adoc#set-resolution-and-rotation[Screen Configuration utility] or xref:configuration.adoc#set-the-kms-display-mode[KMS video settings] in `cmdline.txt`. -The `sdtv_mode` command defines the TV standard used for composite video output. On the original Raspberry Pi, composite video is output on the RCA socket. On other Raspberry Pi's, except for Pi Zero and Compute Module, composite video is output along with sound on the 4 pole TRRS ("headphone") socket. On the Pi Zero, there is an unpopulated header labelled "TV" which outputs composite video. On the Compute Module, composite video is available via the TVDAC pin. The default value of `sdtv_mode` is `0`. +==== HDMI Pipeline for 4-series devices -|=== -| sdtv_mode | result - -| 0 -| Normal NTSC - -| 1 -| Japanese version of NTSC -- no pedestal - -| 2 -| Normal PAL - -| 3 -| Brazilian version of PAL -- 525/60 rather than 625/50, different subcarrier - -| 16 -| Progressive scan NTSC - -| 18 -| Progressive scan PAL -|=== - -==== `sdtv_aspect` - -The `sdtv_aspect` command defines the aspect ratio for composite video output. The default value is `1`. - -|=== -| sdtv_aspect | result - -| 1 -| 4:3 - -| 2 -| 14:9 - -| 3 -| 16:9 -|=== - -==== `sdtv_disable_colourburst` - -Setting `sdtv_disable_colourburst` to `1` disables colourburst on composite video output. The picture will be displayed in monochrome, but it may appear sharper. - -==== `enable_tvout` (Raspberry Pi 4, Model B Only) - -On the Raspberry Pi 4, composite output is disabled by default, due to the way the internal clocks are interrelated and allocated. Because composite video requires a very specific clock, setting that clock to the required speed on the Pi 4 means that other clocks connected to it are detrimentally affected, which slightly slows down the entire system. Since composite video is a less commonly used function, we decided to disable it by default to prevent this system slowdown. - -To enable composite output, use the `enable_tvout=1` option. As described above, this will detrimentally affect performance to a small degree. - -On older Pi models, the composite behaviour remains the same. - -=== HDMI Mode - -NOTE: Because the Raspberry Pi 4B has two HDMI ports, some HDMI commands can be applied to either port. You can use the syntax `:`, where port is 0 or 1, to specify which port the setting should apply to. If no port is specified, the default is 0. If you specify a port number on a command that does not require a port number, the port is ignored. Further details on the syntax and alternatives mechanisms can be found in the HDMI sub-section on the xref:config_txt.adoc#conditional-filters[conditionals section] of the documentation. - -In order to support dual 4k displays, the Raspberrry Pi 4 has xref:config_txt.adoc#raspberry-pi-4-hdmi-pipeline[updated video hardware], which imposes minor restrictions on the modes supported. - -==== `hdmi_safe` - -Setting `hdmi_safe` to `1` will lead to "safe mode" settings being used to try to boot with maximum HDMI compatibility. This is the same as setting the following parameters: - ----- -hdmi_force_hotplug=1 -hdmi_ignore_edid=0xa5000080 -config_hdmi_boost=4 -hdmi_group=2 -hdmi_mode=4 -disable_overscan=0 -overscan_left=24 -overscan_right=24 -overscan_top=24 -overscan_bottom=24 ----- - -==== `hdmi_ignore_edid` - -Setting `hdmi_ignore_edid` to `0xa5000080` enables the ignoring of EDID/display data if your display does not have an accurate https://en.wikipedia.org/wiki/Extended_display_identification_data[EDID]. It requires this unusual value to ensure that it is not triggered accidentally. - -==== `hdmi_edid_file` - -Setting `hdmi_edid_file` to `1` will cause the GPU to read EDID data from the `edid.dat` file, located in the boot partition, instead of reading it from the monitor. More information is available https://www.raspberrypi.org/forums/viewtopic.php?p=173430#p173430[on the forums]. - -==== `hdmi_edid_filename` - -On the Raspberry Pi 4B, you can use the `hdmi_edid_filename` command to specify the filename of the EDID file to use, and also to specify which port the file is to be applied to. This also requires `hdmi_edid_file=1` to enable EDID files. - -For example: - ----- -hdmi_edid_file=1 -hdmi_edid_filename:0=FileForPortZero.edid -hdmi_edid_filename:1=FileForPortOne.edid ----- - -==== `hdmi_force_edid_audio` - -Setting `hdmi_force_edid_audio` to `1` pretends that all audio formats are supported by the display, allowing passthrough of DTS/AC3 even when this is not reported as supported. - -==== `hdmi_ignore_edid_audio` - -Setting `hdmi_ignore_edid_audio` to `1` pretends that all audio formats are unsupported by the display. This means ALSA will default to the analogue audio (headphone) jack. - -==== `hdmi_force_edid_3d` - -Setting `hdmi_force_edid_3d` to `1` pretends that all CEA modes support 3D, even when the EDID does not indicate support for this. - -==== `hdmi_ignore_cec_init` - -Setting `hdmi_ignore_cec_init` to `1` will stop the initial active source message being sent during bootup. This prevents a CEC-enabled TV from coming out of standby and channel-switching when you are rebooting your Raspberry Pi. - -==== `hdmi_ignore_cec` - -Setting `hdmi_ignore_cec` to `1` pretends that https://en.wikipedia.org/wiki/Consumer_Electronics_Control#CEC[CEC] is not supported at all by the TV. No CEC functions will be supported. - -==== `cec_osd_name` +In order to support dual displays and modes up to 4Kp60, Raspberry Pi 4, Compute Module 4, and Pi 400 generate 2 output pixels for every clock cycle. -The `cec_osd_name` command sets the initial CEC name of the device. The default is Raspberry Pi. +Every HDMI mode has a list of timings that control all the parameters around sync pulse durations. These are typically defined via a pixel clock, and then a number of active pixels, a front porch, sync pulse, and back porch for each of the horizontal and vertical directions. -==== `hdmi_pixel_encoding` +Running everything at 2 pixels per clock means that the 4-series devices cannot support a timing where _any_ of the horizontal timings are not divisible by 2. The firmware and Linux kernel filter out any mode that does not fulfil this criteria. -The `hdmi_pixel_encoding` command forces the pixel encoding mode. By default, it will use the mode requested from the EDID, so you shouldn't need to change it. +There is only one incompatible mode in the CEA and DMT standards: DMT mode 81, 1366x768 @ 60Hz. This mode has odd-numbered values for the horizontal sync and back porch timings and a width that indivisible by 8. -|=== -| hdmi_pixel_encoding | result - -| 0 -| default (RGB limited for CEA, RGB full for DMT) - -| 1 -| RGB limited (16-235) - -| 2 -| RGB full (0-255) - -| 3 -| YCbCr limited (16-235) - -| 4 -| YCbCr full (0-255) -|=== - -==== `hdmi_max_pixel_freq` - -The pixel frequency is used by the firmware and KMS to filter HDMI modes. Note, this is not the same as the frame rate. It specifies the maximum frequency that a valid mode can have, thereby culling out higher frequency modes. So for example, if you wish to disable all 4K modes, you could specify a maximum frequency of 200000000, since all 4K modes have frequencies greater than this. - -==== `hdmi_blanking` - -The `hdmi_blanking` command controls what happens when the operating system asks for the display to be put into standby mode, using DPMS, to save power. If this option is not set or set to 0, the HDMI output is blanked but not switched off. In order to mimic the behaviour of other computers, you can set the HDMI output to switch off as well by setting this option to 1: the attached display will go into a low power standby mode. - -NOTE: On the Raspberry Pi 4, setting `hdmi_blanking=1` will not cause the HDMI output to be switched off, since this feature has not yet been implemented. This feature may cause issues when using applications which don't use the framebuffer, such as `omxplayer`. - -|=== -| hdmi_blanking | result +If your monitor has this resolution, 4-series devices automatically drop down to the next mode advertised by the monitor; typically 1280x720. -| 0 -| HDMI output will be blanked +==== HDMI Pipeline for 5-series devices -| 1 -| HDMI output will be switched off and blanked -|=== +Flagship models since Raspberry Pi 5, Compute Module models since CM5, and Keyboard models since Pi 500 also work at 2 output pixels per clock cycle. These models have special handling for odd timings and can handle these modes directly. -==== `hdmi_drive` +=== Composite video mode -The `hdmi_drive` command allows you to choose between HDMI and DVI output modes. +Composite video output can be found on each model of Raspberry Pi computer: |=== -| hdmi_drive | result - -| 1 -| Normal DVI mode (no sound) - -| 2 -| Normal HDMI mode (sound will be sent if supported and enabled) -|=== - -==== `config_hdmi_boost` - -Configures the signal strength of the HDMI interface. The minimum value is `0` and the maximum is `11`. +| model | composite output -The default value for the original Model B and A is `2`. The default value for the Model B+ and all later models is `5`. +| Raspberry Pi 1 A and B +| RCA jack -If you are seeing HDMI issues (speckling, interference) then try `7`. Very long HDMI cables may need up to `11`, but values this high should not be used unless absolutely necessary. +| Raspberry Pi Zero +| Unpopulated `TV` header -This option is ignored on the Raspberry Pi 4. +| Raspberry Pi Zero 2 W +| Test pads on underside of board -==== `hdmi_group` +| Raspberry Pi 5 +| J7 pad next to HDMI socket -The `hdmi_group` command defines the HDMI output group to be either CEA (Consumer Electronics Association, the standard typically used by TVs) or DMT (Display Monitor Timings, the standard typically used by monitors). This setting should be used in conjunction with `hdmi_mode`. - -|=== -| hdmi_group | result - -| 0 -| Auto-detect from EDID - -| 1 -| CEA - -| 2 -| DMT +| All other models +| 3.5mm AV jack |=== -==== `hdmi_mode` - -Together with `hdmi_group`, `hdmi_mode` defines the HDMI output format. Format mode numbers are derived from the https://web.archive.org/web/20171201033424/https://standards.cta.tech/kwspub/published_docs/CTA-861-G_FINAL_revised_2017.pdf[CTA specification]. - -To set a custom display mode not listed here, see more information on https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=24679[the forums]. - -NOTE: Not all modes are available on all models. - -These values are valid if `hdmi_group=1` (CEA): - -[cols=",,,^,"] -|=== -| hdmi_mode | Resolution | Frequency | Screen Aspect | Notes - -| 1 -| VGA (640x480) -| 60Hz -| 4:3 -| - -| 2 -| 480p -| 60Hz -| 4:3 -| - -| 3 -| 480p -| 60Hz -| 16:9 -| - -| 4 -| 720p -| 60Hz -| 16:9 -| - -| 5 -| 1080i -| 60Hz -| 16:9 -| - -| 6 -| 480i -| 60Hz -| 4:3 -| - -| 7 -| 480i -| 60Hz -| 16:9 -| - -| 8 -| 240p -| 60Hz -| 4:3 -| - -| 9 -| 240p -| 60Hz -| 16:9 -| - -| 10 -| 480i -| 60Hz -| 4:3 -| pixel quadrupling - -| 11 -| 480i -| 60Hz -| 16:9 -| pixel quadrupling - -| 12 -| 240p -| 60Hz -| 4:3 -| pixel quadrupling - -| 13 -| 240p -| 60Hz -| 16:9 -| pixel quadrupling - -| 14 -| 480p -| 60Hz -| 4:3 -| pixel doubling - -| 15 -| 480p -| 60Hz -| 16:9 -| pixel doubling - -| 16 -| 1080p -| 60Hz -| 16:9 -| - -| 17 -| 576p -| 50Hz -| 4:3 -| - -| 18 -| 576p -| 50Hz -| 16:9 -| - -| 19 -| 720p -| 50Hz -| 16:9 -| - -| 20 -| 1080i -| 50Hz -| 16:9 -| +NOTE: Composite video output is not available on Keyboard models. -| 21 -| 576i -| 50Hz -| 4:3 -| +==== `enable_tvout` -| 22 -| 576i -| 50Hz -| 16:9 -| +Set to `1` to enable composite video output and `0` to disable. On Flagship models since Raspberry Pi 4, Compute Modules since CM4, and Zero models, composite output is only available if you set this to `1`, which also disables HDMI output. Composite output is not available on Keyboard models. -| 23 -| 288p -| 50Hz -| 4:3 -| +[%header,cols="1,1"] -| 24 -| 288p -| 50Hz -| 16:9 -| - -| 25 -| 576i -| 50Hz -| 4:3 -| pixel quadrupling - -| 26 -| 576i -| 50Hz -| 16:9 -| pixel quadrupling - -| 27 -| 288p -| 50Hz -| 4:3 -| pixel quadrupling - -| 28 -| 288p -| 50Hz -| 16:9 -| pixel quadrupling - -| 29 -| 576p -| 50Hz -| 4:3 -| pixel doubling - -| 30 -| 576p -| 50Hz -| 16:9 -| pixel doubling - -| 31 -| 1080p -| 50Hz -| 16:9 -| - -| 32 -| 1080p -| 24Hz -| 16:9 -| - -| 33 -| 1080p -| 25Hz -| 16:9 -| - -| 34 -| 1080p -| 30Hz -| 16:9 -| - -| 35 -| 480p -| 60Hz -| 4:3 -| pixel quadrupling - -| 36 -| 480p -| 60Hz -| 16:9 -| pixel quadrupling - -| 37 -| 576p -| 50Hz -| 4:3 -| pixel quadrupling - -| 38 -| 576p -| 50Hz -| 16:9 -| pixel quadrupling - -| 39 -| 1080i -| 50Hz -| 16:9 -| reduced blanking - -| 40 -| 1080i -| 100Hz -| 16:9 -| - -| 41 -| 720p -| 100Hz -| 16:9 -| - -| 42 -| 576p -| 100Hz -| 4:3 -| - -| 43 -| 576p -| 100Hz -| 16:9 -| - -| 44 -| 576i -| 100Hz -| 4:3 -| - -| 45 -| 576i -| 100Hz -| 16:9 -| - -| 46 -| 1080i -| 120Hz -| 16:9 -| - -| 47 -| 720p -| 120Hz -| 16:9 -| - -| 48 -| 480p -| 120Hz -| 4:3 -| - -| 49 -| 480p -| 120Hz -| 16:9 -| - -| 50 -| 480i -| 120Hz -| 4:3 -| - -| 51 -| 480i -| 120Hz -| 16:9 -| - -| 52 -| 576p -| 200Hz -| 4:3 -| - -| 53 -| 576p -| 200Hz -| 16:9 -| - -| 54 -| 576i -| 200Hz -| 4:3 -| - -| 55 -| 576i -| 200Hz -| 16:9 -| - -| 56 -| 480p -| 240Hz -| 4:3 -| - -| 57 -| 480p -| 240Hz -| 16:9 -| - -| 58 -| 480i -| 240Hz -| 4:3 -| - -| 59 -| 480i -| 240Hz -| 16:9 -| - -| 60 -| 720p -| 24Hz -| 16:9 -| - -| 61 -| 720p -| 25Hz -| 16:9 -| - -| 62 -| 720p -| 30Hz -| 16:9 -| - -| 63 -| 1080p -| 120Hz -| 16:9 -| - -| 64 -| 1080p -| 100Hz -| 16:9 -| - -| 65 -| Custom -| -| -| - -| 66 -| 720p -| 25Hz -| 64:27 -| Pi 4 - -| 67 -| 720p -| 30Hz -| 64:27 -| Pi 4 - -| 68 -| 720p -| 50Hz -| 64:27 -| Pi 4 - -| 69 -| 720p -| 60Hz -| 64:27 -| Pi 4 - -| 70 -| 720p -| 100Hz -| 64:27 -| Pi 4 - -| 71 -| 720p -| 120Hz -| 64:27 -| Pi 4 - -| 72 -| 1080p -| 24Hz -| 64:27 -| Pi 4 - -| 73 -| 1080p -| 25Hz -| 64:27 -| Pi 4 - -| 74 -| 1080p -| 30Hz -| 64:27 -| Pi 4 - -| 75 -| 1080p -| 50Hz -| 64:27 -| Pi 4 - -| 76 -| 1080p -| 60Hz -| 64:27 -| Pi 4 - -| 77 -| 1080p -| 100Hz -| 64:27 -| Pi 4 - -| 78 -| 1080p -| 120Hz -| 64:27 -| Pi 4 - -| 79 -| 1680x720 -| 24Hz -| 64:27 -| Pi 4 - -| 80 -| 1680x720 -| 25z -| 64:27 -| Pi 4 - -| 81 -| 1680x720 -| 30Hz -| 64:27 -| Pi 4 - -| 82 -| 1680x720 -| 50Hz -| 64:27 -| Pi 4 - -| 83 -| 1680x720 -| 60Hz -| 64:27 -| Pi 4 - -| 84 -| 1680x720 -| 100Hz -| 64:27 -| Pi 4 - -| 85 -| 1680x720 -| 120Hz -| 64:27 -| Pi 4 - -| 86 -| 2560x720 -| 24Hz -| 64:27 -| Pi 4 - -| 87 -| 2560x720 -| 25Hz -| 64:27 -| Pi 4 - -| 88 -| 2560x720 -| 30Hz -| 64:27 -| Pi 4 - -| 89 -| 2560x720 -| 50Hz -| 64:27 -| Pi 4 - -| 90 -| 2560x720 -| 60Hz -| 64:27 -| Pi 4 - -| 91 -| 2560x720 -| 100Hz -| 64:27 -| Pi 4 - -| 92 -| 2560x720 -| 120Hz -| 64:27 -| Pi 4 - -| 93 -| 2160p -| 24Hz -| 16:9 -| Pi 4 - -| 94 -| 2160p -| 25Hz -| 16:9 -| Pi 4 - -| 95 -| 2160p -| 30Hz -| 16:9 -| Pi 4 - -| 96 -| 2160p -| 50Hz -| 16:9 -| Pi 4 - -| 97 -| 2160p -| 60Hz -| 16:9 -| Pi 4 - -| 98 -| 4096x2160 -| 24Hz -| 256:135 -| Pi 4 - -| 99 -| 4096x2160 -| 25Hz -| 256:135 -| Pi 4 - -| 100 -| 4096x2160 -| 30Hz -| 256:135 -| Pi 4 - -| 101 -| 4096x2160 -| 50Hz -| 256:135 -| Pi 4 - -| 102 -| 4096x2160 -| 60Hz -| 256:135 -| Pi 4 - -| 103 -| 2160p -| 24Hz -| 64:27 -| Pi 4 - -| 104 -| 2160p -| 25Hz -| 64:27 -| Pi 4 - -| 105 -| 2160p -| 30Hz -| 64:27 -| Pi 4 - -| 106 -| 2160p -| 50Hz -| 64:27 -| Pi 4 - -| 107 -| 2160p -| 60Hz -| 64:27 -| Pi 4 |=== +|Model +|Default -Pixel doubling and quadrupling indicates a higher clock rate, with each pixel repeated two or four times respectively. - -These values are valid if `hdmi_group=2` (DMT): +|Flagship models since Raspberry Pi 4B, Compute Modules since CM4, Keyboard models +|0 -[cols=",,,^,"] +|All other models +|1 |=== -| hdmi_mode | Resolution | Frequency | Screen Aspect | Notes - -| 1 -| 640x350 -| 85Hz -| -| - -| 2 -| 640x400 -| 85Hz -| 16:10 -| - -| 3 -| 720x400 -| 85Hz -| -| - -| 4 -| 640x480 -| 60Hz -| 4:3 -| - -| 5 -| 640x480 -| 72Hz -| 4:3 -| - -| 6 -| 640x480 -| 75Hz -| 4:3 -| - -| 7 -| 640x480 -| 85Hz -| 4:3 -| - -| 8 -| 800x600 -| 56Hz -| 4:3 -| - -| 9 -| 800x600 -| 60Hz -| 4:3 -| - -| 10 -| 800x600 -| 72Hz -| 4:3 -| - -| 11 -| 800x600 -| 75Hz -| 4:3 -| - -| 12 -| 800x600 -| 85Hz -| 4:3 -| - -| 13 -| 800x600 -| 120Hz -| 4:3 -| - -| 14 -| 848x480 -| 60Hz -| 16:9 -| - -| 15 -| 1024x768 -| 43Hz -| 4:3 -| incompatible with the Raspberry Pi - -| 16 -| 1024x768 -| 60Hz -| 4:3 -| - -| 17 -| 1024x768 -| 70Hz -| 4:3 -| - -| 18 -| 1024x768 -| 75Hz -| 4:3 -| -| 19 -| 1024x768 -| 85Hz -| 4:3 -| +On supported models, you must disable HDMI output to enable composite output. HDMI output is disabled when no HDMI display is detected. Set `enable_tvout=0` to prevent composite being enabled when HDMI is disabled. -| 20 -| 1024x768 -| 120Hz -| 4:3 -| +To enable composite output, append `,composite` to the end of the `dtoverlay=vc4-kms-v3d` line in xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]: -| 21 -| 1152x864 -| 75Hz -| 4:3 -| - -| 22 -| 1280x768 -| 60Hz -| 15:9 -| reduced blanking - -| 23 -| 1280x768 -| 60Hz -| 15:9 -| - -| 24 -| 1280x768 -| 75Hz -| 15:9 -| - -| 25 -| 1280x768 -| 85Hz -| 15:9 -| - -| 26 -| 1280x768 -| 120Hz -| 15:9 -| reduced blanking - -| 27 -| 1280x800 -| 60 -| 16:10 -| reduced blanking - -| 28 -| 1280x800 -| 60Hz -| 16:10 -| - -| 29 -| 1280x800 -| 75Hz -| 16:10 -| - -| 30 -| 1280x800 -| 85Hz -| 16:10 -| - -| 31 -| 1280x800 -| 120Hz -| 16:10 -| reduced blanking - -| 32 -| 1280x960 -| 60Hz -| 4:3 -| - -| 33 -| 1280x960 -| 85Hz -| 4:3 -| - -| 34 -| 1280x960 -| 120Hz -| 4:3 -| reduced blanking - -| 35 -| 1280x1024 -| 60Hz -| 5:4 -| - -| 36 -| 1280x1024 -| 75Hz -| 5:4 -| - -| 37 -| 1280x1024 -| 85Hz -| 5:4 -| - -| 38 -| 1280x1024 -| 120Hz -| 5:4 -| reduced blanking - -| 39 -| 1360x768 -| 60Hz -| 16:9 -| - -| 40 -| 1360x768 -| 120Hz -| 16:9 -| reduced blanking - -| 41 -| 1400x1050 -| 60Hz -| 4:3 -| reduced blanking - -| 42 -| 1400x1050 -| 60Hz -| 4:3 -| - -| 43 -| 1400x1050 -| 75Hz -| 4:3 -| - -| 44 -| 1400x1050 -| 85Hz -| 4:3 -| - -| 45 -| 1400x1050 -| 120Hz -| 4:3 -| reduced blanking - -| 46 -| 1440x900 -| 60Hz -| 16:10 -| reduced blanking - -| 47 -| 1440x900 -| 60Hz -| 16:10 -| - -| 48 -| 1440x900 -| 75Hz -| 16:10 -| - -| 49 -| 1440x900 -| 85Hz -| 16:10 -| - -| 50 -| 1440x900 -| 120Hz -| 16:10 -| reduced blanking - -| 51 -| 1600x1200 -| 60Hz -| 4:3 -| - -| 52 -| 1600x1200 -| 65Hz -| 4:3 -| - -| 53 -| 1600x1200 -| 70Hz -| 4:3 -| - -| 54 -| 1600x1200 -| 75Hz -| 4:3 -| - -| 55 -| 1600x1200 -| 85Hz -| 4:3 -| - -| 56 -| 1600x1200 -| 120Hz -| 4:3 -| reduced blanking - -| 57 -| 1680x1050 -| 60Hz -| 16:10 -| reduced blanking - -| 58 -| 1680x1050 -| 60Hz -| 16:10 -| - -| 59 -| 1680x1050 -| 75Hz -| 16:10 -| - -| 60 -| 1680x1050 -| 85Hz -| 16:10 -| - -| 61 -| 1680x1050 -| 120Hz -| 16:10 -| reduced blanking - -| 62 -| 1792x1344 -| 60Hz -| 4:3 -| - -| 63 -| 1792x1344 -| 75Hz -| 4:3 -| - -| 64 -| 1792x1344 -| 120Hz -| 4:3 -| reduced blanking - -| 65 -| 1856x1392 -| 60Hz -| 4:3 -| - -| 66 -| 1856x1392 -| 75Hz -| 4:3 -| - -| 67 -| 1856x1392 -| 120Hz -| 4:3 -| reduced blanking - -| 68 -| 1920x1200 -| 60Hz -| 16:10 -| reduced blanking - -| 69 -| 1920x1200 -| 60Hz -| 16:10 -| - -| 70 -| 1920x1200 -| 75Hz -| 16:10 -| - -| 71 -| 1920x1200 -| 85Hz -| 16:10 -| - -| 72 -| 1920x1200 -| 120Hz -| 16:10 -| reduced blanking - -| 73 -| 1920x1440 -| 60Hz -| 4:3 -| - -| 74 -| 1920x1440 -| 75Hz -| 4:3 -| - -| 75 -| 1920x1440 -| 120Hz -| 4:3 -| reduced blanking - -| 76 -| 2560x1600 -| 60Hz -| 16:10 -| reduced blanking - -| 77 -| 2560x1600 -| 60Hz -| 16:10 -| - -| 78 -| 2560x1600 -| 75Hz -| 16:10 -| - -| 79 -| 2560x1600 -| 85Hz -| 16:10 -| - -| 80 -| 2560x1600 -| 120Hz -| 16:10 -| reduced blanking - -| 81 -| 1366x768 -| 60Hz -| 16:9 -| xref:config_txt.adoc#raspberry-pi-4-hdmi-pipeline[NOT on Raspberry Pi 4] - -| 82 -| 1920x1080 -| 60Hz -| 16:9 -| 1080p - -| 83 -| 1600x900 -| 60Hz -| 16:9 -| reduced blanking - -| 84 -| 2048x1152 -| 60Hz -| 16:9 -| reduced blanking - -| 85 -| 1280x720 -| 60Hz -| 16:9 -| 720p - -| 86 -| 1366x768 -| 60Hz -| 16:9 -| reduced blanking -|=== - -NOTE: There is a https://www.raspberrypi.org/forums/viewtopic.php?f=26&t=20155&p=195443#p195443[pixel clock limit].The highest supported mode on models prior to the Raspberry Pi 4 is 1920x1200 at 60Hz with reduced blanking, whilst the Raspberry Pi 4 can support up to 4096x2160 (known as 4k) at 60Hz. Also note that if you are using both HDMI ports of the Raspberry Pi 4 for 4k output, then you are limited to 30Hz on both. - -==== `hdmi_timings` - -This allows setting of raw HDMI timing values for a custom mode, selected using `hdmi_group=2` and `hdmi_mode=87`. - -[source] +[source,ini] ---- -hdmi_timings= +dtoverlay=vc4-kms-v3d,composite ---- -[source] ----- - = horizontal pixels (width) - = invert hsync polarity - = horizontal forward padding from DE acitve edge - = hsync pulse width in pixel clocks - = vertical back padding from DE active edge - = vertical pixels height (lines) - = invert vsync polarity - = vertical forward padding from DE active edge - = vsync pulse width in pixel clocks - = vertical back padding from DE active edge - = leave at zero - = leave at zero - = leave at zero - = screen refresh rate in Hz - = leave at zero - = clock frequency (width*height*framerate) - = * ----- - -`*` The aspect ratio can be set to one of eight values (choose the closest for your screen): +By default, this outputs composite NTSC video. To choose a different mode, instead append the following to the single line in `/boot/firmware/cmdline.txt`: -[source] +[source,ini] ---- -HDMI_ASPECT_4_3 = 1 -HDMI_ASPECT_14_9 = 2 -HDMI_ASPECT_16_9 = 3 -HDMI_ASPECT_5_4 = 4 -HDMI_ASPECT_16_10 = 5 -HDMI_ASPECT_15_9 = 6 -HDMI_ASPECT_21_9 = 7 -HDMI_ASPECT_64_27 = 8 +vc4.tv_norm= ---- -==== `hdmi_force_mode` - -Setting to `1` will remove all other modes except the ones specified by `hdmi_mode` and `hdmi_group` from the internal list, meaning they will not appear in any enumerated lists of modes. This option may help if a display seems to be ignoring the `hdmi_mode` and `hdmi_group` settings. - -==== `edid_content_type` - -Forces the EDID content type to a specific value. - -The options are: +Replace the `` placeholder with one of the following values: -* `0` = `EDID_ContentType_NODATA`, content type none. -* `1` = `EDID_ContentType_Graphics`, content type graphics, ITC must be set to 1 -* `2` = `EDID_ContentType_Photo`, content type photo -* `3` = `EDID_ContentType_Cinema`, content type cinema -* `4` = `EDID_ContentType_Game`, content type game +* `NTSC` +* `NTSC-J` +* `NTSC-443` +* `PAL` +* `PAL-M` +* `PAL-N` +* `PAL60` +* `SECAM` -==== `hdmi_enable_4kp60` (Raspberry Pi 4, Model B Only) - -By default, when connected to a 4K monitor, the Raspberry Pi 4B will select a 30hz refresh rate. Use this option to allow selection of 60Hz refresh rates. Note, this will increase power consumption and increase the temperature of the Raspberry Pi. It is not possible to output 4Kp60 on both micro HDMI ports simultaneously. - -=== Which Values are Valid for my Monitor? - -Your HDMI monitor may only support a limited set of formats. To find out which formats are supported, use the following method: - -. Set the output format to VGA 60Hz (`hdmi_group=1` and `hdmi_mode=1`) and boot up your Raspberry Pi -. Enter the following command to give a list of CEA-supported modes: `/opt/vc/bin/tvservice -m CEA` -. Enter the following command to give a list of DMT-supported modes: `/opt/vc/bin/tvservice -m DMT` -. Enter the following command to show your current state: `/opt/vc/bin/tvservice -s` -. Enter the following commands to dump more detailed information from your monitor: `/opt/vc/bin/tvservice -d edid.dat; /opt/vc/bin/edidparser edid.dat` - -The `edid.dat` should also be provided when troubleshooting problems with the default HDMI mode. - -[[custom-mode]] -=== Custom Mode - -If your monitor requires a mode that is not in one of the tables above, then it's possible to define a custom CVT mode for it instead: - -[source] ----- -hdmi_cvt= ----- - -|=== -| Value | Default | Description - -| width -| (required) -| width in pixels - -| height -| (required) -| height in pixels - -| framerate -| (required) -| framerate in Hz - -| aspect -| 3 -| aspect ratio 1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10, 6=15:9 - -| margins -| 0 -| 0=margins disabled, 1=margins enabled - -| interlace -| 0 -| 0=progressive, 1=interlaced - -| rb -| 0 -| 0=normal, 1=reduced blanking -|=== - -Fields at the end can be omitted to use the default values. - -Note that this simply *creates* the mode (group 2 mode 87). In order to make the Pi use this by default, you must add some additional settings. For example, the following selects an 800 × 480 resolution and enables audio drive: - ----- -hdmi_cvt=800 480 60 6 -hdmi_group=2 -hdmi_mode=87 -hdmi_drive=2 ----- - -This may not work if your monitor does not support standard CVT timings. - -=== LCD Displays and Touchscreens +=== LCD displays and touchscreens ==== `ignore_lcd` -By default the Raspberry Pi LCD display is used when it is detected on the I2C bus. `ignore_lcd=1` will skip this detection phase, and therefore the LCD display will not be used. - -==== `display_default_lcd` - -If a Raspberry Pi DSI LCD is detected it will be used as the default display and will show the framebuffer. Setting `display_default_lcd=0` will ensure the LCD is not the default display, which usually implies the HDMI output will be the default. The LCD can still be used by choosing its display number from supported applications, for example, omxplayer. - -==== `lcd_framerate` - -Specify the framerate of the Raspberry Pi LCD display, in Hertz/fps. Defaults to 60Hz. - -==== `lcd_rotate` - -This flips the display using the LCD's inbuilt flip functionality, which is a cheaper operation that using the GPU-based rotate operation. - -For example, `lcd_rotate=2` will compensate for an upside down display. +By default, the Raspberry Pi Touch Display is used when detected on the I2C bus. `ignore_lcd=1` skips this detection phase. This prevents the LCD display from being used. ==== `disable_touchscreen` -Enable/disable the touchscreen. - -`disable_touchscreen=1` will disable the touchscreen on the official Raspberry Pi LCD display. - -==== `enable_dpi_lcd` - -Enable LCD displays attached to the DPI GPIOs. This is to allow the use of third-party LCD displays using the parallel display interface. - -==== `dpi_group`, `dpi_mode`, `dpi_output_format` - -The `dpi_group` and `dpi_mode` `config.txt` parameters are used to set either predetermined modes (DMT or CEA modes as used by HDMI above). A user can generate custom modes in much the same way as for HDMI (see `dpi_timings` section). - -`dpi_output_format` is a bitmask specifying various parameters used to set up the display format. - -==== `dpi_timings` - -This allows setting of raw DPI timing values for a custom mode, selected using `dpi_group=2` and `dpi_mode=87`. - -[source] ----- -dpi_timings= ----- - -[source] ----- - = horizontal pixels (width) - = invert hsync polarity - = horizontal forward padding from DE acitve edge - = hsync pulse width in pixel clocks - = vertical back padding from DE active edge - = vertical pixels height (lines) - = invert vsync polarity - = vertical forward padding from DE active edge - = vsync pulse width in pixel clocks - = vertical back padding from DE active edge - = leave at zero - = leave at zero - = leave at zero - = screen refresh rate in Hz - = leave at zero - = clock frequency (width*height*framerate) - = * ----- - -`*` The aspect ratio can be set to one of eight values (choose the closest for your screen): - ----- -HDMI_ASPECT_4_3 = 1 -HDMI_ASPECT_14_9 = 2 -HDMI_ASPECT_16_9 = 3 -HDMI_ASPECT_5_4 = 4 -HDMI_ASPECT_16_10 = 5 -HDMI_ASPECT_15_9 = 6 -HDMI_ASPECT_21_9 = 7 -HDMI_ASPECT_64_27 = 8 ----- - -=== Generic Display Options - -==== `hdmi_force_hotplug` - -Setting `hdmi_force_hotplug` to `1` pretends that the HDMI hotplug signal is asserted, so it appears that a HDMI display is attached. In other words, HDMI output mode will be used, even if no HDMI monitor is detected. - -==== `hdmi_ignore_hotplug` - -Setting `hdmi_ignore_hotplug` to `1` pretends that the HDMI hotplug signal is not asserted, so it appears that a HDMI display is not attached. In other words, composite output mode will be used, even if an HDMI monitor is detected. - -==== `disable_overscan` - -Set `disable_overscan` to `1` to disable the default values of xref:configuration.adoc#underscan[overscan] that is set by the firmware. The default value of overscan for the left, right, top, and bottom edges is `48` for HD CEA modes, `32` for SD CEA modes, and `0` for DMT modes. The default value for `disable_overscan` is `0`. - -NOTE: Any further additional overscan options such as `overscan_scale` or overscan edges can still be applied after this option. - -==== `overscan_left` - -The `overscan_left` command specifies the number of pixels to add to the firmware default value of overscan on the left edge of the screen. The default value is `0`. - -Increase this value if the text flows off the left edge of the screen; decrease it if there is a black border between the left edge of the screen and the text. - -==== `overscan_right` - -The `overscan_right` command specifies the number of pixels to add to the firmware default value of overscan on the right edge of the screen. The default value is `0`. - -Increase this value if the text flows off the right edge of the screen; decrease it if there is a black border between the right edge of the screen and the text. - -==== `overscan_top` - -The `overscan_top` command specifies the number of pixels to add to the firmware default value of overscan on the top edge of the screen. The default value is `0`. - -Increase this value if the text flows off the top edge of the screen; decrease it if there is a black border between the top edge of the screen and the text. - -==== `overscan_bottom` - -The `overscan_bottom` command specifies the number of pixels to add to the firmware default value of overscan on the bottom edge of the screen. The default value is `0`. - -Increase this value if the text flows off the bottom edge of the screen; decrease it if there is a black border between the bottom edge of the screen and the text. - -==== `overscan_scale` - -Set `overscan_scale` to `1` to force any non-framebuffer layers to conform to the overscan settings. The default value is `0`. - -*NOTE:* this feature is generally not recommended: it can reduce image quality because all layers on the display will be scaled by the GPU. Disabling overscan on the display itself is the recommended option to avoid images being scaled twice (by the GPU and the display). - -==== `framebuffer_width` +Enables and disables the touchscreen. -The `framebuffer_width` command specifies the console framebuffer width in pixels. The default is the display width minus the total horizontal overscan. +`disable_touchscreen=1` disables the touchscreen component of the official Raspberry Pi Touch Display. -==== `framebuffer_height` - -The `framebuffer_height` command specifies the console framebuffer height in pixels. The default is the display height minus the total vertical overscan. -C4 - -==== `max_framebuffer_heigh`t, `max_framebuffer_width` - -Specifies the maximum dimensions that the internal frame buffer is allowed to be. - -==== `framebuffer_depth` - -Use `framebuffer_depth` to specify the console framebuffer depth in bits per pixel. The default value is `16`. - -|=== -| framebuffer_depth | result | notes - -| 8 -| 8bit framebuffer -| Default RGB palette makes screen unreadable - -| 16 -| 16bit framebuffer -| - -| 24 -| 24bit framebuffer -| May result in a corrupted display - -| 32 -| 32bit framebuffer -| May need to be used in conjunction with `framebuffer_ignore_alpha=1` -|=== - -==== `framebuffer_ignore_alpha` - -Set `framebuffer_ignore_alpha` to `1` to disable the alpha channel. Can help with the display of a 32bit `framebuffer_depth`. - -==== `framebuffer_priority` - -In a system with multiple displays, using the legacy (pre-KMS) graphics driver, this forces a specific internal display device to be the first Linux framebuffer (i.e. `/dev/fb0`). - -The options that can be set are: - -|=== -| Display | ID - -| Main LCD -| 0 - -| Secondary LCD -| 1 - -| HDMI 0 -| 2 - -| Composite -| 3 - -| HDMI 1 -| 7 -|=== - -==== `max_framebuffers` - -This configuration entry sets the maximum number of firmware framebuffers that can be created. Valid options are 0,1, and 2. By default on devices before the Pi4 this is set to 1, so will need to be increased to 2 when using more than one display, for example HDMI and a DSI or DPI display. The Raspberry Pi4 configuration sets this to 2 by default as it has two HDMI ports. - -Generally in most cases it is safe to set this to 2, as framebuffers will only be created when an attached device is actually detected. - -Setting this value to 0 can be used to reduce memory requirements when used in headless mode as it will prevent any framebuffers from being allocated. - -==== `test_mode` - -The `test_mode` command displays a test image and sound during boot (over the composite video and analogue audio outputs only) for the given number of seconds, before continuing to boot the OS as normal. This is used as a manufacturing test; the default value is `0`. - -==== `display_hdmi_rotate` - -Use `display_hdmi_rotate` to rotate or flip the HDMI display orientation. The default value is `0`. - -|=== -| display_hdmi_rotate | result - -| 0 -| no rotation - -| 1 -| rotate 90 degrees clockwise - -| 2 -| rotate 180 degrees clockwise - -| 3 -| rotate 270 degrees clockwise - -| 0x10000 -| horizontal flip - -| 0x20000 -| vertical flip -|=== - -Note that the 90 and 270 degree rotation options require additional memory on the GPU, so these will not work with the 16MB GPU split. - -If using the VC4 FKMS V3D driver (this is the default on the Raspberry Pi 4), then 90 and 270 degree rotations are not supported. The Screen Configuration utility xref:configuration.adoc#rotating-your-display[provides display rotations] for this driver. - -==== `display_lcd_rotate` - -For the legacy graphics driver (default on models prior to the Pi4), use `display_lcd_rotate` to rotate or flip the LCD orientation. Parameters are the same as `display_hdmi_rotate`. See also `lcd_rotate`. - -==== `display_rotate` - -`display_rotate` is deprecated in the latest firmware but has been retained for backwards compatibility. Please use `display_lcd_rotate` and `display_hdmi_rotate` instead. - -Use `display_rotate` to rotate or flip the screen orientation. Parameters are the same as `display_hdmi_rotate`. +=== Generic display options ==== `disable_fw_kms_setup` -By default, the firmware parses the EDID of any HDMI attached display, picks an appropriate video mode, then passes the resolution and frame rate of the mode, along with overscan parameters, to the Linux kernel via settings on the kernel command line. In rare circumstances, this can have the effect of choosing a mode that is not in the EDID, and may be incompatible with the device. You can use `disable_fw_kms_setup=1` to disable the passing of these parameters and avoid this problem. The Linux video mode system (KMS) will then parse the EDID itself and pick an appropriate mode. - -=== Other Options +By default, the firmware parses the EDID of any HDMI attached display, picks an appropriate video mode, then passes the resolution and frame rate of the mode (and overscan parameters) to the Linux kernel via settings on the kernel command line. In rare circumstances, the firmware can choose a mode not in the EDID that may be incompatible with the device. Use `disable_fw_kms_setup=1` to disable passing video mode parameters, which can avoid this problem. The Linux video mode system (KMS) instead parses the EDID itself and picks an appropriate mode. -==== `dispmanx_offline` +NOTE: On Raspberry Pi 5, this parameter defaults to `1`. -Forces `dispmanx` composition to be done offline in two offscreen framebuffers. This can allow more `dispmanx` elements to be composited, but is slower and may limit screen framerate to typically 30fps. diff --git a/documentation/asciidoc/computers/config_txt/what_is_config_txt.adoc b/documentation/asciidoc/computers/config_txt/what_is_config_txt.adoc index 775809c7f9..e8fc1bf108 100644 --- a/documentation/asciidoc/computers/config_txt/what_is_config_txt.adoc +++ b/documentation/asciidoc/computers/config_txt/what_is_config_txt.adoc @@ -1,34 +1,66 @@ == What is `config.txt`? -The Raspberry Pi uses a configuration file instead of the https://en.wikipedia.org/wiki/BIOS[BIOS] you would expect to find on a conventional PC. The system configuration parameters, which would traditionally be edited and stored using a BIOS, are stored instead in an optional text file named `config.txt`. This is read by the GPU before the ARM CPU and Linux are initialised. It must therefore be located on the first (boot) partition of your SD card, alongside `bootcode.bin` and `start.elf`. This file is normally accessible as `/boot/config.txt` from Linux, and must be edited as xref:using_linux.adoc#root-and-sudo[root]. From Windows or OS X it is visible as a file in the only accessible part of the card. If you need to apply some of the config settings below, but you don't have a `config.txt` on your boot partition yet, simply create it as a new text file. +Instead of the https://en.wikipedia.org/wiki/BIOS[BIOS] found on a conventional PC, Raspberry Pi devices use a configuration file called `config.txt`. The GPU reads `config.txt` before the Arm CPU and Linux initialise. Raspberry Pi OS looks for this file in the *boot partition*, located at `/boot/firmware/`. -Any changes will only take effect after you have rebooted your Raspberry Pi. After Linux has booted, you can view the current active settings using the following commands: +NOTE: Prior to Raspberry Pi OS _Bookworm_, Raspberry Pi OS stored the boot partition at `/boot/`. -* `vcgencmd get_config `: this displays a specific config value, e.g. `vcgencmd get_config arm_freq`. -* `vcgencmd get_config int`: this lists all the integer config options that are set (non-zero). -* `vcgencmd get_config str`: this lists all the string config options that are set (non-null). +You can edit `config.txt` directly from your Raspberry Pi OS installation. You can also remove the storage device and edit files in the boot partition, including `config.txt`, from a separate computer. -NOTE: There are some config settings that cannot be retrieved using `vcgencmd`. +Changes to `config.txt` only take effect after a reboot. You can view the current active settings using the following commands: -=== File Format +`vcgencmd get_config `:: displays a specific config value, e.g. `vcgencmd get_config arm_freq` +`vcgencmd get_config int`:: lists all non-zero integer config options (non-zero) +`vcgencmd get_config str`:: lists all non-null string config options -The `config.txt` file is read by the early-stage boot firmware, so it has a very simple file format. The format is a single `property=value` statement on each line, where `value` is either an integer or a string. Comments may be added, or existing config values may be commented out and disabled, by starting a line with the `#` character. +NOTE: Not all config settings can be retrieved using `vcgencmd`. -There is an 80 character line length limit to entries, any characters past this limit will be ignored. +=== File format + +The `config.txt` file is read by the early-stage boot firmware, so it uses a very simple file format: **a single `property=value` statement on each line, where `value` is either an integer or a string**. Comments may be added, or existing config values may be commented out and disabled, by starting a line with the `#` character. + +There is a 98-character line length limit for entries. Raspberry Pi OS ignores any characters past this limit. Here is an example file: +[source,ini] ---- -# Force the monitor to HDMI mode so that sound will be sent over HDMI cable -hdmi_drive=2 -# Set monitor mode to DMT -hdmi_group=2 -# Set monitor resolution to 1024x768 XGA 60Hz (HDMI_DMT_XGA_60) -hdmi_mode=16 -# Make display smaller to stop text spilling off the screen -overscan_left=20 -overscan_right=12 -overscan_top=10 -overscan_bottom=10 +# Enable audio (loads snd_bcm2835) +dtparam=audio=on + +# Automatically load overlays for detected cameras +camera_auto_detect=1 + +# Automatically load overlays for detected DSI displays +display_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d ---- +=== Advanced features + +==== `include` + +Causes the content of the specified file to be inserted into the current file. + +For example, adding the line `include extraconfig.txt` to `config.txt` will include the content of `extraconfig.txt` file in the `config.txt` file. + +[NOTE] +==== + +The `bootcode.bin` or EEPROM bootloaders do not support the `include` directive. + +Settings which are handled by the bootloader will only take effect if they are specified in `config.txt` (rather than any additional included file): + +* `bootcode_delay`, +* `gpu_mem`, `gpu_mem_256`, `gpu_mem_512`, `gpu_mem_1024`, +* `total_mem`, +* `sdram_freq`, +* `start_x`, `start_debug`, `start_file`, `fixup_file`, +* `uart_2ndstage`. + +==== + +==== Conditional filtering + +Conditional filters are covered in the xref:config_txt.adoc#conditional-filters[conditionals section]. diff --git a/documentation/asciidoc/computers/configuration.adoc b/documentation/asciidoc/computers/configuration.adoc index 53b0c3ed37..17ffa15f5d 100644 --- a/documentation/asciidoc/computers/configuration.adoc +++ b/documentation/asciidoc/computers/configuration.adoc @@ -1,41 +1,46 @@ include::configuration/raspi-config.adoc[] +include::configuration/display-resolution.adoc[] + +include::configuration/audio-config.adoc[] + include::configuration/configuring-networking.adoc[] -include::configuration/headless.adoc[] +include::configuration/screensaver.adoc[] -include::configuration/access-point-routed.adoc[] +include::configuration/users.adoc[] -include::configuration/access-point-bridged.adoc[] +include::configuration/external-storage.adoc[] -include::configuration/use-a-proxy.adoc[] +include::configuration/kernel-command-line-config.adoc[] -include::configuration/hdmi-config.adoc[] +include::configuration/localisation.adoc[] -include::configuration/display-rotation.adoc[] +include::configuration/securing-the-raspberry-pi.adoc[] -include::configuration/audio-config.adoc[] +include::configuration/headless.adoc[] -include::configuration/external-storage.adoc[] +include::configuration/host-wireless-network.adoc[] -include::configuration/localisation.adoc[] +include::configuration/use-a-proxy.adoc[] -include::configuration/pin-configuration.adoc[] +include::configuration/boot_folder.adoc[] + +include::configuration/led_blink_warnings.adoc[] + +include::configuration/uart.adoc[] include::configuration/device-tree.adoc[] -include::configuration/kernel-command-line-config.adoc[] +include::configuration/pin-configuration.adoc[] + + + -include::configuration/uart.adoc[] -include::configuration/warning-icons.adoc[] -include::configuration/led_blink_warnings.adoc[] -include::configuration/securing-the-raspberry-pi.adoc[] -include::configuration/screensaver.adoc[] -include::configuration/boot_folder.adoc[] diff --git a/documentation/asciidoc/computers/configuration/access-point-bridged.adoc b/documentation/asciidoc/computers/configuration/access-point-bridged.adoc deleted file mode 100644 index 3b8cad4764..0000000000 --- a/documentation/asciidoc/computers/configuration/access-point-bridged.adoc +++ /dev/null @@ -1,198 +0,0 @@ -== Setting up a Bridged Wireless Access Point - -The Raspberry Pi can be used as a bridged wireless access point within an existing Ethernet network. This will extend the network to wireless computers and devices. - -If you wish to create a standalone wireless network, consider instead setting up a xref:configuration.adoc#setting-up-a-routed-wireless-access-point[routed access point]. - ----- - +- RPi -------+ - +---+ 10.10.0.2 | +- Laptop ----+ - | | WLAN AP +-))) (((-+ WLAN Client | - | | Bridge | | 10.10.0.5 | - | +-------------+ +-------------+ - +- Router ----+ | - | Firewall | | +- PC#2 ------+ -(Internet)---WAN-+ DHCP server +-LAN-+---+ 10.10.0.3 | - | 10.10.0.1 | | +-------------+ - +-------------+ | - | +- PC#1 ------+ - +---+ 10.10.0.4 | - +-------------+ ----- - -A bridged wireless access point can be created using the inbuilt wireless features of the Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero W, or by using a suitable USB wireless dongle that supports access point mode. -It is possible that some USB dongles may need slight changes to their settings. If you are having trouble with a USB wireless dongle, please check the https://www.raspberrypi.org/forums/[forums]. - -This documentation was tested on a Raspberry Pi 3B running a fresh installation of Raspberry Pi OS Buster. - -[[intro-to-bridged-wap]] -=== Before you Begin - -* Ensure you have administrative access to your Raspberry Pi. The network setup will be entirely reset as part of the installation: local access, with screen and keyboard connected to your Raspberry Pi, is recommended. -+ -[NOTE] -====== -If installing remotely via SSH, connect to your Raspberry Pi *by name* rather than by IP address, e.g. `ssh pi@raspberrypi.local`, as the address of your Raspberry Pi on the network will probably change after installation. You should also be ready to add screen and keyboard if needed in case you lose contact with your Raspberry Pi after installation. -====== -* Connect your Raspberry Pi to the Ethernet network and boot the Raspberry Pi OS. -* Ensure the Raspberry Pi OS on your Raspberry Pi is xref:os.adoc#updating-and-upgrading-raspberry-pi-os[up-to-date] and reboot if packages were installed in the process. -* Have a wireless client (laptop, smartphone, ...) ready to test your new access point. - -[[access-point-software-install]] -=== Install AP and Management Software - -In order to work as a bridged access point, the Raspberry Pi needs to have the `hostapd` access point software package installed: - ----- -sudo apt install hostapd ----- - -Enable the wireless access point service and set it to start when your Raspberry Pi boots: - ----- -sudo systemctl unmask hostapd -sudo systemctl enable hostapd ----- - -Software installation is complete. We will configure the access point software later on. - -[[bridging]] -=== Setup the Network Bridge - -A bridge network device running on the Raspberry Pi will connect the Ethernet and wireless networks using its built-in interfaces. - -==== Create a bridge device and populate the bridge - -Add a bridge network device named `br0` by creating a file using the following command, with the contents below: - ----- -sudo nano /etc/systemd/network/bridge-br0.netdev ----- - -File contents: - ----- -[NetDev] -Name=br0 -Kind=bridge ----- - -In order to bridge the Ethernet network with the wireless network, first add the built-in Ethernet interface (`eth0`) as a bridge member by creating the following file: - ----- -sudo nano /etc/systemd/network/br0-member-eth0.network ----- - -File contents: - ----- -[Match] -Name=eth0 - -[Network] -Bridge=br0 ----- - -NOTE: The access point software will add the wireless interface `wlan0` to the bridge when the service starts. There is no need to create a file for that interface. This situation is particular to wireless LAN interfaces. - -Now enable the `systemd-networkd` service to create and populate the bridge when your Raspberry Pi boots: - ----- -sudo systemctl enable systemd-networkd ----- - -==== Define the bridge device IP configuration - -Network interfaces that are members of a bridge device are never assigned an IP address, since they communicate via the bridge. The bridge device itself needs an IP address, so that you can reach your Raspberry Pi on the network. - -`dhcpcd`, the DHCP client on the Raspberry Pi, automatically requests an IP address for every active interface. So we need to block the `eth0` and `wlan0` interfaces from being processed, and let `dhcpcd` configure only `br0` via DHCP. - ----- -sudo nano /etc/dhcpcd.conf ----- - -Add the following line near the beginning of the file (above the first `interface xxx` line, if any): - ----- -denyinterfaces wlan0 eth0 ----- - -Go to the end of the file and add the following: - ----- - -interface br0 ----- - -With this line, interface `br0` will be configured in accordance with the defaults via DHCP. Save the file to complete the IP configuration of the machine. - -[[ensure-wireless-operation]] -=== Ensure Wireless Operation - -Countries around the world regulate the use of telecommunication radio frequency bands to ensure interference-free operation. -The Linux OS helps users https://wireless.wiki.kernel.org/en/developers/regulatory/statement[comply] with these rules by allowing applications to be configured with a two-letter "WiFi country code", e.g. `US` for a computer used in the United States. - -In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process (see wireless configuration pages in this xref:configuration.adoc#configuring-networking[section] for details.) - -To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command: - ----- -sudo rfkill unblock wlan ----- - -This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next. - -[[configure-access-point-software]] -=== Configure the AP Software - -Create the `hostapd` configuration file, located at `/etc/hostapd/hostapd.conf`, to add the various parameters for your new wireless network. - ----- -sudo nano /etc/hostapd/hostapd.conf ----- - -Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of `NameOfNetwork`, and a password `AardvarkBadgerHedgehog`. Note that the name and password should *not* have quotes around them. The passphrase should be between 8 and 64 characters in length. - ----- -country_code=GB -interface=wlan0 -bridge=br0 -ssid=NameOfNetwork -hw_mode=g -channel=7 -macaddr_acl=0 -auth_algs=1 -ignore_broadcast_ssid=0 -wpa=2 -wpa_passphrase=AardvarkBadgerHedgehog -wpa_key_mgmt=WPA-PSK -wpa_pairwise=TKIP -rsn_pairwise=CCMP ----- - -Note the lines `interface=wlan0` and `bridge=br0`: these direct `hostapd` to add the `wlan0` interface as a bridge member to `br0` when the access point starts, completing the bridge between Ethernet and wireless. - -Note the line `country_code=GB`: it configures the computer to use the correct wireless frequencies in the United Kingdom. *Adapt this line* and specify the two-letter ISO code of your country. See https://en.wikipedia.org/wiki/ISO_3166-1[Wikipedia] for a list of two-letter ISO 3166-1 country codes. - -To use the 5 GHz band, you can change the operations mode from `hw_mode=g` to `hw_mode=a`. Possible values for `hw_mode` are: - -* a = IEEE 802.11a (5 GHz) (Raspberry Pi 3B+ onwards) -* b = IEEE 802.11b (2.4 GHz) -* g = IEEE 802.11g (2.4 GHz) - -Note that when changing the `hw_mode`, you may need to also change the `channel` - see https://en.wikipedia.org/wiki/List_of_WLAN_channels[Wikipedia] for a list of allowed combinations. - -[[run-wireless-access-point]] -=== Run the new Wireless AP - -Now restart your Raspberry Pi and verify that the wireless access point becomes automatically available. - ----- -sudo systemctl reboot ----- - -Once your Raspberry Pi has restarted, search for wireless networks with your wireless client. The network SSID you specified in file `/etc/hostapd/hostapd.conf` should now be present, and it should be accessible with the specified password. - -If your wireless client has access to the local network and the internet, congratulations on setting up your new access point! - -If you encounter difficulties, contact the https://www.raspberrypi.org/forums/[forums] for assistance. Please refer to this page in your message. diff --git a/documentation/asciidoc/computers/configuration/access-point-routed.adoc b/documentation/asciidoc/computers/configuration/access-point-routed.adoc deleted file mode 100644 index 46aa96a195..0000000000 --- a/documentation/asciidoc/computers/configuration/access-point-routed.adoc +++ /dev/null @@ -1,225 +0,0 @@ -== Setting up a Routed Wireless Access Point - -A Raspberry Pi within an Ethernet network can be used as a wireless access point, creating a secondary network. The resulting new wireless network is entirely managed by the Raspberry Pi. - -If you wish to extend an existing Ethernet network to wireless clients, consider instead setting up a xref:configuration.adoc#setting-up-a-bridged-wireless-access-point[bridged access point]. - ----- - +- RPi -------+ - +---+ 10.10.0.2 | +- Laptop ----+ - | | WLAN AP +-))) (((-+ WLAN Client | - | | 192.168.4.1 | | 192.168.4.2 | - | +-------------+ +-------------+ - +- Router ----+ | - | Firewall | | +- PC#2 ------+ -(Internet)---WAN-+ DHCP server +-LAN-+---+ 10.10.0.3 | - | 10.10.0.1 | | +-------------+ - +-------------+ | - | +- PC#1 ------+ - +---+ 10.10.0.4 | - +-------------+ ----- - -A routed wireless access point can be created using the inbuilt wireless features of the Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero W, or by using a suitable USB wireless dongle that supports access point mode. -It is possible that some USB dongles may need slight changes to their settings. If you are having trouble with a USB wireless dongle, please check the https://www.raspberrypi.org/forums/[forums]. - -This documentation was tested on a Raspberry Pi 3B running a fresh installation of Raspberry Pi OS Buster. - -[[intro]] -=== Before you Begin - -* Ensure you have administrative access to your Raspberry Pi. The network setup will be modified as part of the installation: local access, with screen and keyboard connected to your Raspberry Pi, is recommended. -* Connect your Raspberry Pi to the Ethernet network and boot the Raspberry Pi OS. -* Ensure the Raspberry Pi OS on your Raspberry Pi is xref:os.adoc#updating-and-upgrading-raspberry-pi-os[up-to-date] and reboot if packages were installed in the process. -* Take note of the IP configuration of the Ethernet network the Raspberry Pi is connected to: - ** In this document, we assume IP network `10.10.0.0/24` is configured on the Ethernet LAN, and the Raspberry Pi is going to manage IP network `192.168.4.0/24` for wireless clients. - ** Please select another IP network for wireless, e.g. `192.168.10.0/24`, if IP network `192.168.4.0/24` is already in use by your Ethernet LAN. -* Have a wireless client (laptop, smartphone, ...) ready to test your new access point. - -[[software-install]] -=== Install AP and Management Software - -In order to work as an access point, the Raspberry Pi needs to have the `hostapd` access point software package installed: - ----- -sudo apt install hostapd ----- - -Enable the wireless access point service and set it to start when your Raspberry Pi boots: - ----- -sudo systemctl unmask hostapd -sudo systemctl enable hostapd ----- - -In order to provide network management services (DNS, DHCP) to wireless clients, the Raspberry Pi needs to have the `dnsmasq` software package installed: - ----- -sudo apt install dnsmasq ----- - -Finally, install `netfilter-persistent` and its plugin `iptables-persistent`. This utilty helps by saving firewall rules and restoring them when the Raspberry Pi boots: - ----- -sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent ----- - -Software installation is complete. We will configure the software packages later on. - -[[routing]] -=== Set up the Network Router - -The Raspberry Pi will run and manage a standalone wireless network. It will also route between the wireless and Ethernet networks, providing internet access to wireless clients. If you prefer, you can choose to skip the routing by skipping the section "Enable routing and IP masquerading" below, and run the wireless network in complete isolation. - -==== Define the Wireless Interface IP Configuration - -The Raspberry Pi runs a DHCP server for the wireless network; this requires static IP configuration for the wireless interface (`wlan0`) in the Raspberry Pi. -The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: `192.168.4.1`. - -To configure the static IP address, edit the configuration file for `dhcpcd` with: - ----- -sudo nano /etc/dhcpcd.conf ----- - -Go to the end of the file and add the following: - ----- -interface wlan0 - static ip_address=192.168.4.1/24 - nohook wpa_supplicant ----- - -==== Enable Routing and IP Masquerading - -This section configures the Raspberry Pi to let wireless clients access computers on the main (Ethernet) network, and from there the internet. - -NOTE: If you wish to block wireless clients from accessing the Ethernet network and the internet, skip this section. - -To enable routing, i.e. to allow traffic to flow from one network to the other in the Raspberry Pi, create a file using the following command, with the contents below: - ----- -sudo nano /etc/sysctl.d/routed-ap.conf ----- - -File contents: - ----- -# Enable IPv4 routing -net.ipv4.ip_forward=1 ----- - -Enabling routing will allow hosts from network `192.168.4.0/24` to reach the LAN and the main router towards the internet. In order to allow traffic between clients on this foreign wireless network and the internet without changing the configuration of the main router, the Raspberry Pi can substitute the IP address of wireless clients with its own IP address on the LAN using a "masquerade" firewall rule. - -* The main router will see all outgoing traffic from wireless clients as coming from the Raspberry Pi, allowing communication with the internet. -* The Raspberry Pi will receive all incoming traffic, substitute the IP addresses back, and forward traffic to the original wireless client. - -This process is configured by adding a single firewall rule in the Raspberry Pi: - ----- -sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ----- - -Now save the current firewall rules for IPv4 (including the rule above) and IPv6 to be loaded at boot by the `netfilter-persistent` service: - ----- -sudo netfilter-persistent save ----- - -Filtering rules are saved to the directory `/etc/iptables/`. If in the future you change the configuration of your firewall, make sure to save the configuration before rebooting. - -==== Configure the DHCP and DNS services for the wireless network - -The DHCP and DNS services are provided by `dnsmasq`. The default configuration file serves as a template for all possible configuration options, whereas we only need a few. It is easier to start from an empty file. - -Rename the default configuration file and edit a new one: - ----- -sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -sudo nano /etc/dnsmasq.conf ----- - -Add the following to the file and save it: - ----- -interface=wlan0 # Listening interface -dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h - # Pool of IP addresses served via DHCP -domain=wlan # Local wireless DNS domain -address=/gw.wlan/192.168.4.1 - # Alias for this router ----- - -The Raspberry Pi will deliver IP addresses between `192.168.4.2` and `192.168.4.20`, with a lease time of 24 hours, to wireless DHCP clients. You should be able to reach the Raspberry Pi under the name `gw.wlan` from wireless clients. - -There are many more options for `dnsmasq`; see the default configuration file (`/etc/dnsmasq.conf`) or the http://www.thekelleys.org.uk/dnsmasq/doc.html[online documentation] for details. - -[[wifi-cc-rfkill]] -=== Ensure Wireless Operation - -Countries around the world regulate the use of telecommunication radio frequency bands to ensure interference-free operation. -The Linux OS helps users https://wireless.wiki.kernel.org/en/developers/regulatory/statement[comply] with these rules by allowing applications to be configured with a two-letter "WiFi country code", e.g. `US` for a computer used in the United States. - -In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process (see wireless configuration pages in this xref:configuration.adoc#configuring-networking[section] for details.) - -To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command: - ----- -sudo rfkill unblock wlan ----- - -This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next. - -[[ap-config]] -=== Configure the AP Software - -Create the `hostapd` configuration file, located at `/etc/hostapd/hostapd.conf`, to add the various parameters for your new wireless network. - ----- -sudo nano /etc/hostapd/hostapd.conf ----- - -Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of `NameOfNetwork`, and a password `AardvarkBadgerHedgehog`. Note that the name and password should *not* have quotes around them. The passphrase should be between 8 and 64 characters in length. - ----- -country_code=GB -interface=wlan0 -ssid=NameOfNetwork -hw_mode=g -channel=7 -macaddr_acl=0 -auth_algs=1 -ignore_broadcast_ssid=0 -wpa=2 -wpa_passphrase=AardvarkBadgerHedgehog -wpa_key_mgmt=WPA-PSK -wpa_pairwise=TKIP -rsn_pairwise=CCMP ----- - -Note the line `country_code=GB`: it configures the computer to use the correct wireless frequencies in the United Kingdom. *Adapt this line* and specify the two-letter ISO code of your country. See https://en.wikipedia.org/wiki/ISO_3166-1[Wikipedia] for a list of two-letter ISO 3166-1 country codes. - -To use the 5 GHz band, you can change the operations mode from `hw_mode=g` to `hw_mode=a`. Possible values for `hw_mode` are: - -* a = IEEE 802.11a (5 GHz) (Raspberry Pi 3B+ onwards) -* b = IEEE 802.11b (2.4 GHz) -* g = IEEE 802.11g (2.4 GHz) - -Note that when changing the `hw_mode`, you may need to also change the `channel` - see https://en.wikipedia.org/wiki/List_of_WLAN_channels[Wikipedia] for a list of allowed combinations. - -[[conclusion]] -=== Running the new Wireless AP - -Now restart your Raspberry Pi and verify that the wireless access point becomes automatically available. - ----- -sudo systemctl reboot ----- - -Once your Raspberry Pi has restarted, search for wireless networks with your wireless client. The network SSID you specified in file `/etc/hostapd/hostapd.conf` should now be present, and it should be accessible with the specified password. - -If SSH is enabled on the Raspberry Pi, it should be possible to connect to it from your wireless client as follows, assuming the `pi` account is present: `ssh pi@192.168.4.1` or `ssh pi@gw.wlan` - -If your wireless client has access to your Raspberry Pi (and the internet, if you set up routing), congratulations on setting up your new access point! - -If you encounter difficulties, contact the https://www.raspberrypi.org/forums/[forums] for assistance. Please refer to this page in your message. diff --git a/documentation/asciidoc/computers/configuration/audio-config.adoc b/documentation/asciidoc/computers/configuration/audio-config.adoc index f0f897c44b..e12c032b46 100644 --- a/documentation/asciidoc/computers/configuration/audio-config.adoc +++ b/documentation/asciidoc/computers/configuration/audio-config.adoc @@ -1,35 +1,43 @@ -== Audio Configuration +== Audio -The Raspberry Pi has up to three audio output modes: HDMI 1 and 2, if present, and a headphone jack. You can switch between these modes at any time. +Raspberry Pi OS has multiple audio output modes: HDMI 1, the headphone jack (if your device has one), and USB audio. -If your HDMI monitor or TV has built-in speakers, the audio can be played over the HDMI cable, but you can switch it to a set of headphones or other speakers plugged into the headphone jack. If your display claims to have speakers, sound is output via HDMI by default; if not, it is output via the headphone jack. This may not be the desired output setup, or the auto-detection is inaccurate, in which case you can manually switch the output. +By default, Raspberry Pi OS outputs audio to HDMI 1. If no HDMI output is available, Raspberry Pi OS outputs audio to the headphone jack or a connected USB audio device. -=== Changing the Audio Output +=== Change audio output -There are two ways of setting the audio output; using the Desktop volume control, or using `raspi-config` command line tool. +Use the following methods to configure audio output in Raspberry Pi OS: -==== Using the Desktop +[[pro-audio-profile]] -Right-clicking the volume icon on the desktop taskbar brings up the audio output selector; this allows you to select between the internal audio outputs. It also allows you to select any external audio devices, such as USB sound cards and Bluetooth audio devices. A green tick is shown against the currently selected audio output device -- simply left-click the desired output in the pop-up menu to change this. The volume control and mute operate on the currently selected device. - -==== Using raspi-config - -Open up xref:configuration.adoc#raspi-config[raspi-config] by entering the following into the command line: +[tabs] +====== +Desktop volume control:: ++ +Right-click the volume icon on the system tray to open the **audio output selector**. This interface lets you choose an audio output device. Click an audio output device to switch audio output to that device. ++ +You may see a device profile named **Pro Audio** when viewing an audio device in the audio output selector. This profile exposes the maximum number of channels across every audio device, allowing you greater control over the routing of signals. Unless you require fine-tuned control over audio output, use a different device profile. ++ +For more information about the Pro Audio profile, visit https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ#what-is-the-pro-audio-profile[PipeWire's FAQ]. +`raspi-config`:: ++ +To change your audio output using xref:configuration.adoc#raspi-config[`raspi-config`], run the following command: ++ +[source,console] ---- -sudo raspi-config +$ sudo raspi-config ---- ++ +You should see a configuration screen. Complete the following steps to change your audio output: ++ +. Select `System options` and press `Enter`. ++ +. Select the `Audio` option and press `Enter`. ++ +. Select your required mode and press `Enter` to select that mode. ++ +. Press the right arrow key to exit the options list. Select `Finish` to exit the configuration tool. +====== -This will open the configuration screen: - -Select `System Options` (Currently option 1, but yours may be different) and press `Enter`. - -Now select the Option named, `Audio` (Currently option S2, but yours may be different) and press `Enter`: - -Select your required mode, press `Enter` and press the right arrow key to exit the options list, then select `Finish` to exit the configuration tool. - -After you have finished modifying your audio settings, you need to restart your Raspberry Pi in order for your changes to take effect. - -=== Troubleshooting your HDMI -In some rare cases, it is necessary to edit `config.txt` to force HDMI mode (as opposed to DVI mode, which does not send sound). You can do this by editing `/boot/config.txt` and setting `hdmi_drive=2`, then rebooting for the change to take effect. diff --git a/documentation/asciidoc/computers/configuration/boot_folder.adoc b/documentation/asciidoc/computers/configuration/boot_folder.adoc index 79dba8465d..309b9c3f63 100644 --- a/documentation/asciidoc/computers/configuration/boot_folder.adoc +++ b/documentation/asciidoc/computers/configuration/boot_folder.adoc @@ -1,82 +1,101 @@ -== The `boot` Folder +== `boot` folder contents -In a basic xref:os.adoc[Raspberry Pi OS] install, the boot files are stored on the first partition of the SD card, which is formatted with the FAT file system. This means that it can be read on Windows, macOS, and Linux devices. +Raspberry Pi OS stores boot files on the first partition of the SD card, formatted with the FAT file system. -When the Raspberry Pi is powered on, it loads various files from the boot partition/folder in order to start up the various processors, then it boots the Linux kernel. +On startup, each Raspberry Pi loads various files from the boot partition in order to start up the various processors before the Linux kernel boots. -Once Linux has booted, the boot partition is mounted as `/boot`. +On boot, Linux mounts the boot partition as `/boot/firmware/`. -=== Boot Folder Contents +NOTE: Prior to _Bookworm_, Raspberry Pi OS stored the boot partition at `/boot/`. Since _Bookworm_, the boot partition is located at `/boot/firmware/`. -==== bootcode.bin +=== `bootcode.bin` -This is the bootloader, which is loaded by the SoC on boot, does some very basic setup, and then loads one of the `start*.elf` files. `bootcode.bin` is not used on the Raspberry Pi 4, because it has been replaced by boot code in the xref:raspberry-pi.adoc#raspberry-pi-4-boot-eeprom[onboard EEPROM]. +The bootloader, loaded by the SoC on boot. It performs some very basic setup, and then loads one of the `start*.elf` files. -==== start.elf, start_x.elf, start_db.elf, start_cd.elf, start4.elf, start4x.elf, start4cd.elf, start4db.elf +The Raspberry Pi 4 and 5 do not use `bootcode.bin`. It has been replaced by boot code in the xref:raspberry-pi.adoc#raspberry-pi-boot-eeprom[onboard EEPROM]. -These are binary blobs (firmware) that are loaded on to the VideoCore in the SoC, which then take over the boot process. -`start.elf` is the basic firmware, `start_x.elf` includes camera drivers and codec, `start_db.elf` is a debug version of the firmware, and `start_cd.elf` is a cut-down version with no support hardware blocks like codecs and 3D, and for use when `gpu_mem=16` is specified in `config.txt`. More information on how to use these can be found in xref:config_txt.adoc#boot-options[the `config.txt` section]. +=== `start*.elf` -`start4.elf`, `start4x.elf`, `start4cd.elf`, and `start4db.elf` are firmware files specific to the Pi 4. +Binary firmware blobs loaded onto the VideoCore GPU in the SoC, which then take over the boot process. -==== fixup*.dat +`start.elf`:: the basic firmware. +`start_x.elf`:: includes additional codecs. +`start_db.elf`:: used for debugging. +`start_cd.elf`:: a cut-down version of the firmware that removes support for hardware blocks such as codecs and 3D as well as debug logging support; it also imposes initial frame buffer limitations. The cut-down firmware is automatically used when `gpu_mem=16` is specified in `config.txt`. -These are linker files and are matched pairs with the `start*.elf` files listed in the previous section. +`start4.elf`, `start4x.elf`, `start4db.elf` and `start4cd.elf` are equivalent firmware files specific to the Raspberry Pi 4-series (Model 4B, Pi 400, Compute Module 4 and Compute Module 4S). -==== cmdline.txt +For more information on how to use these files, see the xref:config_txt.adoc#boot-options[`config.txt` documentation]. -The kernel command line passed in to the kernel when it boots. +The Raspberry Pi 5 does not use `elf` files. The firmware is self-contained within the bootloader EEPROM. -==== config.txt +=== `fixup*.dat` -Contains many configuration parameters for setting up the Pi. See xref:config_txt.adoc[the `config.txt` section]. +Linker files found in matched pairs with the `start*.elf` files listed in the previous section. -==== issue.txt +=== `cmdline.txt` -Some text-based housekeeping information containing the date and git commit ID of the distribution. +The <> passed into the kernel at boot. -==== ssh or ssh.txt +=== `config.txt` -When this file is present, SSH will be enabled on boot. The contents don't matter, it can be empty. SSH is otherwise disabled by default. +Contains many configuration parameters for setting up the Raspberry Pi. For more information, see the xref:config_txt.adoc[`config.txt` documentation]. -==== wpa_supplicant.conf +IMPORTANT: Raspberry Pi 5 requires a non-empty `config.txt` file in the boot partition. -This is the file to configure wireless network settings (if the hardware is capable of it). Edit the country code and the network part to fit your case. More information on how to use this file can be found in xref:configuration.adoc#setting-up-a-headless-raspberry-pi[the `wireless/headless` section]. +=== `issue.txt` -==== Device Tree files +Text-based housekeeping information containing the date and git commit ID of the distribution. -There are various Device Tree blob files, which have the extension `.dtb`. These contain the hardware definitions of the various models of Raspberry Pi, and are used on boot to set up the kernel xref:configuration.adoc#part3.1[according to which Pi model is detected]. +=== `initramfs*` -==== Kernel Files +Contents of the initial ramdisk. This loads a temporary root file system into memory before the real root file system can be mounted. -The boot folder will contain various xref:linux_kernel.adoc#kernel[kernel] image files, used for the different Raspberry Pi models: +Since Bookworm, Raspberry Pi OS includes an `initramfs` file by default. To enable the initial ramdisk, configure it in xref:config_txt.adoc[`config.txt`] with the xref:config_txt.adoc#auto_initramfs[`auto_initramfs`] keyword. + +=== `ssh` or `ssh.txt` + +When this file is present, enables SSH at boot. SSH is otherwise disabled by default. The contents do not matter. Even an empty file enables SSH. + +=== Device Tree blob files (`*.dtb`) + +Device tree blob files contain the hardware definitions of the various models of Raspberry Pi. These files set up the kernel at boot xref:configuration.adoc#part3.1[based on the detected Raspberry Pi model]. + +=== Kernel files (`*.img`) + +Various xref:linux_kernel.adoc#kernel[kernel] image files that correspond to Raspberry Pi models: |=== | Filename | Processor | Raspberry Pi model | Notes -| kernel.img +| `kernel.img` | BCM2835 -| Pi Zero, Pi 1 +| Pi Zero, Pi 1, CM1 | -| kernel7.img +| `kernel7.img` | BCM2836, BCM2837 -| Pi 2, Pi 3 -| Later Pi 2 uses the BCM2837 +| Pi Zero 2 W, Pi 2, Pi 3, CM3, Pi 3+, CM3+ +| Later revisions of Pi 2 use BCM2837 -| kernel7l.img +| `kernel7l.img` | BCM2711 -| Pi 4 +| Pi 4, CM4, CM4S, Pi 400 | Large Physical Address Extension (LPAE) -| kernel8.img -| BCM2837, BCM2711 -| Pi 2, Pi 3, Pi 4 -| Beta xref:config_txt.adoc#boot-options[64 bit kernel]. Raspberry Pi 2 with BCM2836 does not support 64-bit. +| `kernel8.img` +| BCM2837, BCM2711, BCM2712 +| Pi Zero 2 W, Pi 2 (later revisions), Pi 3, CM3, Pi 3+, CM3+, Pi 4, CM4, CM4S, Pi 400, CM5, Pi 5, Pi 500 +| xref:config_txt.adoc#boot-options[64-bit kernel]. Earlier revisions of Raspberry Pi 2 (with BCM2836) do not support 64-bit kernels. + +| `kernel_2712.img` +| BCM2712 +| Pi 5, CM5, Pi 500 +| Pi 5-optimized xref:config_txt.adoc#boot-options[64-bit kernel]. |=== -NOTE: The architecture reported by `lscpu` is `armv7l` for 32-bit systems (i.e. everything except kernel8.img), and `aarch64` for 64-bit systems. The `l` in the `armv7l` case refers to the architecture being little-endian, not `LPAE` as is indicated by the `l` in the `kernel7l.img` filename. +NOTE: `lscpu` reports a CPU architecture of `armv7l` for systems running a 32-bit kernel, and `aarch64` for systems running a 64-bit kernel. The `l` in the `armv7l` case refers to little-endian CPU architecture, not `LPAE` as is indicated by the `l` in the `kernel7l.img` filename. -=== The Overlays Folder +=== `overlays` folder -The `overlays` sub-folder contains Device Tree overlays. These are used to configure various hardware devices that may be attached to the system, for example the Raspberry Pi Touch Display or third-party sound boards. These overlays are selected using entries in `config.txt` -- see xref:configuration.adoc#part2['Device Trees, overlays and parameters, part 2' for more info]. +Contains Device Tree overlays. These are used to configure various hardware devices, such as third-party sound boards. Entries in `config.txt` select these overlays. For more information, see xref:configuration.adoc#part2[Device Trees, overlays and parameters]. diff --git a/documentation/asciidoc/computers/configuration/configuring-networking.adoc b/documentation/asciidoc/computers/configuration/configuring-networking.adoc index 6b3a7b9139..aea9de8203 100644 --- a/documentation/asciidoc/computers/configuration/configuring-networking.adoc +++ b/documentation/asciidoc/computers/configuration/configuring-networking.adoc @@ -1,185 +1,196 @@ -== Configuring Networking +== Networking -A GUI is provided for setting up wireless connections in Raspberry Pi OS within the Raspberry Pi Desktop. However if you are not using the Raspberry Pi Desktop, you can set up wireless networking from the command line. +Raspberry Pi OS provides a graphical user interface (GUI) for setting up wireless connections. Users of Raspberry Pi OS Lite and headless machines can set up wireless networking from the command line with https://networkmanager.dev/docs/api/latest/nmcli.html[`nmcli`]. -=== Using the Desktop +NOTE: Starting with Raspberry Pi OS _Bookworm_, Network Manager is the default networking configuration tool. Earlier versions of Raspberry Pi OS used `dhcpd` and other tools for network configuration. -Wireless connections can be made via the network icon at the right-hand end of the menu bar. If you are using a Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, left-clicking this icon will bring up a list of available wireless networks, as shown below. If no networks are found, it will show the message 'No APs found - scanning...'. Wait a few seconds without closing the menu, and it should find your network. +=== Connect to a wireless network -Note that on Raspberry Pi devices that support the 5GHz band (Pi3B+, Pi4, CM4, Pi400), wireless networking is disabled for regulatory reasons, until the country code has been set. To set the country code, open the `Raspberry Pi Configuration` application from the Preferences Menu, select *Localisation* and set the appropriate code. +==== via the desktop + +Access Network Manager via the network icon at the right-hand end of the menu bar. If you are using a Raspberry Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, click this icon to bring up a list of available wireless networks. If you see the message 'No APs found - scanning...', wait a few seconds, and Network Manager should find your network. + +NOTE: Devices with dual-band wireless automatically disable networking until you assign a wireless LAN country. Flagship models since Raspberry Pi 3B+, Compute Modules since CM4, and Keyboard models support dual-band wireless. To set a wireless LAN country, open the Raspberry Pi Configuration application from the Preferences menu, select *Localisation* and select your country from the menu. image::images/wifi2.png[wifi2] -The icons on the right show whether a network is secured or not, and give an indication of its signal strength. Click the network that you want to connect to. If it is secured, a dialogue box will prompt you to enter the network key: +The icons on the right show whether a network is secured or not, and give an indication of signal strength. Click the network that you want to connect to. If the network is secured, a dialogue box will prompt you to enter the network key: image::images/key.png[key] -Enter the key and click *OK*, then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When it is ready, the icon will stop flashing and show the signal strength. +Enter the key and click *OK*, then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When connected, the icon will stop flashing and show the signal strength. -[[wireless-networking-command-line]] -=== Using the Command Line +===== Connect to a hidden network -This method is suitable if you don't have access to the graphical user interface normally used to set up a wireless LAN on the Raspberry Pi. It is particularly suitable for use with a serial console cable if you don't have access to a screen or wired Ethernet network. Note also that no additional software is required; everything you need is already included on the Raspberry Pi. +To use a hidden network, navigate to *Advanced options* > *Connect to a hidden Wi-Fi network* in the network menu: -==== Using raspi-config +image::images/network-hidden.png[the connect to a hidden wi-fi network option in advanced options] -The quickest way to enable wireless networking is to use the command line `raspi-config` tool. +Then, enter the SSID for the hidden network. Ask your network administrator which type of security your network uses; while most home networks currently use WPA and WPA2 personal security, public networks sometimes use WPA and WPA2 enterprise security. Select the security type for your network, and enter your credentials: -`sudo raspi-config` +image::images/network-hidden-authentication.png[hidden wi-fi network authentication] -Select the *Localisation Options* item from the menu, then the *Change wireless country* option. On a fresh install, for regulatory purposes, you will need to specify the country in which the device is being used. Then set the SSID of the network, and the passphrase for the network. If you do not know the SSID of the network you want to connect to, see the next section on how to list available networks prior to running `raspi-config`. +Click the *Connect* button to initiate the network connection. -Note that `raspi-config` does not provide a complete set of options for setting up wireless networking; you may need to refer to the extra sections below for more details if `raspi-config` fails to connect the Pi to your requested network. +[[wireless-networking-command-line]] +==== via the command line -==== Getting Wireless LAN Network Details +This guide will help you configure a wireless connection on your Raspberry Pi from a terminal without using graphical tools. No additional software is required. -To scan for wireless networks, use the command `sudo iwlist wlan0 scan`. This will list all available wireless networks, along with other useful information. Look out for: +NOTE: This guide should work for WEP, WPA, WPA2, or WPA3 networks, but may not work for enterprise networks. -. 'ESSID:"testing"' is the name of the wireless network. -. 'IE: IEEE 802.11i/WPA2 Version 1' is the authentication used. In this case it's WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. You'll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router. The ESSID (ssid) for the examples below is `testing` and the password (psk) is `testingPassword`. +===== Enable wireless networking -==== Adding the Network Details to your Raspberry Pi +On a fresh install, you must specify the country where you use your device. This allows your device to choose the correct frequency bands for 5GHz networking. Once you have specified a wireless LAN country, you can use your Raspberry Pi's built-in wireless networking module. -Open the `wpa-supplicant` configuration file in nano: +To do this, set your wireless LAN country with the command line `raspi-config` tool. Run the following command: + +[source,console] +---- +$ sudo raspi-config +---- -`sudo nano /etc/wpa_supplicant/wpa_supplicant.conf` +Select the *Localisation options* menu item using the arrow keys. Choose the *WLAN country* option. +Pick your country from the dropdown using the arrow keys. Press `Enter` to select your country. -Go to the bottom of the file and add the following: +You should now have access to wireless networking. Run the following command to check if your Wi-Fi radio is enabled: +[source,console] ---- -network={ - ssid="testing" - psk="testingPassword" -} +$ nmcli radio wifi ---- -The password can be configured either as the ASCII representation, in quotes as per the example above, or as a pre-encrypted 32 byte hexadecimal number. You can use the `wpa_passphrase` utility to generate an encrypted PSK. This takes the SSID and the password, and generates the encrypted PSK. With the example from above, you can generate the PSK with `wpa_passphrase "testing"`. Then you will be asked for the password of the wireless network (in this case `testingPassword`). The output is as follows: +If this command returns the text "enabled", you're ready to configure a connection. If this command returns "disabled", try enabling Wi-Fi with the following command: +[source,console] ---- - network={ - ssid="testing" - #psk="testingPassword" - psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531 - } +$ nmcli radio wifi on ---- -Note that the plain text version of the code is present, but commented out. You should delete this line from the final `wpa_supplicant` file for extra security. +===== Find networks -The `wpa_passphrase` tool requires a password with between 8 and 63 characters. To use a more complex password, you can extract the content of a text file and use it as input for `wpa_passphrase`. Store the password in a text file and input it to `wpa_passphrase` by calling `wpa_passphrase "testing" < file_where_password_is_stored`. For extra security, you should delete the `file_where_password_is_stored` afterwards, so there is no plain text copy of the original password on the system. +To scan for wireless networks, run the following command: -To use the `wpa_passphrase`--encrypted PSK, you can either copy and paste the encrypted PSK into the `wpa_supplicant.conf` file, or redirect the tool's output to the configuration file in one of two ways: - -* Either change to `root` by executing `sudo su`, then call `wpa_passphrase "testing" >> /etc/wpa_supplicant/wpa_supplicant.conf` and enter the testing password when asked -* Or use `wpa_passphrase "testing" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null` and enter the testing password when asked; the redirection to `/dev/null` prevents `tee` from *also* outputting to the screen (standard output). +[source,console] +---- +$ nmcli dev wifi list +---- -If you want to use one of these two options, *make sure you use `>>`, or use `-a` with `tee`* -- either will *append* text to an existing file. Using a single chevron `>`, or omitting `-a` when using `tee`, will erase all contents and *then* append the output to the specified file. +You should see output similar to the following: -Now save the file by pressing `Ctrl+X`, then `Y`, then finally press `Enter`. +---- +IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY + 90:72:40:1B:42:05 myNetwork Infra 132 405 Mbit/s 89 **** WPA2 + 90:72:42:1B:78:04 myNetwork5G Infra 11 195 Mbit/s 79 *** WPA2 + 9C:AB:F8:88:EB:0D Pi Towers Infra 1 260 Mbit/s 75 *** WPA2 802.1X + B4:2A:0E:64:BD:BE Example Infra 6 195 Mbit/s 37 ** WPA1 WPA2 +---- -Reconfigure the interface with `wpa_cli -i wlan0 reconfigure`. +Look in the "SSID" column for the name of the network you would like to connect to. Use the SSID and a password to connect to the network. -You can verify whether it has successfully connected using `ifconfig wlan0`. If the `inet addr` field has an address beside it, the Raspberry Pi has connected to the network. If not, check that your password and ESSID are correct. +===== Connect to a network -On the Raspberry Pi 3B+ and Raspberry Pi 4B, you will also need to set the country code, so that the 5GHz networking can choose the correct frequency bands. You can do this using the `raspi-config` application: select the 'Localisation Options' menu, then 'Change Wi-Fi Country'. Alternatively, you can edit the `wpa_supplicant.conf` file and add the following. (Note: you need to replace 'GB' with the 2 letter ISO code of your country. See https://en.wikipedia.org/wiki/ISO_3166-1[Wikipedia] for a list of 2 letter ISO 3166-1 country codes.) +Run the following command to configure a network connection, replacing the `` placeholder with the name of the network you're trying to configure: +[source,console] ---- -country=GB +$ sudo nmcli --ask dev wifi connect ---- -Note that with the latest Buster Raspberry Pi OS release, you must ensure that the `wpa_supplicant.conf` file contains the following information at the top: +Enter your network password when prompted. + +Your Raspberry Pi should automatically connect to the network once you enter your password. + +If you see error output that claims that "Secrets were required, but not provided", you entered an incorrect password. Run the above command again, carefully entering your password. +To check if you're connected to a network, run the following command: + +[source,console] ---- -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -update_config=1 -country= +$ nmcli dev wifi list ---- -==== Using Unsecured Networks - -If the network you are connecting to does not use a password, the `wpa_supplicant` entry for the network will need to include the correct `key_mgmt` entry. -e.g. +You should see output similar to the following: ---- -network={ - ssid="testing" - key_mgmt=NONE -} +IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY +* 90:72:40:1B:42:05 myNetwork Infra 132 405 Mbit/s 89 **** WPA2 + 90:72:42:1B:78:04 myNetwork5G Infra 11 195 Mbit/s 79 *** WPA2 + 9C:AB:F8:88:EB:0D Pi Towers Infra 1 260 Mbit/s 75 *** WPA2 802.1X + B4:2A:0E:64:BD:BE Example Infra 6 195 Mbit/s 37 ** WPA1 WPA2 ---- -WARNING: You should be careful when using unsecured wireless networks. +Check for an asterisk (`*`) in the "IN-USE" column; it should appear in the same row as the SSID of the network you intended to connect to. -==== Hidden Networks +NOTE: You can manually edit your connection configurations in the `/etc/NetworkManager/system-connections/` directory. -If you are using a hidden network, an extra option in the `wpa_supplicant file`, `scan_ssid`, may help connection. +===== Connect to an unsecured network +If the network you are connecting to does not use a password, run the following command: + +[source,console] ---- -network={ - ssid="yourHiddenSSID" - scan_ssid=1 - psk="Your_wireless_network_password" -} +$ sudo nmcli dev wifi connect ---- -You can verify whether it has successfully connected using `ifconfig wlan0`. If the `inet addr` field has an address beside it, the Raspberry Pi has connected to the network. If not, check your password and ESSID are correct. - -==== Adding Multiple Wireless Network Configurations +WARNING: Unsecured wireless networks can put your personal information at risk. Whenever possible, use a secured wireless network or VPN. -On recent versions of Raspberry Pi OS, it is possible to set up multiple configurations for wireless networking. For example, you could set up one for home and one for school. +===== Connect to a hidden network -For example +If you are using a hidden network, specify the "hidden" option with a value of "yes" when you run `nmcli`: +[source,console] ---- -network={ - ssid="SchoolNetworkSSID" - psk="passwordSchool" - id_str="school" -} - -network={ - ssid="HomeNetworkSSID" - psk="passwordHome" - id_str="home" -} +$ sudo nmcli --ask dev wifi connect hidden yes ---- -If you have two networks in range, you can add the priority option to choose between them. The network in range, with the highest priority, will be the one that is connected. +===== Set network priority ----- -network={ - ssid="HomeOneSSID" - psk="passwordOne" - priority=1 - id_str="homeOne" -} +If your device detects more than one known networks at the same time, it could connect any of the detected known networks. Use the priority option to force your Raspberry Pi to prefer certain networks. Your device will connect to the network that is in range with the highest priority. Run the following command to view the priority of known networks: -network={ - ssid="HomeTwoSSID" - psk="passwordTwo" - priority=2 - id_str="homeTwo" -} +[source,console] +---- +$ nmcli --fields autoconnect-priority,name connection ---- +You should see output similar to the following: -=== The DHCP Daemon - -The Raspberry Pi uses `dhcpcd` to configure TCP/IP across all of its network interfaces. The `dhcpcd` daemonis intended to be an all-in-one ZeroConf client for UNIX-like systems. This includes assigning each interface an IP address, setting netmasks, and configuring DNS resolution via the Name Service Switch (NSS) facility. +---- +AUTOCONNECT-PRIORITY NAME +0 myNetwork +0 lo +0 Pi Towers +0 Example +-999 Wired connection 1 +---- -By default, Raspberry Pi OS attempts to automatically configure all network interfaces by DHCP, falling back to automatic private addresses in the range 169.254.0.0/16 if DHCP fails. This is consistent with the behaviour of other Linux variants and of Microsoft Windows. +Use the `nmcli connection modify` command to set the priority of a network. +The following example command sets the priority of a network named "Pi Towers" to `10`: -=== Static IP Addresses +[source,console] +---- +$ nmcli connection modify "Pi Towers" connection.autoconnect-priority 10 +---- -If you wish to disable automatic configuration for an interface and instead configure it statically, add the details to `/etc/dhcpcd.conf`. For example: +Your device will always try to connect to the in-range network with the highest non-negative priority value. You can also assign a network a negative priority; your device will only attempt to connect to a negative priority network if no other known network is in range. For example, consider three networks: ---- -interface eth0 -static ip_address=192.168.0.4/24 -static routers=192.168.0.254 -static domain_name_servers=192.168.0.254 8.8.8.8 +AUTOCONNECT-PRIORITY NAME +-1 snake +0 rabbit +1 cat +1000 dog ---- -You can find the names of the interfaces present on your system using the `ip link` command. +* If all of these networks were in range, your device would first attempt to connect to the "dog" network. +* If connection to the "dog" network fails, your device would attempt to connect to the "cat" network. +* If connection to the "cat" network fails, your device would attempt to connect to the "rabbit" network. +* If connection to the "rabbit" network fails, and your device detects no other known networks, your device will attempt to connect to the "snake" network. + +=== Configure DHCP + +By default, Raspberry Pi OS attempts to automatically configure all network interfaces by DHCP, falling back to automatic private addresses in the range 169.254.0.0/16 if DHCP fails. -Note that if you have several Raspberry Pis connected to the same network, you may find it easier instead to set address reservations on your DHCP server. In this way, each Pi will keep the same IP address, but they will all be managed in one place, making reconfiguring your network in the future more straightforward. +=== Assign a static IP address -On Raspberry Pi systems where the graphical desktop is installed, a GUI tool called `lxplug-network` is used to allow the user to make changes to the configuration of `dhcpcd`, including setting static IP addresses. The `lxplug-network` tool is based on `dhcpcd-ui`, which was also developed by Roy Marples. +To allocate a static IP address to your Raspberry Pi, reserve an address for it on your router. Your Raspberry Pi will continue to have its address allocated via DHCP, but will receive the same address each time. A "fixed" address can be allocated by associating the MAC address of your Raspberry Pi with a static IP address in your DHCP server. diff --git a/documentation/asciidoc/computers/configuration/device-tree.adoc b/documentation/asciidoc/computers/configuration/device-tree.adoc index 7ac18d0a81..561ec68a29 100644 --- a/documentation/asciidoc/computers/configuration/device-tree.adoc +++ b/documentation/asciidoc/computers/configuration/device-tree.adoc @@ -1,25 +1,28 @@ -== Device Trees, Overlays, and Parameters +== Device Trees, overlays, and parameters -Raspberry Pi kernels and firmware use a Device Tree (DT) to describe the hardware present in the Pi. These Device Trees may include DT parameters that provide a degree of control over some onboard features. DT overlays allow optional external hardware to be described and configured, and they also support parameters for more control. +Raspberry Pi kernels and firmware use a Device Tree (DT) to describe hardware. These Device Trees may include DT parameters that to control onboard features. DT overlays allow optional external hardware to be described and configured, and they also support parameters for more control. -The firmware loader (`start.elf` and its variants) is responsible for loading the DTB (Device Tree Blob - a machine readable DT file). It chooses which one to load based on the board revision number, and makes certain modifications to further tailor it (memory size, Ethernet addresses etc.). This runtime customisation avoids the need for lots of DTBs with only minor differences. +The firmware loader (`start.elf` and its variants) is responsible for loading the DTB (Device Tree Blob - a machine-readable DT file). It chooses which one to load based on the board revision number, and makes modifications to further tailor it. This runtime customisation avoids the need for many DTBs with only minor differences. -`config.txt` is scanned for user-provided parameters, along with any overlays and their parameters, which are then applied. The loader examines the result to learn (for example) which UART, if any, is to be used for the console. Finally it launches the kernel, passing a pointer to the merged DTB. +User-provided parameters in `config.txt` are scanned, along with any overlays and their parameters, which are then applied. The loader examines the result to learn (for example) which UART, if any, is to be used for the console. Finally it launches the kernel, passing a pointer to the merged DTB. [[part1]] === Device Trees -A Device Tree (DT) is a description of the hardware in a system. It should include the name of the base CPU, its memory configuration, and any peripherals (internal and external). A DT should not be used to describe the software, although by listing the hardware modules it does usually cause driver modules to be loaded. It helps to remember that DTs are supposed to be OS-neutral, so anything which is Linux-specific probably shouldn't be there. +A Device Tree (DT) is a description of the hardware in a system. It should include the name of the base CPU, its memory configuration, and any peripherals (internal and external). A DT should not be used to describe the software, although by listing the hardware modules it does usually cause driver modules to be loaded. + +NOTE: It helps to remember that DTs are supposed to be OS-neutral, so anything which is Linux-specific shouldn't be there. A Device Tree represents the hardware configuration as a hierarchy of nodes. Each node may contain properties and subnodes. Properties are named arrays of bytes, which may contain strings, numbers (big-endian), arbitrary sequences of bytes, and any combination thereof. By analogy to a filesystem, nodes are directories and properties are files. The locations of nodes and properties within the tree can be described using a path, with slashes as separators and a single slash (`/`) to indicate the root. [[part1.1]] ==== Basic DTS syntax -Device Trees are usually written in a textual form known as Device Tree Source (DTS) and stored in files with a `.dts` suffix. DTS syntax is C-like, with braces for grouping and semicolons at the end of each line. Note that DTS requires semicolons after closing braces: think of C ``struct``s rather than functions. The compiled binary format is referred to as Flattened Device Tree (FDT) or Device Tree Blob (DTB), and is stored in `.dtb` files. +Device Trees are usually written in a textual form known as Device Tree Source (DTS), and are stored in files with a `.dts` suffix. DTS syntax is C-like, with braces for grouping and semicolons at the end of each line. Note that DTS requires semicolons after closing braces: think of C ``struct``s rather than functions. The compiled binary format is referred to as Flattened Device Tree (FDT) or Device Tree Blob (DTB), and is stored in `.dtb` files. The following is a simple tree in the `.dts` format: +[source,kotlin] ---- /dts-v1/; /include/ "common.dtsi"; @@ -53,43 +56,48 @@ The following is a simple tree in the `.dts` format: This tree contains: -* a required header: `/dts-v1/`. -* The inclusion of another DTS file, conventionally named `*.dtsi` and analogous to a `.h` header file in C - see _An aside about /include/_ below. +* a required header: `/dts-v1/` +* The inclusion of another DTS file, conventionally named `*.dtsi` and analogous to a `.h` header file in C * a single root node: `/` * a couple of child nodes: `node1` and `node2` * some children for node1: `child-node1` and `child-node2` -* a label (`cousin`) and a reference to that label (`&cousin`): see _Labels and References_ below. +* a label (`cousin`) and a reference to that label (`&cousin`) * several properties scattered through the tree -* a repeated node (`/node2`) - see _An aside about /include/_ below. +* a repeated node (`/node2`) Properties are simple key-value pairs where the value can either be empty or contain an arbitrary byte stream. While data types are not encoded in the data structure, there are a few fundamental data representations that can be expressed in a Device Tree source file. Text strings (NUL-terminated) are indicated with double quotes: +[source,kotlin] ---- string-property = "a string"; ---- Cells are 32-bit unsigned integers delimited by angle brackets: +[source,kotlin] ---- cell-property = <0xbeef 123 0xabcd1234>; ---- Arbitrary byte data is delimited with square brackets, and entered in hex: +[source,kotlin] ---- binary-property = [01 23 45 67 89 ab cd ef]; ---- Data of differing representations can be concatenated using a comma: +[source,kotlin] ---- mixed-property = "a string", [01 23 45 67], <0x12345678>; ---- Commas are also used to create lists of strings: +[source,kotlin] ---- string-list = "red fish", "blue fish"; ---- @@ -101,6 +109,7 @@ The `/include/` directive results in simple textual inclusion, much like C's `#i In the example above, the second appearance of `/node2` causes a new property to be added to the original: +[source,kotlin] ---- /node2 { an-empty-property; @@ -112,54 +121,47 @@ In the example above, the second appearance of `/node2` causes a new property to }; ---- -It is thus possible for one `.dtsi` to overwrite, or provide defaults for, multiple places in a tree. +It is therefore possible for one `.dtsi` to overwrite, or provide defaults for, multiple places in a tree. [[part1.3]] ==== Labels and references It is often necessary for one part of the tree to refer to another, and there are four ways to do this: -. Path strings -+ -Paths should be self-explanatory, by analogy with a filesystem - `/soc/i2s@7e203000` is the full path to the I2S device in BCM2835 and BCM2836. Note that although it is easy to construct a path to a property (for example, `/soc/i2s@7e203000/status`), the standard APIs don't do that; you first find a node, then choose properties of that node. +Path strings:: Similar to filesystem paths, e.g. `/soc/i2s@7e203000` is the full path to the I2S device in BCM2835 and BCM2836. The standard APIs don't create paths to properties like `/soc/i2s@7e203000/status`: instead, you first find a node, then choose properties of that node. -. phandles -+ -A phandle is a unique 32-bit integer assigned to a node in its `phandle` property. For historical reasons, you may also see a redundant, matching `linux,phandle`. phandles are numbered sequentially, starting from 1; 0 is not a valid phandle. They are usually allocated by the DT compiler when it encounters a reference to a node in an integer context, usually in the form of a label (see below). References to nodes using phandles are simply encoded as the corresponding integer (cell) values; there is no markup to indicate that they should be interpreted as phandles, as that is application-defined. +Phandles:: A unique 32-bit integer assigned to a node in its `phandle` property. For historical reasons, you may also see a redundant, matching `linux,phandle`. Phandles are numbered sequentially, starting from 1; 0 is not a valid phandle. They are usually allocated by the DT compiler when it encounters a reference to a node in an integer context, usually in the form of a label. References to nodes using phandles are simply encoded as the corresponding integer (cell) values; there is no markup to indicate that they should be interpreted as phandles, as that is application-defined. -. Labels -+ -Just as a label in C gives a name to a place in the code, a DT label assigns a name to a node in the hierarchy. The compiler takes references to labels and converts them into paths when used in string context (`&node`) and phandles in integer context (`<&node>`); the original labels do not appear in the compiled output. Note that labels contain no structure; they are just tokens in a flat, global namespace. +Labels:: Just as a label in C gives a name to a place in the code, a DT label assigns a name to a node in the hierarchy. The compiler takes references to labels and converts them into paths when used in string context (`&node`) and phandles in integer context (`<&node>`); the original labels do not appear in the compiled output. Note that labels contain no structure; they are just tokens in a flat, global namespace. -. Aliases -+ -Aliases are similar to labels, except that they do appear in the FDT output as a form of index. They are stored as properties of the `/aliases` node, with each property mapping an alias name to a path string. Although the aliases node appears in the source, the path strings usually appear as references to labels (`&node`), rather then being written out in full. DT APIs that resolve a path string to a node typically look at the first character of the path, treating paths that do not start with a slash as aliases that must first be converted to a path using the `/aliases` table. +Aliases:: Similar to labels, except that they do appear in the FDT output as a form of index. They are stored as properties of the `/aliases` node, with each property mapping an alias name to a path string. Although the aliases node appears in the source, the path strings usually appear as references to labels (`&node`), rather then being written out in full. DT APIs that resolve a path string to a node typically look at the first character of the path, treating paths that do not start with a slash as aliases that must first be converted to a path using the `/aliases` table. [[part1.4]] ==== Device Tree semantics -How to construct a Device Tree, and how best to use it to capture the configuration of some hardware, is a large and complex subject. There are many resources available, some of which are listed below, but several points deserve mentioning in this document: +How to construct a Device Tree, and how best to use it to capture the configuration of some hardware, is a large and complex subject. There are many resources available, some of which are listed below, but several points deserve highlighting: -`compatible` properties are the link between the hardware description and the driver software. When an OS encounters a node with a `compatible` property, it looks it up in its database of device drivers to find the best match. In Linux, this usually results in the driver module being automatically loaded, provided it has been appropriately labelled and not blacklisted. +* `compatible` properties are the link between the hardware description and the driver software. When an OS encounters a node with a `compatible` property, it looks it up in its database of device drivers to find the best match. In Linux, this usually results in the driver module being automatically loaded, provided it has been appropriately labelled and not blacklisted. -The `status` property indicates whether a device is enabled or disabled. If the `status` is `ok`, `okay` or absent, then the device is enabled. Otherwise, `status` should be `disabled`, so that the device is disabled. It can be useful to place devices in a `.dtsi` file with the status set to `disabled`. A derived configuration can then include that `.dtsi` and set the status for the devices which are needed to `okay`. +* The `status` property indicates whether a device is enabled or disabled. If the `status` is `ok`, `okay` or absent, then the device is enabled. Otherwise, `status` should be `disabled`, so that the device is disabled. It can be useful to place devices in a `.dtsi` file with the status set to `disabled`. A derived configuration can then include that `.dtsi` and set the status for the devices which are needed to `okay`. [[part2]] -=== Device Tree Overlays +=== Device Tree overlays -A modern SoC (System on a Chip) is a very complicated device; a complete Device Tree could be hundreds of lines long. Taking that one step further and placing the SoC on a board with other components only makes matters worse. To keep that manageable, particularly if there are related devices that share components, it makes sense to put the common elements in `.dtsi` files, to be included from possibly multiple `.dts` files. +A modern System on a Chip (SoC) is a very complicated device; a complete Device Tree could be hundreds of lines long. Taking that one step further and placing the SoC on a board with other components only makes matters more complicated. To keep that manageable, particularly if there are related devices which share components, it makes sense to put the common elements in `.dtsi` files, to be included from possibly multiple `.dts` files. When a system like Raspberry Pi also supports optional plug-in accessories such as HATs, the problem grows. Ultimately, each possible configuration requires a Device Tree to describe it, but once you factor in all the different base models and the large number of available accessories, the number of combinations starts to multiply rapidly. What is needed is a way to describe these optional components using a partial Device Tree, and then to be able to build a complete tree by taking a base DT and adding a number of optional elements. You can do this, and these optional elements are called "overlays". -Unless you want to learn how to write overlays for Raspberry Pis, you might prefer to skip on to <>. +Unless you want to learn how to write overlays for Raspberry Pis, you might prefer to skip on to <>. [[part2.1]] ==== Fragments A DT overlay comprises a number of fragments, each of which targets one node and its subnodes. Although the concept sounds simple enough, the syntax seems rather strange at first: +[source,kotlin] ---- // Enable the i2s interface /dts-v1/; @@ -181,10 +183,11 @@ A DT overlay comprises a number of fragments, each of which targets one node and }; ---- -The `compatible` string identifies this as being for BCM2835, which is the base architecture for the Raspberry Pi SoCs; if the overlay makes use of features of a Pi 4 then `brcm,bcm2711` is the correct value to use, otherwise `brcm,bcm2835` can be used for all Pi overlays. Then comes the first (and in this case only) fragment. Fragments should be numbered sequentially from zero. Failure to adhere to this may cause some or all of your fragments to be missed. +The `compatible` string identifies this as being for BCM2835, which is the base architecture for the Raspberry Pi SoCs; if the overlay makes use of features of a Raspberry Pi 4 then `brcm,bcm2711` is the correct value to use, otherwise `brcm,bcm2835` can be used for all Raspberry Pi overlays. Then comes the first (and in this case only) fragment. Fragments should be numbered sequentially from zero. Failure to adhere to this may cause some or all of your fragments to be missed. -Each fragment consists of two parts: a `target` property, identifying the node to apply the overlay to; and the `__overlay__` itself, the body of which is added to the target node. The example above can be interpreted as if it were written like this: +Each fragment consists of two parts: a `target` property, identifying the node to apply the overlay to; and the `+__overlay__+` itself, the body of which is added to the target node. The example above can be interpreted as if it were written like this: +[source,kotlin] ---- /dts-v1/; /plugin/; @@ -202,15 +205,16 @@ Each fragment consists of two parts: a `target` property, identifying the node t }; ---- -(In fact, with a sufficiently new version of `dtc` you can write it exactly like that and get identical output, but some homegrown tools don't understand this format yet so any overlay that you might want to be included in the standard Raspberry Pi OS kernel should be written in the old format for now). +With a sufficiently new version of `dtc` you can write the example exactly as above and get identical output, but some homegrown tools don't understand this format yet. Any overlay that you might want to see included in the standard Raspberry Pi OS kernel should be written in the old format for now. The effect of merging that overlay with a standard Raspberry Pi base Device Tree (e.g. `bcm2708-rpi-b-plus.dtb`), provided the overlay is loaded afterwards, would be to enable the I2S interface by changing its status to `okay`. But if you try to compile this overlay using: +[source,console] ---- -dtc -I dts -O dtb -o 2nd.dtbo 2nd-overlay.dts +$ dtc -I dts -O dtb -o 2nd.dtbo 2nd-overlay.dts ---- -you will get an error: +...you will get an error: ---- Label or path i2s not found @@ -220,21 +224,29 @@ This shouldn't be too unexpected, since there is no reference to the base `.dtb` Trying again, this time using the original example and adding the `-@` option to allow unresolved references (and `-Hepapr` to remove some clutter): +[source,console] ---- -dtc -@ -Hepapr -I dts -O dtb -o 1st.dtbo 1st-overlay.dts +$ dtc -@ -Hepapr -I dts -O dtb -o 1st.dtbo 1st-overlay.dts ---- If `dtc` returns an error about the third line, it doesn't have the extensions required for overlay work. Run `sudo apt install device-tree-compiler` and try again - this time, compilation should complete successfully. Note that a suitable compiler is also available in the kernel tree as `scripts/dtc/dtc`, built when the `dtbs` make target is used: +[source,console] ---- -make ARCH=arm dtbs +$ make ARCH=arm dtbs ---- -It is interesting to dump the contents of the DTB file to see what the compiler has generated: +Dump the contents of the DTB file to see what the compiler has generated: -[,console] +[source,console] ---- $ fdtdump 1st.dtbo +---- + +This should output something similar to the following: + +[source,kotlin] +---- /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x207 (519) @@ -280,24 +292,25 @@ After the verbose description of the file structure there is our fragment. But l After the fragment there are three new nodes: -* `__symbols__` lists the labels used in the overlay (`test_label` here), and the path to the labelled node. This node is the key to how unresolved symbols are dealt with. -* `__fixups__` contains a list of properties mapping the names of unresolved symbols to lists of paths to cells within the fragments that need patching with the phandle of the target node, once that target has been located. In this case, the path is to the `0xffffffff` value of `target`, but fragments can contain other unresolved references which would require additional fixes. -* `__local_fixups__` holds the locations of any references to labels that exist within the overlay - the `test_ref` property. This is required because the program performing the merge will have to ensure that phandle numbers are sequential and unique. +* `+__symbols__+` lists the labels used in the overlay (`test_label` here), and the path to the labelled node. This node is the key to how unresolved symbols are dealt with. +* `+__fixups__+` contains a list of properties mapping the names of unresolved symbols to lists of paths to cells within the fragments that need patching with the phandle of the target node, once that target has been located. In this case, the path is to the `0xffffffff` value of `target`, but fragments can contain other unresolved references which would require additional fixes. +* `+__local_fixups__+` holds the locations of any references to labels that exist within the overlay - the `test_ref` property. This is required because the program performing the merge will have to ensure that phandle numbers are sequential and unique. -Back in <> it says that "the original labels do not appear in the compiled output", but this isn't true when using the `-@` switch. Instead, every label results in a property in the `__symbols__` node, mapping a label to a path, exactly like the `aliases` node. In fact, the mechanism is so similar that when resolving symbols, the Raspberry Pi loader will search the "aliases" node in the absence of a `__symbols__` node. This was useful at one time because providing sufficient aliases allowed very old versions of `dtc` to be used to build the base DTB files, but fortunately that is ancient history now. +Back in <> it says that "the original labels do not appear in the compiled output", but this isn't true when using the `-@` switch. Instead, every label results in a property in the `+__symbols__+` node, mapping a label to a path, exactly like the `aliases` node. In fact, the mechanism is so similar that when resolving symbols, the Raspberry Pi loader will search the "aliases" node in the absence of a `+__symbols__+` node. This was useful at one time because providing sufficient aliases allowed very old versions of `dtc` to be used to build the base DTB files, but fortunately that is ancient history now. [[part2.2]] ==== Device Tree parameters To avoid the need for lots of Device Tree overlays, and to reduce the need for users of peripherals to modify DTS files, the Raspberry Pi loader supports a new feature - Device Tree parameters. This permits small changes to the DT using named parameters, similar to the way kernel modules receive parameters from `modprobe` and the kernel command line. Parameters can be exposed by the base DTBs and by overlays, including HAT overlays. -Parameters are defined in the DTS by adding an `__overrides__` node to the root. It contains properties whose names are the chosen parameter names, and whose values are a sequence comprising a phandle (reference to a label) for the target node, and a string indicating the target property; string, integer (cell) and boolean properties are supported. +Parameters are defined in the DTS by adding an `+__overrides__+` node to the root. It contains properties whose names are the chosen parameter names, and whose values are a sequence comprising a phandle (reference to a label) for the target node, and a string indicating the target property; string, integer (cell) and boolean properties are supported. [[part2.2.1]] ===== String parameters String parameters are declared like this: +[source,kotlin] ---- name = <&label>,"property"; ---- @@ -311,6 +324,7 @@ Note that properties called `status` are treated specially; non-zero/true/yes/on Integer parameters are declared like this: +[source,kotlin] ---- name = <&label>,"property.offset"; // 8-bit name = <&label>,"property;offset"; // 16-bit @@ -318,29 +332,30 @@ name = <&label>,"property:offset"; // 32-bit name = <&label>,"property#offset"; // 64-bit ---- -where `label`, `property` and `offset` are replaced by suitable values; the offset is specified in bytes relative to the start of the property (in decimal by default), and the preceding separator dictates the size of the parameter. In a change from earlier implementations, integer parameters may refer to non-existent properties or to offsets beyond the end of an existing property. +Here, `label`, `property` and `offset` are replaced by suitable values; the offset is specified in bytes relative to the start of the property (in decimal by default), and the preceding separator dictates the size of the parameter. In a change from earlier implementations, integer parameters may refer to non-existent properties or to offsets beyond the end of an existing property. [[part2.2.3]] ===== Boolean parameters Device Tree encodes boolean values as zero-length properties; if present then the property is true, otherwise it is false. They are defined like this: +[source,kotlin] ---- boolean_property; // Set 'boolean_property' to true ---- -Note that a property is assigned the value `false` by not defining it. Boolean parameters are declared like this: +A property is assigned the value `false` by not defining it. Boolean parameters are declared like this, replacing the `label` and `property` placeholders with suitable values: +[source,kotlin] ---- name = <&label>,"property?"; ---- -where `label` and `property` are replaced by suitable values. - -Inverted booleans invert the input value before applying it in the same was as a regular boolean; they are declared similarly, but use `!` to indicate the inversion: +Inverted booleans invert the input value before applying it in the same way as a regular boolean; they are declared similarly, but use `!` to indicate the inversion: +[source,kotlin] ---- -name = <&label>,"property!"; +name = <&label>,"!"; ---- Boolean parameters can cause properties to be created or deleted, but they can't delete a property that already exists in the base DTB. @@ -350,6 +365,7 @@ Boolean parameters can cause properties to be created or deleted, but they can't Byte string properties are arbitrary sequences of bytes, e.g. MAC addresses. They accept strings of hexadecimal bytes, with or without colons between the bytes. +[source,kotlin] ---- mac_address = <ðernet0>,"local_mac_address["; ---- @@ -365,41 +381,44 @@ local_mac_address = [aa bb cc dd ee ff]; There are some situations where it is convenient to be able to set the same value in multiple locations within the Device Tree. Rather than the ungainly approach of creating multiple parameters, it is possible to add multiple targets to a single parameter by concatenating them, like this: +[source,kotlin] ---- - __overrides__ { - gpiopin = <&w1>,"gpios:4", - <&w1_pins>,"brcm,pins:0"; - ... - }; +__overrides__ { + gpiopin = <&w1>,"gpios:4", + <&w1_pins>,"brcm,pins:0"; + ... +}; ---- (example taken from the `w1-gpio` overlay) -Note that it is even possible to target properties of different types with a single parameter. You could reasonably connect an "enable" parameter to a `status` string, cells containing zero or one, and a proper boolean property. +NOTE: It is even possible to target properties of different types with a single parameter. You could reasonably connect an "enable" parameter to a `status` string, cells containing zero or one, and a proper boolean property. [[part2.2.6]] ===== Literal assignments -As seen in <>, the DT parameter mechanism allows multiple targets to be patched from the same parameter, but the utility is limited by the fact that the same value has to be written to all locations (except for format conversion and the negation available from inverted booleans). The addition of embedded literal assignments allows a parameter to write arbitrary values, regardless of the parameter value supplied by the user. +The DT parameter mechanism allows multiple targets to be patched from the same parameter, but the utility is limited by the fact that the same value has to be written to all locations (except for format conversion and the negation available from inverted booleans). The addition of embedded literal assignments allows a parameter to write arbitrary values, regardless of the parameter value supplied by the user. Assignments appear at the end of a declaration, and are indicated by a `=`: +[source,kotlin] ---- str_val = <&target>,"strprop=value"; // 1 -int_val = <&target>,"intprop:0=42 // 2 +int_val = <&target>,"intprop:0=42" // 2 int_val2 = <&target>,"intprop:0=",<42>; // 3 bytes = <&target>,"bytestr[=b8:27:eb:01:23:45"; // 4 ---- Lines 1, 2 and 4 are fairly obvious, but line 3 is more interesting because the value appears as an integer (cell) value. The DT compiler evaluates integer expressions at compile time, which might be convenient (particularly if macro values are used), but the cell can also contain a reference to a label: +[source,kotlin] ---- // Force an LED to use a GPIO on the internal GPIO controller. exp_led = <&led1>,"gpios:0=",<&gpio>, <&led1>,"gpios:4"; ---- -When the overlay is applied, the label will be resolved against the base DTB in the usual way. Note that it is a good idea to split multi-part parameters over multiple lines like this to make them easier to read - something that becomes more necessary with the addition of cell value assignments like this. +When the overlay is applied, the label will be resolved against the base DTB in the usual way. It is a good idea to split multi-part parameters over multiple lines like this to make them easier to read - something that becomes more necessary with the addition of cell value assignments. Bear in mind that parameters do nothing unless they are applied - a default value in a lookup table is ignored unless the parameter name is used without assigning a value. @@ -408,6 +427,7 @@ Bear in mind that parameters do nothing unless they are applied - a default valu Lookup tables allow parameter input values to be transformed before they are used. They act as associative arrays, rather like switch/case statements: +[source,kotlin] ---- phonetic = <&node>,"letter{a=alpha,b=bravo,c=charlie,d,e,='tango uniform'}"; bus = <&fragment>,"target:0{0=",<&i2c0>,"1=",<&i2c1>,"}"; @@ -415,17 +435,18 @@ bus = <&fragment>,"target:0{0=",<&i2c0>,"1=",<&i2c1>,"}"; A key with no `=value` means to use the key as the value, an `=` with no key before it is the default value in the case of no match, and starting or ending the list with a comma (or an empty key=value pair anywhere) indicates that the unmatched input value should be used unaltered; otherwise, not finding a match is an error. -Note that the comma separator within the table string after a cell integer value is implicit - adding one explicitly creates an empty pair (see above). +NOTE: The comma separator within the table string after a cell integer value is implicit - adding one explicitly creates an empty pair (see above). -N.B. As lookup tables operate on input values and literal assigments ignore them, it's not possible to combine the two - characters after the closing `}` in the lookup declaration are treated as an error. +NOTE: As lookup tables operate on input values and literal assignments ignore them, it's not possible to combine the two - characters after the closing `}` in the lookup declaration are treated as an error. [[part2.2.8]] ===== Overlay/fragment parameters -The DT parameter mechanism as described has a number of limitations, including the inability to change the name of a node and to write arbitrary values to arbitrary properties when a parameter is used. One way to overcome some of these limitations is to conditionally include or exclude certain fragments. +The DT parameter mechanism as described has a number of limitations, including the lack of an easy way to create arrays of integers, and the inability to create new nodes. One way to overcome some of these limitations is to conditionally include or exclude certain fragments. -A fragment can be excluded from the final merge process (disabled) by renaming the `__overlay__` node to `__dormant__`. The parameter declaration syntax has been extended to allow the otherwise illegal zero target phandle to indicate that the following string contains operations at fragment or overlay scope. So far, four operations have been implemented: +A fragment can be excluded from the final merge process (disabled) by renaming the `+__overlay__+` node to `+__dormant__+`. The parameter declaration syntax has been extended to allow the otherwise illegal zero target phandle to indicate that the following string contains operations at fragment or overlay scope. So far, four operations have been implemented: +[source,kotlin] ---- + // Enable fragment - // Disable fragment @@ -435,6 +456,7 @@ A fragment can be excluded from the final merge process (disabled) by renaming t Examples: +[source,kotlin] ---- just_one = <0>,"+1-2"; // Enable 1, disable 2 conditional = <0>,"=3!4"; // Enable 3, disable 4 if value is true, @@ -446,17 +468,18 @@ The `i2c-rtc` overlay uses this technique. [[part2.2.9]] ===== Special properties -A few property names, when targeted by a parameter, get special handling. One you may have noticed already - `status` - which will convert a boolean to either `okay` for true and `disabled` for false. +A few property names, when targeted by a parameter, get special handling. One you may have noticed already - `status` - will convert a boolean to either `okay` for true and `disabled` for false. Assigning to the `bootargs` property appends to it rather than overwriting it - this is how settings can be added to the kernel command line. The `reg` property is used to specify device addresses - the location of a memory-mapped hardware block, the address on an I2C bus, etc. The names of child nodes should be qualified with their addresses in hexadecimal, using `@` as a separator: +[source,kotlin] ---- - bmp280@76 { - reg = <0x77>; - ... - }; +bmp280@76 { + reg = <0x77>; + ... +}; ---- When assigning to the `reg` property, the address portion of the parent node name will be replaced with the assigned value. This can be used to prevent a node name clash when using the same overlay multiple times - a technique used by the `i2c-gpio` overlay. @@ -466,23 +489,25 @@ The `name` property is a pseudo-property - it shouldn't appear in a DT, but assi [[part2.2.10]] ===== The overlay map file -The introduction of the Pi 4, built around the BCM2711 SoC, brought with it many changes; some of these changes are additional interfaces, and some are modifications to (or removals of) existing interfaces. There are new overlays intended specifically for the Pi 4 that don't make sense on older hardware, e.g. overlays that enable the new SPI, I2C and UART interfaces, but other overlays don't apply correctly even though they control features that are still relevant on the new device. +The introduction of the Raspberry Pi 4, built around the BCM2711 SoC, brought with it many changes; some of these changes are additional interfaces, and some are modifications to (or removals of) existing interfaces. There are new overlays intended specifically for the Raspberry Pi 4 that don't make sense on older hardware, e.g. overlays that enable the new SPI, I2C and UART interfaces, but other overlays don't apply correctly even though they control features that are still relevant on the new device. There is therefore a need for a method of tailoring an overlay to multiple platforms with differing hardware. Supporting them all in a single .dtbo file would require heavy use of hidden ("dormant") fragments and a switch to an on-demand symbol resolution mechanism so that a missing symbol that isn't needed doesn't cause a failure. A simpler solution is to add a facility to map an overlay name to one of several implementation files depending on the current platform. -The overlay map, which is rolling out with the switch to Linux 5.4, is a file that gets loaded by the firmware at bootup. It is written in DTS source format - `overlay_map.dts`, compiled to `overlay_map.dtb` and stored in the overlays directory. +The overlay map is a file that gets loaded by the firmware at bootup. It is written in DTS source format - `overlay_map.dts`, compiled to `overlay_map.dtb` and stored in the overlays directory. -This is an edited version of the current map file (see the https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/overlay_map.dts[full version]): +This is an extract from the current map file (see the https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/overlay_map.dts[full version]): +[source,kotlin] ---- / { - vc4-kms-v3d { + disable-bt { bcm2835; - bcm2711 = "vc4-kms-v3d-pi4"; + bcm2711; + bcm2712 = "disable-bt-pi5"; }; - vc4-kms-v3d-pi4 { - bcm2711; + disable-bt-pi5 { + bcm2712; }; uart5 { @@ -499,20 +524,28 @@ This is an edited version of the current map file (see the https://github.com/ra }; ---- -Each node has the name of an overlay that requires special handling. The properties of each node are either platform names or one of a small number of special directives. The current supported platforms are `bcm2835`, which includes all Pis built around the BCM2835, BCM2836 and BCM2837 SoCs, and `bcm2711` for Pi 4B. +Each node has the name of an overlay that requires special handling. The properties of each node are either platform names or one of a small number of special directives. The overlay map supports the following platform names: + +* `bcm2835` for all Raspberry Pis built around the BCM2835, BCM2836, BCM2837, and RP3A0 SoCs +* `bcm2711` for Raspberry Pi 4B, CM4, CM4S, and Pi 400 +* `bcm2712` for Raspberry Pi 5, CM5, and Pi 500 -A platform name with no value (an empty property) indicates that the current overlay is compatible with the platform; for example, `vc4-kms-v3d` is compatible with the `bcm2835` platform. A non-empty value for a platform is the name of an alternative overlay to use in place of the requested one; asking for `vc4-kms-v3d` on BCM2711 results in `vc4-kms-v3d-pi4` being loaded instead. Any platform not included in an overlay's node is not compatible with that overlay. +A platform name with no value (an empty property) indicates that the current overlay is compatible with the platform; for example, `uart5` is compatible with the `bcm2711` platform. A non-empty value for a platform is the name of an alternative overlay to use in place of the requested one; asking for `disable-bt` on BCM2712 results in `disable-bt-pi5` being loaded instead. Any platform not included in an overlay's node is not compatible with that overlay. Any overlay not mentioned in the map is assumed to be compatible with all platforms. -The second example node - `vc4-kms-v3d-pi4` - could be inferred from the content of `vc4-kms-v3d`, but that intelligence goes into the construction of the file, not its interpretation. +The second example node - `disable-bt-pi5` - could be inferred from the content of `disable-bt`, but that intelligence goes into the construction of the file, not its interpretation. + +The `uart5` overlay only makes sense on BCM2711. In the event that a platform is not listed for an overlay, one of the special directives may apply: * The `renamed` directive indicates the new name of the overlay (which should be largely compatible with the original), but also logs a warning about the rename. * The `deprecated` directive contains a brief explanatory error message which will be logged after the common prefix `+overlay '...' is deprecated:+`. +Chaining renames and platform-specific implementations is possible, but be careful to avoid loops! + Remember: only exceptions need to be listed - the absence of a node for an overlay means that the default file should be used for all platforms. -Accessing diagnostic messages from the firmware is covered in <>. +Accessing diagnostic messages from the firmware is covered in <>. The `dtoverlay` and `dtmerge` utilities have been extended to support the map file: @@ -526,6 +559,7 @@ They both send errors, warnings and any debug output to STDERR. Here are some examples of different types of properties, with parameters to modify them: +[source,kotlin] ---- / { fragment@0 { @@ -587,15 +621,16 @@ Here are some examples of different types of properties, with parameters to modi }; ---- -For further examples, there is a large collection of overlay source files https://github.com/raspberrypi/linux/tree/rpi-5.4.y/arch/arm/boot/dts/overlays[hosted in the Raspberry Pi Linux GitHub repository]. +For further examples, a large collection of overlay source files is hosted in the https://github.com/raspberrypi/linux/tree/rpi-6.1.y/arch/arm/boot/dts/overlays[Raspberry Pi Linux GitHub repository]. [[part2.3]] -==== Exporting labels +==== Export labels -The overlay handling in the firmware and the run-time overlay application using the `dtoverlay` utility treat labels defined in an overlay as being private to that overlay. This avoids the need to invent globally unique names for labels (which keeps them short), and it allows the same overlay to be used multiple times without clashing (provided some tricks are used - see <>). +The overlay handling in the firmware, and the run-time overlay application using the `dtoverlay` utility, treat labels defined in an overlay as being private to that overlay. This avoids the need to invent globally unique names for labels (which keeps them short), and it allows the same overlay to be used multiple times without clashing (provided some tricks are used - see <>). -Sometimes, however, it is very useful to be able to create a label with one overlay and use it from another. Firmware released since 14th February 2020 has the ability to declare some labels as being global - the `__export__` node: +Sometimes it is very useful to be able to create a label with one overlay and use it from another. Firmware released since 14th February 2020 has the ability to declare some labels as being global - the `+__exports__+` node: +[source,kotlin] ---- ... public: ... @@ -611,42 +646,41 @@ When this overlay is applied, the loader strips out all symbols except those tha [[part2.4]] ==== Overlay application order -Under most circumstances it shouldn't matter which order the fragments are applied, but for overlays that patch themselves (where the target of a fragment is a label in the overlay, known as an intra-overlay fragment) it becomes important. In older firmware, fragments are applied strictly in order, top to bottom. With firmware released since 14th February 2020, fragments are applied in two passes: +Under most circumstances it shouldn't matter in which order the fragments are applied, but for overlays that patch themselves (where the target of a fragment is a label in the overlay, known as an intra-overlay fragment) it becomes important. In older firmware, fragments are applied strictly in order, top to bottom. With firmware released since 14th February 2020, fragments are applied in two passes: -. First the fragments that target other fragments are applied and hidden. -. Then the regular fragments are applied. +* First the fragments that target other fragments are applied and hidden. +* Then the regular fragments are applied. -This split is particularly important for runtime overlays, since step (i) occurs in the `dtoverlay` utility, and step (ii) is performed by the kernel (which can't handle intra-overlay fragments). +This split is particularly important for runtime overlays, since the first step occurs in the `dtoverlay` utility, and the second is performed by the kernel (which can't handle intra-overlay fragments). [[part3]] === Using Device Trees on Raspberry Pi [[part3.1]] -==== DTBs, overlays and config.txt - -On a Raspberry Pi it is the job of the loader (one of the `start.elf` images) to combine overlays with an appropriate base device tree, and then to pass a fully resolved Device Tree to the kernel. The base Device Trees are located alongside `start.elf` in the FAT partition (/boot from Linux), named `bcm2711-rpi-4-b.dtb`, `bcm2710-rpi-3-b-plus.dtb`, etc. Note that some models (3A+, A, A+) will use the "b" equivalents (3B+, B, B+), respectively. This selection is automatic, and allows the same SD card image to be used in a variety of devices. +==== DTBs, overlays and `config.txt` -Note that DT and ATAGs are mutually exclusive, and passing a DT blob to a kernel that doesn't understand it will cause a boot failure. The firmware will always try to load the DT and pass it to the kernel, since all kernels since rpi-4.4.y will not function without a DTB. You can override this by adding `device_tree=` in config.txt, which forces the use of ATAGs, which can be useful for simple "bare-metal" kernels. +On a Raspberry Pi it is the job of the loader (one of the `start.elf` images) to combine overlays with an appropriate base device tree, and then to pass a fully resolved Device Tree to the kernel. The base Device Trees are located alongside `start.elf` in the FAT partition (`/boot/firmware/` from Linux), named `bcm2711-rpi-4-b.dtb`, `bcm2710-rpi-3-b-plus.dtb`, etc. Note that some models (3A+, A, A+) will use the "b" equivalents (3B+, B, B+), respectively. This selection is automatic, and allows the same SD card image to be used in a variety of devices. -[ The firmware used to look for a trailer appended to kernels by the `mkknlimg` utility, but support for this has been withdrawn. ] +NOTE: DT and ATAGs are mutually exclusive, and passing a DT blob to a kernel that doesn't understand it will cause a boot failure. The firmware will always try to load the DT and pass it to the kernel, since all kernels since rpi-4.4.y will not function without a DTB. You can override this by adding `device_tree=` in config.txt, which forces the use of ATAGs, which can be useful for simple bare-metal kernels. The loader now supports builds using bcm2835_defconfig, which selects the upstreamed BCM2835 support. This configuration will cause `bcm2835-rpi-b.dtb` and `bcm2835-rpi-b-plus.dtb` to be built. If these files are copied with the kernel, then the loader will attempt to load one of those DTBs by default. In order to manage Device Tree and overlays, the loader supports a number of `config.txt` directives: +[source,ini] ---- dtoverlay=acme-board dtparam=foo=bar,level=42 ---- -This will cause the loader to look for `overlays/acme-board.dtbo` in the firmware partition, which Raspberry Pi OS mounts on `/boot`. It will then search for parameters `foo` and `level`, and assign the indicated values to them. +This will cause the loader to look for `overlays/acme-board.dtbo` in the firmware partition, which Raspberry Pi OS mounts on `/boot/firmware/`. It will then search for parameters `foo` and `level`, and assign the indicated values to them. The loader will also search for an attached HAT with a programmed EEPROM, and load the supporting overlay from there - either directly or by name from the "overlays" directory; this happens without any user intervention. -There are several ways to tell that the kernel is using Device Tree: +There are multiple ways to tell that the kernel is using Device Tree: -. The "Machine model:" kernel message during bootup has a board-specific value such as "Raspberry Pi 2 Model B", rather than "BCM2709". -. `/proc/device-tree` exists, and contains subdirectories and files that exactly mirror the nodes and properties of the DT. +* The "Machine model:" kernel message during bootup has a board-specific value such as "Raspberry Pi 2 Model B", rather than "BCM2709". +* `/proc/device-tree` exists, and contains subdirectories and files that exactly mirror the nodes and properties of the DT. With a Device Tree, the kernel will automatically search for and load modules that support the indicated enabled devices. As a result, by creating an appropriate DT overlay for a device you save users of the device from having to edit `/etc/modules`; all of the configuration goes in `config.txt`, and in the case of a HAT, even that step is unnecessary. Note, however, that layered modules such as `i2c-dev` still need to be loaded explicitly. @@ -657,14 +691,16 @@ The flipside is that because platform devices don't get created unless requested As described above, DT parameters are a convenient way to make small changes to a device's configuration. The current base DTBs support parameters for enabling and controlling the onboard audio, I2C, I2S and SPI interfaces without using dedicated overlays. In use, parameters look like this: +[source,ini] ---- dtparam=audio=on,i2c_arm=on,i2c_arm_baudrate=400000,spi=on ---- -Note that multiple assignments can be placed on the same line, but ensure you don't exceed the 80-character limit. +NOTE: Multiple assignments can be placed on the same line, but ensure you don't exceed the 80-character limit. If you have an overlay that defines some parameters, they can be specified either on subsequent lines like this: +[source,ini] ---- dtoverlay=lirc-rpi dtparam=gpio_out_pin=16 @@ -672,14 +708,16 @@ dtparam=gpio_in_pin=17 dtparam=gpio_in_pull=down ---- -or appended to the overlay line like this: +...or appended to the overlay line like this: +[source,ini] ---- dtoverlay=lirc-rpi,gpio_out_pin=16,gpio_in_pin=17,gpio_in_pull=down ---- -Overlay parameters are only in scope until the next overlay is loaded. In the event of a parameter with the same name being exported by both the overlay and the base, the parameter in the overlay takes precedence; for clarity, it's recommended that you avoid doing this. To expose the parameter exported by the base DTB instead, end the current overlay scope using: +Overlay parameters are only in scope until the next overlay is loaded. In the event of a parameter with the same name being exported by both the overlay and the base, the parameter in the overlay takes precedence; it's recommended that you avoid doing this. To expose the parameter exported by the base DTB instead, end the current overlay scope using: +[source,ini] ---- dtoverlay= ---- @@ -687,9 +725,9 @@ dtoverlay= [[part3.3]] ==== Board-specific labels and parameters -Raspberry Pi boards have two I2C interfaces. These are nominally split: one for the ARM, and one for VideoCore (the "GPU"). On almost all models, `i2c1` belongs to the ARM and `i2c0` to VC, where it is used to control the camera and read the HAT EEPROM. However, there are two early revisions of the Model B that have those roles reversed. +Raspberry Pi boards have two I2C interfaces. These are nominally split: one for the ARM, and one for VideoCore (the GPU). On almost all models, `i2c1` belongs to the ARM and `i2c0` to VC, where it is used to control the camera and read the HAT EEPROM. However, there are two early revisions of the Model B that have those roles reversed. -To make it possible to use one set of overlays and parameters with all Pis, the firmware creates some board-specific DT parameters. These are: +To make it possible to use one set of overlays and parameters with all Raspberry Pis, the firmware creates some board-specific DT parameters. These are: ---- i2c/i2c_arm @@ -698,10 +736,11 @@ i2c_baudrate/i2c_arm_baudrate i2c_vc_baudrate ---- -These are aliases for `i2c0`, `i2c1`, `i2c0_baudrate`, and `i2c1_baudrate`. It is recommended that you only use `i2c_vc` and `i2c_vc_baudrate` if you really need to - for example, if you are programming a HAT EEPROM (which is better done using a software I2C bus using the `i2c-gpio` overlay). Enabling `i2c_vc` can stop the Pi Camera or 7" DSI display functioning correctly. +These are aliases for `i2c0`, `i2c1`, `i2c0_baudrate`, and `i2c1_baudrate`. It is recommended that you only use `i2c_vc` and `i2c_vc_baudrate` if you really need to - for example, if you are programming a HAT EEPROM (which is better done using a software I2C bus using the `i2c-gpio` overlay). Enabling `i2c_vc` can stop the Raspberry Pi Camera or Raspberry Pi Touch Display functioning correctly. For people writing overlays, the same aliasing has been applied to the labels on the I2C DT nodes. Thus, you should write: +[source,kotlin] ---- fragment@0 { target = <&i2c_arm>; @@ -723,7 +762,7 @@ The HAT overlay is automatically loaded by the firmware after the base DTB, so i [[part3.5]] ==== Dynamic Device Tree -As of Linux 4.4, the RPi kernels support the dynamic loading of overlays and parameters. Compatible kernels manage a stack of overlays that are applied on top of the base DTB. Changes are immediately reflected in `/proc/device-tree` and can cause modules to be loaded and platform devices to be created and destroyed. +As of Linux 4.4, Raspberry Pi kernels support the dynamic loading of overlays and parameters. Compatible kernels manage a stack of overlays that are applied on top of the base DTB. Changes are immediately reflected in `/proc/device-tree` and can cause modules to be loaded and platform devices to be created and destroyed. The use of the word "stack" above is important - overlays can only be added and removed at the top of the stack; changing something further down the stack requires that anything on top of it must first be removed. @@ -732,10 +771,11 @@ There are some new commands for managing overlays: [[part3.5.1]] ===== The `dtoverlay` command -`dtoverlay` is a command line utility that loads and removes overlays while the system is running, as well as listing the available overlays and displaying their help information: +`dtoverlay` is a command line utility that loads and removes overlays while the system is running, as well as listing the available overlays and displaying their help information. + +Use `dtoverlay -h` to get usage information: ---- -pi@raspberrypi ~ $ dtoverlay -h Usage: dtoverlay [=...] Add an overlay (with parameters) @@ -751,39 +791,32 @@ Usage: where is the name of an overlay or 'dtparam' for dtparams Options applicable to most variants: -d Specify an alternate location for the overlays - (defaults to /boot/overlays or /flash/overlays) + (defaults to /boot/firmware/overlays or /flash/overlays) -v Verbose operation ---- Unlike the `config.txt` equivalent, all parameters to an overlay must be included in the same command line - the <> command is only for parameters of the base DTB. -Two points to note: - -. Command variants that change kernel state (adding and removing things) require root privilege, so you may need to prefix the command with `sudo`. -. Only overlays and parameters applied at run-time can be unloaded - an overlay or parameter applied by the firmware becomes "baked in" such that it won't be listed by `dtoverlay` and can't be removed. +Command variants that change kernel state (adding and removing things) require root privilege, so you may need to prefix the command with `sudo`. Only overlays and parameters applied at run-time can be unloaded - an overlay or parameter applied by the firmware becomes "baked in" such that it won't be listed by `dtoverlay` and can't be removed. [[part3.5.2]] ===== The `dtparam` command -`dtparam` creates and loads an overlay that has largely the same effect as using a dtparam directive in `config.txt`. In usage it is largely equivalent to `dtoverlay` with an overlay name of `-`, but there are a few differences: - -. `dtparam` will list the help information for all known parameters of the base DTB. Help on the dtparam command is still available using `dtparam -h`. -. When indicating a parameter for removal, only index numbers can be used (not names). -. Not all Linux subsystems respond to the addition of devices at runtime - I2C, SPI and sound devices work, but some won't. +`dtparam` creates and loads an overlay that has largely the same effect as using a dtparam directive in `config.txt`. In usage it is largely equivalent to `dtoverlay` with an overlay name of `-`, but there are a few differences: `dtparam` will list the help information for all known parameters of the base DTB. Help on the dtparam command is still available using `dtparam -h`. When indicating a parameter for removal, only index numbers can be used (not names). Not all Linux subsystems respond to the addition of devices at runtime - I2C, SPI and sound devices work, but some won't. [[part3.5.3]] ===== Guidelines for writing runtime-capable overlays -This area is poorly documented, but here are some accumulated tips: +The creation or deletion of a device object is triggered by a node being added or removed, or by the status of a node changing from disabled to enabled or vice versa. The absence of a "status" property means the node is enabled. -* The creation or deletion of a device object is triggered by a node being added or removed, or by the status of a node changing from disabled to enabled or vice versa. Beware - the absence of a "status" property means the node is enabled. -* Don't create a node within a fragment that will overwrite an existing node in the base DTB - the kernel will rename the new node to make it unique. If you want to change the properties of an existing node, create a fragment that targets it. -* ALSA doesn't prevent its codecs and other components from being unloaded while they are in use. Removing an overlay can cause a kernel exception if it deletes a codec that is still being used by a sound card. Experimentation found that devices are deleted in the reverse of fragment order in the overlay, so placing the node for the card after the nodes for the components allows an orderly shutdown. +Don't create a node within a fragment that will overwrite an existing node in the base DTB - the kernel will rename the new node to make it unique. If you want to change the properties of an existing node, create a fragment that targets it. + +ALSA doesn't prevent its codecs and other components from being unloaded while they are in use. Removing an overlay can cause a kernel exception if it deletes a codec that is still being used by a sound card. Experimentation found that devices are deleted in the reverse of fragment order in the overlay, so placing the node for the card after the nodes for the components allows an orderly shutdown. [[part3.5.4]] ===== Caveats -The loading of overlays at runtime is a recent addition to the kernel, and so far there is no accepted way to do this from userspace. By hiding the details of this mechanism behind commands the aim is to insulate users from changes in the event that a different kernel interface becomes standardised. +The loading of overlays at runtime is a recent addition to the kernel, and at the time of writing there is no accepted way to do this from userspace. By hiding the details of this mechanism behind commands, users are insulated from changes in the event that a different kernel interface becomes standardised. * Some overlays work better at run-time than others. Parts of the Device Tree are only used at boot time - changing them using an overlay will not have any effect. * Applying or removing some overlays may cause unexpected behaviour, so it should be done with caution. This is one of the reasons it requires `sudo`. @@ -795,26 +828,212 @@ The loading of overlays at runtime is a recent addition to the kernel, and so fa [[part3.6]] ==== Supported overlays and parameters -As it is too time-consuming to document the individual overlays here, please refer to the https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README[README] file found alongside the overlay `.dtbo` files in `/boot/overlays`. It is kept up-to-date with additions and changes. +For a list of supported overlays and parameters, see the https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README[README] file found alongside the overlay `.dtbo` files in `/boot/firmware/overlays`. It is kept up-to-date with additions and changes. [[part4]] +=== Firmware parameters + +The firmware uses the special https://www.kernel.org/doc/html/latest/devicetree/usage-model.html#runtime-configuration[/chosen] node to pass parameters between the bootloader and/or firmware and the operating system. + +* Each property is stored as a 32-bit unsigned integer unless indicated otherwise. +* Numbers in device-tree are stored in binary and are big-endian. + +Example shell command for reading a 32-bit unsigned integer property: +[source,console] +---- +printf "%d" "0x$(od "/proc/device-tree/chosen/bootloader/partition" -v -An -t x1 | tr -d ' ' )" +---- + +`overlay_prefix`:: _(string)_ The xref:config_txt.adoc#overlay_prefix[overlay_prefix] string selected by `config.txt`. + +`os_prefix`:: _(string)_ The xref:config_txt.adoc#os_prefix[os_prefix] string selected by `config.txt`. + +`rpi-boardrev-ext`:: The extended board revision code from xref:raspberry-pi.adoc#otp-register-and-bit-definitions[OTP row 33]. + +`rpi-country-code`:: The country code used used by https://github.com/raspberrypi-ui/piwiz[PiWiz]. Keyboard models only. + +`rpi-duid`:: _(string)_ Raspberry Pi 5 only. A string representation of the QR code on the PCB. + +`rpi-serial64`:: _(string)_ A string representation of the 64-bit serial number. On flagship models since Raspberry Pi 5 this is same as the normal serial number (`/proc/device-tree/serial-number`). On earlier models the default serial number is still 32-bit but with newer firmware a 64-bit serial number is now available and is visible through this node. + +==== Common bootloader properties `/chosen/bootloader` + +`boot-mode`:: The boot-mode used to load the kernel. See the xref:raspberry-pi.adoc#BOOT_ORDER[BOOT_ORDER] documentation for a list of possible boot-mode values. + +`partition`:: The partition number used during boot. If a `boot.img` ramdisk is loaded then this refers to partition that the ramdisk was loaded from rather than the partition number within the ramdisk. + +`pm_rsts`:: The value of the `PM_RSTS` register during boot. + +`tryboot`:: Set to `1` if the `tryboot` flag was set at boot. + +==== Boot variables `/chosen/bootloader` + +Raspberry Pi 5 only. + +`arg1`:: The value of the user defined reboot argument from the previous boot. See xref:config_txt.adoc#boot_arg1[boot_arg1] + +`count`:: The value of the 8-bit `boot_count` variable when the OS was started. See xref:config_txt.adoc#boot_count[boot_count] + +==== Power supply properties `/chosen/power` + +Raspberry Pi 5 only. + +`max_current`:: The maximum current in mA that the power supply can supply. The firmware reports the value indicated by the USB-C, USB-PD or PoE interfaces. For bench power supplies (e.g. connected to the GPIO header) define `PSU_MAX_CURRENT` in the bootloader configuration to indicate the power supply current capability. + +`power_reset`:: Raspberry Pi 5 only. A bit field indicating the reason why the PMIC was reset. + +|=== +| Bit | Reason + +| 0 +| Over voltage + +| 1 +| Under voltage + +| 2 +| Over temperature + +| 3 +| Enable signal + +| 4 +| Watchdog +|=== + +`rpi_power_supply`:: _(two 32-bit integers)_ The USB VID and Product VDO of the official Raspberry Pi 27W power supply (if connected). + +`usb_max_current_enable`:: Zero if the USB port current limiter was set to the low-limit during boot; or non-zero if the high limit was enabled. The high level is automatically enabled if the power supply claims 5A max-current OR `usb_max_current_enable=1` is forced in `config.txt` + +`usb_over_current_detected`:: Non-zero if a USB over-current event occurred during USB boot. + +`usbpd_power_data_objects`:: _(binary blob containing multiple 32-bit integers)_ The raw binary USB-PD objects (fixed supply only) received by the bootloader during USB-PD negotiation. To capture this for a bug report, run `hexdump -C /proc/device-tree/chosen/power/usbpd_power_data_objects`. + +The format is defined by the https://usb.org/document-library/usb-power-delivery[USB Power Delivery] specification. + +==== BCM2711 and BCM2712 specific bootloader properties `/chosen/bootloader` + +The following properties are specific to the BCM2711 and BCM2712 SPI EEPROM bootloaders. + +`build_timestamp`:: The UTC build time for the EEPROM bootloader. + +`capabilities`:: This bit-field describes the features supported by the current bootloader. This may be used to check whether a feature (e.g. USB boot) is supported before enabling it in the bootloader EEPROM config. + +|=== +| Bit | Feature + +| 0 +| xref:raspberry-pi.adoc#usb-mass-storage-boot[USB boot] using the VLI USB host controller + +| 1 +| xref:remote-access.adoc#network-boot-your-raspberry-pi[Network boot] + +| 2 +| xref:raspberry-pi.adoc#fail-safe-os-updates-tryboot[TRYBOOT_A_B] mode + +| 3 +| xref:raspberry-pi.adoc#fail-safe-os-updates-tryboot[TRYBOOT] + +| 4 +| xref:raspberry-pi.adoc#usb-mass-storage-boot[USB boot] using the BCM2711 USB host controller + +| 5 +| xref:config_txt.adoc#boot_ramdisk[RAM disk - boot.img] + +| 6 +| xref:raspberry-pi.adoc#nvme-ssd-boot[NVMe boot] + +| 7 +| https://github.com/raspberrypi/usbboot/blob/master/Readme.md#secure-boot[Secure Boot] +|=== + +`update_timestamp`:: The UTC update timestamp set by `rpi-eeprom-update`. + +`signed`:: If Secure Boot is enabled, this bit-field will be non-zero. The individual bits indicate the current Secure Boot configuration. + +|=== +| Bit | Description + +| 0 +| `SIGNED_BOOT` was defined in the EEPROM config file. + +| 1 +| Reserved + +| 2 +| The ROM development key has been revoked. See xref:config_txt.adoc#revoke_devkey[revoke_devkey]. + +| 3 +| The customer public key digest has been written to OTP. See xref:config_txt.adoc#program_pubkey[program_pubkey]. + +| 4...31 +| Reserved +|=== + +`version`:: _(string)_ The Git version string for the bootloader. + +==== BCM2711 and BCM2712 USB boot properties `/chosen/bootloader/usb` + +The following properties are defined if the system was booted from USB. These may be used to uniquely identify the USB boot device. + +`usb-version`:: The USB major protocol version (2 or 3). + +`route-string`:: The USB route-string identifier for the device as defined by the USB 3.0 specification. + +`root-hub-port-number`:: The root hub port number that the boot device is connected to - possibly via other USB hubs. + +`lun`:: The Logical Unit Number for the mass-storage device. + +==== NVMEM nodes + +The firmware provides read-only, in-memory copies of portions of the bootloader EEPROM via the https://www.kernel.org/doc/html/latest/driver-api/nvmem.html[NVMEM] subsystem. + +Each region appears as an NVMEM device under `/sys/bus/nvmem/devices/` with a named alias under `/sys/firmware/devicetree/base/aliases`. + +Example shell script code for reading an NVMEM mode from https://github.com/raspberrypi/rpi-eeprom/blob/master/rpi-eeprom-update[rpi-eeprom-update]: + +[source,shell] +---- +blconfig_alias="/sys/firmware/devicetree/base/aliases/blconfig" +blconfig_nvmem_path="" + +if [ -f "${blconfig_alias}" ]; then + blconfig_ofnode_path="/sys/firmware/devicetree/base"$(strings "${blconfig_alias}")"" + blconfig_ofnode_link=$(find -L /sys/bus/nvmem -samefile "${blconfig_ofnode_path}" 2>/dev/null) + if [ -e "${blconfig_ofnode_link}" ]; then + blconfig_nvmem_path=$(dirname "${blconfig_ofnode_link}") + fi + fi +fi +---- + +`blconfig`:: alias that refers to an NVMEM device that stores a copy of the bootloader EEPROM config file. + +`blpubkey`:: alias that points to an NVMEM device that stores a copy of the bootloader EEPROM public key (if defined) in binary format. +The https://github.com/raspberrypi/usbboot/blob/master/tools/rpi-bootloader-key-convert[rpi-bootloader-key-convert] utility can be used to convert the data into PEM format for use with OpenSSL. + +For more information, see https://github.com/raspberrypi/usbboot#secure-boot[secure-boot]. + +[[part5]] === Troubleshooting -[[part4.1]] +[[part5.1]] ==== Debugging The loader will skip over missing overlays and bad parameters, but if there are serious errors, such as a missing or corrupt base DTB or a failed overlay merge, then the loader will fall back to a non-DT boot. If this happens, or if your settings don't behave as you expect, it is worth checking for warnings or errors from the loader: +[source,console] ---- -sudo vcdbg log msg +$ sudo vclog --msg ---- Extra debugging can be enabled by adding `dtdebug=1` to `config.txt`. You can create a human-readable representation of the current state of DT like this: +[source,console] ---- -dtc -I fs /proc/device-tree +$ dtc -I fs /proc/device-tree ---- This can be useful to see the effect of merging overlays onto the underlying tree. @@ -833,36 +1052,40 @@ MODULE_DEVICE_TABLE(of, xxx_of_match); Failing that, `depmod` has failed or the updated modules haven't been installed on the target filesystem. -[[part4.2]] -==== Testing overlays using dtmerge, dtdiff and ovmerge +[[part5.2]] +==== Test overlays using `dtmerge`, `dtdiff` and `ovmerge` Alongside the `dtoverlay` and `dtparam` commands is a utility for applying an overlay to a DTB - `dtmerge`. To use it you first need to obtain your base DTB, which can be obtained in one of two ways: -a) generate it from the live DT state in `/proc/device-tree`: +Generate it from the live DT state in `/proc/device-tree`: +[source,console] ---- -dtc -I fs -O dtb -o base.dtb /proc/device-tree +$ dtc -I fs -O dtb -o base.dtb /proc/device-tree ---- -This will include any overlays and parameters you have applied so far, either in `config.txt` or by loading them at runtime, which may or may not be what you want. Alternatively... +This will include any overlays and parameters you have applied so far, either in `config.txt` or by loading them at runtime, which may or may not be what you want. Alternatively: -b) copy it from the source DTBs in /boot. This won't include overlays and parameters, but it also won't include any other modifications by the firmware. To allow testing of all overlays, the `dtmerge` utility will create some of the board-specific aliases ("i2c_arm", etc.), but this means that the result of a merge will include more differences from the original DTB than you might expect. The solution to this is to use dtmerge to make the copy: +Copy it from the source DTBs in `/boot/firmware/`. This won't include overlays and parameters, but it also won't include any other modifications by the firmware. To allow testing of all overlays, the `dtmerge` utility will create some of the board-specific aliases ("i2c_arm", etc.), but this means that the result of a merge will include more differences from the original DTB than you might expect. The solution to this is to use dtmerge to make the copy: +[source,console] ---- -dtmerge /boot/bcm2710-rpi-3-b.dtb base.dtb - +$ dtmerge /boot/firmware/bcm2710-rpi-3-b.dtb base.dtb - ---- (the `-` indicates an absent overlay name). You can now try applying an overlay or parameter: +[source,console] ---- -dtmerge base.dtb merged.dtb - sd_overclock=62 -dtdiff base.dtb merged.dtb +$ dtmerge base.dtb merged.dtb - sd_overclock=62 +$ dtdiff base.dtb merged.dtb ---- which will return: +[source,diff] ---- --- /dev/fd/63 2016-05-16 14:48:26.396024813 +0100 +++ /dev/fd/62 2016-05-16 14:48:26.396024813 +0100 @@ -879,14 +1102,16 @@ which will return: You can also compare different overlays or parameters. +[source,console] ---- -dtmerge base.dtb merged1.dtb /boot/overlays/spi1-1cs.dtbo -dtmerge base.dtb merged2.dtb /boot/overlays/spi1-2cs.dtbo -dtdiff merged1.dtb merged2.dtb +$ dtmerge base.dtb merged1.dtb /boot/firmware/overlays/spi1-1cs.dtbo +$ dtmerge base.dtb merged2.dtb /boot/firmware/overlays/spi1-2cs.dtbo +$ dtdiff merged1.dtb merged2.dtb ---- to get: +[source,diff] ---- --- /dev/fd/63 2016-05-16 14:18:56.189634286 +0100 +++ /dev/fd/62 2016-05-16 14:18:56.189634286 +0100 @@ -929,31 +1154,34 @@ to get: The https://github.com/raspberrypi/utils[Utils] repo includes another DT utility - `ovmerge`. Unlike `dtmerge`, `ovmerge` combines file and applies overlays in source form. Because the overlay is never compiled, labels are preserved and the result is usually more readable. It also has a number of other tricks, such as the ability to list the order of file inclusion. -[[part4.3]] -==== Forcing a specific Device Tree +[[part5.3]] +==== Force a specific Device Tree If you have very specific needs that aren't supported by the default DTBs, or if you just want to experiment with writing your own DTs, you can tell the loader to load an alternate DTB file like this: +[source,ini] ---- device_tree=my-pi.dtb ---- -[[part4.4]] -==== Disabling Device Tree usage +[[part5.4]] +==== Disable Device Tree usage -Since the switch to the 4.4 kernel and the use of more upstream drivers, Device Tree usage is required in Pi Linux kernels. However, for bare metal and other OSs, the method of disabling DT usage is to add: +Device Tree usage is required in Raspberry Pi Linux kernels. For bare metal and other OSs, DT usage can be disabled by adding: +[source,ini] ---- device_tree= ---- to `config.txt`. -[[part4.5]] +[[part5.5]] ==== Shortcuts and syntax variants The loader understands a few shortcuts: +[source,ini] ---- dtparam=i2c_arm=on dtparam=i2s=on @@ -961,33 +1189,30 @@ dtparam=i2s=on can be shortened to: +[source,ini] ---- dtparam=i2c,i2s ---- (`i2c` is an alias of `i2c_arm`, and the `=on` is assumed). It also still accepts the long-form versions: `device_tree_overlay` and `device_tree_param`. -[[part4.6]] -==== Other DT commands available in config.txt +[[part5.6]] +==== Other DT commands available in `config.txt` -`device_tree_address` -This is used to override the address where the firmware loads the device tree (not dt-blob). By default the firmware will choose a suitable place. +`device_tree_address`:: This is used to override the address where the firmware loads the device tree (not dt-blob). By default the firmware will choose a suitable place. -`device_tree_end` -This sets an (exclusive) limit to the loaded device tree. By default the device tree can grow to the end of usable memory, which is almost certainly what is required. +`device_tree_end`:: This sets an (exclusive) limit to the loaded device tree. By default the device tree can grow to the end of usable memory, which is almost certainly what is required. -`dtdebug` -If non-zero, turn on some extra logging for the firmware's device tree processing. +`dtdebug`:: If non-zero, turn on some extra logging for the firmware's device tree processing. -`enable_uart` -Enable the primary/console xref:configuration.adoc#configuring-uarts[UART] (ttyS0 on a Pi 3, ttyAMA0 otherwise - unless swapped with an overlay such as miniuart-bt). If the primary UART is ttyAMA0 then enable_uart defaults to 1 (enabled), otherwise it defaults to 0 (disabled). This is because it is necessary to stop the core frequency from changing which would make ttyS0 unusable, so `enable_uart=1` implies core_freq=250 (unless force_turbo=1). In some cases this is a performance hit, so it is off by default. +`enable_uart`:: Enable the xref:configuration.adoc#primary-and-secondary-uart[primary/console UART]. If the primary UART is `ttyAMA0`, `enable_uart` defaults to 1 (enabled), otherwise it defaults to 0 (disabled). This stops the core frequency from changing, which would make `ttyS0` unusable. As a result, `enable_uart=1` implies `core_freq=250` (unless `force_turbo=1`). In some cases this is a performance hit, so it is off by default. -`overlay_prefix` -Specifies a subdirectory/prefix from which to load overlays - defaults to "overlays/". Note the trailing "/". If desired you can add something after the final "/" to add a prefix to each file, although this is not likely to be needed. +`overlay_prefix`:: Specifies a subdirectory/prefix from which to load overlays - defaults to "overlays/". Note the trailing "/". If desired you can add something after the final "/" to add a prefix to each file, although this is not likely to be needed. -Further ports can be controlled by the DT, for more details see <>. +Further ports can be controlled by the DT. For more details see <>. -[[part4.7]] +[[part5.7]] ==== Further help -If you've read through this document and not found the answer to a Device Tree problem, there is help available. The author can usually be found on Raspberry Pi forums, particularly the https://www.raspberrypi.org/forums/viewforum.php?f=107[Device Tree] forum. +If you've read through this document and have not found the answer to a Device Tree problem, there is help available. The author can usually be found on Raspberry Pi forums, particularly the https://forums.raspberrypi.com/viewforum.php?f=107[Device Tree] forum. + diff --git a/documentation/asciidoc/computers/configuration/display-resolution.adoc b/documentation/asciidoc/computers/configuration/display-resolution.adoc new file mode 100644 index 0000000000..0a294f5b21 --- /dev/null +++ b/documentation/asciidoc/computers/configuration/display-resolution.adoc @@ -0,0 +1,86 @@ +== Displays + +To configure your Raspberry Pi to use a non-default display mode, set the resolution or rotation manually. + +=== Support for HDMI monitors + +With most HDMI monitors, Raspberry Pi OS uses the highest resolution and refresh rate supported by the monitor. + +The Raspberry Pi Zero, Zero W and Zero 2 W have a mini HDMI port, so you need a mini-HDMI-to-full-size-HDMI lead or adapter. + +Flagship models since Raspberry Pi 4B and Keyboard models have two micro HDMI ports, so you need a micro-HDMI-to-full-size-HDMI lead or adapter for each display you wish to attach. Connect the cables before turning on the Raspberry Pi. + +Flagship models since Raspberry Pi 4B, Compute Modules since CM4 (except for CM4S), and Keyboard models can drive up to two displays. + +4-series devices support resolutions up to 1080p at a 60Hz refresh rate, or two 4K displays at a 30Hz refresh rate. You can also drive a single display at 4K with a 60Hz refresh rate if you connect the display to the `HDMI0` port and set the `hdmi_enable_4kp60=1` flag in xref:../computers/config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]. + +5-series devices support up to two displays at 4K resolution at a 60hz refresh rate with no additional configuration. + +=== Set resolution and rotation + +On the Raspberry Pi Desktop, open the *Preferences* menu and select the **Screen Configuration** utility. You should see a graphical representation of the displays connected to the Raspberry Pi. Right click on the display you wish to modify, and select an option. Click **Apply** to and close **Screen Configuration** to save your changes. + +Alternatively, use the following command to open the **Screen Configuration** utility: + +[source,console] +---- +$ raindrop +---- + +[TIP] +==== +If your installation of Raspberry Pi OS doesn't already include `raindrop`, you can install it with the following command: + +[source,console] +---- +$ sudo apt install raindrop +---- + +Older versions of Raspberry Pi OS used a different screen configuration utility named `arandr`. To uninstall `arandr`, run the following command: + +[source,console] +---- +$ sudo apt purge arandr +---- +==== + +=== Manually set resolution and rotation + +==== Determine display device name + +To manually configure resolution and rotation, you'll need to know the names of your display devices. To determine the device names, run the following command to display information about attached devices: + +[source,console] +---- +$ kmsprint | grep Connector +---- + +==== Set a custom resolution + +To set a custom resolution, use our Screen Configuration tool, `raindrop`. If your Raspberry Pi OS installation doesn't already include `raindrop` (for instance, if you're still using the previous Screen Configuration tool, `arandr`), you can download `raindrop` from `apt` or the Recommended Software GUI. + +==== Set a custom rotation + +To set a custom resolution, use our Screen Configuration tool, `raindrop`. If your Raspberry Pi OS installation doesn't already include `raindrop` (for instance, if you're still using the previous Screen Configuration tool, `arandr`), you can download `raindrop` from `apt` or the Recommended Software GUI. + +If you run the Wayland desktop compositor, you can set a custom display rotation with `wlr-randr`. The following commands rotate the display by 0°, 90°, 180°, and 270°: + +[source,console] +---- +$ wlr-randr --output HDMI-A-1 --transform normal +$ wlr-randr --output HDMI-A-1 --transform 90 +$ wlr-randr --output HDMI-A-1 --transform 180 +$ wlr-randr --output HDMI-A-1 --transform 270 +---- + +The `--output` option specifies the device to be rotated. + +NOTE: To run this command over SSH, add the following prefix: `WAYLAND_DISPLAY=wayland-1`, e.g. `WAYLAND_DISPLAY=wayland-1 wlr-randr --output HDMI-A-1 --transform 90`. + +You can also use one of the following `--transform` options to mirror the display at the same time as rotating it: `flipped`, `flipped-90`, `flipped-180`, `flipped-270`. + +=== Console resolution and rotation + +To change the resolution and rotation of your Raspberry Pi in console mode, use the KMS settings. For more information, see <>. + +NOTE: When using console mode with multiple displays, all connected displays share the same rotation settings. diff --git a/documentation/asciidoc/computers/configuration/display-rotation.adoc b/documentation/asciidoc/computers/configuration/display-rotation.adoc deleted file mode 100644 index b3eaf241c3..0000000000 --- a/documentation/asciidoc/computers/configuration/display-rotation.adoc +++ /dev/null @@ -1,64 +0,0 @@ -== Rotating your Display - -The options to rotate the display of your Raspberry Pi depend on which display driver software it is running, which may also depend on which Raspberry Pi you are using. - -=== Fake or Full KMS Graphics Driver - -NOTE: This is the default for Raspberry Pi 4 Model B. - -If you are running the Raspberry Pi desktop then rotation is achieved by using the `Screen Configuration Utility` from the desktop `Preferences` menu. This will bring up a graphical representation of the display or displays connected to the Raspberry Pi. Right click on the display you wish to rotate and select the required option. - -It is also possible to change these settings using the command line `xrandr` option. The following commands give 0°, -90°, +90° and 180° rotations respectively. - -[,bash] ----- -xrandr --output HDMI-1 --rotate normal -xrandr --output HDMI-1 --rotate left -xrandr --output HDMI-1 --rotate right -xrandr --output HDMI-1 --rotate inverted ----- - -Note that the `--output` entry specifies to which device the rotation applies. You can determine the device name by simply typing `xrandr` on the command line which will display information, including the name, for all attached devices. - -You can also use the command line to mirror the display using the `--reflect` option. Reflection can be one of 'normal' 'x', 'y' or 'xy'. This causes the output contents to be reflected across the specified axes. For example: - -[,bash] ----- -xrandr --output HDMI-1 --reflect x ----- - -If you are using the console only (no graphical desktop) then you will need to set the appropriate kernel command line flags. Change the console settings as described on the xref:configuration.adoc#the-kernel-command-line[this page]. - -=== Legacy Graphics Driver - -NOTE: This is the default for models prior to the Raspberry Pi 4 Model B. - -There are `config.txt` options for rotating when using the legacy display drivers. - -`display_hdmi_rotate` is used to rotate the HDMI display, `display_lcd_rotate` is used to rotate any attached LCD panel (using the DSI or DPI interface). These options rotate both the desktop and console. Each option takes one of the following parameters : - -|=== -| display_*_rotate | result - -| 0 -| no rotation - -| 1 -| rotate 90 degrees clockwise - -| 2 -| rotate 180 degrees clockwise - -| 3 -| rotate 270 degrees clockwise - -| 0x10000 -| horizontal flip - -| 0x20000 -| vertical flip -|=== - -Note that the 90 and 270 degree rotation options require additional memory on the GPU, so these will not work with the 16MB GPU split. - -You can combine the rotation settings with the flips by adding them together. You can also have both horizontal and vertical flips in the same way. E.g. A 180 degree rotation with a vertical and horizontal flip will be 0x20000 + 0x10000 + 2 = 0x30002. diff --git a/documentation/asciidoc/computers/configuration/external-storage.adoc b/documentation/asciidoc/computers/configuration/external-storage.adoc index 3ae06bb83d..5e1ea106cd 100644 --- a/documentation/asciidoc/computers/configuration/external-storage.adoc +++ b/documentation/asciidoc/computers/configuration/external-storage.adoc @@ -1,4 +1,4 @@ -== External Storage Configuration +== External storage You can connect your external hard disk, SSD, or USB stick to any of the USB ports on the Raspberry Pi, and mount the file system to access the data stored on it. @@ -8,100 +8,109 @@ NOTE: Raspberry Pi OS Lite does not implement automounting. To set up your storage device so that it always mounts to a specific location of your choice, you must mount it manually. -=== Mounting a Storage Device +=== Mount a storage device You can mount your storage device at a specific folder location. It is conventional to do this within the `/mnt` folder, for example `/mnt/mydisk`. Note that the folder must be empty. -. Plug the storage device into a USB port on the Raspberry Pi. -. List all the disk partitions on the Pi using the following command: -+ +Plug the storage device into a USB port on the Raspberry Pi, and list all the disk partitions on the Raspberry Pi using the following command: + +[source,console] ---- - sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL +$ sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL ---- -+ -The Raspberry Pi uses mount points `/` and `/boot`. Your storage device will show up in this list, along with any other connected storage. -. Use the SIZE, LABEL, and MODEL columns to identify the name of the disk partition that points to your storage device. For example, `sda1`. -. The FSTYPE column contains the filesystem type. If your storage device uses an exFAT file system, install the exFAT driver: -+ +The Raspberry Pi uses mount points `/` and `/boot/firmware/`. Your storage device will show up in this list, along with any other connected storage. + +Use the SIZE, LABEL, and MODEL columns to identify the name of the disk partition that points to your storage device. For example, `sda1`. +The FSTYPE column contains the filesystem type. If your storage device uses an exFAT file system, install the exFAT driver: + +[source,console] ---- - sudo apt update - sudo apt install exfat-fuse +$ sudo apt update +$ sudo apt install exfat-fuse ---- -. If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver: -+ +If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver: + +[source,console] ---- - sudo apt update - sudo apt install ntfs-3g +$ sudo apt update +$ sudo apt install ntfs-3g ---- -. Run the following command to get the location of the disk partition: -+ +Run the following command to get the location of the disk partition: + +[source,console] ---- - sudo blkid +$ sudo blkid ---- -+ + For example, `/dev/sda1`. -. Create a target folder to be the mount point of the storage device. +Create a target folder to be the mount point of the storage device. The mount point name used in this case is `mydisk`. You can specify a name of your choice: -+ + +[source,console] ---- - sudo mkdir /mnt/mydisk +$ sudo mkdir /mnt/mydisk ---- -. Mount the storage device at the mount point you created: -+ +Mount the storage device at the mount point you created: + +[source,console] ---- - sudo mount /dev/sda1 /mnt/mydisk +$ sudo mount /dev/sda1 /mnt/mydisk ---- -. Verify that the storage device is mounted successfully by listing the contents: -+ +Verify that the storage device is mounted successfully by listing the contents: + +[source,console] ---- - ls /mnt/mydisk +$ ls /mnt/mydisk ---- -=== Setting up Automatic Mounting +=== Automatically mount a storage device You can modify the `fstab` file to define the location where the storage device will be automatically mounted when the Raspberry Pi starts up. In the `fstab` file, the disk partition is identified by the universally unique identifier (UUID). -. Get the UUID of the disk partition: -+ +Get the UUID of the disk partition: + +[source,console] ---- - sudo blkid +$ sudo blkid ---- -. Find the disk partition from the list and note the UUID. For example, `5C24-1453`. -. Open the fstab file using a command line editor such as nano: -+ +Find the disk partition from the list and note the UUID. (For example, `5C24-1453`.) Open the fstab file using a command line editor such as nano: + +[source,console] ---- - sudo nano /etc/fstab +$ sudo nano /etc/fstab ---- -. Add the following line in the `fstab` file: -+ +Add the following line in the `fstab` file: + +[source,bash] ---- - UUID=5C24-1453 /mnt/mydisk fstype defaults,auto,users,rw,nofail 0 0 +UUID=5C24-1453 /mnt/mydisk fstype defaults,auto,users,rw,nofail 0 0 ---- -+ -Replace `fstype` with the type of your file system, which you found in step 2 of 'Mounting a storage device' above, for example: `ntfs`. -. If the filesystem type is FAT or NTFS, add `,umask=000` immediately after `nofail` - this will allow all users full read/write access to every file on the storage device. +Replace `fstype` with the type of your file system, which you found when you went through the steps above, for example: `ntfs`. + +If the filesystem type is FAT or NTFS, add `,umask=000` immediately after `nofail` - this will allow all users full read/write access to every file on the storage device. -Now that you have set an entry in `fstab`, you can start up your Raspberry Pi with or without the storage device attached. Before you unplug the device you must either shut down the Pi, or manually unmount it using the steps in 'Unmounting a storage device' below. +Now that you have set an entry in `fstab`, you can start up your Raspberry Pi with or without the storage device attached. Before you unplug the device you must either shut down the Raspberry Pi, or manually unmount it. -NOTE: if you do not have the storage device attached when the Pi starts, the Pi will take an extra 90 seconds to start up. You can shorten this by adding `,x-systemd.device-timeout=30` immediately after `nofail` in step 4. This will change the timeout to 30 seconds, meaning the system will only wait 30 seconds before giving up trying to mount the disk. +NOTE: If you do not have the storage device attached when the Raspberry Pi starts, it will take an extra 90 seconds to start up. You can shorten this by adding `,x-systemd.device-timeout=30` immediately after `nofail`. This will change the timeout to 30 seconds, meaning the system will only wait 30 seconds before giving up trying to mount the disk. For more information on each Linux command, refer to the specific manual page using the `man` command. For example, `man fstab`. -=== Unmounting a Storage Device +=== Unmount a storage device When the Raspberry Pi shuts down, the system takes care of unmounting the storage device so that it is safe to unplug it. If you want to manually unmount a device, you can use the following command: +[source,console] ---- -sudo umount /mnt/mydisk +$ sudo umount /mnt/mydisk ---- If you receive an error that the 'target is busy', this means that the storage device was not unmounted. If no error was displayed, you can now safely unplug the device. @@ -110,17 +119,19 @@ If you receive an error that the 'target is busy', this means that the storage d The 'target is busy' message means there are files on the storage device that are in use by a program. To close the files, use the following procedure. -. Close any program which has open files on the storage device. -. If you have a terminal open, make sure that you are not in the folder where the storage device is mounted, or in a sub-folder of it. -. If you are still unable to unmount the storage device, you can use the `lsof` tool to check which program has files open on the device. You need to first install `lsof` using `apt`: -+ +Close any program which has open files on the storage device. If you have a terminal open, make sure that you are not in the folder where the storage device is mounted, or in a sub-folder of it. + +If you are still unable to unmount the storage device, you can use the `lsof` tool to check which program has files open on the device. You need to first install `lsof` using `apt`: + +[source,console] ---- - sudo apt update - sudo apt install lsof +$ sudo apt update +$ sudo apt install lsof ---- -+ + To use lsof: -+ + +[source,console] ---- - lsof /mnt/mydisk +$ lsof /mnt/mydisk ---- diff --git a/documentation/asciidoc/computers/configuration/hdmi-config.adoc b/documentation/asciidoc/computers/configuration/hdmi-config.adoc deleted file mode 100644 index d960892cbb..0000000000 --- a/documentation/asciidoc/computers/configuration/hdmi-config.adoc +++ /dev/null @@ -1,149 +0,0 @@ -== HDMI Configuration - -In the vast majority of cases, simply plugging your HDMI-equipped monitor into the Raspberry Pi using a standard HDMI cable will automatically lead to the Pi using the best resolution the monitor supports. The Raspberry Pi Zero uses a mini HDMI port, so you will need a mini-HDMI-to-full-size-HDMI lead or adapter. On the Raspberry Pi 4 there are two micro HDMI ports, so you will need either one or two micro-HDMI-to-full-size-HDMI leads or adapters, depending on how many displays you wish to attach. You should connect any HDMI leads before turning on the Raspberry Pi. - -The Raspberry Pi 4 can drive up to two displays, with a resolution up to 1080p at a 60Hz refresh rate. At 4K resolution, if you connect two displays then you are limited to a 30Hz refresh rate. You can also drive a single display at 4K with a 60Hz refresh rate: this requires that the display is attached to the HDMI port adjacent to the USB-C power input (labelled HDMI0). You must also enable 4Kp60 output by setting the `hdmi_enable_4kp60=1` flag in config.txt. This flag can also be set using the 'Raspberry Pi Configuration' tool within the desktop environment. - -If you are running the 3D graphics driver (also known as the FKMS driver), then in the Preferences menu you will find a graphical application for setting up standard displays, including multi-display setups. - -[NOTE] -====== -The Screen Configuration tool (`arandr`) is a graphical tool for selecting display modes and setting up multiple displays. You can find this tool in the desktop Preferences menu, but only if the 3D graphics driver is being used, as it is this driver that provides the required mode setting functionality. Use the Configure menu option to select the screen, resolution, and orientation. If you're using a multi-screen setup, drag around the displays to any position you want. When you have the required setup, click the Tick button to apply the settings. -====== - -If you are using legacy graphics drivers, or find yourself in circumstances where the Raspberry Pi may not be able to determine the best mode, or you may specifically wish to set a non-default resolution, the rest of this page may be useful. - -NOTE: All the commands are documented fully in the xref:config_txt.adoc#video-options[config.txt] section of the documentation. - -=== HDMI Groups and Mode - -HDMI has two common groups: CEA (Consumer Electronics Association, the standard typically used by TVs) and DMT (Display Monitor Timings, the standard typically used by monitors). Each group advertises a particular set of modes, where a mode describes the resolution, frame rate, clock rate, and aspect ratio of the output. - -=== What Modes does my Device Support? - -You can use the `tvservice` application on the command line to determine which modes are supported by your device, along with other useful data: - -* `tvservice -s` displays the current HDMI status, including mode and resolution -* `tvservice -m CEA` lists all supported CEA modes -* `tvservice -m DMT` lists all supported DMT modes - -If you are using a Pi 4 with more than one display attached, then `tvservice` needs to be told which device to ask for information. You can get display IDs for all attached devices by using: - -`tvservice -l` - -You can specify which display `tvservice` uses by adding `-v ` to the `tvservice` command, e.g: - -* `tvservice -v 7 -m CEA`, lists all supported CEA modes for display ID 7 - -=== Setting a Specific HDMI Mode - -Setting a specific mode is done using the `hdmi_group` and `hdmi_mode` config.txt entries. The group entry selects between CEA or DMT, and the mode selects the resolution and frame rate. You can find tables of modes on the config.txt xref:config_txt.adoc#video-options[Video Configuration] page, but you should use the `tvservice` command described above to find out exactly which modes your device supports. - -On the Pi 4, to specify the HDMI port, add an index identifier to the `hdmi_group` or `hdmi_mode` entry in config.txt, e.g. `hdmi_mode:0` or `hdmi_group:1`. - -=== Setting a Custom HDMI Mode - -There are two options for setting a custom mode: `hdmi_cvt` and `hdmi_timings`. - -`hdmi_cvt` sets a custom Coordinated Video Timing entry, which is described fully here: xref:config_txt.adoc#custom-mode[Video Configuration] - -In certain rare cases it may be necessary to define the exact clock requirements of the HDMI signal. This is a fully custom mode, and it is activated by setting `hdmi_group=2` and `hdmi_mode=87`. You can then use the `hdmi_timings` config.txt command to set the specific parameters for your display. -`hdmi_timings` specifies all the timings that an HDMI signal needs to use. These timings are usually found in the datasheet of the display being used. - -[source] ----- -hdmi_timings= v_front_porch> ----- - -|=== -| Timing | Purpose - -| `h_active_pixels` -| The horizontal resolution - -| `h_sync_polarity` -| 0 or 1 to define the horizontal sync polarity - -| `h_front_porch` -| Number of horizontal front porch pixels - -| `h_sync_pulse` -| Width of horizontal sync pulse - -| `h_back_porch` -| Number of horizontal back porch pixels - -| `v_active_lines` -| The vertical resolution - -| `v_sync_polarity` -| 0 or 1 to define the vertical sync polarity - -| `v_front_porch` -| Number of vertical front porch pixels - -| `v_sync_pulse` -| Width of vertical sync pulse - -| `v_back_porch` -| Number of vertical back porch pixels - -| `v_sync_offset_a` -| Leave at 0 - -| `v_sync_offset_b` -| Leave at 0 - -| `pixel_rep` -| Leave at 0 - -| `frame_rate` -| Frame rate of mode - -| `interlaced` -| 0 for non-interlaced, 1 for interlaced - -| `pixel_freq` -| The mode pixel frequency - -| `aspect_ratio` -| The aspect ratio required -|=== - -`aspect_ratio` should be one of the following: - -|=== -| Ratio | `aspect_ratio` ID - -| `4:3` -| 1 - -| `14:9` -| 2 - -| `16:9` -| 3 - -| `5:4` -| 4 - -| `16:10` -| 5 - -| `15:9` -| 6 - -| `21:9` -| 7 - -| `64:27` -| 8 -|=== - -For the Pi4, to specify the HDMI port, you can add an index identifier to the config.txt. e.g. `+hdmi_cvt:0=...+` or `+hdmi_timings:1=...+`. If no port identifier is specified, the settings are applied to port 0. - -=== Troubleshooting your HDMI - -In some rare cases you may need to increase the HDMI drive strength, for example when there is speckling on the display or when you are using very long cables. There is a config.txt item to do this, `config_hdmi_boost`, which is documented on the xref:config_txt.adoc#video-options[config.txt video page]. - -NOTE: The Raspberry Pi 4B does not yet support `config_hdmi_boost`, support for this option will be added in a future software update. diff --git a/documentation/asciidoc/computers/configuration/headless.adoc b/documentation/asciidoc/computers/configuration/headless.adoc index b7286ba756..e62c2eef09 100644 --- a/documentation/asciidoc/computers/configuration/headless.adoc +++ b/documentation/asciidoc/computers/configuration/headless.adoc @@ -1,56 +1,49 @@ -== Setting up a Headless Raspberry Pi +[[setting-up-a-headless-raspberry-pi]] +== Set up a headless Raspberry Pi -If you do not use a monitor or keyboard to run your Pi (known as headless), but you still need to do some wireless setup, there is a facility to enable wireless networking and SSH when creating a image. +A **headless** Raspberry Pi runs without a monitor, keyboard, or mouse. To run a Raspberry Pi headless, you need a way to access it from another computer. To access your Raspberry Pi remotely, you'll need to connect your Raspberry Pi to a network, and a way to access the Raspberry Pi over that network. -Once an image is created on an SD card, by inserting it into a card reader on a Linux or Windows machines the xref:configuration.adoc#the-boot-folder[boot folder] can be accessed. Adding certain files to this folder will activate certain setup features on the first boot of the Pi itself. +To connect your Raspberry Pi to a network, you can either plug your device into a wired connection via Ethernet or configure wireless networking. -=== Configuring Networking +To access your Raspberry Pi over that network, use SSH. Once you've connected over SSH, you can use `raspi-config` to xref:remote-access.adoc#vnc[enable VNC] if you'd prefer a graphical desktop environment. -You will need to define a `wpa_supplicant.conf` file for your particular wireless network. Put this file onto the boot partition of the SD card, and when the Pi first boots, it will copy that file into the correct location in the Linux root file system and use those settings to start up wireless networking. +If you're setting up your Raspberry Pi from scratch, set up wireless networking and SSH during the xref:getting-started.adoc#installing-the-operating-system[imaging process]. If you've already got a Raspberry Pi set up, you can configure SSH using `raspi-config`. -The Rapsberry Pi's IP address will not be visible immediately after power on, so this step is crucial to connect to it headlessly. Depending on the OS and editor you are creating this on, the file could have incorrect newlines or the wrong file extension so make sure you use an editor that accounts for this. Linux expects the line feed (LF) newline character. +WARNING: Depending on the model of Raspberry Pi and type of SD card you use, your Raspberry Pi may require up to five minutes to boot and connect to your wireless network the first time it boots. -WARNING: After your Raspberry Pi is connected to power, make sure to wait a few (up to 5) minutes for it to boot up and register on the network. +=== Connect to a wired network -A xref:configuration.adoc#wireless-networking-command-line[`wpa_supplicant.conf`] file example: +To connect to a wired network at first boot, plug your headless Raspberry Pi in via Ethernet, or use an Ethernet adapter if your Raspberry Pi model does not include an Ethernet port. Your Raspberry Pi will automatically connect to the network. ----- -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -country= -update_config=1 - -network={ - ssid="" - psk="" -} ----- +=== Connect to a wireless network + +To configure wireless network access at first boot in a headless Raspberry Pi, use the advanced settings menu in Raspberry Pi Imager. Enter the SSID and password of your preferred wireless network. Your Raspberry Pi will use these credentials to connect to the network on first boot. Some wireless adapters and some Raspberry Pi boards do not support 5GHz networks; check the documentation for your wireless module to ensure compatibility with your preferred network. + +NOTE: Previous versions of Raspberry Pi OS made use of a `wpa_supplicant.conf` file which could be placed into the boot folder to configure wireless network settings. This functionality is not available from Raspberry Pi OS Bookworm onwards. + +=== Remote access + +With no keyboard or monitor, you need a way to xref:remote-access.adoc[remotely control] your headless Raspberry Pi. On first boot, the only option is SSH. To enable SSH on a fresh installation of Raspberry Pi OS, choose one of the following methods: -Where the country code should be set the two letter ISO/IEC alpha2 code for the country in which you are using, e.g. +* enable SSH in the OS customisation menu in Raspberry Pi Imager, then enter a username and password +* create a file named `ssh` at the root of the first partition of the SD card (labeled `bootfs`), then configure a user manually with `userconf.txt` following the instructions in the section below -* GB (United Kingdom) -* FR (France) -* DE (Germany) -* US (United States) -* SE (Sweden) +For more information, see xref:remote-access.adoc#ssh[set up an SSH server]. Once you've connected over SSH, you can use `raspi-config` to xref:remote-access.adoc#vnc[enable VNC] if you'd prefer a graphical desktop environment. -Here is a more elaborate example that should work for most typical wpa2 personal networks. This template below works for 2.4ghz/5ghz hidden or not networks. The utilization of quotes around the ssid - psk can help avoid any oddities if your network ssid or password has special chars (! @ # $ etc) +[[configuring-a-user]] +==== Configure a user manually +At the root of the first partition of your SD card (the filesystem labeled `bootfs`), create a file named `userconf.txt`. + +This file should contain a single line of text, consisting of `:`: your desired username, followed immediately by a colon, followed immediately by an *encrypted* representation of the password you want to use. + +NOTE: `` must only contain lower-case letters, digits and hyphens, and must start with a letter. It may not be longer than 31 characters. + +To generate the encrypted password, use https://www.openssl.org[OpenSSL] on another computer. Open a terminal and enter the following: + +[source,console] ---- -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -update_config=1 -country= - -network={ - scan_ssid=1 - ssid="" - psk="" - proto=RSN - key_mgmt=WPA-PSK - pairwise=CCMP - auth_alg=OPEN -} +$ openssl passwd -6 ---- -Note that some older pi's (zerow or 3b) or usb wireless dongles don't support 5GHz networks. - -NOTE: With no keyboard or monitor, you will need some way of xref:remote-access.adoc#remote-access[remotely accessing] your headless Raspberry Pi. +When prompted, enter your password and verify it. This command will then output an encrypted version of the supplied password. diff --git a/documentation/asciidoc/computers/configuration/host-wireless-network.adoc b/documentation/asciidoc/computers/configuration/host-wireless-network.adoc new file mode 100644 index 0000000000..9bd7dcc1e0 --- /dev/null +++ b/documentation/asciidoc/computers/configuration/host-wireless-network.adoc @@ -0,0 +1,107 @@ +== Host a wireless network from your Raspberry Pi + +Your Raspberry Pi can host its own wireless network using a wireless module. If you connect your Raspberry Pi to the internet via the Ethernet port (or a second wireless module), other devices connected to the wireless network can access the internet through your Raspberry Pi. + +Consider a wired network that uses the `10.x.x.x` IP block. You can connect your Raspberry Pi to that network and serve wireless clients on a separate network that uses another IP block, such as `192.168.x.x`. + +In the diagram below, note that the laptop exists in an IP block separate from the router and wired clients: + +image::images/host-a-network.png[] + + +With this network configuration, wireless clients can all communicate with each other through the Raspberry Pi router. However, clients on the wireless network cannot directly interact with clients on the wired network other than the Raspberry Pi; wireless clients exist in a private network separate from the network that serves wired clients. + +NOTE: The Raspberry Pi 5, 4, 3, Zero W, and Zero 2 W can host a wireless network using the built-in wireless module. Raspberry Pi models that lack a built-in module support this functionality using a separate wireless dongle. + +=== Enable hotspot + +To create a hosted wireless network on the command line, run the following command, replacing the `` and `` placeholders with your own values: + +[source,console] +---- +$ sudo nmcli device wifi hotspot ssid password +---- + +Use another wireless client, such as a laptop or smartphone, to connect to the network. Look for a network with a SSID matching ``. Enter your network password, and you should connect successfully to the network. If your Raspberry Pi has internet access via an Ethernet connection or a second wireless adapter, you should be able to access the internet. + +=== Disable hotspot + +To disable the hotspot network and resume use of your Pi as a wireless client, run the following command: + +[source,console] +---- +$ sudo nmcli device disconnect wlan0 +---- + +After disabling the network, run the following command to reconnect to another Wi-Fi network: + +[source,console] +---- +$ sudo nmcli device up wlan0 +---- + +TIP: For more information about connecting to wireless networks, see xref:configuration.adoc#networking[Configure networking]. + +=== Use your Raspberry Pi as a network bridge + +By default, the wireless network hosted from your Raspberry Pi exists separately from the parent network connected via Ethernet. In this arrangement, devices connected to the parent network cannot directly communicate with devices connected to the wireless network hosted from your Raspberry Pi. If you want connected wireless devices to be able to communicate with devices on the parent network, you can configure your Raspberry Pi as a https://en.wikipedia.org/wiki/Network_bridge[network bridge]. With a network bridge in place, each device connected to the Pi-hosted wireless network is assigned an IP address in the parent network. + +In the diagram below, the laptop exists in the same IP block as the router and wired clients: + +image::images/bridge-network.png[] + +The following steps describe how to set up a network bridge on your Raspberry Pi to enable communication between wireless clients and the parent network. + +First, create a network bridge interface: + +[source,console] +---- +$ sudo nmcli connection add type bridge con-name 'Bridge' ifname bridge0 +---- + +Next, add your device's Ethernet connection to the parent network to the bridge: + +[source,console] +---- +$ sudo nmcli connection add type ethernet slave-type bridge \ + con-name 'Ethernet' ifname eth0 master bridge0 +---- + +Finally, add your wireless hotspot connection to the bridge. You can either add an existing hotspot interface or create a new one: + +* If you have already created a wireless hotspot connection using the instructions above, add the existing interface to the bridge with the following command: ++ +[source,console] +---- +$ sudo nmcli connection modify 'Hotspot' master bridge0 +---- + +* If you have not yet created a wireless hotspot connection, create a new interface and add it to the bridge with a single command, replacing the `` and `` placeholders with a network name and password of your choice, respectively: ++ +[source,console?prompt=$] +---- +$ sudo nmcli connection add con-name 'Hotspot' \ + ifname wlan0 type wifi slave-type bridge master bridge0 \ + wifi.mode ap wifi.ssid wifi-sec.key-mgmt wpa-psk \ + wifi-sec.proto rsn wifi-sec.pairwise ccmp \ + wifi-sec.psk +---- + + +Now that you've configured your bridge, it's time to activate it. Run the following command to activate the bridge: + +[source,console] +---- +$ sudo nmcli connection up Bridge +---- + +And run the following command to start hosting your wireless network: + +[source,console] +---- +$ sudo nmcli connection up Hotspot +---- + +You can use the `nmcli device` command to verify that the bridge, Ethernet interface, and wireless hotspot interface are all active. + +TIP: Use a tool such as https://github.com/royhills/arp-scan[arp-scan] to check if devices on the parent network are accessible once connected to the hotspot. diff --git a/documentation/asciidoc/computers/configuration/images/blanking.png b/documentation/asciidoc/computers/configuration/images/blanking.png new file mode 100644 index 0000000000..6ec7406c7a Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/blanking.png differ diff --git a/documentation/asciidoc/computers/configuration/images/bridge-network.png b/documentation/asciidoc/computers/configuration/images/bridge-network.png new file mode 100644 index 0000000000..a016be514f Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/bridge-network.png differ diff --git a/documentation/asciidoc/computers/configuration/images/create-hotspot-dialog.png b/documentation/asciidoc/computers/configuration/images/create-hotspot-dialog.png new file mode 100644 index 0000000000..42085c98a7 Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/create-hotspot-dialog.png differ diff --git a/documentation/asciidoc/computers/configuration/images/create-hotspot-network-menu.png b/documentation/asciidoc/computers/configuration/images/create-hotspot-network-menu.png new file mode 100644 index 0000000000..39ce5334d3 Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/create-hotspot-network-menu.png differ diff --git a/documentation/asciidoc/computers/configuration/images/host-a-network.png b/documentation/asciidoc/computers/configuration/images/host-a-network.png new file mode 100644 index 0000000000..4f7c894774 Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/host-a-network.png differ diff --git a/documentation/asciidoc/computers/configuration/images/key.png b/documentation/asciidoc/computers/configuration/images/key.png old mode 100644 new mode 100755 index 0242eeb984..ca0c65b118 Binary files a/documentation/asciidoc/computers/configuration/images/key.png and b/documentation/asciidoc/computers/configuration/images/key.png differ diff --git a/documentation/asciidoc/computers/configuration/images/network-hidden-authentication.png b/documentation/asciidoc/computers/configuration/images/network-hidden-authentication.png new file mode 100644 index 0000000000..87f12a9aaa Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/network-hidden-authentication.png differ diff --git a/documentation/asciidoc/computers/configuration/images/network-hidden.png b/documentation/asciidoc/computers/configuration/images/network-hidden.png new file mode 100644 index 0000000000..42d0d79480 Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/network-hidden.png differ diff --git a/documentation/asciidoc/computers/configuration/images/pi-configuration.png b/documentation/asciidoc/computers/configuration/images/pi-configuration.png new file mode 100644 index 0000000000..c7bee2fad3 Binary files /dev/null and b/documentation/asciidoc/computers/configuration/images/pi-configuration.png differ diff --git a/documentation/asciidoc/computers/configuration/images/proxy-edit-sudoers.png b/documentation/asciidoc/computers/configuration/images/proxy-edit-sudoers.png deleted file mode 100644 index 3a76f38a37..0000000000 Binary files a/documentation/asciidoc/computers/configuration/images/proxy-edit-sudoers.png and /dev/null differ diff --git a/documentation/asciidoc/computers/configuration/images/proxy-environment-variables.png b/documentation/asciidoc/computers/configuration/images/proxy-environment-variables.png deleted file mode 100644 index 137484c735..0000000000 Binary files a/documentation/asciidoc/computers/configuration/images/proxy-environment-variables.png and /dev/null differ diff --git a/documentation/asciidoc/computers/configuration/images/raspi-config.png b/documentation/asciidoc/computers/configuration/images/raspi-config.png index 2aff53913a..e1af511809 100644 Binary files a/documentation/asciidoc/computers/configuration/images/raspi-config.png and b/documentation/asciidoc/computers/configuration/images/raspi-config.png differ diff --git a/documentation/asciidoc/computers/configuration/images/wifi2.png b/documentation/asciidoc/computers/configuration/images/wifi2.png old mode 100644 new mode 100755 index 7320f0809c..536abb0c13 Binary files a/documentation/asciidoc/computers/configuration/images/wifi2.png and b/documentation/asciidoc/computers/configuration/images/wifi2.png differ diff --git a/documentation/asciidoc/computers/configuration/kernel-command-line-config.adoc b/documentation/asciidoc/computers/configuration/kernel-command-line-config.adoc index bb228e1d7f..27fbc1c260 100644 --- a/documentation/asciidoc/computers/configuration/kernel-command-line-config.adoc +++ b/documentation/asciidoc/computers/configuration/kernel-command-line-config.adoc @@ -1,60 +1,71 @@ -== The Kernel Command Line +== Kernel command line (`cmdline.txt`) -The Linux kernel accepts a command line of parameters during boot. On the Raspberry Pi, this command line is defined in a file in the boot partition, called cmdline.txt. This is a simple text file that can be edited using any text editor, e.g. Nano. +The Linux kernel accepts a collection of command line parameters during boot. On the Raspberry Pi, this command line is defined in a file in the boot partition, called `cmdline.txt`. You can edit this text file with any text editor. +[source,console] ---- -sudo nano /boot/cmdline.txt +$ sudo nano /boot/firmware/cmdline.txt ---- -Note that we have to use `sudo` to edit anything in the boot partition, and that all parameters in `cmdline.txt` must be on the same line (no carriage returns). +IMPORTANT: Put all parameters in `cmdline.txt` on the same line. Do _not_ use newlines. -The command line that was passed to the kernel at boot time can be displayed using `cat /proc/cmdline`. It will not be exactly the same as that in `cmdline.txt` as the firmware can make changes to it prior to launching the kernel. +To view the command line passed to the kernel at boot time, run the following command: -=== Command Line Options +[source,console] +---- +$ cat /proc/cmdline +---- + +Because Raspberry Pi firmware makes changes to the command line before launching the kernel, the output of this command will not exactly match the contents of `cmdline.txt`. + +=== Command line options + +There are many kernel command line parameters, some of which are defined by the kernel itself. Others are defined by code that the kernel may be using, such as the Plymouth splash screen system. -There are many kernel command line parameters, some of which are defined by the kernel. Others are defined by code that the kernel may be using, such as the Plymouth splash screen system. +==== Standard entries -[discrete] -===== Standard Entries +`console`:: defines the serial console. There are usually two entries: -* console: defines the serial console. There are usually two entries: - ** `console=serial0,115200` - ** `console=tty1` -* root: defines the location of the root filesystem, e.g. `root=/dev/mmcblk0p2` means multimedia card block 0 partition 2. -* rootfstype: defines what type of filesystem the rootfs uses, e.g. `rootfstype=ext4` -* elevator: specifies the I/O scheduler to use. `elevator=deadline` means the kernel imposes a deadline on all I/O operations to prevent request starvation. -* quiet: sets the default kernel log level to `KERN_WARNING`, which suppresses all but very serious log messages during boot. +* `console=serial0,115200` +* `console=tty1` -[discrete] -===== Display Entries in FKMS and KMS modes +`root`:: defines the location of the root filesystem. e.g. `root=/dev/mmcblk0p2` means multimedia card block 0 partition 2. -The firmware automatically adds a preferred resolution and overscan settings via an entry such as: +`rootfstype`:: defines what type of filesystem the rootfs uses, e.g. `rootfstype=ext4`. -[source] +`quiet`:: sets the default kernel log level to `KERN_WARNING`, which suppresses all but very serious log messages during boot. + +==== Set the KMS display mode + +The legacy firmware and FKMS display modes used in earlier versions of Raspberry Pi OS are no longer supported. Instead, recent OS versions use KMS (Kernel Mode Setting). + +If no `video` entry is present in `cmdline.txt`, Raspberry Pi OS uses the https://en.wikipedia.org/wiki/Extended_Display_Identification_Data[EDID] of the HDMI-connected monitor to automatically pick the best resolution supported by your display based on information in the Linux kernel. In Raspberry Pi OS Lite or console mode, you must customise the `video` entry to control resolution and rotation. + +[source,bash] ---- -video=HDMI-A-1:1920x1080M@60,margin_left=0,margin_right=0,margin_top=0,margin_bottom=0 +video=HDMI-A-1:1920x1080M@60 ---- -This default entry can be modified by duplicating the entry above manually in /boot/cmdline.txt and making required changes to the margin parameters. In addition, it is possible to add rotation and reflect parameters as documented in the standard https://github.com/raspberrypi/linux/blob/rpi-5.4.y/Documentation/fb/modedb.rst[Linux framebuffer documentation]. By default the `margin_*` options are set from the `overscan` entries in config.txt, if present. The firmware can be prevented from making any KMS specific changes to the command line by adding `disable_fw_kms_setup=1` to `config.txt` - -An example entry may be as follows: +In addition, it is possible to add rotation and reflect parameters as documented in the standard https://github.com/raspberrypi/linux/blob/rpi-6.1.y/Documentation/fb/modedb.rst[Linux framebuffer documentation]. The following example defines a display named `HDMI-A-1` at a resolution of 1080p, a refresh rate of 60Hz, 90 degrees of rotation, and a reflection over the X axis: -[source] +[source,bash] ---- -video=HDMI-A-1:1920x1080M@60,margin_left=0,margin_right=0,margin_top=0,margin_bottom=0,rotate=90,reflect_x` +video=HDMI-A-1:1920x1080M@60,rotate=90,reflect_x ---- -Possible options for the display type, the first part of the `video=` entry, are as follows: +You must specify the resolution explicitly when specifying rotation and reflection parameters. -[cols="^,<"] +Possible options for the display type - the first part of the `video=` entry - include: + +[cols="1m,3"] |=== -| video option | Display +| Video Option | Display | HDMI-A-1 -| HDMI 1 (HDMI 0 on silkscreen of Pi4B, HDMI on single HDMI boards) +| HDMI 1 (HDMI 0 on silkscreen of Raspberry Pi 4B, HDMI on single HDMI boards) | HDMI-A-2 -| HDMI 2 (HDMI 1 on silkscreen of Pi4B) +| HDMI 2 (HDMI 1 on silkscreen of Raspberry Pi 4B) | DSI-1 | DSI or DPI @@ -63,12 +74,21 @@ Possible options for the display type, the first part of the `video=` entry, ar | Composite |=== -[discrete] -===== Other Entries (not exhaustive) +==== Other entries + +This section contains some of the other entries you can use in the kernel command line. This list is not exhaustive. + +`splash`:: tells the boot to use a splash screen via the Plymouth module. + +`plymouth.ignore-serial-consoles`:: normally if the Plymouth module is enabled it will prevent boot messages from appearing on any serial console which may be present. This flag tells Plymouth to ignore all serial consoles, making boot messages visible again, as they would be if Plymouth was not running. + +`dwc_otg.lpm_enable=0`:: turns off Link Power Management (LPM) in the `dwc_otg` driver, which drives the USB controller built into the processor used on Raspberry Pi computers. On Raspberry Pi 4, this controller is disabled by default, and is only connected to the USB type C power input connector. The USB-A ports on Raspberry Pi 4 are driven by a separate USB controller which is not affected by this setting. + +`dwc_otg.speed`:: sets the speed of the USB controller built into the processor on Raspberry Pi computers. `dwc_otg.speed=1` will set it to full speed (USB 1.0), which is slower than high speed (USB 2.0). This option should not be set except during troubleshooting of problems with USB devices. + +`smsc95xx.turbo_mode`:: enables/disables the wired networking driver turbo mode. `smsc95xx.turbo_mode=N` turns turbo mode off. + +`usbhid.mousepoll`:: specifies the mouse polling interval. If you have problems with a slow or erratic wireless mouse, setting this to 0 with `usbhid.mousepoll=0` might help. + +`drm.edid_firmware=HDMI-A-1:edid/your_edid.bin`:: Override your monitor's built-in EDID with the contents of `/usr/lib/firmware/edid/your_edid.bin`. -* splash: tells the boot to use a splash screen via the Plymouth module. -* plymouth.ignore-serial-consoles: normally if the Plymouth module is enabled it will prevent boot messages from appearing on any serial console which may be present. This flag tells Plymouth to ignore all serial consoles, making boot messages visible again, as they would be if Plymouth was not running. -* dwc_otg.lpm_enable: turns off Link Power Management (LPM) in the dwc_otg driver; the dwc_otg driver is the driver for the USB controller built into the Raspberry Pi. -* dwc_otg.speed: sets the speed of the USB controller. `dwc_otg.speed=1` will set it to full speed (USB 1.0), which is slower than high speed (USB 2.0). This option should not be set except during troubleshooting of problems with USB devices. -* smsc95xx.turbo_mode: enables/disables the wired networking driver turbo mode. `smsc95xx.turbo_mode=N` turns turbo mode off. -* usbhid.mousepoll: specifies the mouse polling interval. If you have problems with a slow or erratic wireless mouse, setting this to 0 might help: `usbhid.mousepoll=0`. diff --git a/documentation/asciidoc/computers/configuration/led_blink_warnings.adoc b/documentation/asciidoc/computers/configuration/led_blink_warnings.adoc index 99730ae173..5eebc6d7c1 100644 --- a/documentation/asciidoc/computers/configuration/led_blink_warnings.adoc +++ b/documentation/asciidoc/computers/configuration/led_blink_warnings.adoc @@ -1,6 +1,6 @@ -== LED Warning Flash Codes +== LED warning flash codes -If a Pi fails to boot for some reason, or has to shut down, in many cases an LED will be flashed a specific number of times to indicate what happened. The LED will blink for a number of long flashes (0 or more), then short flashes, to indicate the exact status. In most cases, the pattern will repeat after a 2 second gap. +If a Raspberry Pi fails to boot for some reason, or has to shut down, in many cases an LED will flash a specific number of times to indicate what happened. The LED will blink for a number of long flashes (0 or more), then produce short flashes, to indicate the exact status. In most cases, the pattern will repeat after a two-second gap. [cols="^,^,"] |=== @@ -30,6 +30,10 @@ If a Pi fails to boot for some reason, or has to shut down, in many cases an LED | 10 | In HALT state +| 1 +| 2 +| SD card overcurrent detected + | 2 | 1 | Partition not FAT @@ -44,19 +48,27 @@ If a Pi fails to boot for some reason, or has to shut down, in many cases an LED | 2 | 4 -| File signature/hash mismatch - Pi 4 +| File signature/hash mismatch - Pi 4 and Pi 5 | 3 | 1 -| SPI EEPROM error - Pi 4 +| SPI EEPROM error - Pi 4 and Pi 5 | 3 | 2 -| SPI EEPROM is write protected - Pi 4 +| SPI EEPROM is write protected - Pi 4 and Pi 5 | 3 | 3 -| I2C error - Pi 4 +| I2C error - Pi 4 and Pi 5 + +| 3 +| 4 +| Secure-boot configuration is not valid + +| 4 +| 3 +| RP1 not found | 4 | 4 diff --git a/documentation/asciidoc/computers/configuration/localisation.adoc b/documentation/asciidoc/computers/configuration/localisation.adoc index bc335a70c3..47fb2aba58 100644 --- a/documentation/asciidoc/computers/configuration/localisation.adoc +++ b/documentation/asciidoc/computers/configuration/localisation.adoc @@ -1,15 +1,5 @@ -== Localising your Raspberry Pi +== Localise your Raspberry Pi -You can set your Raspberry Pi up to match your regional settings. +You can configure the UI language, keyboard layout, and time zone of Raspberry Pi OS with the xref:configuration.adoc#raspi-config[`raspi-config`] tool. -=== Changing the Language -If you've installed Raspberry Pi OS using NOOBS, it should automatically pick up the same language you were using within NOOBS. But if you want to select a different language, or if you've installed Raspberry Pi OS from a standalone image, use xref:configuration.adoc#change-locale[raspi-config]. - -=== Configuring the Keyboard - -If you've installed Raspberry Pi OS using NOOBS, it should automatically pick up the same keyboard you were using in NOOBS. But if you want to select a different keyboard, or if you've installed Raspberry Pi OS from a standalone image, use xref:configuration.adoc#change-keyboard-layout[raspi-config]. - -=== Changing the Timezone - -Once again, this is something you can change using the xref:configuration.adoc#change-timezone[raspi-config] tool. diff --git a/documentation/asciidoc/computers/configuration/pin-configuration.adoc b/documentation/asciidoc/computers/configuration/pin-configuration.adoc index c1d9373a65..d17bcbd9c2 100644 --- a/documentation/asciidoc/computers/configuration/pin-configuration.adoc +++ b/documentation/asciidoc/computers/configuration/pin-configuration.adoc @@ -1,122 +1,128 @@ -== Changing the default pin configuration +== Change the default pin configuration -WARNING: This feature is intended for advanced users. +NOTE: Custom default pin configurations via user-provided Device Tree blobs has been deprecated. -As of July 2014, the Raspberry Pi firmware supports custom default pin configurations through a user-provided Device Tree blob file. To find out whether your firmware is recent enough, please run `vcgencmd version`. - -=== Device Pins During Boot Sequence +=== Device pins during boot sequence During the bootup sequence, the GPIO pins go through various actions. -. Power-on -- pins default to inputs with default pulls; the default pulls for each pin are described in the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[datasheet] -. Setting by the bootrom -. Setting by `bootcode.bin` -. Setting by `dt-blob.bin` (this page) -. Setting by the xref:config_txt.adoc#gpio-control[GPIO command] in `config.txt` -. Additional firmware pins (e.g. UARTS) -. Kernel/Device Tree +* Power-on - pins default to inputs with default pulls, which are described in the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[datasheet] +* Setting by the bootrom +* Setting by `bootcode.bin` +* Setting by `dt-blob.bin` (this page) +* Setting by the xref:config_txt.adoc#gpio-control[GPIO command] in `config.txt` +* Additional firmware pins (e.g. UARTS) +* Kernel/Device Tree On a soft reset, the same procedure applies, except for default pulls, which are only applied on a power-on reset. -Note that it may take a few seconds to get from stage 1 to stage 4. During that time, the GPIO pins may not be in the state expected by attached peripherals (as defined in `dtblob.bin` or `config.txt`). Since different GPIO pins have different default pulls, you should do *one of the following* for your peripheral: +It may take a few seconds to run through the process. During this time, the GPIO pins may not be in the state expected by attached peripherals (as defined in `dt-blob.bin` or `config.txt`). Since different GPIO pins have different default pulls, you should do *one of the following* for your peripheral: -* Choose a GPIO pins that defaults to pulls as required by the peripheral on reset -* Delay the peripheral's startup until stage 4/5 has been reached -* Add an appropriate pull-up/-down resistor +* Choose a GPIO pin that defaults to pulls as required by the peripheral on reset +* Delay the peripheral's startup until the actions are completed +* Add an appropriate pull-up/pull-down resistor -=== Providing a Custom Device Tree Blob +=== Provide a custom Device Tree blob In order to compile a Device Tree source (`.dts`) file into a Device Tree blob (`.dtb`) file, the Device Tree compiler must be installed by running `sudo apt install device-tree-compiler`. The `dtc` command can then be used as follows: +[source,console] ---- -sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob.dts +$ sudo dtc -I dts -O dtb -o /boot/firmware/dt-blob.bin dt-blob.dts ---- Similarly, a `.dtb` file can be converted back to a `.dts` file, if required. +[source,console] ---- -dtc -I dtb -O dts -o dt-blob.dts /boot/dt-blob.bin +$ dtc -I dtb -O dts -o dt-blob.dts /boot/firmware/dt-blob.bin ---- === Sections of the `dt-blob` -The `dt-blob.bin` is used to configure the binary blob (VideoCore) at boot time. It is not currently used by the Linux kernel, but a kernel section will be added at a later stage, when we reconfigure the Raspberry Pi kernel to use a dt-blob for configuration. The dt-blob can configure all versions of the Raspberry Pi, including the Compute Module, to use the alternative settings. The following sections are valid in the dt-blob: +The `dt-blob.bin` is used to configure the binary blob (VideoCore) at boot time. It is not currently used by the Linux kernel. The dt-blob can configure all versions of the Raspberry Pi, including the Compute Module, to use the alternative settings. The following sections are valid in the dt-blob: + +==== `videocore` -. `videocore` -+ This section contains all of the VideoCore blob information. All subsequent sections must be enclosed within this section. -. `pins_*` - - There are a number of separate `pins_*` sections, based on particular Raspberry Pi models, namely: - -* *pins_rev1* Rev1 pin setup. There are some differences because of the moved I2C pins. -* *pins_rev2* Rev2 pin setup. This includes the additional codec pins on P5. -* *pins_bplus1* Model B+ rev 1.1, including the full 40pin connector. -* *pins_bplus2* Model B+ rev 1.2, swapping the low-power and lan-run pins. -* *pins_aplus* Model A+, lacking Ethernet. -* *pins_2b1* Pi 2 Model B rev 1.0; controls the SMPS via I2C0. -* *pins_2b2* Pi 2 Model B rev 1.1; controls the SMPS via software I2C on 42 and 43. -* *pins_3b1* Pi 3 Model B rev 1.0 -* *pins_3b2* Pi 3 Model B rev 1.2 -* *pins_3bplus* Pi 3 Model B+ -* *pins_3aplus* Pi 3 Model A+ -* *pins_pi0* The Pi Zero -* *pins_pi0w* The Pi Zero W -* *pins_cm* The Compute Module. The default for this is the default for the chip, so it is a useful source of information about default pull ups/downs on the chip. -* *pins_cm3* The Compute Module version 3 -+ +==== `pins_*` + +There are a number of separate `pins_*` sections, based on particular Raspberry Pi models, namely: + +* `pins_rev1`: Rev1 pin setup. There are some differences because of the moved I2C pins. +* `pins_rev2`: Rev2 pin setup. This includes the additional codec pins on P5. +* `pins_bplus1`: Raspberry Pi 1 Model B+ rev 1.1, including the full 40pin connector. +* `pins_bplus2`: Raspberry Pi 1 Model B+ rev 1.2, swapping the low-power and lan-run pins. +* `pins_aplus`: Raspberry Pi 1 Model A+, lacking Ethernet. +* `pins_2b1`: Raspberry Pi 2 Model B rev 1.0; controls the SMPS via I2C0. +* `pins_2b2`: Raspberry Pi 2 Model B rev 1.1; controls the SMPS via software I2C on 42 and 43. +* `pins_3b1`: Raspberry Pi 3 Model B rev 1.0 +* `pins_3b2`: Raspberry Pi 3 Model B rev 1.2 +* `pins_3bplus`: Raspberry Pi 3 Model B+ +* `pins_3aplus`: Raspberry Pi 3 Model A+ +* `pins_pi0`: Raspberry Pi Zero +* `pins_pi0w`: Raspberry Pi Zero W +* `pins_pi02w`: Raspberry Pi Zero 2 W +* `pins_cm`: Raspberry Pi Compute Module 1. The default for this is the default for the chip, so it is a useful source of information about default pull-ups/pull-downs on the chip. +* `pins_cm3`: Raspberry Pi Compute Module 3 +* `pins_cm3plus`: Raspberry Pi Compute Module 3+ +* `pins_cm4s`: Raspberry Pi Compute Module 4S +* `pins_cm4`: Raspberry Pi Compute Module 4 + Each `pins_*` section can contain `pin_config` and `pin_defines` sections. -. `pin_config` -+ +==== `pin_config` + The `pin_config` section is used to configure the individual pins. Each item in this section must be a named pin section, such as `pin@p32`, meaning GPIO32. There is a special section `pin@default`, which contains the default settings for anything not specifically named in the pin_config section. -. `pin@pinname` -+ +==== `pin@pinname` + This section can contain any combination of the following items: - .. `polarity` - *** `active_high` - *** `active_low` - .. `termination` - *** `pull_up` - *** `pull_down` - *** `no_pulling` - .. `startup_state` - *** `active` - *** `inactive` - .. `function` - *** `input` - *** `output` - *** `sdcard` - *** `i2c0` - *** `i2c1` - *** `spi` - *** `spi1` - *** `spi2` - *** `smi` - *** `dpi` - *** `pcm` - *** `pwm` - *** `uart0` - *** `uart1` - *** `gp_clk` - *** `emmc` - *** `arm_jtag` - .. `drive_strength_mA` + * `polarity` + ** `active_high` + ** `active_low` + * `termination` + ** `pull_up` + ** `pull_down` + ** `no_pulling` + * `startup_state` + ** `active` + ** `inactive` + * `function` + ** `input` + ** `output` + ** `sdcard` + ** `i2c0` + ** `i2c1` + ** `spi` + ** `spi1` + ** `spi2` + ** `smi` + ** `dpi` + ** `pcm` + ** `pwm` + ** `uart0` + ** `uart1` + ** `gp_clk` + ** `emmc` + ** `arm_jtag` + * `drive_strength_mA` ++ The drive strength is used to set a strength for the pins. Please note that you can only specify a single drive strength for the bank. <8> and <16> are valid values. -. `pin_defines` -+ -This section is used to set specific VideoCore functionality to particular pins. This enables the user to move the camera power enable pin to somewhere different, or move the HDMI hotplug position: things that Linux does not control. Please refer to the example DTS file below. +==== `pin_defines` + +This section is used to set specific VideoCore functionality to particular pins. This enables the user to move the camera power enable pin to somewhere different, or move the HDMI hotplug position: these are things that Linux does not control. Please refer to the example DTS file below. -=== Clock Configuration +=== Clock configuration It is possible to change the configuration of the clocks through this interface, although it can be difficult to predict the results! The configuration of the clocking system is very complex. There are five separate PLLs, and each one has its own fixed (or variable, in the case of PLLC) VCO frequency. Each VCO then has a number of different channels which can be set up with a different division of the VCO frequency. Each of the clock destinations can be configured to come from one of the clock channels, although there is a restricted mapping of source to destination, so not all channels can be routed to all clock destinations. Here are a couple of example configurations that you can use to alter specific clocks. We will add to this resource when requests for clock configurations are made. +[source,kotlin] ---- clock_routing { vco@PLLA { freq = <1966080000>; }; @@ -133,7 +139,7 @@ clock_setup { The above will set the PLLA to a source VCO running at 1.96608GHz (the limits for this VCO are 600MHz - 2.4GHz), change the APER channel to /4, and configure GPCLK0 to be sourced from PLLA through APER. This is used to give an audio codec the 12288000Hz it needs to produce the 48000 range of frequencies. -=== Sample Device Tree Source File +=== Sample Device Tree source file -The example file comes from the firmware repository, https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts. This is the master Raspberry Pi blob, from which others are usually derived. +The firmware repository contains a https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts[master Raspberry Pi blob] from which others are usually derived. diff --git a/documentation/asciidoc/computers/configuration/raspi-config.adoc b/documentation/asciidoc/computers/configuration/raspi-config.adoc index e60292fe23..483cb66bce 100644 --- a/documentation/asciidoc/computers/configuration/raspi-config.adoc +++ b/documentation/asciidoc/computers/configuration/raspi-config.adoc @@ -1,258 +1,813 @@ [[raspi-config]] -== The `raspi-config` Tool +== `raspi-config` -`raspi-config` is the Raspberry Pi configuration tool originally written by https://github.com/asb[Alex Bradbury]. You will be shown `raspi-config` on first booting into Raspberry Pi OS. To open the configuration tool after this,a simply run the following from the command line: +`raspi-config` helps you configure your Raspberry Pi. Changes to `raspi-config` will modify xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] and other configuration files. ----- -sudo raspi-config ----- - -The `sudo` is required because you will be changing files that you do not own as the `pi` user. +=== Getting started -NOTE: If you are using the Raspberry Pi desktop then you can use the graphical `Raspberry Pi Configuration` application from the `Preferences` menu to configure your Raspberry Pi. +To open the configuration tool from the desktop GUI, go to **Preferences** > **Raspberry Pi Configuration**. -You should then see a blue screen with options in a grey box: +Alternatively, run the following command to access the configuration tool via the terminal: -image::images/raspi-config.png[raspi-config main screen] +[source,console] +---- +$ sudo raspi-config +---- -NOTE: The menu shown may differ slightly. +TIP: Some advanced configuration is available in the `raspi-config` CLI, but not the Raspberry Pi Configuration GUI. -Use the `up` and `down` arrow keys to move the highlighted selection between the options available. Pressing the `right` arrow key will jump out of the Options menu and take you to the `` or `` options using the **Right** arrow or **Tab**. +* Return to the settings list using the **Left** arrow or **Tab**. +* Type a letter to jump ahead alphabetically. For example, type `E` to jump ahead to 'Europe' in the time zone list. -NOTE: In long lists of option values (like the list of timezone cities), you can also type a letter to skip to that section of the list. For example, entering `L` will skip you to Lisbon, just two options away from London, to save you scrolling all the way through the alphabet. +image::images/raspi-config.png[raspi-config main screen] [[menu-options]] -=== List of Options - -NOTE: Due to the continual development of the `raspi-config` tool, the list of options below may not be completely up to date. Also please be aware that different models of Raspberry Pi may have different options available. +=== System options -==== System Options +Configure parts of the boot, login, and networking process, along with other system level changes. -The system options submenu allows you to make configuration changes to various parts of the boot, login and networking process, along with some other system level changes. +==== Wireless LAN -===== Wireless LAN +Configure Wi-Fi SSID and passphrase. -Allows setting of the wireless LAN SSID and passphrase. +==== Audio -===== Audio +Specify the audio output destination. -Specifiy the audio output destination. +==== Password -[[change-user-password]] -===== Password +Change your password. -The default user on Raspberry Pi OS is `pi` with the password `raspberry`. You can change that here. Read about other xref:using_linux.adoc#linux-users[users]. +For more information, see xref:configuration.adoc#change-user-password[Change a user's password]. [[hostname]] -===== Hostname +==== Hostname -Set the visible name for this Pi on a network. +Set the visible xref:remote-access.adoc#resolve-raspberrypi-local-with-mdns[mDNS] name for this Raspberry Pi on a network. [[boot-options]] -===== Boot / Auto login +==== Boot/Auto login -From this submenu you can select whether to boot to console or desktop and whether you need to log in or not. If you select automatic login, you will be logged in as the `pi` user. +Boot to console or desktop with the option of an automatic login to your current user account. -===== Network at Boot +==== Network at boot -Use this option to wait for a network connection before letting boot proceed. +Wait for a network connection before proceeding with boot. -===== Splash Screen +==== Splash screen -Enable or disable the splash screen displayed at boot time +Enable or disable the splash screen displayed at boot time. -===== Power LED +==== Power LED -If the model of Pi permits it, you can change the behaviour of the power LED using this option. +If your Raspberry Pi model allows, change the behaviour of the power LED. -==== Display Options +==== Browser -[[resolution]] -===== Resolution +Change the default web browser. -Define the default HDMI/DVI video resolution to use when the system boots without a TV or monitor being connected. This can have an effect on RealVNC if the VNC option is enabled. +=== Display options [[underscan]] -===== Underscan +==== Underscan -Old TV sets had a significant variation in the size of the picture they produced; some had cabinets that overlapped the screen. TV pictures were therefore given a black border so that none of the picture was lost; this is called overscan. Modern TVs and monitors don't need the border, and the signal doesn't allow for it. If the initial text shown on the screen disappears off the edge, you need to enable overscan to bring the border back. +NOTE: Unavailable when running Wayland. -Any changes will take effect after a reboot. You can have greater control over the settings by editing xref:config_txt.adoc[config.txt]. +If the initial text shown on the screen disappears off the edge, enable overscan to adjust the border. On some displays, particularly monitors, disabling overscan will make the picture fill the whole screen and remove the black border. -On some displays, particularly monitors, disabling overscan will make the picture fill the whole screen and correct the resolution. For other displays, it may be necessary to leave overscan enabled and adjust its values. +==== Screen blanking -[[pixel-doubling]] -===== Pixel Doubling +Enable or disable screen blanking. -Enable/disable 2x2 pixel mapping. +[[resolution]] +==== VNC resolution -===== Composite Video +Define the video resolution to use in xref:configuration.adoc#setting-up-a-headless-raspberry-pi[headless] setups. -On the Raspberry Pi4, enable composite video. On models prior to the Raspberry Pi4, composite video is enabled by default so this option is not displayed. +==== Composite -===== Screen Blanking +Enable or disable composite video. -Enable or disable screen blanking. +==== 4Kp60 HDMI + +Enable or disable 4Kp60 resolution for HDMI outputs. [[interfacing-options]] -==== Interfacing Options +=== Interface options -In this submenu there are the following options to enable/disable: Camera, SSH, VNC, SPI, I2C, Serial, 1-wire, and Remote GPIO. +Enable and disable various physical and virtual interfaces. -[[camera]] -===== Camera +[[ssh]] +==== SSH -Enable/disable the CSI camera interface. +Enable or disable remote terminal access to your Raspberry Pi using SSH. -[[ssh]] -===== SSH +SSH allows you to remotely access the command line of the Raspberry Pi from another computer. SSH is disabled by default. For more information about SSH, see the xref:remote-access.adoc#ssh[SSH documentation]. -Enable/disable remote command line access to your Pi using SSH. +[[rpi-connect]] +==== RPi Connect -SSH allows you to remotely access the command line of the Raspberry Pi from another computer. SSH is disabled by default. Read more about using SSH on the xref:remote-access.adoc#ssh[SSH documentation page]. If connecting your Pi directly to a public network, you should not enable SSH unless you have set up secure passwords for all users. +Enable or disable xref:../services/connect.adoc[Raspberry Pi Connect], which provides the ability to access your Raspberry Pi remotely with no manual network configuration. [[VNC]] -===== VNC +==== VNC -Enable/disable the RealVNC virtual network computing server. +Enable or disable the WayVNC or RealVNC virtual network computing server. [[spi]] -===== SPI +==== SPI -Enable/disable SPI interfaces and automatic loading of the SPI kernel module, needed for products such as PiFace. +Enable or disable SPI interfaces and automatic loading of the SPI kernel module. [[i2c]] -===== I2C +==== I2C -Enable/disable I2C interfaces and automatic loading of the I2C kernel module. +Enable or disable I2C interfaces and automatic loading of the I2C kernel module. [[serial]] -===== Serial +==== Serial port -Enable/disable shell and kernel messages on the serial connection. +Enable or disable shell and kernel messages on the serial connection. [[one-wire]] -===== 1-wire +==== 1-Wire -Enable/disable the Dallas 1-wire interface. This is usually used for DS18B20 temperature sensors. +Enable or disable the Dallas 1-wire interface, often used for DS18B20 temperature sensors. -===== Remote GPIO +==== Remote GPIO Enable or disable remote access to the GPIO pins. -==== Performance Options +=== Performance options [[overclock]] ==== Overclock -On some models it is possible to overclock your Raspberry Pi's CPU using this tool. The overclocking you can achieve will vary; overclocking too high may result in instability. Selecting this option shows the following warning: +If your Raspberry Pi model allows, overclock the CPU. Overclocking potential varies between individual Raspberry Pi devices, even within the same model. Overclocking too high may result in instability. -*Be aware that overclocking may reduce the lifetime of your Raspberry Pi.* If overclocking at a certain level causes system instability, try a more modest overclock. Hold down the Shift key during boot to temporarily disable overclocking. +WARNING: *Overclocking may reduce the lifetime of your Raspberry Pi.* If overclocking at a certain level causes system instability, try a more modest overclock. Hold down the *Shift* key during boot to temporarily disable overclocking. [[memory-split]] -===== GPU Memory +==== GPU memory Change the amount of memory made available to the GPU. -===== Overlay File System +==== Overlay file system -Enable or disable a read-only filesystem +Enable or disable a read-only filesystem. -===== Fan +==== Fan -Set the behaviour of a GPIO connected fan +Customise the behaviour of the GPIO-connected https://www.raspberrypi.com/products/raspberry-pi-4-case-fan/[Raspberry Pi 4 Case Fan]. Not applicable to other fan models. [[localisation-options]] -==== Localisation Options +=== Localisation options -The localisation submenu gives you these options to choose from: keyboard layout, time zone, locale, and wireless LAN country code. +Configure location and country-related options. [[change-locale]] -===== Locale +==== Locale Select a locale, for example `en_GB.UTF-8 UTF-8`. [[change-timezone]] -===== Time Zone +==== Time zone -Select your local time zone, starting with the region, e.g. Europe, then selecting a city, e.g. London. Type a letter to skip down the list to that point in the alphabet. +Set your local time zone in the format `Region/City`, for example 'Europe/London'. Type a letter to jump to that letter in the list. [[change-keyboard-layout]] -===== Keyboard +==== Keyboard -This option opens another menu which allows you to select your keyboard layout. It will take a long time to display while it reads all the keyboard types. Changes usually take effect immediately, but may require a reboot. +Open a menu where you can select your keyboard layout. Changes usually take effect immediately, but may require a reboot. Type a letter to jump to that letter in the list. -===== WLAN Country +==== WLAN country -This option sets the country code for your wireless network. +Set the country code for your wireless network. [[advanced-options]] -==== Advanced Options +=== Advanced options + + +WARNING: Changes to advanced options may prevent your Raspberry Pi from working as intended. Avoid configuring advanced options unless instructed by a Raspberry Pi engineer. [[expand-filesystem]] -===== Expand Filesystem +==== Expand filesystem + +Expand your OS partition to fill the whole storage device, giving you more space to use for files. Reboot your Raspberry Pi to complete this action. Normally, Raspberry Pi OS runs this action on first boot. This option can be useful if you clone your OS to a separate storage device with more capacity than the original. + +WARNING: There is no confirmation step. Selecting the option begins the partition expansion immediately. + +==== Network interface names + +Enable or disable predictable network interface names. + +==== Network proxy settings + +Configure the network's proxy settings. + +==== Boot order + +On Raspberry Pi 4 and later, specify whether to boot from USB or network when no SD card or SSD has been detected. For more information, see xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration]. + +==== Bootloader version + +On the Raspberry Pi 4 and later, switch to the latest boot ROM software. Alternatively, you can revert to the factory default if the latest version causes problems. + +==== Wayland + +Switch between the X11 and Wayland backends, and choose a window manager. Since Raspberry Pi OS _Bookworm_, all Raspberry Pi models run Wayland using labwc by default. + +NOTE: To use Wayland on Raspberry Pi models prior to Raspberry Pi 4 running a version of Raspberry Pi OS earlier than _Bookworm_, add `wayland=on` to `/boot/firmware/cmdline.txt`. + +==== Audio config + +Switch between the PulseAudio and PipeWire audio backends. Prior to Raspberry Pi OS Bookworm, Raspberry Pi OS used PulseAudio. + +[[update]] +=== Update + +Update this tool to the latest version. + +[[about]] +=== About raspi-config + +Display a description of `raspi-config`. + +[[finish]] +=== Finish + +Exit `raspi-config`. If necessary, `raspi-config` will ask you to reboot when you exit. When implementing changes for the first time, reboot to ensure your changes take effect. + +[[raspi-config-cli]] +== non-interactive `raspi-config` + +The `raspi-config` tool also supports non-interactive options and flags that change options entirely on the command line with no visual component. Available options may differ between Raspberry Pi models. + +[source,console] +---- +$ sudo raspi-config nonint [optional-argument] +---- + +NOTE: The meaning of `0` and `1` varies between options. Always check the documentation before passing a value to an option. + +[[raspi-config-cli-commands]] + +=== System options + +==== Wireless LAN + +Configure Wi-Fi SSID and passphrase. + +[source,console] +---- +$ sudo raspi-config nonint do_wifi_ssid_passphrase [hidden] [plain] +---- + +Pass a wireless network name (SSID) and passphrase, if required. The following flags are optional: + +The `` option indicates the visibility of the SSID. If the network broadcasts an open SSID, pass `0` or omit the option. If your SSID is hidden, pass `1`. Defaults to `0`. + +The `` option indicates whether the given passphrase is wrapped in an extra set of quotation marks. Most users can ignore this option: as an implementation detail, `raspi-config` may need to add quotation marks before passing the passphrase to other parts of the system, and a `` value of `0` indicates that the quotation marks are already present. A value of `1` indicates that the quotation marks are not present, and the implementation should add them as necessary. Defaults to `1`. To pass this option, you must specify a value for ``. + +For example, run the following commands to connect to a: + +* non-hidden network named `myssid` with the passphrase `mypassphrase`: ++ +[source,console] +---- +$ sudo raspi-config nonint do_wifi_ssid_passphrase myssid mypassphrase +---- + +* hidden network named `myssid` with the passphrase `mypassphrase`: ++ +[source,console] +---- +$ sudo raspi-config nonint do_wifi_ssid_passphrase myssid mypassphrase 1 +---- + +* non-hidden network named `myssid` with the passphrase `my passphrase`: ++ +[source,console] +---- +$ sudo raspi-config nonint do_wifi_ssid_passphrase myssid 'my passphrase' +---- + +* non-hidden network named `myssid` with the passphrase `mypassphrase`, where you have already added extra quotes to the passphrase: ++ +[source,console] +---- +$ sudo raspi-config nonint do_wifi_ssid_passphrase myssid '"mypassphrase"' 0 0 +---- + +==== Audio + +Specify the audio output destination. + +[source,console] +---- +$ sudo raspi-config nonint do_audio +---- + +On Raspberry Pi 4B, you can use the following options: + +* `0`: bcm2835 headphone jack +* `1`: vc4-hdmi-0 +* `2`: vc4-hdmi-1 + +For a full list of possible `` values, see the numbers used in the interactive `raspi-config` version of this option. + +[[change-user-password-nonint]] +==== Password + +Change your password. + +For more information, see xref:configuration.adoc#change-user-password[Change a user's password]. + +[source,console] +---- +$ sudo raspi-config nonint do_change_pass +---- + +NOTE: This function uses a full-screen interactive interface, even when run from a CLI option. + +[[hostname-nonint]] +==== Hostname + +Set the visible xref:remote-access.adoc#resolve-raspberrypi-local-with-mdns[mDNS] name for this Raspberry Pi on a network. + +[source,console] +---- +$ sudo raspi-config nonint do_hostname +---- + +[[boot-options-nonint]] +==== Boot/Auto login + +Select the following behaviour at boot time: + +* whether to boot to console or desktop +* whether your Raspberry Pi automatically logs into your current user account when powered on + +[source,console] +---- +$ sudo raspi-config nonint do_boot_behaviour +---- + +* `B1`: boot to console, requiring login +* `B2`: boot to console, logging in automatically +* `B3`: boot to desktop, requiring login +* `B4`: boot to desktop, logging in automatically + +==== Network at boot + +Wait for a network connection before letting boot proceed. + +[source,console] +---- +$ sudo raspi-config nonint do_boot_wait <0/1> +---- + +* `0`: boot without waiting for network connection +* `1`: boot after waiting for network connection + +==== Splash screen + +Enable or disable the splash screen displayed at boot time. + +[source,console] +---- +$ sudo raspi-config nonint do_boot_splash <0/1> +---- + +* `0`: enable splash screen +* `1`: disable splash screen + +==== Power LED + +If your Raspberry Pi model allows, change the behaviour of the power LED. + +[source,console] +---- +$ sudo raspi-config nonint do_leds <0/1> +---- + +* `0`: flash for disk activity +* `1`: keep the power LED lit at all times + +==== Browser + +Change the default web browser. Choosing a web browser that isn't currently installed won't work. + +[source,console] +---- +$ sudo raspi-config nonint do_browser +---- + +=== Display options + +[[underscan-nonint]] +==== Underscan + +NOTE: Unavailable when running Wayland. + +If the initial text shown on the screen disappears off the edge, enable overscan to adjust the border. On some displays, particularly monitors, disabling overscan will make the picture fill the whole screen and remove the black border. + +[source,console] +---- +$ sudo raspi-config nonint do_overscan_kms +---- + +Device: + +* `1`: HDMI-1 +* `2`: HDMI-2 + +Enabled: + +* `0`: enable overscan +* `1`: disable overscan + +==== Screen blanking + +Enable or disable screen blanking. + +[source,console] +---- +$ sudo raspi-config nonint do_blanking <0/1> +---- + +* `0`: enable screen blanking +* `1`: disable screen blanking + +[[resolution-nonint]] +==== VNC resolution + +Define the video resolution to use for VNC in xref:configuration.adoc#setting-up-a-headless-raspberry-pi[headless] setups. + +[source,console] +---- +$ sudo raspi-config nonint do_vnc_resolution x +---- + +==== Composite + +Enable or disable composite video output. + +On Raspberry Pi 4: -If you have installed Raspberry Pi OS using NOOBS, the filesystem will have been expanded automatically. There may be a rare occasion where this is not the case, e.g. if you have copied a smaller SD card onto a larger one. In this case, you should use this option to expand your installation to fill the whole SD card, giving you more space to use for files. You will need to reboot the Raspberry Pi to make this available. Note that there is no confirmation: selecting the option begins the partition expansion immediately. +[source,console] +---- +$ sudo raspi-config nonint do_pi4video +---- + +* `V1`: enable 4Kp60 HDMI output +* `V2`: enable composite video output +* `V3`: disable 4Kp60 and composite output + +On other models: + +[source,console] +---- +$ sudo raspi-config nonint do_composite <0/1> +---- + +* `0`: enable composite video +* `1`: disable composite video + +[[interfacing-options-nonint]] +=== Interface options + +[[ssh-nonint]] +==== SSH + +Enable or disable remote terminal access to your Raspberry Pi using SSH. + +SSH allows you to remotely access the command line of the Raspberry Pi from another computer. For more information about SSH, see the xref:remote-access.adoc#ssh[SSH documentation]. + +[source,console] +---- +$ sudo raspi-config nonint do_ssh <0/1> +---- + +* `0`: enable SSH +* `1`: disable SSH + +[[rpi-connect-nonit]] +==== Raspberry Pi Connect + +Enable or disable xref:../services/connect.adoc[Raspberry Pi Connect], which provides the ability to access your Raspberry Pi remotely with no manual network configuration. + +[source,console] +---- +$ sudo raspi-config nonint do_rpi_connect <0/1> +---- + +* `0`: enable Raspberry Pi Connect +* `1`: disable Raspberry Pi Connect + +[[VNC-nonint]] +==== VNC + +Enable or disable a Virtual Network Computing (VNC) server. For more information about VNC, see the xref:remote-access.adoc#vnc[VNC documentation]. -[[GL-driver]] -===== GL Driver +[source,console] +---- +$ sudo raspi-config nonint do_vnc <0/1> +---- + +* `0`: enable VNC +* `1`: disable VNC -Enable/disable the experimental GL desktop graphics drivers. +[[spi-nonint]] +==== SPI -[[GL-full-KMS]] -====== GL (Full KMS) +Enable or disable SPI interfaces and automatic loading of the SPI kernel module. -Enable/disable the experimental OpenGL Full KMS (kernel mode setting) desktop graphics driver. +[source,console] +---- +$ sudo raspi-config nonint do_spi <0/1> +---- -[[GL-fake-KMS]] -====== GL (Fake KMS) +* `0`: enable SPI +* `1`: disable SPI -Enable/disable the experimental OpenGL Fake KMS desktop graphics driver. +[[i2c-nonint]] +==== I2C -[[legacy]] -====== Legacy +Enable or disable I2C interfaces and automatic loading of the I2C kernel module. + +[source,console] +---- +$ sudo raspi-config nonint do_i2c <0/1> +---- + +* `0`: enable I2C +* `1`: disable I2C + +[[serial-nonint]] +==== Serial Port + +Enable or disable the serial connection hardware. + +[source,console] +---- +$ sudo raspi-config nonint do_serial_hw <0/1> +---- -Enable/disable the original legacy non-GL VideoCore desktop graphics driver. +* `0`: enable serial port +* `1`: disable serial port -===== Compositor +[[serial-console-nonint]] +==== Serial console -Enable/Display the xcompmgr composition manager +Enable or disable shell and kernel messages on the serial connection. -===== Network Interface Names +[source,console] +---- +$ sudo raspi-config nonint do_serial_cons <0/1> +---- + +* `0`: enable console over serial port +* `1`: disable console over serial port + +[[one-wire-nonint]] +==== 1-wire + +Enable or disable the Dallas 1-wire interface. This is usually used for DS18B20 temperature sensors. + +[source,console] +---- +$ sudo raspi-config nonint do_onewire <0/1> +---- + +* `0`: enable 1-wire +* `1`: disable 1-wire + +==== Remote GPIO + +Enable or disable remote access to the GPIO pins. + +[source,console] +---- +$ sudo raspi-config nonint do_rgpio <0/1> +---- + +* `0`: enable remote GPIO +* `1`: disable remote GPIO + +=== Performance options + +[[overclock-nonint]] +==== Overclock + +If your Raspberry Pi model allows, overclock the CPU. Overclocking potential varies between individual Raspberry Pi devices, even within the same model. Overclocking too high may result in instability. + +WARNING: *Overclocking may reduce the lifetime of your Raspberry Pi.* If overclocking at a certain level causes system instability, try a more modest overclock. Hold down the *Shift* key during boot to temporarily disable overclocking. + +[source,console] +---- +$ sudo raspi-config nonint do_overclock +---- + +This command accepts the following `` values: + +* `None`: no overclock (default) +* `Modest`: overclock to 50% of the maximum +* `Medium`: overclock to 75% of the maximum +* `High`: overclock to 100% of the maximum +* `Turbo`: overclock to 125% of the maximum + +[[memory-split-nonint]] +==== GPU memory + +Change the amount of memory made available to the GPU. + +[source,console] +---- +$ sudo raspi-config nonint do_memory_split +---- + +==== Overlay file system + +Enable or disable a read-only filesystem. + +[source,console] +---- +$ sudo raspi-config nonint do_overlayfs <0/1> +---- + +* `0`: enable overlay filesystem +* `1`: disable overlay filesystem + +==== Fan + +Customise the behaviour of the GPIO-connected https://www.raspberrypi.com/products/raspberry-pi-4-case-fan/[Raspberry Pi 4 Case Fan]. This setting is inapplicable to other fan models. + +[source,console] +---- +$ sudo raspi-config nonint do_fan <0/1> [gpio] [onTemp] +---- + +* `0`: enable fan +* `1`: disable fan + +`gpio` defaults to `14`. + +`onTemp` defaults to `80` **degrees Celsius**. + +[[localisation-options-nonint]] +=== Localisation options + +[[change-locale-nonint]] +==== Locale + +Select a locale, for example `en_GB.UTF-8 UTF-8`. + +[source,console] +---- +$ sudo raspi-config nonint do_change_locale +---- + +For a full list of possible `` values, see the abbreviations used in the interactive `raspi-config` version of this option. + +[[change-timezone-nonint]] +==== Time zone + +Set your local time zone in the format `Region/City`, for example 'Europe/London'. + +[source,console] +---- +$ sudo raspi-config nonint do_change_timezone +---- + +For a full list of possible `` values, see the abbreviations used in the interactive `raspi-config` version of this option. + +[[change-keyboard-layout-nonint]] +==== Keyboard + +Set your keyboard layout. Changes usually take effect immediately, but may require a reboot. + +[source,console] +---- +$ sudo raspi-config nonint do_configure_keyboard +---- + +For a full list of possible `` values, see the the abbreviations used in the interactive `raspi-config` version of this option. + +==== WLAN country + +Set the country code for your wireless network. + +[source,console] +---- +$ sudo raspi-config nonint do_wifi_country +---- + +For a full list of possible `` values, see the abbreviations used in the interactive `raspi-config` version of this option. + +[[advanced-options-nonint]] +=== Advanced options + + +WARNING: Changes to advanced options may prevent your Raspberry Pi from working as intended. Avoid configuring advanced options unless instructed by a Raspberry Pi engineer. + +[[expand-filesystem-nonint]] +==== Expand filesystem + +Expand your OS partition to fill the whole storage device, giving you more space to use for files. Reboot the Raspberry Pi to complete this action. Normally, Raspberry Pi OS runs this action on first boot. This option can be useful if you clone your OS to a separate storage device with more capacity than the original. + +WARNING: There is no confirmation step. Selecting the option begins the partition expansion immediately. + +[source,console] +---- +$ sudo raspi-config nonint do_expand_rootfs +---- + +==== Network interface names Enable or disable predictable network interface names. -===== Network Proxy Settings +[source,console] +---- +$ sudo raspi-config nonint do_net_names <0/1> +---- + +* `0`: enable predictable network interface names +* `1`: disable predictable network interface names + +==== Network proxy settings Configure the network's proxy settings. -===== Boot Order +[source,console] +---- +$ sudo raspi-config nonint do_proxy
+---- -On the Raspberry Pi4, you can specify whether to boot from USB or network if the SD card isn't inserted. See xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[this page] for more information. +==== Boot order -===== Bootloader Version +On the Raspberry Pi 4 and later, specify whether to boot from USB or network in absence of an SD card. See the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration] section for more information. -On the Raspberry Pi4, you can tell the system to use the very latest boot ROM software, or default to the factory default if the latest version causes problems. +[source,console] +---- +$ sudo raspi-config nonint do_boot_order +---- -[[update]] -==== Update +Depending on your device, you can choose from the following options: -Update this tool to the latest version. +* `B1`: SD card boot - boot from SD card if available, otherwise boot from NVMe, otherwise boot from USB +* `B2`: NVMe/USB boot - boot from NVMe if available, otherwise boot from USB if available, otherwise boot from SD card +* `B3`: Network boot - boot from SD card _if inserted_, otherwise boot from network -[[about]] -==== About raspi-config +==== Bootloader version -Selecting this option shows the following text: +On the Raspberry Pi 4 and later, switch to the latest boot ROM software. Alternatively, you can revert to the factory default if the latest version causes problems. +[source,console] ---- -This tool provides a straightforward way of doing initial configuration of the Raspberry Pi. -Although it can be run at any time, some of the options may have difficulties if you have heavily customised your installation. +$ sudo raspi-config nonint do_boot_rom ---- -[[finish]] -==== Finish +* `E1`: use the latest boot ROM +* `E2`: use the factory default + +==== Wayland + +Switch between the X11 and Wayland backends, and choose a window manager. Since Raspberry Pi OS _Bookworm_, all Raspberry Pi models run Wayland using the labwc window manager by default. + +NOTE: To use Wayland on Raspberry Pi models prior to Raspberry Pi 4 running a version of Raspberry Pi OS earlier than _Bookworm_, add `wayland=on` to `/boot/firmware/cmdline.txt`. + +[source,console] +---- +$ sudo raspi-config nonint do_wayland +---- + +* `W1`: use the Openbox window manager with X11 backend +* `W2`: use the wayfire window manager with Wayland backend +* `W3`: use the labwc window manager with Wayland backend + +==== Audio config -Use this button when you have completed your changes. You will be asked whether you want to reboot or not. When used for the first time, it's best to reboot. There will be a delay in rebooting if you have chosen to resize your SD card. +Use this option to switch between the PulseAudio and PipeWire audio backends. Prior to Raspberry Pi OS Bookworm, Raspberry Pi OS used PulseAudio. +[source,console] +---- +$ sudo raspi-config nonint do_audioconf <1/2> +---- + +* `1`: use the PulseAudio backend +* `2`: use the PipeWire backend + +[[update-nonint]] +=== Update + +Update this tool to the latest version. + +[source,console] +---- +$ sudo raspi-config nonint do_update +---- diff --git a/documentation/asciidoc/computers/configuration/screensaver.adoc b/documentation/asciidoc/computers/configuration/screensaver.adoc index 41b7b07cad..f12900f3f0 100644 --- a/documentation/asciidoc/computers/configuration/screensaver.adoc +++ b/documentation/asciidoc/computers/configuration/screensaver.adoc @@ -1,53 +1,59 @@ -== Configuring Screen Blanking +== Screen blanking -You can configure your Raspberry Pi to use a screen saver or to blank the screen. +You can configure your Raspberry Pi to blank the screen after a period of inactivity. By default, Raspberry Pi OS blanks the screen after ten minutes of inactivity when screen blanking is enabled. -=== On Console +=== Desktop -When running without a graphical desktop, Raspberry Pi OS will blank the screen after 10 minutes without user input, e.g. mouse movement or key presses. +You can control screen blanking using the *Screen Blanking* option in the Raspberry Pi Configuration menu. -The current setting, in seconds, can be displayed using: +==== Raspberry Pi Configuration ----- -cat /sys/module/kernel/parameters/consoleblank ----- +Click the Raspberry Pi button in the menu bar. Navigate to *Preferences* > *Raspberry Pi Configuration*. + +image::images/pi-configuration.png[opening the Raspberry Pi Configuration menu from the desktop] + +Select the *Display* tab. Toggle the *Screen Blanking* radio button into the on position. Press *OK* to confirm your selection. + +image::images/blanking.png[toggle Screen Blanking on in the Raspberry Pi Configuration menu] -To change the `consoleblank` setting, edit the kernel command line: +==== CLI +You can enable and disable screen blanking with the `raspi-config` CLI tool. Run the following command to open the tool: + +[source,console] ---- -sudo nano /boot/cmdline.txt +$ sudo raspi-config ---- -The file `/boot/cmdline.txt` contains a single line of text. Add `consoleblank=n` to have the console blank after `n` seconds of inactivity. For example `consoleblank=300` will cause the console to blank after 300 seconds, 5 minutes, of inactivity. Make sure that you add your `consoleblank` option to the single line of text already in the `cmdline.txt` file. To disable screen blanking, set `consoleblank=0`. +Use the arrow keys to navigate and the *Enter* key to select. Select `Display Options` > `Screen Blanking`. Choose `yes` with the arrow keys to enable screen blanking, or `no` to disable screen blanking. -You can also use the `raspi-config` tool to disable screen blanking. Note that the screen blanking setting in `raspi-config` also controls screen blanking when the graphical desktop is running. +=== Console -=== On the Desktop +The `dpms_timeout` screen blanking configuration used by Raspberry Pi Configuration only affects desktop sessions. In *console mode*, when your Raspberry Pi is connected to a monitor and keyboard with only a terminal for input, use the `consoleblank` setting in the kernel command line. -Raspberry Pi OS will blank the graphical desktop after 10 minutes without user input. You can disable this by changing the 'Screen Blanking' option in the Raspberry Pi Configuration tool, which is available on the Preferences menu. Note that the 'Screen Blanking' option also controls screen blanking when the graphical desktop is not running. +==== Set console mode screen blanking -There is also a graphical screensaver available, which can be installed as follows: +To change the console mode screen blanking configuration, open `/boot/firmware/cmdline.txt` in a text editor as an administrator: +[source,console] ---- -sudo apt install xscreensaver +$ sudo nano /boot/firmware/cmdline.txt ---- -This may take a few minutes. - -Once this has been installed, you can find the Screensaver application on the Preferences menu: it provides many options for setting up the screensaver, including disabling it completely. - -=== Switching off HDMI +You can adjust the number of seconds before Raspberry Pi OS blanks the console here. For instance, add `consoleblank=600` to disable display output after 600 seconds of inactivity. Set the value to `0` to never blank the screen. -If you want to switch off the video display entirely, you can use the xref:os.adoc#vcgencmd[vcgencmd] command, +Changes to `cmdline.txt` only take effect after a reboot. Use the following command to reboot your Raspberry Pi: -[,shell] +[source,console] ---- -vcgencmd display_power 0 +$ sudo reboot ---- -Video will not come back on until you reboot or switch it back on: +==== View current screen blanking setting -[,shell] +You can display the current console blank time in seconds with the following command: + +[source,console] +---- +$ cat /sys/module/kernel/parameters/consoleblank ---- -vcgencmd display_power 1 ----- \ No newline at end of file diff --git a/documentation/asciidoc/computers/configuration/securing-the-raspberry-pi.adoc b/documentation/asciidoc/computers/configuration/securing-the-raspberry-pi.adoc index 6125200e5d..85a00c8d3f 100644 --- a/documentation/asciidoc/computers/configuration/securing-the-raspberry-pi.adoc +++ b/documentation/asciidoc/computers/configuration/securing-the-raspberry-pi.adoc @@ -1,288 +1,192 @@ -== Securing your Raspberry Pi +== Secure your Raspberry Pi -The security of your Raspberry Pi is important. Gaps in security leave your Raspberry Pi open to hackers who can then use it without your permission. +Here, we describe some common ways to improve the security of your Raspberry Pi. -What level of security you need depends on how you wish to use your Raspberry Pi. For example, if you are simply using your Raspberry Pi on your home network, behind a router with a firewall, then it is already quite secure by default. +=== Require a password for `sudo` commands -However, if you wish to expose your Raspberry Pi directly to the internet, either with a direct connection (unlikely) or by letting certain protocols through your router firewall (e.g. SSH), then you need to make some basic security changes. +Prefixing a command with `sudo` runs it as a superuser. By default, that does not need a password. However, you can make your Raspberry Pi more secure by requiring a password for all commands run with `sudo`. -Even if you are hidden behind a firewall, it is sensible to take security seriously. This documentation will describe some ways of improving the security of your Raspberry Pi. Please note, though, that it is not exhaustive. +To force `sudo` to require a password, edit the `010_pi-nopasswd` sudoers file: -=== Change the Default Password - -The default username and password is used for every single Raspberry Pi running Raspberry Pi OS. So, if you can get access to a Raspberry Pi, and these settings have not been changed, you have `root` access to that Raspberry Pi. - -So the first thing to do is change the password. This can be done via the `raspi-config` application, or from the command line. - -[,bash] ----- -sudo raspi-config ----- - -Select option 2, and follow the instructions to change the password. - -However, all `raspi-config` does is start up the command line `passwd` application, which you can do from the command line. So instead you can type in your new password and confirm it. - -[,bash] ----- -passwd ----- - -=== Changing your Username - -You can, of course, make your Raspberry Pi even more secure by also changing your username. All Raspberry Pis come with the default username `pi`, so changing this will immediately make your Raspberry Pi more secure. - -To add a new user, enter: - -[,bash] ----- -sudo adduser alice ----- - -You will be prompted to create a password for the new user. - -The new user will have a home directory at `/home/alice/`. - -To add them to the `sudo` group to give them `sudo` permissions as well as all of the other necessary permissions: - -[,bash] ----- -sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi alice ----- - -You can check your permissions are in place (i.e. you can use `sudo`) by trying the following: - -[,bash] ----- -sudo su - alice ----- - -If it runs successfully, then you can be sure that the new account is in the `sudo` group. - -Once you have confirmed that the new account is working, you can delete the `pi` user. In order to do this, you'll need to first close its process with the following: - -[,bash] ----- -sudo pkill -u pi ----- - -Please note that with the current Raspberry Pi OS distribution, there are some aspects that require the `pi` user to be present. If you are unsure whether you will be affected by this, then leave the `pi` user in place. Work is being done to reduce the dependency on the `pi` user. - -To delete the `pi` user, type the following: - -[,bash] ----- -sudo deluser pi +[source,console] ---- - -This command will delete the `pi` user but will leave the `/home/pi` folder. If necessary, you can use the command below to remove the home folder for the `pi` user at the same time. Note the data in this folder will be permanently deleted, so make sure any required data is stored elsewhere. - -[,bash] +$ sudo visudo /etc/sudoers.d/010_pi-nopasswd ---- -sudo deluser -remove-home pi ----- - -This command will result in a warning that the group `pi` has no more members. The `deluser` command removes both the `pi` user and the `pi` group though, so the warning can be safely ignored. -=== Make `sudo` Require a Password +Change the `` entry to the following, replacing `` with your username: -Placing `sudo` in front of a command runs it as a superuser, and by default, that does not need a password. In general, this is not a problem. However, if your Pi is exposed to the internet and somehow becomes exploited (perhaps via a webpage exploit for example), the attacker will be able to change things that require superuser credentials, unless you have set `sudo` to require a password. - -To force `sudo` to require a password, enter: - -[,bash] +[source,bash] ---- -sudo visudo /etc/sudoers.d/010_pi-nopasswd + ALL=(ALL) PASSWD: ALL ---- -and change the `pi` entry (or whichever usernames have superuser rights) to: - -[,bash] ----- -pi ALL=(ALL) PASSWD: ALL ----- +Save the file. Your new preference should take effect immediately. -Then save the file: it will be checked for any syntax errors. If no errors were detected, the file will be saved and you will be returned to the shell prompt. If errors were detected, you will be asked 'what now?' Press the 'enter' key on your keyboard: this will bring up a list of options. You will probably want to use 'e' for '(e)dit sudoers file again,' so you can edit the file and fix the problem. *Note that choosing option 'Q' will save the file with any syntax errors still in place, which makes it impossible for _any_ user to use the sudo command.* +=== Update Raspberry Pi OS -=== Updating Raspberry Pi OS +Only the latest OS distribution contains all the latest security fixes. Always keep your device xref:os.adoc#update-software[updated] to the latest version of Raspberry Pi OS. -An up-to-date distribution contains all the latest security fixes, so you should go ahead and xref:os.adoc#updating-and-upgrading-raspberry-pi-os[update] your version of Raspberry Pi OS to the latest version. +=== Automatically update your SSH server -If you are using SSH to connect to your Raspberry Pi, it can be worthwhile to xref:using_linux.adoc#scheduling-tasks-with-cron[add a cron job] that specifically updates the ssh-server. The following command, perhaps as a daily cron job, will ensure you have the latest SSH security fixes promptly, independent of your normal update process. +If you use SSH to connect to your Raspberry Pi, it can be worthwhile to add a `cron` job that specifically updates the SSH server. The following command, perhaps run as a daily `cron` job, ensures you have the latest SSH security fixes promptly, independent of your normal update process. -[,bash] +[source,console] ---- -apt install openssh-server +$ apt install openssh-server ---- -=== Improving SSH Security - -SSH is a common way of accessing a Raspberry Pi remotely. By default, logging in with SSH requires a username/password pair, and there are ways to make this more secure. An even more secure method is to use key based authentication. +=== Improve SSH security -==== Improving username/password security +SSH is a common way to remotely access a Raspberry Pi. By default, SSH requires a username and password. To make SSH even more secure, use xref:remote-access.adoc#configure-ssh-without-a-password[key-based authentication]. -The most important thing to do is ensure you have a very robust password. If your Raspberry Pi is exposed to the internet, the password needs to be very secure. This will help to avoid dictionary attacks or the like. +==== Enable and disable SSH users You can also *allow* or *deny* specific users by altering the `sshd` configuration. -[,bash] +[source,console] ---- -sudo nano /etc/ssh/sshd_config +$ sudo nano /etc/ssh/sshd_config ---- Add, edit, or append to the end of the file the following line, which contains the usernames you wish to allow to log in: +[source,bash] ---- AllowUsers alice bob ---- You can also use `DenyUsers` to specifically stop some usernames from logging in: +[source,bash] ---- DenyUsers jane john ---- -After the change you will need to restart the `sshd` service using `sudo systemctl restart ssh` or reboot so the changes take effect. - -==== Using key-based authentication. - -Key pairs are two cryptographically secure keys. One is private, and one is public. They can be used to authenticate a client to an SSH server (in this case the Raspberry Pi). +After the change, restart the `sshd` service with the following command to put your changes into effect: -The client generates two keys, which are cryptographically linked to each other. The private key should never be released, but the public key can be freely shared. The SSH server takes a copy of the public key, and, when a link is requested, uses this key to send the client a challenge message, which the client will encrypt using the private key. If the server can use the public key to decrypt this message back to the original challenge message, then the identity of the client can be confirmed. - -Generating a key pair in Linux is done using the `ssh-keygen` command on the *client*; the keys are stored by default in the `.ssh` folder in the user's home directory. The private key will be called `id_rsa` and the associated public key will be called `id_rsa.pub`. The key will be 2048 bits long: breaking the encryption on a key of that length would take an extremely long time, so it is very secure. You can make longer keys if the situation demands it. Note that you should only do the generation process once: if repeated, it will overwrite any previous generated keys. Anything relying on those old keys will need to be updated to the new keys. - -You will be prompted for a passphrase during key generation: this is an extra level of security. For the moment, leave this blank. - -The public key now needs to be moved on to the server: see xref:remote-access.adoc#copy-your-public-key-to-your-raspberry-pi[Copy your public key to your Raspberry Pi]. - -Finally, we need to disable password logins, so that all authentication is done by the key pairs. - -[,bash] +[source,console] ---- -sudo nano /etc/ssh/sshd_config +$ sudo systemctl restart ssh ---- -There are three lines that need to be changed to `no`, if they are not set that way already: - -[,bash] ----- -ChallengeResponseAuthentication no -PasswordAuthentication no -UsePAM no ----- +=== Use a firewall -Save the file and either restart the ssh system with `sudo service ssh reload` or reboot. +There are many firewall solutions available for Linux. Most use the underlying http://www.netfilter.org/projects/iptables/index.html[iptables] project to provide packet filtering. This project sits over the Linux netfiltering system. By default, `iptables` is installed on Raspberry Pi OS, but is not set up. Setting it up can be a complicated task, and one project that offers a simpler interface than `iptables` is https://www.linux.com/learn/introduction-uncomplicated-firewall-ufw[Uncomplicated Firewall (UFW)]. This is the default firewall tool in Ubuntu, and can be installed on your Raspberry Pi: -=== Install a Firewall - -There are many firewall solutions available for Linux. Most use the underlying http://www.netfilter.org/projects/iptables/index.html[iptables] project to provide packet filtering. This project sits over the Linux netfiltering system. `iptables` is installed by default on Raspberry Pi OS, but is not set up. Setting it up can be a complicated task, and one project that provides a simpler interface than `iptables` is https://www.linux.com/learn/introduction-uncomplicated-firewall-ufw[ufw], which stands for 'Uncomplicated Fire Wall'. This is the default firewall tool in Ubuntu, and can be easily installed on your Raspberry Pi: - -[,bash] +[source,console] ---- -sudo apt install ufw +$ sudo apt install ufw ---- -`ufw` is a fairly straightforward command line tool, although there are some GUIs available for it. This document will describe a few of the basic command line options. Note that `ufw` needs to be run with superuser privileges, so all commands are preceded with `sudo`. It is also possible to use the option `--dry-run` any `ufw` commands, which indicates the results of the command without actually making any changes. +`ufw` is a command-line tool, although there are some GUIs available for it. Note that `ufw` needs to be run with superuser privileges, so all commands are preceded with `sudo`. It is also possible to use the option `--dry-run` any `ufw` commands, which indicates the results of the command without actually making any changes. To enable the firewall, which will also ensure it starts up on boot, use: -[,bash] +[source,console] ---- -sudo ufw enable +$ sudo ufw enable ---- To disable the firewall, and disable start up on boot, use: -[,bash] +[source,console] ---- -sudo ufw disable +$ sudo ufw disable ---- Allow a particular port to have access (we have used port 22 in our example): -[,bash] +[source,console] ---- -sudo ufw allow 22 +$ sudo ufw allow 22 ---- Denying access on a port is also very simple (again, we have used port 22 as an example): -[,bash] +[source,console] ---- -sudo ufw deny 22 +$ sudo ufw deny 22 ---- -You can also specify which service you are allowing or denying on a port. In this example, we are denying tcp on port 22: +You can also specify which service you are allowing or denying on a port. In this example, we are denying TCP on port 22: -[,bash] +[source,console] ---- -sudo ufw deny 22/tcp +$ sudo ufw deny 22/tcp ---- You can specify the service even if you do not know which port it uses. This example allows the ssh service access through the firewall: -[,bash] +[source,console] ---- -sudo ufw allow ssh +$ sudo ufw allow ssh ---- The status command lists all current settings for the firewall: -[,bash] +[source,console] ---- -sudo ufw status +$ sudo ufw status ---- -The rules can be quite complicated, allowing specific IP addresses to be blocked, specifying in which direction traffic is allowed, or limiting the number of attempts to connect, for example to help defeat a Denial of Service (DoS) attack. You can also specify the device rules are to be applied to (e.g. eth0, wlan0). Please refer to the `ufw` man page (`man ufw`) for full details, but here are some examples of more sophisticated commands. +The rules can be quite complicated, allowing specific IP addresses to be blocked, specifying in which direction traffic is allowed, or limiting the number of attempts to connect (for example to help defeat a DDoS attack). You can also specify the device rules are to be applied to (e.g. eth0, wlan0). Please refer to the `ufw` man page (`man ufw`) for full details beyond the commands below. -Limit login attempts on ssh port using tcp: this denies connection if an IP address has attempted to connect six or more times in the last 30 seconds: +Limit login attempts on ssh port using TCP. This denies connection if an IP address has attempted to connect six or more times in the last 30 seconds: -[,bash] +[source,console] ---- -sudo ufw limit ssh/tcp +$ sudo ufw limit ssh/tcp ---- Deny access to port 30 from IP address 192.168.2.1 -[,bash] +[source,console] ---- -sudo ufw deny from 192.168.2.1 port 30 +$ sudo ufw deny from 192.168.2.1 port 30 ---- -=== Installing `fail2ban` +=== Block suspicious activity with `fail2ban` -If you are using your Raspberry Pi as some sort of server, for example an `ssh` or a webserver, your firewall will have deliberate 'holes' in it to let the server traffic through. In these cases, http://www.fail2ban.org[Fail2ban] can be useful. Fail2ban, written in Python, is a scanner that examines the log files produced by the Raspberry Pi, and checks them for suspicious activity. It catches things like multiple brute-force attempts to log in, and can inform any installed firewall to stop further login attempts from suspicious IP addresses. It saves you having to manually check log files for intrusion attempts and then update the firewall (via `iptables`) to prevent them. +When using a Raspberry Pi as a server, you must create deliberate holes in your firewall to allow server traffic. http://www.fail2ban.org[Fail2ban] can help secure your server. Fail2ban examines log files and checks for suspicious activity, like multiple brute-force login attempts. It saves you having to manually check log files for intrusion attempts and then update the firewall (via `iptables`) to prevent them. -Install `fail2ban` using the following command: +To install `fail2ban`, run the following command: -[,bash] +[source,console] ---- -sudo apt install fail2ban +$ sudo apt install fail2ban ---- -On installation, Fail2ban creates a folder `/etc/fail2ban` in which there is a configuration file called `jail.conf`. This needs to be copied to `jail.local` to enable it. Inside this configuration file are a set of default options, together with options for checking specific services for abnormalities. Do the following to examine/change the rules that are used for `ssh`: +On installation, Fail2ban creates `/etc/fail2ban/jail.conf`. To enable Fail2ban, copy `jail.conf` to `jail.local`: -[,bash] +[source,console] ---- -sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local -sudo nano /etc/fail2ban/jail.local +$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local ---- -Add the following section to the `jail.local` file. On some versions of fail2ban this section may already exist, so update this pre-existing section if it is there. +Inside this configuration file are a set of default options, together with options for checking specific services for abnormalities. To examine the rules used for `ssh`, open `jail.local` in an editor: +[source,console] +---- +$ sudo nano /etc/fail2ban/jail.local +---- + +Create the `[ssh]` section if it does not already exist and add the following lines to the section: + +[source,ini] ---- [ssh] enabled = true port = ssh filter = sshd -logpath = /var/log/auth.log +backend = systemd maxretry = 6 ---- -As you can see, this section is named ssh, is enabled, examines the ssh port, filters using the `sshd` parameters, parses the `/var/log/auth.log` for malicious activity, and allows six retries before the detection threshold is reached. Checking the default section, we can see that the default banning action is: +This enables Fail2ban checks for suspicious `ssh` activity, including system log checks, and allows six retries before blocking activity. + +The `[default]` section in this same file defines the default banning action, `iptables-multiport`, which runs the `/etc/fail2ban/action.d/iptables-multiport.conf` file when the detection threshold is reached: -[,bash] +[source,ini] ---- # Default banning action (e.g. iptables, iptables-new, # iptables-multiport, shorewall, etc) It is used to define @@ -291,16 +195,17 @@ As you can see, this section is named ssh, is enabled, examines the ssh port, fi banaction = iptables-multiport ---- -`iptables-multiport` means that the Fail2ban system will run the `/etc/fail2ban/action.d/iptables-multiport.conf` file when the detection threshold is reached. There are a number of different action configuration files that can be used. Multiport bans all access on all ports. +Multiport bans all access on all ports. The `action.d` folder contains a number of alternative action configuration files you can use to customise your server's response to suspicious activity. -If you want to permanently ban an IP address after three failed attempts, you can change the maxretry value in the `[ssh]` section, and set the bantime to a negative number: +For instance, to permanently ban an IP address after three failed attempts, change the `maxretry` value in the `[ssh]` section to `3` and set the `bantime` to a negative number: +[source,ini] ---- [ssh] enabled = true port = ssh filter = sshd -logpath = /var/log/auth.log +backend = systemd maxretry = 3 -bantime = -1 +bantime = -1 ---- diff --git a/documentation/asciidoc/computers/configuration/uart.adoc b/documentation/asciidoc/computers/configuration/uart.adoc index ab09878eb9..a6026e3d55 100644 --- a/documentation/asciidoc/computers/configuration/uart.adoc +++ b/documentation/asciidoc/computers/configuration/uart.adoc @@ -1,8 +1,8 @@ -== Configuring UARTs +== Configure UARTs There are two types of UART available on the Raspberry Pi - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0183g/index.html[PL011] and mini UART. The PL011 is a capable, broadly 16550-compatible UART, while the mini UART has a reduced feature set. -All UARTs on the Raspberry Pi are 3.3V only - damage will occur if they are connected to 5V systems. An adaptor can be used to connect to 5V systems. Alternatively, low-cost USB to 3.3V serial adaptors are available from various third parties. +All UARTs on the Raspberry Pi are 3.3V only - damage will occur if they are connected to 5V systems. An adapter can be used to connect to 5V systems. Alternatively, low-cost USB to 3.3V serial adapters are available from various third parties. === Raspberry Pi Zero, 1, 2 and 3 @@ -18,9 +18,9 @@ The Raspberry Pi Zero, 1, 2, and 3 each contain two UARTs as follows: | mini UART |=== -=== Raspberry Pi 4 and 400 +=== Raspberry Pi 4 and 400 -The Raspberry Pi 4B and 400 have an additional four PL011s, which are disabled by default: +The Raspberry Pi 4 Model B and 400 have an additional four PL011s, which are disabled by default: |=== | Name | Type @@ -44,12 +44,39 @@ The Raspberry Pi 4B and 400 have an additional four PL011s, which are disabled b | PL011 |=== -=== CM, CM 3, CM 3+ and CM 4 +=== Raspberry Pi 5 -The first generation Compute Module, together with Compute Module 3 and Compute Module 3+ each have two UARTs, while Compute Module 4 has six UARTs as described above. +Raspberry Pi 5 has an additional four PL011s, which are disabled by default: -On all models of compute module, the UARTs are disabled by default and must be explicitly enabled using a device tree overlay. You must also specify which GPIO pins to use, for example: +|=== +| Name | Type + +| UART0 +| PL011 + +| UART1 +| PL011 + +| UART2 +| PL011 + +| UART3 +| PL011 +| UART4 +| PL011 + +|=== + +Raspberry Pi 5 does not have mini UART. + +=== CM1, CM3, CM3+ and CM4 + +The first generation Compute Module, together with Compute Module 3 and Compute Module 3+, has two UARTs, while Compute Module 4 has six UARTs as described above. + +On all models of Compute Module, the UARTs are disabled by default and can be explicitly enabled using a Device Tree overlay. You may also specify which GPIO pins to use, for example: + +[source,ini] ---- dtoverlay=uart1,txd1_pin=32,rxd1_pin=33 ---- @@ -58,43 +85,51 @@ dtoverlay=uart1,txd1_pin=32,rxd1_pin=33 On the Raspberry Pi, one UART is selected to be present on GPIO 14 (transmit) and 15 (receive) - this is the primary UART. By default, this will also be the UART on which a Linux console may be present. Note that GPIO 14 is pin 8 on the GPIO header, while GPIO 15 is pin 10. +On Raspberry Pi 5, the primary UART appears on the Debug header. + === Secondary UART The secondary UART is not normally present on the GPIO connector. By default, the secondary UART is connected to the Bluetooth side of the combined wireless LAN/Bluetooth controller, on models which contain this controller. === Primary and Secondary UART -The following table summarises the assignment of the first two UARTs: +The following table summarises the assignment of UARTs on various Raspberry Pi devices: |=== -| Model | first PL011 (UART0) | mini UART +| Model | Primary/console | Secondary/Bluetooth | Raspberry Pi Zero -| primary -| secondary +| UART0 +| UART1 -| Raspberry Pi Zero W -| secondary (Bluetooth) -| primary +| Raspberry Pi Zero W / Raspberry Pi Zero 2 W +| UART1 +| UART0 | Raspberry Pi 1 -| primary -| secondary +| UART0 +| UART1 | Raspberry Pi 2 -| primary -| secondary +| UART0 +| UART1 | Raspberry Pi 3 -| secondary (Bluetooth) -| primary +| UART1 +| UART0 + +| Compute Module 3 & 3+ +| UART0 +| UART1 | Raspberry Pi 4 -| secondary (Bluetooth) -| primary -|=== +| UART1 +| UART0 -NOTE: The mini UART is disabled by default, whether it is designated primary or secondary UART. +| Raspberry Pi 5 +| UART10 +| +|=== Linux devices on Raspberry Pi OS: @@ -112,12 +147,28 @@ Linux devices on Raspberry Pi OS: | `/dev/serial1` | secondary UART + +| `/dev/ttyAMA10` +| Raspberry Pi 5 Debug UART |=== -NOTE: `/dev/serial0` and `/dev/serial1` are symbolic links which point to either `/dev/ttyS0` or `/dev/ttyAMA0`. +`/dev/serial0` and `/dev/serial1` are symbolic links which point to either `/dev/ttyS0` or `/dev/ttyAMA0`. + +On the Raspberry Pi 5, `/dev/serial0` is a symbolic link that points to `/dev/ttyAMA10`. + +Due to changes in Bookworm, `/dev/serial1` does not exist by default. You can re-enable `serial1` by setting the following values in `config.txt`: + +[source,ini] +---- +dtparam=krnbt=off +---- + +TIP: This option may not work on all models in the future. Only use this option if there is no other alternative for your use case. === Mini-UART and CPU Core Frequency +NOTE: The mini UART is disabled by default if it is the primary or when Bluetooth is disabled. + In order to use the mini UART, you need to configure the Raspberry Pi to use a fixed VPU core clock frequency. This is because the mini UART clock is linked to the VPU core clock, so that when the core clock frequency changes, the UART baud rate will also change. The `enable_uart` and `core_freq` settings can be added to `config.txt` to change the behaviour of the mini UART. The following table summarises the possible combinations: |=== @@ -156,33 +207,43 @@ The default state of the `enable_uart` flag depends on which UART is the primary By default, the primary UART is assigned to the Linux console. If you wish to use the primary UART for other purposes, you must reconfigure Raspberry Pi OS. This can be done by using xref:configuration.adoc#raspi-config[raspi-config]: -. Start raspi-config: `sudo raspi-config`. -. Select option 3 - Interface Options. -. Select option P6 - Serial Port. -. At the prompt `Would you like a login shell to be accessible over serial?` answer 'No' -. At the prompt `Would you like the serial port hardware to be enabled?` answer 'Yes' -. Exit raspi-config and reboot the Pi for changes to take effect. +* Start raspi-config: `sudo raspi-config` +* Select option 3 - Interface Options +* Select option P6 - Serial Port +* At the prompt `Would you like a login shell to be accessible over serial?`, answer 'No' +* At the prompt `Would you like the serial port hardware to be enabled?`, answer 'Yes' +* Exit `raspi-config` and reboot the Raspberry Pi for changes to take effect -=== Enabling Early Console for Linux +=== Enabling early console for Linux Although the Linux kernel starts the UARTs relatively early in the boot process, it is still long after some critical bits of infrastructure have been set up. A failure in those early stages can be hard to diagnose without access to the kernel log messages from that time. To enable `earlycon` support for one of the UARTs, add one of the following options to `cmdline.txt`, depending on which UART is the primary: -For Pi 4, 400 and Compute Module 4: +For Raspberry Pi 5, `earlycon` output only appears on the 3-pin debug connector with the following configuration: + +[source,ini] +---- +earlycon=pl011,0x107d001000,115200n8 +---- + +For Raspberry Pi 4, Compute Module 4, Compute Module 4S, and Pi 400: +[source,ini] ---- earlycon=uart8250,mmio32,0xfe215040 earlycon=pl011,mmio32,0xfe201000 ---- -For Pi 2, Pi 3 and Compute Module 3: +For Raspberry Pi 2, 3, 3+, Zero 2 W, Compute Module 3, and Compute Module 3+: +[source,ini] ---- earlycon=uart8250,mmio32,0x3f215040 earlycon=pl011,mmio32,0x3f201000 ---- -For Pi 1, Pi Zero and Compute Module: +For Raspberry Pi 1, Zero, Zero W, and Compute Module 1: +[source,ini] ---- earlycon=uart8250,mmio32,0x20215040 earlycon=pl011,mmio32,0x20201000 @@ -190,20 +251,21 @@ earlycon=pl011,mmio32,0x20201000 The baudrate defaults to 115200bps. -NOTE: Selecting the wrong early console can prevent the Pi from booting. +NOTE: Selecting the wrong early console can prevent the Raspberry Pi from booting. === UARTs and Device Tree -Various UART Device Tree overlay definitions can be found in the https://github.com/raspberrypi/linux[kernel GitHub tree]. The two most useful overlays are https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/disable-bt-overlay.dts[`disable-bt`] and https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts[`miniuart-bt`]. +Various UART Device Tree overlay definitions can be found in the https://github.com/raspberrypi/linux[kernel GitHub]. The two most useful overlays are https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/disable-bt-overlay.dts[`disable-bt`] and https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts[`miniuart-bt`]. `disable-bt` disables the Bluetooth device and makes the first PL011 (UART0) the primary UART. You must also disable the system service that initialises the modem, so it does not connect to the UART, using `sudo systemctl disable hciuart`. `miniuart-bt` switches the Bluetooth function to use the mini UART, and makes the first PL011 (UART0) the primary UART. Note that this may reduce the maximum usable baud rate (see mini UART limitations below). You must also set the VPU core clock to a fixed frequency using either `force_turbo=1` or `core_freq=250`. -The overlays `uart2`, `uart3`, `uart4`, and `uart5` are used to enable the four additional UARTs on the Pi 4. There are other UART-specific overlays in the folder. Refer to `/boot/overlays/README` for details on Device Tree overlays, or run `dtoverlay -h overlay-name` for descriptions and usage information. +The overlays `uart2`, `uart3`, `uart4`, and `uart5` are used to enable the four additional UARTs on the Raspberry Pi 4. There are other UART-specific overlays in the folder. Refer to `/boot/firmware/overlays/README` for details on Device Tree overlays, or run `dtoverlay -h overlay-name` for descriptions and usage information. You add a line to the `config.txt` file to apply a xref:configuration.adoc#device-trees-overlays-and-parameters[Device Tree overlay]. Note that the `-overlay.dts` part of the filename is removed. For example: +[source,ini] ---- dtoverlay=disable-bt ---- @@ -214,12 +276,13 @@ There are some differences between PL011 UARTs and mini-UART. The mini-UART has smaller FIFOs. Combined with the lack of flow control, this makes it more prone to losing characters at higher baudrates. It is also generally less capable than a PL011, mainly due to its baud rate link to the VPU clock speed. -The particular deficiencies of the mini UART compared to a PL011 are : +The particular deficiencies of the mini UART compared to a PL011 are: * No break detection * No framing errors detection * No parity bit * No receive timeout interrupt -* No DCD, DSR, DTR or RI signals -Further documentation on the mini UART can be found in the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[SoC peripherals document]. +Neither the mini UART nor the BCM2835 implementation of the PL011 has DCD, DSR, DTR or RI signals. + +Further documentation on the mini UART can be found in the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[SoC peripherals document]. diff --git a/documentation/asciidoc/computers/configuration/use-a-proxy.adoc b/documentation/asciidoc/computers/configuration/use-a-proxy.adoc index 50f82a749d..56eced10d8 100644 --- a/documentation/asciidoc/computers/configuration/use-a-proxy.adoc +++ b/documentation/asciidoc/computers/configuration/use-a-proxy.adoc @@ -1,79 +1,89 @@ -== Using a Proxy Server +== Use a proxy server -If you want your Raspberry Pi to access the Internet via a proxy server (perhaps from a school or other workplace), you will need to configure your Pi to use the server before you can get online. +A **proxy server** acts as an intermediary between a client device and the Internet. +To configure your Raspberry Pi as a proxy server client, follow the instructions in this section. You will need: -* The IP address or hostname and port of your proxy server -* A username and password for your proxy (if required) +* the IP address or hostname and port of your proxy server +* a username and password for your proxy (if required) -=== Configuring your Raspberry Pi +=== Configure your Raspberry Pi You will need to set up three environment variables (`http_proxy`, `https_proxy`, and `no_proxy`) so your Raspberry Pi knows how to access the proxy server. Open a terminal window, and open the file `/etc/environment` using nano: +[source,console] ---- -sudo nano /etc/environment +$ sudo nano /etc/environment ---- Add the following to the `/etc/environment` file to create the `http_proxy` variable: +[source,bash] ---- -export http_proxy="http://proxyipaddress:proxyport" +export http_proxy="http://:" ---- -Replace `proxyipaddress` and `proxyport` with the IP address and port of your proxy. +Replace the `` and `` placeholders with the IP address and port of your proxy. -NOTE: if your proxy requires a username and password, add them using the following format: +[NOTE] +==== +If your proxy requires a username and password, add them using the following format: +[source,bash] ---- -export http_proxy="http://username:password@proxyipaddress:proxyport" +export http_proxy="http://:@proxyipaddress:proxyport" ---- +Replace the `` and `` placeholders with the username and password you use to authenticate with your proxy. +==== + Enter the same information for the environment variable `https_proxy`: +[source,bash] ---- export https_proxy="http://username:password@proxyipaddress:proxyport" ---- -Create the `no_proxy` environment variable, which is a comma-separated list of addresses your Pi should not use the proxy for: +Create the `no_proxy` environment variable, which is a comma-separated list of addresses your Raspberry Pi should not use the proxy for: +[source,bash] ---- export no_proxy="localhost, 127.0.0.1" ---- -Your `/etc/environment` file should now look like this: +Your `/etc/environment` file should now look like the following: +[source,bash] ---- export http_proxy="http://username:password@proxyipaddress:proxyport" export https_proxy="http://username:password@proxyipaddress:proxyport" export no_proxy="localhost, 127.0.0.1" ---- -image::images/proxy-environment-variables.png[environment variables] +Press **Ctrl + X** to save and exit. -Press ++++++Ctrl + X++++++ to save and exit. +=== Update the `sudoers` file -=== Update the `sudoers` File - -In order for operations that run as `sudo` (e.g. downloading and installing software) to use the new environment variables, you'll need to update `sudoers`. +To use the proxy environment variables with operations that run as `sudo`, such as downloading and installing software, update `sudoers`. Use the following command to open `sudoers`: +[source,console] ---- -sudo visudo +$ sudo visudo ---- Add the following line to the file so `sudo` will use the environment variables you just created: +[source,bash] ---- Defaults env_keep+="http_proxy https_proxy no_proxy" ---- -image::images/proxy-edit-sudoers.png[edit sudoers] - -Press ++++++Ctrl + X++++++ to save and exit. +Press **Ctrl + X** to save and exit. === Reboot your Raspberry Pi diff --git a/documentation/asciidoc/computers/configuration/users.adoc b/documentation/asciidoc/computers/configuration/users.adoc new file mode 100644 index 0000000000..d9f45c13dc --- /dev/null +++ b/documentation/asciidoc/computers/configuration/users.adoc @@ -0,0 +1,71 @@ +== Users + +[[change-user-password]] +=== Change a user's password + +You can change the password for the current user account via the `raspi-config` application on from the command line: + +[source,console] +---- +$ sudo raspi-config +---- + +Select option 2, and follow the instructions to change the password. + +Alternatively, use the `passwd` application: + +[source,console] +---- +$ passwd +---- + +=== Add a user + +To add a new user, enter the following command, replacing the `` placeholder with the username for the new user: + +[source,console] +---- +$ sudo adduser +---- + +When prompted, enter a password for the new user. + +You can find the home directory for the new user at `/home//`. + +To grant the new user necessary permissions, like `sudo`, run the following command to add the user to the associated user groups, replacing the `` placeholder with the username for the new user: + +[source,console] +---- +$ sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi +---- + +To check that the permissions were successfully granted, run the following command, replacing the `` placeholder with the username for the new user: + +[source,console] +---- +$ sudo su - +---- + +If the above command runs successfully, permissions were successfully configured for the user. + +=== Delete a user + +To delete a user, run the following command, replacing the `` placeholder with the username you would like to delete: + +[source,console] +---- +$ sudo deluser -remove-home +---- + +This command deletes the user as well as their home directory. If you'd like to preserve the user's home directory, run the command without the `-remove-home` option. + +=== Change the default user + +To change the user that automatically logs into your Raspberry Pi on boot, run the following command: + +[source,console] +---- +$ sudo raspi-config +---- + +Select option `1`, `Boot/Auto login`. Reboot to put your changes into effect. diff --git a/documentation/asciidoc/computers/configuration/warning-icons.adoc b/documentation/asciidoc/computers/configuration/warning-icons.adoc deleted file mode 100644 index 3ae335e32c..0000000000 --- a/documentation/asciidoc/computers/configuration/warning-icons.adoc +++ /dev/null @@ -1,21 +0,0 @@ -== Firmware Warning Icons - -Under certain circumstances, the Raspberry Pi firmware will display a warning icon on the display, to indicate an issue. There are currently three icons that can be displayed. - -=== Undervoltage Warning - -If the power supply to the Raspberry Pi drops below 4.63V (±5%), the following icon is displayed. - -image::images/under_volt.png[Under Voltage] - -=== Over Temperature Warning (80-85°C) - -If the temperature of the SoC is between 80C and 85C, the following icon is displayed. The ARM core(s) will be throttled back in an attempt to reduce the core temperature. - -image::images/over_temperature_80_85.png[Over Temperature (80-85°C)] - -=== Over Temperature Warning (over 85°C) - -If the temperature of the SoC is over 85°C, the following icon is displayed. The ARM core(s) and the GPU will be throttled back in an attempt to reduce the core temperature. - -image::images/over_temperature_85.png[Over Temperature (85°C+)] diff --git a/documentation/asciidoc/computers/getting-started.adoc b/documentation/asciidoc/computers/getting-started.adoc index 81f3f3815b..0828a4e29a 100644 --- a/documentation/asciidoc/computers/getting-started.adoc +++ b/documentation/asciidoc/computers/getting-started.adoc @@ -1,16 +1,7 @@ include::getting-started/setting-up.adoc[] -include::getting-started/installing-from-an-image.adoc[] +include::getting-started/install.adoc[] -include::getting-started/installing-from-chromeos.adoc[] - -include::getting-started/installing-from-linux.adoc[] - -include::getting-started/installing-from-mac.adoc[] - -include::getting-started/installing-from-windows.adoc[] - -include::getting-started/sd-cards.adoc[] - -include::getting-started/connecting-a-monitor.adoc[] +include::getting-started/configuring.adoc[] +include::getting-started/wrapping-up.adoc[] diff --git a/documentation/asciidoc/computers/getting-started/configuring.adoc b/documentation/asciidoc/computers/getting-started/configuring.adoc new file mode 100644 index 0000000000..633bca35f5 --- /dev/null +++ b/documentation/asciidoc/computers/getting-started/configuring.adoc @@ -0,0 +1,87 @@ +== Set up your Raspberry Pi + +After installing an operating system image, connect your storage device to your Raspberry Pi. + +First, unplug your Raspberry Pi's power supply to ensure that the Raspberry Pi is powered down while you connect peripherals. +If you installed the operating system on a microSD card, you can plug it into your Raspberry Pi's card slot now. +If you installed the operating system on any other storage device, you can connect it to your Raspberry Pi now. + +image::images/peripherals/sd-card.png[alt="Inserting a microSD card into a Raspberry Pi.",width="80%"] + +Then, plug in any other peripherals, such as your mouse, keyboard, and monitor. + +image::images/peripherals/cable-all.png[alt="Attaching the power supply to a Raspberry Pi.",width="80%"] + +Finally, connect the power supply to your Raspberry Pi. You should see the status LED light up when your Pi powers on. If your Pi is connected to a display, you should see the boot screen within minutes. + +== Configuration on first boot + +If you used OS customisation in Imager to preconfigure your Raspberry Pi, **congratulations!** Your device is ready to use. Proceed to xref:getting-started.adoc#next-steps[next steps] to learn how you can put your Raspberry Pi to good use. + +If your Raspberry Pi does not boot within 5 minutes, check the status LED. If it's flashing, see the xref:configuration.adoc#led-warning-flash-codes[LED warning flash codes for more information]. If your Pi refuses to boot, try the following mitigation steps: + +* if you used a boot device other than an SD card, try booting from an SD card +* xref:getting-started.adoc#installing-the-operating-system[re-image your SD card]; be sure to complete the entire verify step in Imager +* xref:raspberry-pi.adoc#bootloader_update_stable[update the bootloader] on your Raspberry Pi, then xref:getting-started.adoc#installing-the-operating-system[re-image your SD card] + +If you chose to skip OS customisation in Imager, your Raspberry Pi will run a configuration wizard on first boot. You need a monitor and keyboard to navigate through the wizard; a mouse is optional. + +image::images/initial-setup/start.png[alt="Click Next to get started with configuration.",width="80%"] + +=== Bluetooth + +If you're using a Bluetooth keyboard or mouse, this step will walk you through device pairing. Your Raspberry Pi will scan for pairable devices and connect to the first device it finds for each item. + +This process works with built-in or external USB Bluetooth adapters. If you use a USB adapter, plug it in before booting your Raspberry Pi. + +=== Locale + +This page helps you configure your country, language, and time zone, and keyboard layout. + +image::images/initial-setup/locale.png[alt="Adjust country, language, time zone, and keyboard layout.",width="80%"] + +=== User + +This page helps you configure the username and password for the default user account. + +By default, older versions of Raspberry Pi OS set the username to "pi". If you use the username "pi", avoid the old default password of "raspberry" to keep your Raspberry Pi secure. + +image::images/initial-setup/user.png[alt="Create your username and password.",width="80%"] + +=== Wi-Fi + +This page helps you connect to a Wi-Fi network. Choose your preferred network from the list. + +image::images/initial-setup/network.png[alt="Selecting a wireless network.",width="80%"] + +If your network requires a password, you can enter it here. + +image::images/initial-setup/network_password.png[alt="Entering a password for a wireless network.",width="80%"] + +=== Browser + +This page lets you select Firefox or Chromium as your default internet browser. You can optionally uninstall the browser you don't set as default. + +image::images/initial-setup/browser.png[alt="The Choose Browser page.",width="80%"] + +=== Raspberry Pi Connect + +This page lets you enable xref:../services/connect.adoc[Raspberry Pi Connect], which provides the ability to access your Raspberry Pi remotely with no manual network configuration. + +image::images/initial-setup/connect.png[alt="The Enable Raspberry Pi Connect page.",width="80%"] + +=== Software updates + +Once your Raspberry Pi has internet access, this page helps you update your operating system and software to the latest versions. During the software update process, the wizard will remove the non-default browser if you opted to uninstall it in the browser selection step. Downloading updates may take several minutes. + +image::images/initial-setup/update.png[alt="You can download the latest software updates during the wizard before you boot for the first time.",width="80%"] + +image::images/initial-setup/download.png[alt="You can download the latest software updates during the wizard before you boot for the first time.",width="80%"] + +When you see a popup indicating that your system is up to date, click **OK** to proceed to the next step. + +=== Finish + +At the end of the configuration wizard, click **Restart** to reboot your Raspberry Pi. Your Raspberry Pi will apply your configuration and boot to the desktop. + +image::images/initial-setup/restart.png[alt="The Setup Complete dialogue prompts to restart your Raspberry Pi.",width="80%"] diff --git a/documentation/asciidoc/computers/getting-started/connecting-a-monitor.adoc b/documentation/asciidoc/computers/getting-started/connecting-a-monitor.adoc deleted file mode 100644 index c5f1705617..0000000000 --- a/documentation/asciidoc/computers/getting-started/connecting-a-monitor.adoc +++ /dev/null @@ -1,37 +0,0 @@ -== Connecting a Display - -Unless you're setting up your Raspberry Pi to operate "https://aallan.medium.com/setting-up-a-headless-raspberry-pi-zero-3ded0b83f274[headless]," for regular use you'll want to plug the Raspberry Pi in to a display: either a computer monitor, or a televison. - -=== Connecting using HDMI - -The Raspberry Pi has an HDMI port which you can connect directly to a monitor or TV with an HDMI cable. This is the easiest solution; some modern monitors and TVs have HDMI ports, some do not, but there are other options. - -image::images/hdmi_connector.png[HDMI cable] - -NOTE: The Raspberry Pi 4 has two micro HDMI connectors, which require a good-quality micro HDMI cable, especially when using 4K monitors or television. Raspberry Pi sells a https://www.raspberrypi.org/products/micro-hdmi-to-standard-hdmi-a-cable/[suitable cable]. - -image::images/hdmi_micro.png[HDMI_micro] - -If you're using your Raspberry Pi with a monitor with built-in speakers and are connecting to it using an HDMI cable you can also use it to output sound. - -=== Connecting using DVI - -For monitors with a DVI port, you can use an HDMI-to-DVI cable, or an HDMI cable with a DVI adapter. - -image::images/dvi_hdmi_cable.png[DVI-HDMI cable] - -NOTE: Unlike HDMI the DVI standard does not support audio - -=== Connecting using VGA - -For monitors with VGA only, you can use an HDMI-to-VGA adapter. Note that VGA does not support audio. - -image::images/hdmi-vga.jpg[VGA-HDMI adapter] - -=== Using the Composite Port - -Most models of Raspberry Pi have a composite out port for connecting to analog devices, but the type of connector varies depending on the model. The original Raspberry Pi used an RCA connector, and a standard RCA composite video lead will work. Others models (Raspberry Pi B+ and later) combine the audio out and composite out on to the same 3.5mm jackplug. This requires a particular type of lead, with audio left on the tip, audio right on ring 1, ground on ring 2, and video on the sleeve. This is the same as leads used on the Zune, and on Apple devices. - -image::images/rca_connector.png[RCA cable] - -More information on connecting to a monitor can be found in our https://www.raspberrypi.org/learning/hardware-guide/equipment/[learning resources section]. diff --git a/documentation/asciidoc/computers/getting-started/images/beta-bootloader-1.png b/documentation/asciidoc/computers/getting-started/images/beta-bootloader-1.png new file mode 100644 index 0000000000..790dd1c5bb Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/beta-bootloader-1.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/beta-bootloader-2.png b/documentation/asciidoc/computers/getting-started/images/beta-bootloader-2.png new file mode 100644 index 0000000000..1e63573ef2 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/beta-bootloader-2.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/fifth-editon-cover.png b/documentation/asciidoc/computers/getting-started/images/fifth-editon-cover.png new file mode 100644 index 0000000000..f756508ee2 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/fifth-editon-cover.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/are-you-sure.png b/documentation/asciidoc/computers/getting-started/images/imager/are-you-sure.png new file mode 100644 index 0000000000..73c1f6c84b Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/are-you-sure.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/choose-model.png b/documentation/asciidoc/computers/getting-started/images/imager/choose-model.png new file mode 100644 index 0000000000..6e0602383f Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/choose-model.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/choose-os.png b/documentation/asciidoc/computers/getting-started/images/imager/choose-os.png new file mode 100644 index 0000000000..c6fd9a25d4 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/choose-os.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/choose-storage.png b/documentation/asciidoc/computers/getting-started/images/imager/choose-storage.png new file mode 100644 index 0000000000..274b52b818 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/choose-storage.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/finished.png b/documentation/asciidoc/computers/getting-started/images/imager/finished.png new file mode 100644 index 0000000000..bd8df650f6 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/finished.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-general.png b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-general.png new file mode 100644 index 0000000000..7bf615091b Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-general.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-options.png b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-options.png new file mode 100644 index 0000000000..971108d398 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-options.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-prompt.png b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-prompt.png new file mode 100644 index 0000000000..9998c82b05 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-prompt.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-services.png b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-services.png new file mode 100644 index 0000000000..98924e3f5c Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/os-customisation-services.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/stop-ask-verify.png b/documentation/asciidoc/computers/getting-started/images/imager/stop-ask-verify.png new file mode 100644 index 0000000000..e9a90c5101 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/stop-ask-verify.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/welcome.png b/documentation/asciidoc/computers/getting-started/images/imager/welcome.png new file mode 100644 index 0000000000..13fc67987c Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/welcome.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/imager/writing.png b/documentation/asciidoc/computers/getting-started/images/imager/writing.png new file mode 100644 index 0000000000..a21845b2d9 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/imager/writing.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/browser.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/browser.png new file mode 100644 index 0000000000..4d34f86255 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/browser.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/connect.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/connect.png new file mode 100644 index 0000000000..8f0044d83e Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/connect.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/download.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/download.png new file mode 100644 index 0000000000..7bf8322454 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/download.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/locale.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/locale.png new file mode 100644 index 0000000000..160670cb16 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/locale.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/network.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/network.png new file mode 100644 index 0000000000..932f0e29dc Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/network.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/network_password.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/network_password.png new file mode 100644 index 0000000000..f21b495baa Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/network_password.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/restart.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/restart.png new file mode 100644 index 0000000000..4beac383fc Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/restart.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/start.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/start.png new file mode 100644 index 0000000000..7f037078d9 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/start.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/update.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/update.png new file mode 100644 index 0000000000..112aca48e4 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/update.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/initial-setup/user.png b/documentation/asciidoc/computers/getting-started/images/initial-setup/user.png new file mode 100644 index 0000000000..4032ba0680 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/initial-setup/user.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/network-install-1.png b/documentation/asciidoc/computers/getting-started/images/network-install-1.png new file mode 100644 index 0000000000..ec4d8fcffe Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/network-install-1.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/network-install-2.png b/documentation/asciidoc/computers/getting-started/images/network-install-2.png new file mode 100644 index 0000000000..b97b3e0a14 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/network-install-2.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/network-install-3.png b/documentation/asciidoc/computers/getting-started/images/network-install-3.png new file mode 100644 index 0000000000..f0730798a5 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/network-install-3.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/network-install-4.png b/documentation/asciidoc/computers/getting-started/images/network-install-4.png new file mode 100644 index 0000000000..7029a4aaad Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/network-install-4.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-all.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-all.png new file mode 100644 index 0000000000..03c0124f2c Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-all.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-hdmi.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-hdmi.png new file mode 100644 index 0000000000..62ebf37135 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-hdmi.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-key.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-key.png new file mode 100644 index 0000000000..4f277513e4 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-key.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-mouse.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-mouse.png new file mode 100644 index 0000000000..a00b9e869c Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-mouse.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-net.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-net.png new file mode 100644 index 0000000000..4cf13f9395 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-net.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/cable-power.png b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-power.png new file mode 100644 index 0000000000..44e4b032aa Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/cable-power.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/peripherals/sd-card.png b/documentation/asciidoc/computers/getting-started/images/peripherals/sd-card.png new file mode 100644 index 0000000000..9ea290c670 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/peripherals/sd-card.png differ diff --git a/documentation/asciidoc/computers/getting-started/images/recommended-software.png b/documentation/asciidoc/computers/getting-started/images/recommended-software.png new file mode 100644 index 0000000000..11eb335ed1 Binary files /dev/null and b/documentation/asciidoc/computers/getting-started/images/recommended-software.png differ diff --git a/documentation/asciidoc/computers/getting-started/install.adoc b/documentation/asciidoc/computers/getting-started/install.adoc new file mode 100644 index 0000000000..534417311f --- /dev/null +++ b/documentation/asciidoc/computers/getting-started/install.adoc @@ -0,0 +1,160 @@ +[[installing-the-operating-system]] +== Install an operating system + +To use your Raspberry Pi, you'll need an operating system. By default, Raspberry Pis check for an operating system on any SD card inserted in the SD card slot. + +Depending on your Raspberry Pi model, you can also boot an operating system from other storage devices, including USB drives, storage connected via a HAT, and network storage. + +To install an operating system on a storage device for your Raspberry Pi, you'll need: + +* a computer you can use to image the storage device into a boot device +* a way to plug your storage device into that computer + +Most Raspberry Pi users choose microSD cards as their boot device. + +We recommend installing an operating system using xref:getting-started.adoc#raspberry-pi-imager[Raspberry Pi Imager]. + +Raspberry Pi Imager is a tool that helps you download and write images on macOS, Windows, and Linux. Imager includes many popular operating system images for Raspberry Pi. Imager also supports loading images downloaded directly from https://www.raspberrypi.com/software/operating-systems/[Raspberry Pi] or third-party vendors such as https://ubuntu.com/download/raspberry-pi[Ubuntu]. You can use Imager to preconfigure credentials and remote access settings for your Raspberry Pi. + +Imager supports images packaged in the `.img` format as well as container formats like `.zip`. + +If you have no other computer to write an image to a boot device, you may be able to install an operating system xref:getting-started.adoc#install-over-the-network[directly on your Raspberry Pi from the internet]. + +[[raspberry-pi-imager]] +=== Install using Imager + +//// +TODO: Update this video for the new Imager look & flow (video::ntaXWS8Lk34[youtube,width=80%,height=400px]) +//// + +You can install Imager in the following ways: + +* Download the latest version from https://www.raspberrypi.com/software/[raspberrypi.com/software] and run the installer. +* Install it from a terminal using your package manager, e.g. `sudo apt install rpi-imager`. + +Once you've installed Imager, launch the application by clicking the Raspberry Pi Imager icon or running `rpi-imager`. + +image::images/imager/welcome.png[alt="Raspberry Pi Imager main window.",width="80%"] + +Click **Choose device** and select your Raspberry Pi model from the list. + +image::images/imager/choose-model.png[alt="Raspberry Pi model selections in Imager.",width="80%"] + +Next, click **Choose OS** and select an operating system to install. Imager always shows the recommended version of Raspberry Pi OS for your model at the top of the list. + +image::images/imager/choose-os.png[alt="Operating system selections in Imager.",width="80%"] + +Connect your preferred storage device to your computer. For example, plug a microSD card in using an external or built-in SD card reader. Then, click **Choose storage** and select your storage device. + +WARNING: If you have more than one storage device connected to your computer, _be sure to choose the correct device!_ You can often identify storage devices by size. If you're unsure, disconnect other devices until you've identified the device you want to image. + +image::images/imager/choose-storage.png[alt="Storage selection options in Imager.",width="80%"] + +Next, click **Next**. + +image::images/imager/os-customisation-prompt.png[alt="Imager prompt to open OS customisation menu.",width="80%"] + +In a popup, Imager will ask you to apply OS customisation. We strongly recommend configuring your Raspberry Pi via the OS customisation settings. Click the **Edit Settings** button to open xref:getting-started.adoc#advanced-options[OS customisation]. + +If you don't configure your Raspberry Pi via OS customisation settings, Raspberry Pi OS will ask you for the same information at first boot during the xref:getting-started.adoc#configuration-on-first-boot[configuration wizard]. You can click the **No** button to skip OS customisation. + +[[advanced-options]] +==== OS customisation + +The OS customisation menu lets you set up your Raspberry Pi before first boot. You can preconfigure: + +* a username and password +* Wi-Fi credentials +* the device hostname +* the time zone +* your keyboard layout +* remote connectivity + +When you first open the OS customisation menu, you might see a prompt asking for permission to load Wi-Fi credentials from your host computer. If you respond "yes", Imager will prefill Wi-Fi credentials from the network you're currently connected to. If you respond "no", you can enter Wi-Fi credentials manually. + +The **hostname** option defines the hostname your Raspberry Pi broadcasts to the network using https://en.wikipedia.org/wiki/Multicast_DNS[mDNS]. When you connect your Raspberry Pi to your network, other devices on the network can communicate with your computer using `.local` or `.lan`. + +The **username and password** option defines the username and password of the admin user account on your Raspberry Pi. + +The **wireless LAN** option allows you to enter an SSID (name) and password for your wireless network. If your network does not broadcast an SSID publicly, you should enable the "Hidden SSID" setting. By default, Imager uses the country you're currently in as the "Wireless LAN country". This setting controls the Wi-Fi broadcast frequencies used by your Raspberry Pi. Enter credentials for the wireless LAN option if you plan to run a headless Raspberry Pi. + +The **locale settings** option allows you to define the time zone and default keyboard layout for your Pi. + +image::images/imager/os-customisation-general.png[alt="General settings in the OS customisation menu.",width="80%"] + +The **Services** tab includes settings to help you connect to your Raspberry Pi remotely. + +If you plan to use your Raspberry Pi remotely over your network, check the box next to **Enable SSH**. You should enable this option if you plan to run a headless Raspberry Pi. + +* Choose the **password authentication** option to SSH into your Raspberry Pi over the network using the username and password you provided in the general tab of OS customisation. + +* Choose **Allow public-key authentication only** to preconfigure your Raspberry Pi for passwordless public-key SSH authentication using a private key from the computer you're currently using. If already have an RSA key in your SSH configuration, Imager uses that public key. If you don't, you can click **Run SSH-keygen** to generate a public/private key pair. Imager will use the newly-generated public key. + +image::images/imager/os-customisation-services.png[alt="Services settings in the OS customisation menu.",width="80%"] + +OS customisation also includes an **Options** menu that allows you to configure the behaviour of Imager during a write. These options allow you to play a noise when Imager finishes verifying an image, to automatically unmount storage media after verification, and to disable telemetry. + +image::images/imager/os-customisation-options.png[alt="Options in the OS customisation menu.",width="80%"] + +==== Write + +When you've finished entering OS customisation settings, click **Save** to save your customisation. + +Then, click **Yes** to apply OS customisation settings when you write the image to the storage device. + +Finally, respond **Yes** to the "Are you sure you want to continue?" popup to begin writing data to the storage device. + +image::images/imager/are-you-sure.png[alt="Confirming a reimage of a storage device in Imager.",width="80%"] + +If you see an admin prompt asking for permissions to read and write to your storage medium, grant Imager the permissions to proceed. + +.Grab a cup of coffee or go for a walk. This could take a few minutes. +image::images/imager/writing.png[alt="Writing an image to a device in Imager.",width="80%"] + +.If you want to live especially dangerously, you can click **cancel verify** to skip the verification process. +image::images/imager/stop-ask-verify.png[alt="Verifying an image on a device in Imager.",width="80%"] + +When you see the "Write Successful" popup, your image has been completely written and verified. You're now ready to boot a Raspberry Pi from the storage device! + +image::images/imager/finished.png[alt="The screen Imager shows when it finishes writing an image to a storage device.",width="80%"] + +Next, proceed to the xref:getting-started.adoc#configuration-on-first-boot[first boot configuration instructions] to get your Raspberry Pi up and running. + +=== Install over the network + +Network Install enables a Raspberry Pi to install an operating system on a storage device using a version of Raspberry Pi Imager downloaded over the network. With Network Install, you can get an operating system installed on your Raspberry Pi with no separate SD card reader and no computer other than your Raspberry Pi. You can run Network Install on any compatible storage device, including SD cards and USB storage. + +Network Install only runs on Flagship models since Raspberry Pi 4B and Keyboard models. If your Raspberry Pi runs an older bootloader, you may need to xref:raspberry-pi.adoc#bootloader_update_stable[update the bootloader] to use Network Install. + +//// +TODO: Update this video for the new Imager look & flow video::b1SYVpM9lto[youtube,width=80%,height=400px] +//// + +Network Install requires the following: + +* a compatible Raspberry Pi model running firmware that supports Network Install +* a monitor +* a keyboard +* a wired internet connection + +To launch Network Install, power on your Raspberry Pi _while pressing and holding the **SHIFT** key_ in the following configuration: + +* no bootable storage device +* attached keyboard +* attached compatible storage device, such as an SD card or USB storage + +image::images/network-install-1.png[alt="The Network Install screen.",width="80%"] + +If you haven't already connected your Raspberry Pi to the internet, connect it with an Ethernet cable. + +image::images/network-install-2.png[alt="Starting Network Install.",width="80%"] + +Once you're connected to the internet, your Raspberry Pi will download Raspberry Pi installer. If the download fails, you can repeat the process to try again. + +image::images/network-install-3.png[alt="Downloading Imager using Network Install.",width="80%"] + +Once you finish downloading Raspberry Pi Installer, your Raspberry Pi will automatically start Raspberry Pi Imager. For more information about running Raspberry Pi Imager, see xref:getting-started.adoc#installing-the-operating-system[install an operating system]. + +image::images/network-install-4.png[alt="Choose a storage device.",width="80%"] + +For more information about Network Install configuration, see xref:raspberry-pi.adoc#http-boot[HTTP boot]. diff --git a/documentation/asciidoc/computers/getting-started/installing-from-an-image.adoc b/documentation/asciidoc/computers/getting-started/installing-from-an-image.adoc deleted file mode 100644 index 3ba1c447f1..0000000000 --- a/documentation/asciidoc/computers/getting-started/installing-from-an-image.adoc +++ /dev/null @@ -1,34 +0,0 @@ -== Installing the Operating System - -Raspberry Pi now recommend the use of the https://www.raspberrypi.org/software/[Raspberry Pi Imager] tool to install an operating system on your SD Card. You will need another computer with an SD card reader to install the image. - -NOTE: Before you start, don't forget to check xref:getting-started.adoc#sd-cards[the SD card requirements]. - -=== Using Raspberry Pi Imager - -Raspberry Pi have developed a graphical SD card writing tool that works on Mac OS, Ubuntu 18.04, and Windows. The https://www.raspberrypi.org/downloads/[Raspberry Pi Imager] is the easiest option for most users as it will download the image and install it automatically to the SD card. - -video::ntaXWS8Lk34[youtube] - -Download the latest version of https://www.raspberrypi.org/downloads/[Raspberry Pi Imager] and install it. If you want to use Raspberry Pi Imager from a second Raspberry Pi, you can install it from a terminal using `sudo apt install rpi-imager`. Then; - -* Connect an SD card reader with the SD card inside. -* Open Raspberry Pi Imager and choose the required OS from the list presented. -* Choose the SD card you wish to write your image to. -* Review your selections and click on the 'Write' button to begin writing data to the SD Card. - -NOTE: If using the Raspberry Pi Imager on Windows 10 with "Controlled Folder Access" enabled, you will need to explicitly allow the Raspberry Pi Imager permission to write the SD card. If this is not done, the Imager will fail with a "failed to write" error. - -NOTE: You can see which operating systems are most often downloaded, on our https://rpi-imager-stats.raspberrypi.org/[statistics page]. - -You can now insert the SD card into the Raspberry Pi and power it up. For the official Raspberry Pi OS, if you need to manually log in, the default user name is `pi`, with password `raspberry`, and the default keyboard layout is set to https://datasheets.raspberrypi.org/keyboard-mouse/UK-layout.png[United Kingdom (UK)]. - -You should change the default password straight away to ensure your Raspberry Pi is xref:configuration.adoc#securing-your-raspberry-pi[secure]. - -=== Downloading an Image - -If you are using a different tool than the Raspberry Pi Imager to write to your SD Card most require you to download the image first, and then use the tool to write it to the card. Official images for recommended operating systems are available to download from the Raspberry Pi website https://www.raspberrypi.org/downloads/[downloads page]. Alternative distributions for the Raspberry Pi are also available from some third-party vendors. - -You may need to unzip the downloaded file (`.zip`) to get the image file (`.img`) you need to write to the card. - -NOTE: The Raspberry Pi OS with desktop image contained in the ZIP archive is over 4GB in size and uses the https://en.wikipedia.org/wiki/Zip_%28file_format%29#ZIP64[ZIP64] format. To uncompress the archive, a unzip tool that supports ZIP64 is required. The following zip tools support ZIP64; http://www.7-zip.org/[7-Zip] for Windows, http://unarchiver.c3.cx/unarchiver[The Unarchiver] for macOS, and https://linux.die.net/man/1/unzip[unzip] on Linux. diff --git a/documentation/asciidoc/computers/getting-started/installing-from-chromeos.adoc b/documentation/asciidoc/computers/getting-started/installing-from-chromeos.adoc deleted file mode 100644 index 8e21ba4b14..0000000000 --- a/documentation/asciidoc/computers/getting-started/installing-from-chromeos.adoc +++ /dev/null @@ -1,14 +0,0 @@ -== Installing Images on Chrome OS - -The easiest way to write images to an SD card and USB drives with Chrome OS is to use the official https://chrome.google.com/webstore/detail/chromebook-recovery-utili/jndclpdbaamdhonoechobihbbiimdgai[Chromebook Recovery Utility]. It can be used to create Chromebook Recovery media, and it will also accept `.zip` files containing images. - -* Download the https://chrome.google.com/webstore/detail/chromebook-recovery-utili/pocpnlppkickgojjlmhdmidojbmbodfm[Chromebook Recovery Utility]. -* Download the https://www.raspberrypi.org/downloads/raspbian/[Raspberry Pi OS] zip archive. -* Launch the *Recovery Utility* -* Click on the *Settings Gears* icon in the upper right-hand corner, next to the window close icon. -* Select the *Use Local Image* option. -* Choose the `.zip` file you downloaded. -* Insert the SD card and click *Continue*. -* Read the warning and click the *Create now* button. -* Wait for the progress bar to complete twice (for unpacking and writing). This might take a few minutes. Once the process is complete, a big green checkmark will be shown. -* Close the program and eject the card. diff --git a/documentation/asciidoc/computers/getting-started/installing-from-linux.adoc b/documentation/asciidoc/computers/getting-started/installing-from-linux.adoc deleted file mode 100644 index d94b86fc88..0000000000 --- a/documentation/asciidoc/computers/getting-started/installing-from-linux.adoc +++ /dev/null @@ -1,89 +0,0 @@ -== Installing Images on Linux - -xref:getting-started.adoc#using-raspberry-pi-imager[Raspberry Pi Imager] is typically the easiest option for most users to write images to SD cards, so it is a good place to start. If you're looking for more advanced options on Linux, you can use the standard command line tools below. - -NOTE: Using the `dd` tool can overwrite any partition of your machine. If you specify the wrong device when using `dd`, you could delete your primary Linux partition. Please be careful. - -[discrete] -==== Discovering the SD card mountpoint and unmounting it - -* Run `lsblk -p` to see which devices are currently connected to your machine. -* If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer. -* Run `lsblk -p` again. The new device that has appeared is your SD card (you can also usually tell from the listed device size). The naming of the device will follow the format described in the next paragraph. -* The left column of the results from the `lsblk -p` command gives the device name of your SD card and the names of any partitions on it (usually only one, but there may be several if the card was previously used). It will be listed as something like `/dev/mmcblk0` or `/dev/sdX` (with partition names `/dev/mmcblk0p1` or `/dev/sdX1` respectively), where `X` is a lower-case letter indicating the device (eg. `/dev/sdb1`). The right column shows where the partitions have been mounted (if they haven't been, it will be blank). -* If any partitions on the SD card have been mounted, unmount them all with `umount`, for example `umount /dev/sdX1` (replace `sdX1` with your SD card's device name, and change the number for any other partitions). - -[discrete] -==== Copying the image to the SD card - -* In a terminal window, write the image to the card with the command below, making sure you replace the input file `if=` argument with the path to your `.img` file, and the `/dev/sdX` in the output file `of=` argument with the correct device name. *This is very important, as you will lose all the data on the hard drive if you provide the wrong device name.* Make sure the device name is the name of the whole SD card as described above, not just a partition. For example: `sdd`, not `sdds1` or `sddp1`; `mmcblk0`, not `mmcblk0p1`. -+ -[,bash] ----- -sudo dd if=2021-05-07-raspios-buster-armhf.img of=/dev/sdX bs=4M conv=fsync ----- - -* Please note that block size set to `4M` will work most of the time. If not, try `1M`, although this will take considerably longer. - -[discrete] -==== Copying a zipped image to the SD card - -In Linux it is possible to combine the unzip and SD copying process into one command, which avoids any issues that might occur when the unzipped image is larger than 4GB. This can happen on certain filesystems that do not support files larger than 4GB (e.g. FAT), although it should be noted that most Linux installations do not use FAT and therefore do not have this limitation. - -The following command unzips the zip file (replace 2021-05-07-raspios-buster-armhf.zip with the appropriate zip filename), and pipes the output directly to the dd command. This in turn copies it to the SD card, as described in the previous section. - ----- -unzip -p 2021-05-07-raspios-buster-armhf.zip | sudo dd of=/dev/sdX bs=4M conv=fsync ----- - -[discrete] -==== Checking the image copy progress - -* By default, the `dd` command does not give any information about its progress, so it may appear to have frozen. It can take more some time to finish writing to the card. If your card reader has an LED, it may blink during the write process. -* To see the progress of the copy operation, you can run the dd command with the status option. -+ ----- - sudo dd if=2021-05-07-raspios-buster-armhf.img of=/dev/sdX bs=4M conv=fsync status=progress ----- - -* If you are using an older version of `dd`, the status option may not be available. You may be able to use the `dcfldd` command instead, which will give a progress report showing how much has been written. Another method is to send a USR1 signal to `dd`, which will let it print status information. Find out the PID of `dd` by using `pgrep -l dd` or `ps a | grep dd`. Then use `kill -USR1 PID` to send the USR1 signal to `dd`. - -[discrete] -==== Optional: checking whether the image was correctly written to the SD card - -* After `dd` has finished copying, you can check what has been written to the SD card by `dd`-ing from the card back to another image on your hard disk, truncating the new image to the same size as the original, and then running `diff` (or `md5sum`) on those two images. -* If the SD card is much larger than the image, you don't want to read back the whole SD card, since it will be mostly empty. So you need to check the number of blocks that were written to the card by the `dd` command. At the end of its run, `dd` will have displayed the number of blocks written as follow: -+ ----- -xxx+0 records in -yyy+0 records out -yyyyyyyyyy bytes (yyy kB, yyy KiB) copied, 0.00144744 s, 283 MB/s ----- -+ -We need the number `xxx`, which is the block count. We can ignore the `yyy` numbers. - -* Copy the SD card content to an image on your hard drive using `dd` again: -+ -[,bash] ----- -sudo dd if=/dev/sdX of=from-sd-card.img bs=4M count=xxx ----- -+ -`if` is the input file (i.e. the SD card device), `of` is the output file to which the SD card content is to be copied (called `from-sd-card.img` in this example), and `xxx` is the number of blocks written by the original `dd` operation. - -* In case the SD card image is still larger than the original image, truncate the new image to the size of the original image using the following command (replace the input file `reference` argument with the original image name): -+ -[,bash] ----- -truncate --reference 2021-05-07-raspios-buster-armhf.img from-sd-card.img ----- - -* Compare the two images: `diff` should report that the files are identical. -+ -[,bash] ----- -diff -s from-sd-card.img 2021-05-07-raspios-buster-armhf.img ----- - -* Run `sync`. This will ensure that the write cache is flushed and that it is safe to unmount your SD card. -* Remove the SD card from the card reader. diff --git a/documentation/asciidoc/computers/getting-started/installing-from-mac.adoc b/documentation/asciidoc/computers/getting-started/installing-from-mac.adoc deleted file mode 100644 index ff58896a59..0000000000 --- a/documentation/asciidoc/computers/getting-started/installing-from-mac.adoc +++ /dev/null @@ -1,85 +0,0 @@ -== Installing Images on Mac OS - -xref:getting-started.adoc#using-raspberry-pi-imager[Raspberry Pi Imager] is the recommended option for most users to write images to SD cards. However if you do not want to use the Imager you can setill copy an operating system to the card from the command line. - -[discrete] -==== Finding the SD Card - -Insert the SD card in the slot, or connect the SD card reader with the SD card inside, and type `diskutil list` at the command line. You should see something like this, - -[source,bash] ----- - $ diskutil list - /dev/disk0 (internal): - #: TYPE NAME SIZE IDENTIFIER - 0: GUID_partition_scheme 500.3 GB disk0 - 1: EFI EFI 314.6 MB disk0s1 - 2: Apple_APFS Container disk1 500.0 GB disk0s2 - - /dev/disk1 (synthesized): - #: TYPE NAME SIZE IDENTIFIER - 0: APFS Container Scheme - +500.0 GB disk1 - Physical Store disk0s2 - 1: APFS Volume Macintosh HD 89.6 GB disk1s1 - 2: APFS Volume Preboot 47.3 MB disk1s2 - 3: APFS Volume Recovery 510.4 MB disk1s3 - 4: APFS Volume VM 3.6 GB disk1s4 - - /dev/disk2 (external, physical): - #: TYPE NAME SIZE IDENTIFIER - 0: FDisk_partition_scheme *15.9 GB disk2 - 1: Windows_FAT_32 boot 268.4 MB disk2s1 - 2: Linux 15.7 GB disk2s2 ----- - -Here the SD Card is `/dev/disk2` however your disk and partition list may vary. - -[discrete] -==== Copying the Image - -WARNING: Using the `dd` command line tool can overwrite your Mac's operating system if you specify the wrong disk device. If you're not sure about what to do, we recommend you use the https://www.raspberrypi.org/software/[Raspberry Pi Imager] tool. - -Before copying the image you should unmount the SD Card. - -[source,bash] ----- -diskutil unmountDisk /dev/diskN ----- - -You can then copy the image, - -[source,bash] ----- -sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskN; sync ----- - -replacing `N` with the disk number. - -NOTE: You should use `rdisk` (which stands for 'raw disk') instead of `disk`, this speeds up the copying. - -This can take a few minutes, depending on the image file size. You can check the progress by pressing `Ctrl+T`. After the `dd` command finishes, you can eject the card: - -[source,bash] ----- -sudo diskutil eject /dev/rdiskN ----- - -[discrete] -==== Troubleshooting - -* If the command reports `dd: /dev/rdiskN: Resource busy`, you need to unmount the volume first `sudo diskutil unmountDisk /dev/diskN`. - -* If the command reports `dd: bs: illegal numeric value`, change the block size `bs=1m` to `bs=1M`. - -* If the command reports `dd: /dev/rdiskN: Operation not permitted`, go to `System Preferences` \-> `Security & Privacy` \-> `Privacy` \-> `Files and Folders` \-> `Give Removable Volumes access to Terminal`. - -* If the command reports `dd: /dev/rdiskN: Permission denied`, the partition table of the SD card is being protected against being overwritten by mac OS. -+ -Erase the SD card's partition table using this command: -+ -[source,bash] ----- -sudo diskutil partitionDisk /dev/diskN 1 MBR "Free Space" "%noformat%" 100% ----- -+ -That command will also set the permissions on the device to allow writing. diff --git a/documentation/asciidoc/computers/getting-started/installing-from-windows.adoc b/documentation/asciidoc/computers/getting-started/installing-from-windows.adoc deleted file mode 100644 index e2a9554734..0000000000 --- a/documentation/asciidoc/computers/getting-started/installing-from-windows.adoc +++ /dev/null @@ -1,32 +0,0 @@ -== Installing Images on Windows - -xref:getting-started.adoc#using-raspberry-pi-imager[Raspberry Pi Imager] is our recommended option for most users to write images to SD cards, so it is a good place to start. If you're looking for an alternative on Windows, you can use balenaEtcher, Win32DiskImager or imgFlasher. - -[discrete] -==== balenaEtcher - -* Download the Windows installer from https://www.balena.io/etcher/[balena.io] -* Run balenaEtcher and select the unzipped Raspberry Pi OS image file -* Select the SD card drive -* Finally, click *Burn* to write the Raspberry Pi OS image to the SD card -* You'll see a progress bar. Once complete, the utility will automatically unmount the SD card so it's safe to remove it from your computer. - -[discrete] -==== Win32DiskImager - -* Insert the SD card into your SD card reader. You can use the SD card slot if you have one, or an SD adapter in a USB port. Note the drive letter assigned to the SD card. You can see the drive letter in the left hand column of Windows Explorer, for example *G:* -* Download the Win32DiskImager utility from the http://sourceforge.net/projects/win32diskimager/[Sourceforge Project page] as an installer file, and run it to install the software. -* Run the `Win32DiskImager` utility from your desktop or menu. -* Select the image file you extracted earlier. -* In the device box, select the drive letter of the SD card. Be careful to select the correct drive: if you choose the wrong drive you could destroy the data on your computer's hard disk! If you are using an SD card slot in your computer, and can't see the drive in the Win32DiskImager window, try using an external SD adapter. -* Click 'Write' and wait for the write to complete. -* Exit the imager and eject the SD card. - -[discrete] -==== Upswift imgFlasher - -* Download portable Windows version from https://www.upswift.io/imgflasher/[upswift.io] -* Run imgFlasher and choose an image or zip file -* Choose SD card or USB drive -* Click on 'Flash' -* Wait until the flash is completed. diff --git a/documentation/asciidoc/computers/getting-started/sd-cards.adoc b/documentation/asciidoc/computers/getting-started/sd-cards.adoc deleted file mode 100644 index 9fd5268ada..0000000000 --- a/documentation/asciidoc/computers/getting-started/sd-cards.adoc +++ /dev/null @@ -1,21 +0,0 @@ -[[sd-cards]] -== SD Card for Raspberry Pi - -Raspberry Pi computers use a micro SD card, except for very early models which use a full-sized SD card. - -WARNING: Because of a hardware limitation in the Raspberry Pi Zero, 1 and 2, the boot partition on the SD card must be 256GB or less otherwise the device will not boot up. Later models of Raspberry Pi 2 with a BCM2837 SoC, Raspberry Pi 3, 4, and Raspberry Pi 400 do not have this limitation. This does not affect Raspberry Pi OS, which always uses a small boot partition. - -=== Recommended Capacity - -We recommend using an SD card of 8GB or greater capacity with Raspberry Pi OS. If you are using the lite version of Raspberry Pi OS, you can use a 4GB card. Other operating systems have different requirements: for example, LibreELEC can run from a smaller card. Please check with the supplier of the operating system to find out what capacity of card they recommend. - -=== Troubleshooting - -We recommend buying anPi SD card from one of our official resellers. The official SD cards are micro SD cards and are supplied with an adaptor which allows them to be used in a full-sized SD card slot. - -If you are having problems with your SD card: - -* Make sure you are using a genuine SD card. The best way to avoid fake SD cards is to always buy from a reputable supplier. -* Make sure you are using a good quality power supply: we recommend using an official Raspberry Pi power supply. -* The cable from the power supply unit to the Raspberry Pi can also cause problems. This is usually due to the resistance of the wires in the USB power cable; to save money, USB cables have as little copper in them as possible, which causes a voltage drop across the cable. -* Make sure you shut down the operating system correctly before you power down the Raspberry Pi. diff --git a/documentation/asciidoc/computers/getting-started/setting-up.adoc b/documentation/asciidoc/computers/getting-started/setting-up.adoc index 9eca3625d6..0a3aa35fb8 100644 --- a/documentation/asciidoc/computers/getting-started/setting-up.adoc +++ b/documentation/asciidoc/computers/getting-started/setting-up.adoc @@ -1,31 +1,151 @@ -== Setting up your Raspberry Pi +[[setting-up-your-raspberry-pi]] +== Getting started with your Raspberry Pi -To get started with your Raspberry Pi computer you'll need the following accessories: +video::CQtliTJ41ZE[youtube,width=80%,height=400px] -A computer monitor, or television. Most should work as a display for the Raspberry Pi, but for best results, you should use a display with HDMI input. You'll also need a appropriate xref:getting-started.adoc#connecting-a-display[display] cable, to connect your monitor to your Raspberry Pi. +To get started with your Raspberry Pi, you'll need the following: -NOTE: If your display uses an HDMI connection and has built-in speakers, you can use it to output sound. +* a xref:raspberry-pi.adoc#power-supply[power supply] +* boot media (e.g. a xref:getting-started.adoc#recommended-sd-cards[microSD card with ample storage and speed]) -A computer keyboard and mouse +You can set up your Raspberry Pi as an interactive computer with a desktop, or as a _headless_ computer accessible only over the network. To set your Raspberry Pi up headless, you don't need any additional peripherals: you can preconfigure a hostname, user account, network connection, and SSH when you xref:getting-started.adoc#installing-the-operating-system[install an operating system]. If you want to use your Raspberry Pi directly, you'll need the following additional accessories: - * Any standard USB keyboard and mouse will work with your Raspberry Pi. - * Wireless keyboards and mice will work if already paired. - * For keyboard layout configuration options see xref:configuration.adoc#raspi-config[raspi-config]. +* a display +* a cable to connect your Raspberry Pi to your display +* a keyboard +* a mouse -A good quality xref:raspberry-pi.adoc#power-supply[power supply]. +=== Power supply -We recommend the official Raspberry Pi Power Supply which has been specifically designed to consistently provide +5.1V despite rapid fluctuations in current draw. Those fluctuations in demand is something that happens a lot with when you’re using peripherals with the Raspberry Pi, and something that other supplies—designed to provide consistent current for charging cellphones—usually don’t cope with all that well. It also has an attached micro USB cable, which means that you don’t accidentally use a poor quality cable—something that can be an issue. +The following table shows the USB-PD power mode required to power various Raspberry Pi models. +You can use any high-quality power supply that provides the correct power mode. -For the Raspberry Pi 4, Model B and Raspberry Pi 400 you should use the https://www.raspberrypi.org/products/type-c-power-supply/[type C power supply]; for all other models you should use the https://www.raspberrypi.org/products/raspberry-pi-universal-power-supply/[micro USB power supply]. +[%header,cols="1,1,1"] +|=== +|Model +|Recommended power supply (voltage/current) +|Raspberry Pi power supply -Finally you'll need an xref:getting-started.adoc#sd-cards[SD card]; we recommend a minimum of 8GB micro SD card, and to use the https://www.raspberrypi.org/software/[Raspberry Pi Imager] to install an operating system onto it. +|Raspberry Pi 5 +|5V/5A, 5V/3A limits peripherals to 600mA +|https://www.raspberrypi.com/products/27w-power-supply/[27W USB-C power supply] -=== Optional items +|Raspberry Pi 4 Model B +|5V/3A +|https://www.raspberrypi.com/products/type-c-power-supply/[15W USB-C power supply] -A network (Ethernet) cable to connect your Raspberry Pi to your local network and the Internet. +|Raspberry Pi 3 (all models) +|5V/2.5A +|https://www.raspberrypi.com/products/micro-usb-power-supply/[12.5W Micro USB power supply] -If you aren't using an HDMI monitor with speakers you might also need some form of sound hardware. Audio can be played through speakers or headphones by connecting them to the AV jack (not available on the Raspberry Pi 400). However speakers must have their own amplification since the output from your Raspberry Pi is not powerful enough to drive them directly. +|Raspberry Pi 2 (all models) +|5V/2.5A +|https://www.raspberrypi.com/products/micro-usb-power-supply/[12.5W Micro USB power supply] -=== Troubleshooting +|Raspberry Pi 1 (all models) +|5V/2.5A +|https://www.raspberrypi.com/products/micro-usb-power-supply/[12.5W Micro USB power supply] -You can get help with setting up your Raspberry Pi on our https://www.raspberrypi.org/forums/[forums]. +|Raspberry Pi Zero (all models) +|5V/2.5A +|https://www.raspberrypi.com/products/micro-usb-power-supply/[12.5W Micro USB power supply] +|=== + +image::images/peripherals/cable-power.png[alt="Plugging a power supply into a Raspberry Pi.",width="80%"] + +Plug your power supply into the port marked "POWER IN", "PWR IN", or "PWR". Some Raspberry Pi models, such as the Zero series, have output USB ports with the same form factor as the power port. Be sure to use the correct port on your Raspberry Pi! + +[[sd-cards]] +=== Boot media + +Raspberry Pi models lack onboard storage, so you have to supply it. You can boot your Raspberry Pi from an operating system image installed on any supported media: microSD cards are used commonly, but USB storage, network storage, and storage connected via a PCIe HAT are also available. However, only recent Raspberry Pi models support all of these media types. + +All Raspberry Pi consumer models since the Raspberry Pi 1 Model A+ feature a microSD slot. Your Raspberry Pi automatically boots from the microSD slot when the slot contains a card. + +image::images/peripherals/sd-card.png[alt="Inserting a microSD card into a Raspberry Pi.",width="80%"] + +==== Recommended SD cards + +[[recommended-capacity]] + +We recommend using an SD card with at least 32GB of storage for Raspberry Pi OS installations. For Raspberry Pi OS Lite, we recommend at least 16GB. You can use any SD card with a capacity of less than 2TB. Capacities above 2TB are currently not supported due to limitations in the https://en.wikipedia.org/wiki/Master_boot_record[MBR]. As with any other boot media, you'll see improved performance on SD cards with faster read and write speeds. + +If you're unsure which SD card to buy, consider xref:../accessories/sd-cards.adoc[Raspberry Pi's official SD cards]. + +Because of a hardware limitation, the following devices will only boot from a boot partition of 256GB or less: + +* Raspberry Pi Zero +* Raspberry Pi 1 +* early Raspberry Pi 2 models with the BCM2836 SoC + +Other operating systems have different requirements. Check the documentation for your operating system for capacity requirements. + +=== Keyboard + +You can use any of the USB ports on your Raspberry Pi to connect a https://www.raspberrypi.com/products/raspberry-pi-keyboard-and-hub/[wired keyboard] or USB Bluetooth receiver. + +image:images/peripherals/cable-key.png[alt="Plugging a keyboard into a Raspberry Pi.",width="80%"] + +=== Mouse + +You can use any of the USB ports on your Raspberry Pi to connect a https://www.raspberrypi.com/products/raspberry-pi-mouse/[wired mouse] or USB Bluetooth receiver. + +image:images/peripherals/cable-mouse.png[alt="Plugging a mouse into a Raspberry Pi.",width="80%"] + +=== Display + +Raspberry Pi models have the following display connectivity: + +[%header,cols="1,1"] +|=== +|Model +|Display outputs + +|Raspberry Pi 5 +|2× micro HDMI + +|Raspberry Pi 4 (all models) +|2× micro HDMI, audio and composite out via 3.5mm http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack + +|Raspberry Pi 3 (all models) +|HDMI, audio and composite out via 3.5mm http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack + +|Raspberry Pi 2 (all models) +|HDMI, audio and composite out via 3.5mm http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack + +|Raspberry Pi 1 Model B+ +|HDMI, audio and composite out via 3.5mm http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack + +|Raspberry Pi 1 Model A+ +|HDMI, audio and composite out via 3.5mm http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack + +|Raspberry Pi Zero (all models) +|mini HDMI +|=== + +NOTE: No Raspberry Pi models support video over USB-C (DisplayPort alt mode). + +If your Raspberry Pi has more than one HDMI port, plug your primary monitor into the port marked `HDMI0`. + +Most displays don't have micro or mini HDMI ports. However, you can use a https://www.raspberrypi.com/products/micro-hdmi-to-standard-hdmi-a-cable/[micro-HDMI-to-HDMI cable] or https://www.raspberrypi.com/products/standard-hdmi-a-male-to-mini-hdmi-c-male-cable/[mini-HDMI-to-HDMI cable] to connect those ports on your Raspberry Pi to any HDMI display. For displays that don't support HDMI, consider an adapter that translates display output from HDMI to a port supported by your display. + +image::images/peripherals/cable-hdmi.png[alt="Plugging a micro HDMI cable into a Raspberry Pi.",width="80%"] + +=== Audio + +All Raspberry Pi models with HDMI, micro HDMI, or mini HDMI support audio output over HDMI. +All Raspberry Pi models support audio over USB. All Raspberry Pi models equipped with Bluetooth support Bluetooth audio. +All variants of the Raspberry Pi 1, 2, 3, and 4 include a 3.5mm auxiliary http://en.wikipedia.org/wiki/Phone_connector_(audio)#TRRS_standards[TRRS] jack, which may require amplification for sufficient output volume. + +=== Networking + +The following Raspberry Pi models come with Wi-Fi and Bluetooth connectivity: + +* Flagship models since Raspberry Pi 3 Model B +* All Zero W models +* All Pico W models +* Compute Modules configured with wireless (available since CM4) + +The "Model B" suffix indicates variants with an Ethernet port; "Model A" indicates no Ethernet port. If your Raspberry Pi doesn't have an Ethernet port, you can still connect to a wired internet connection using a USB-to-Ethernet adapter. + +image::images/peripherals/cable-net.png[alt="Plugging an Ethernet cable into a Raspberry Pi.",width="80%"] diff --git a/documentation/asciidoc/computers/getting-started/wrapping-up.adoc b/documentation/asciidoc/computers/getting-started/wrapping-up.adoc new file mode 100644 index 0000000000..59e587657f --- /dev/null +++ b/documentation/asciidoc/computers/getting-started/wrapping-up.adoc @@ -0,0 +1,20 @@ +== Next steps + +Now that your Raspberry Pi is set up and ready to go, what's next? + +=== Recommended software + +Raspberry Pi OS comes with many essential applications pre-installed so you can start using them straight away. If you'd like to take advantage of other applications we find useful, click the raspberry icon in the top left corner of the screen. Select **Preferences > Recommended Software** from the drop-down menu, and you'll find the package manager. You can install a wide variety of recommended software here for free. + +image::images/recommended-software.png[alt="Opening the package manager GUI in Raspberry Pi OS",width="80%"] + +For example, if you plan to use your Raspberry Pi as a home computer, you might find LibreOffice useful for writing and editing documents and spreadsheets. You can also make your Raspberry Pi more accessible with apps like a screen magnifier and Orca screen reader, found under Universal Access. + +=== Tutorials + +Our tutorials demonstrate various ways you can use your new computer. You can learn to code, control external devices, and build exciting new projects by following https://www.raspberrypi.com/tutorials/[tutorials] that pique your interest. + +=== Support + +For support with official Raspberry Pi products, or to connect with other Raspberry Pi users, visit the https://forums.raspberrypi.com/[Raspberry Pi forums]. + diff --git a/documentation/asciidoc/computers/legacy_config_txt.adoc b/documentation/asciidoc/computers/legacy_config_txt.adoc new file mode 100644 index 0000000000..0b020dad32 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt.adoc @@ -0,0 +1,18 @@ +include::legacy_config_txt/legacy.adoc[] + +include::legacy_config_txt/boot.adoc[] + +include::legacy_config_txt/gpio.adoc[] + +include::legacy_config_txt/overclocking.adoc[] + +include::legacy_config_txt/conditional.adoc[] + +include::legacy_config_txt/memory.adoc[] + +include::legacy_config_txt/video.adoc[] + +include::legacy_config_txt/pi4-hdmi.adoc[] + +include::legacy_config_txt/misc.adoc[] + diff --git a/documentation/asciidoc/computers/legacy_config_txt/boot.adoc b/documentation/asciidoc/computers/legacy_config_txt/boot.adoc new file mode 100644 index 0000000000..b7e7356397 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/boot.adoc @@ -0,0 +1,94 @@ +== Legacy boot options +(See also xref:config_txt.adoc#boot-options[config.txt Boot Options].) + +=== `start_x`, `start_debug` + +These provide a shortcut to some alternative `start_file` and `fixup_file` settings, and are the recommended methods for selecting firmware configurations. + +`start_x=1` implies +---- + start_file=start_x.elf + fixup_file=fixup_x.dat +---- + +On Raspberry Pi 4, if the files `start4x.elf` and `fixup4x.dat` are present, these files will be used instead. + +`start_debug=1` implies +---- + start_file=start_db.elf + fixup_file=fixup_db.dat +---- + +=== `disable_commandline_tags` + +Set the `disable_commandline_tags` command to `1` to stop `start.elf` from filling in ATAGS (memory from `0x100`) before launching the kernel. + +=== `arm_control` + +WARNING: This setting is deprecated. Use `arm_64bit` instead to enable 64-bit kernels. + +Sets board-specific control bits. + +=== `armstub` + +`armstub` is the filename on the boot partition from which to load the ARM stub. The default ARM stub is stored in firmware and is selected automatically based on the Raspberry Pi model and various settings. + +The stub is a small piece of ARM code that is run before the kernel. Its job is to set up low-level hardware like the interrupt controller before passing control to the kernel. + +=== `arm_peri_high` + +Set `arm_peri_high` to `1` to enable high peripheral mode on Raspberry Pi 4. It is set automatically if a suitable DTB is loaded. + +NOTE: Enabling high peripheral mode without a compatible Device Tree will make your system fail to boot. Currently ARM stub support is missing, so you will also need to load a suitable file using `armstub`. + +=== `kernel_address` + +`kernel_address` is the memory address to which the kernel image should be loaded. By default, 32-bit kernels are loaded to address `0x8000`, and 64-bit kernels to address `0x200000`. If `kernel_old` is set, kernels are loaded to the address `0x0`. + +=== `kernel_old` + +Set `kernel_old` to `1` to load the kernel to the memory address `0x0`. + +=== `init_uart_baud` + +`init_uart_baud` is the initial UART baud rate. The default value is `115200`. + +=== `init_uart_clock` + +`init_uart_clock` is the initial UART clock frequency. The default value is `48000000` (48MHz). Note that this clock only applies to UART0 (ttyAMA0 in Linux), and that the maximum baudrate for the UART is limited to 1/16th of the clock. The default UART on the Raspberry Pi 3 and Raspberry Pi Zero is UART1 (ttyS0 in Linux), and its clock is the core VPU clock - at least 250MHz. + +=== `bootcode_delay` + +The `bootcode_delay` command delays for a given number of seconds in `bootcode.bin` before loading `start.elf`: the default value is `0`. + +This is particularly useful to insert a delay before reading the EDID of the monitor, for example if the Raspberry Pi and monitor are powered from the same source, but the monitor takes longer to start up than the Raspberry Pi. Try setting this value if the display detection is wrong on initial boot, but is correct if you soft-reboot the Raspberry Pi without removing power from the monitor. + +=== `boot_delay` + +The `boot_delay` command forces a wait for a given number of seconds in `start.elf` before loading the kernel: the default value is `0`. The total delay in milliseconds is calculated as `(1000 x boot_delay) + boot_delay_ms`. This can be useful if your SD card needs a while to get ready before Linux is able to boot from it. + +=== `boot_delay_ms` + +The `boot_delay_ms` command means wait for a given number of milliseconds in `start.elf`, together with `boot_delay`, before loading the kernel. The default value is `0`. + +=== `enable_gic` (Raspberry Pi 4 Only) + +On the Raspberry Pi 4B, if this value is set to `0` then the interrupts will be routed to the Arm cores using the legacy interrupt controller, rather than via the GIC-400. The default value is `1`. + +[[sha256]] +=== `sha256` + +If set to non-zero, enables the logging of SHA256 hashes for loaded files (the kernel, initramfs, Device Tree .dtb file, and overlays), as generated by the `sha256sum` utility. The logging output goes to the UART if enabled, and is also accessible via `sudo vclog --msg`. This option may be useful when debugging boot problems, but at the cost of potentially adding _many_ seconds to the boot time. Defaults to 0 on all platforms. + +=== `uart_2ndstage` + +Setting `uart_2ndstage=1` causes the second-stage loader (`bootcode.bin` on devices prior to the Raspberry Pi 4, or the boot code in the EEPROM for Raspberry Pi 4 devices) and the main firmware (`start*.elf`) to output diagnostic information to UART0. + +Be aware that output is likely to interfere with Bluetooth operation unless it is disabled (`dtoverlay=disable-bt`) or switched to the other UART (`dtoverlay=miniuart-bt`), and if the UART is accessed simultaneously to output from Linux, then data loss can occur leading to corrupted output. This feature should only be required when trying to diagnose an early boot loading problem. + +[[upstream_kernel]] +=== `upstream_kernel` + +If `upstream_kernel=1` is used, the firmware sets xref:config_txt.adoc#os_prefix[`os_prefix`] to "upstream/", unless it has been explicitly set to something else, but like other `os_prefix` values it will be ignored if the required kernel and .dtb file can't be found when using the prefix. + +The firmware will also prefer upstream Linux names for DTBs (`bcm2837-rpi-3-b.dtb` instead of `bcm2710-rpi-3-b.dtb`, for example). If the upstream file isn't found the firmware will load the downstream variant instead and automatically apply the "upstream" overlay to make some adjustments. Note that this process happens _after_ the `os_prefix` has been finalised. diff --git a/documentation/asciidoc/computers/legacy_config_txt/conditional.adoc b/documentation/asciidoc/computers/legacy_config_txt/conditional.adoc new file mode 100644 index 0000000000..232fd2010e --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/conditional.adoc @@ -0,0 +1,30 @@ +== Legacy conditional filters +(See also xref:config_txt.adoc#conditional-filters[config.txt conditional filters].) + +=== The `[HDMI:*]` filter + +NOTE: This filter is for Raspberry Pi 4 only. + +Raspberry Pi 4 has two HDMI ports, and for many `config.txt` commands related to HDMI, it is necessary to specify which HDMI port is being referred to. The HDMI conditional filters subsequent HDMI configurations to the specific port. + +[source] +---- + [HDMI:0] + hdmi_group=2 + hdmi_mode=45 + [HDMI:1] + hdmi_group=2 + hdmi_mode=67 +---- + +An alternative `variable:index` syntax is available on all port-specific HDMI commands. You could use the following, which is the same as the previous example: + +[source] +---- + hdmi_group:0=2 + hdmi_mode:0=45 + hdmi_group:1=2 + hdmi_mode:1=67 +---- + + diff --git a/documentation/asciidoc/computers/legacy_config_txt/gpio.adoc b/documentation/asciidoc/computers/legacy_config_txt/gpio.adoc new file mode 100644 index 0000000000..b564be6015 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/gpio.adoc @@ -0,0 +1,28 @@ +== Legacy GPIO control +(See also xref:config_txt.adoc#gpio-control[config.txt GPIO control].) + +=== `enable_jtag_gpio` + +Setting `enable_jtag_gpio=1` selects Alt4 mode for GPIO pins 22-27, and sets up some internal SoC connections, enabling the JTAG interface for the Arm CPU. It works on all models of Raspberry Pi. + +|=== +| Pin # | Function + +| GPIO22 +| ARM_TRST + +| GPIO23 +| ARM_RTCK + +| GPIO24 +| ARM_TDO + +| GPIO25 +| ARM_TCK + +| GPIO26 +| ARM_TDI + +| GPIO27 +| ARM_TMS +|=== diff --git a/documentation/asciidoc/computers/legacy_config_txt/legacy.adoc b/documentation/asciidoc/computers/legacy_config_txt/legacy.adoc new file mode 100644 index 0000000000..d24139ec38 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/legacy.adoc @@ -0,0 +1,3 @@ +== Legacy options + +The `config.txt` options described here are considered legacy settings, are not used by Raspberry Pi OS Bookworm, and are no longer officially supported. They either relate to older software such as the firmware graphics driver, have been deprecated, or are very unlikely to be used by most people. However they remain documented here as they may still be of benefit to users of older OSes, or people doing bare-metal development. diff --git a/documentation/asciidoc/computers/legacy_config_txt/memory.adoc b/documentation/asciidoc/computers/legacy_config_txt/memory.adoc new file mode 100644 index 0000000000..11996ade05 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/memory.adoc @@ -0,0 +1,54 @@ +== Legacy memory options +(see also xref:config_txt.adoc#memory-options[config.txt Memory Options]) + +NOTE: Raspberry Pi 5 does not allocate GPU memory on behalf of the OS, so the following settings have no effect. + +=== `gpu_mem` + +Specifies how much memory, in megabytes, to reserve for the exclusive use of the GPU: the remaining memory is allocated to the Arm CPU for use by the OS. For Raspberry Pis with less than 1GB of memory, the default is `64`; for Raspberry Pis with 1GB or more of memory the default is `76`. + +IMPORTANT: Unlike GPUs found on x86 machines, where increasing memory can improve 3D performance, the architecture of the VideoCore means *there is no performance advantage from specifying values larger than is necessary*, and doing this can in fact harm performance. + +To ensure the best performance of Linux, you should set `gpu_mem` to the lowest possible value. If a particular graphics feature is not working correctly, try increasing the value of `gpu_mem`, being mindful of the recommended maximums shown below. + +On Raspberry Pi 4 the 3D component of the GPU has its own memory management unit (MMU), and does not use memory from the `gpu_mem` allocation. Instead memory is allocated dynamically within Linux. This allows a smaller value to be specified for `gpu_mem` on the Raspberry Pi 4, compared to previous models. + +On legacy kernels, the memory allocated to the GPU is used for display, 3D, codec and camera purposes as well as some basic firmware housekeeping. The maximums specified below assume you are using all these features. If you are not, then smaller values of gpu_mem should be used. + +The recommended maximum values are as follows: + +|=== +| total RAM | `gpu_mem` recommended maximum + +| 256MB +| `128` + +| 512MB +| `384` + +| 1GB or greater +| `512`, `76` on the Raspberry Pi 4 +|=== + +IMPORTANT: The camera stack (libcamera) on Raspberry Pi OS uses Linux CMA memory to allocate buffers instead of GPU memory, so there is no benefit in increasing the GPU memory size. + +It is possible to set `gpu_mem` to larger values, however this should be avoided since it can cause problems, such as preventing Linux from booting. The minimum value is `16`, however this disables certain GPU features. + +You can also use `gpu_mem_256`, `gpu_mem_512`, and `gpu_mem_1024` to allow swapping the same SD card between Raspberry Pis with different amounts of RAM without having to edit `config.txt` each time: + +=== `gpu_mem_256` + +The `gpu_mem_256` command sets the GPU memory in megabytes for Raspberry Pis with 256MB of memory. It is ignored if memory size is not 256MB. This overrides `gpu_mem`. + +=== `gpu_mem_512` + +The `gpu_mem_512` command sets the GPU memory in megabytes for Raspberry Pis with 512MB of memory. It is ignored if memory size is not 512MB. This overrides `gpu_mem`. + +=== `gpu_mem_1024` + +The `gpu_mem_1024` command sets the GPU memory in megabytes for Raspberry Pis with 1GB or more of memory. It is ignored if memory size is smaller than 1GB. This overrides `gpu_mem`. + +=== `disable_l2cache` + +Setting this to `1` disables the CPU's access to the GPU's L2 cache and requires a corresponding L2 disabled kernel. Default value on BCM2835 is `0`. On BCM2836, BCM2837, BCM2711, and BCM2712, the ARMs have their own L2 cache and therefore the default is `1`. The standard Raspberry Pi `kernel.img` and `kernel7.img` builds reflect this difference in cache setting. + diff --git a/documentation/asciidoc/computers/legacy_config_txt/misc.adoc b/documentation/asciidoc/computers/legacy_config_txt/misc.adoc new file mode 100644 index 0000000000..436b7135d8 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/misc.adoc @@ -0,0 +1,9 @@ +== Legacy Miscellaneous Options + +=== `avoid_warnings` + +`avoid_warnings=2` allows turbo mode even when low-voltage is present. + +=== `logging_level` + +Sets the VideoCore logging level. The value is a VideoCore-specific bitmask. diff --git a/documentation/asciidoc/computers/legacy_config_txt/overclocking.adoc b/documentation/asciidoc/computers/legacy_config_txt/overclocking.adoc new file mode 100644 index 0000000000..6540e50057 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/overclocking.adoc @@ -0,0 +1,13 @@ +== Legacy overclocking options +(See also xref:config_txt.adoc#overclocking-options[config.txt overclocking options].) + +=== Overclocking + +==== `never_over_voltage` + +Sets a bit in the one-time programmable (OTP) memory that prevents the device from being overvoltaged. This is intended to lock the Raspberry Pi down so the warranty bit cannot be set either inadvertently or maliciously by using an invalid overvoltage. + +==== `disable_auto_turbo` + +On Raspberry Pi 2 and 3, setting this flag will disable the GPU from moving into turbo mode, which it can do under particular loads. + diff --git a/documentation/asciidoc/computers/legacy_config_txt/pi4-hdmi.adoc b/documentation/asciidoc/computers/legacy_config_txt/pi4-hdmi.adoc new file mode 100644 index 0000000000..62c6c8bef8 --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/pi4-hdmi.adoc @@ -0,0 +1,19 @@ +[[raspberry-pi-4-hdmi-pipeline]] +== Raspberry Pi 4 HDMI pipeline + +IMPORTANT: When using the VC4 KMS graphics driver, the complete display pipeline is managed by Linux - this includes the HDMI outputs. These settings only apply to the legacy FKMS and firmware-based graphics driver. + +Raspberry Pi 4 is unable to output over HDMI at 1366×768 @ 60Hz. On some monitors it is possible to configure them to use 1360×768 @ 60Hz. They do not typically advertise this mode via their EDID, so the selection can't be made automatically, but it can be selected manually by adding: + +[source] +---- +hdmi_group=2 +hdmi_mode=87 +hdmi_cvt=1360 768 60 +---- + +...to xref:legacy_config_txt.adoc#legacy-video-options[config.txt]. + +Timings specified manually via a `hdmi_timings=` line in `config.txt` will also need to comply with the restriction of all horizontal timing parameters being divisible by two. + +`dpi_timings=` are not restricted in the same way, as that pipeline still only runs at a single pixel per clock cycle. diff --git a/documentation/asciidoc/computers/legacy_config_txt/video.adoc b/documentation/asciidoc/computers/legacy_config_txt/video.adoc new file mode 100644 index 0000000000..fd516df93c --- /dev/null +++ b/documentation/asciidoc/computers/legacy_config_txt/video.adoc @@ -0,0 +1,1804 @@ +== Legacy video options +(see also xref:config_txt.adoc#video-options[config.txt Video Options]) + +=== HDMI mode + +NOTE: For devices with multiple HDMI ports, some HDMI commands can be applied to any port. You can use the syntax `:`, where port is 0 or 1, to specify which port the setting should apply to. If no port is specified, the default is 0. If you specify a port number on a command that does not require a port number, the port is ignored. Further details on the syntax and alternative mechanisms can be found in the HDMI sub-section of the xref:legacy_config_txt.adoc#legacy-conditional-filters[conditionals section] of the documentation. + +==== `hdmi_safe` + +Setting `hdmi_safe` to `1` will lead to "safe mode" settings being used to try to boot with maximum HDMI compatibility. This is the same as setting the following parameters: + +---- +hdmi_force_hotplug=1 +hdmi_ignore_edid=0xa5000080 +config_hdmi_boost=4 +hdmi_group=2 +hdmi_mode=4 +disable_overscan=0 +overscan_left=24 +overscan_right=24 +overscan_top=24 +overscan_bottom=24 +---- + +==== `hdmi_ignore_edid` + +Setting `hdmi_ignore_edid` to `0xa5000080` enables the ignoring of EDID/display data if your display does not have an accurate https://en.wikipedia.org/wiki/Extended_display_identification_data[EDID]. It requires this unusual value to ensure that it is not triggered accidentally. + +==== `hdmi_edid_file` + +Setting `hdmi_edid_file` to `1` will cause the GPU to read EDID data from the `edid.dat` file, located in the boot partition, instead of reading it from the monitor. + +==== `hdmi_edid_filename` + +On the Raspberry Pi 4B, you can use the `hdmi_edid_filename` command to specify the filename of the EDID file to use, and also to specify which port the file is to be applied to. This also requires `hdmi_edid_file=1` to enable EDID files. + +For example: + +---- +hdmi_edid_file=1 +hdmi_edid_filename:0=FileForPortZero.edid +hdmi_edid_filename:1=FileForPortOne.edid +---- + +==== `hdmi_force_edid_audio` + +Setting `hdmi_force_edid_audio` to `1` pretends that all audio formats are supported by the display, allowing passthrough of DTS/AC3 even when this is not reported as supported. + +==== `hdmi_ignore_edid_audio` + +Setting `hdmi_ignore_edid_audio` to `1` pretends that all audio formats are unsupported by the display. This means ALSA will default to the analogue audio (headphone) jack. + +==== `hdmi_force_edid_3d` + +Setting `hdmi_force_edid_3d` to `1` pretends that all CEA modes support 3D, even when the EDID does not indicate support for this. + +==== `hdmi_ignore_cec_init` + +Setting `hdmi_ignore_cec_init` to `1` will stop the initial active source message being sent during bootup. This prevents a CEC-enabled TV from coming out of standby and channel-switching when you are rebooting your Raspberry Pi. + +==== `hdmi_ignore_cec` + +Setting `hdmi_ignore_cec` to `1` pretends that https://en.wikipedia.org/wiki/Consumer_Electronics_Control#CEC[CEC] is not supported at all by the display. No CEC functions will be supported. + +==== `cec_osd_name` + +The `cec_osd_name` command sets the initial CEC name of the device. The default is Raspberry Pi. + +==== `hdmi_pixel_encoding` + +The `hdmi_pixel_encoding` command forces the pixel encoding mode. By default, it will use the mode requested from the EDID, so you shouldn't need to change it. + +|=== +| hdmi_pixel_encoding | result + +| 0 +| default (RGB limited for CEA, RGB full for DMT) + +| 1 +| RGB limited (16-235) + +| 2 +| RGB full (0-255) + +| 3 +| YCbCr limited (16-235) + +| 4 +| YCbCr full (0-255) +|=== + +==== `hdmi_max_pixel_freq` + +The pixel frequency is used by the firmware and KMS to filter HDMI modes. Note, this is not the same as the frame rate. It specifies the maximum frequency that a valid mode can have, thereby culling out higher frequency modes. So for example, if you wish to disable all 4K modes, you could specify a maximum frequency of 200000000, since all 4K modes have frequencies greater than this. + +==== `hdmi_blanking` + +The `hdmi_blanking` command controls what happens when the operating system asks for the display to be put into standby mode, using DPMS, to save power. If this option is not set or set to 0, the HDMI output is blanked but not switched off. In order to mimic the behaviour of other computers, you can set the HDMI output to switch off as well by setting this option to 1: the attached display will go into a low-power standby mode. + +NOTE: On Raspberry Pi 4, setting `hdmi_blanking=1` will not cause the HDMI output to be switched off, since this feature has not yet been implemented. This feature may cause issues when using applications which don't use the framebuffer, such as `omxplayer`. + +|=== +| hdmi_blanking | result + +| 0 +| HDMI output will be blanked + +| 1 +| HDMI output will be switched off and blanked +|=== + +==== `hdmi_drive` + +The `hdmi_drive` command allows you to choose between HDMI and DVI output modes. + +|=== +| hdmi_drive | result + +| 1 +| Normal DVI mode (no sound) + +| 2 +| Normal HDMI mode (sound will be sent if supported and enabled) +|=== + +==== `config_hdmi_boost` + +Configures the signal strength of the HDMI interface. The minimum value is `0` and the maximum is `11`. + +The default value for the original Model B and A is `2`. The default value for the Model B+ and all later models is `5`. + +If you are seeing HDMI issues (speckling, interference) then try `7`. Very long HDMI cables may need up to `11`, but values this high should not be used unless absolutely necessary. + +This option is ignored on Raspberry Pi 4. + +==== `hdmi_group` + +The `hdmi_group` command defines the HDMI output group to be either CEA (Consumer Electronics Association, the standard typically used by TVs) or DMT (Display Monitor Timings, the standard typically used by monitors). This setting should be used in conjunction with `hdmi_mode`. + +|=== +| hdmi_group | result + +| 0 +| Auto-detect from EDID + +| 1 +| CEA + +| 2 +| DMT +|=== + +==== `hdmi_mode` + +Together with `hdmi_group`, `hdmi_mode` defines the HDMI output format. Format mode numbers are derived from the https://web.archive.org/web/20171201033424/https://standards.cta.tech/kwspub/published_docs/CTA-861-G_FINAL_revised_2017.pdf[CTA specification]. + +NOTE: Not all modes are available on all models. + +These values are valid if `hdmi_group=1` (CEA): + +[cols=",,,^,"] +|=== +| hdmi_mode | Resolution | Frequency | Screen aspect | Notes + +| 1 +| VGA (640x480) +| 60Hz +| 4:3 +| + +| 2 +| 480p +| 60Hz +| 4:3 +| + +| 3 +| 480p +| 60Hz +| 16:9 +| + +| 4 +| 720p +| 60Hz +| 16:9 +| + +| 5 +| 1080i +| 60Hz +| 16:9 +| + +| 6 +| 480i +| 60Hz +| 4:3 +| + +| 7 +| 480i +| 60Hz +| 16:9 +| + +| 8 +| 240p +| 60Hz +| 4:3 +| + +| 9 +| 240p +| 60Hz +| 16:9 +| + +| 10 +| 480i +| 60Hz +| 4:3 +| pixel quadrupling + +| 11 +| 480i +| 60Hz +| 16:9 +| pixel quadrupling + +| 12 +| 240p +| 60Hz +| 4:3 +| pixel quadrupling + +| 13 +| 240p +| 60Hz +| 16:9 +| pixel quadrupling + +| 14 +| 480p +| 60Hz +| 4:3 +| pixel doubling + +| 15 +| 480p +| 60Hz +| 16:9 +| pixel doubling + +| 16 +| 1080p +| 60Hz +| 16:9 +| + +| 17 +| 576p +| 50Hz +| 4:3 +| + +| 18 +| 576p +| 50Hz +| 16:9 +| + +| 19 +| 720p +| 50Hz +| 16:9 +| + +| 20 +| 1080i +| 50Hz +| 16:9 +| + +| 21 +| 576i +| 50Hz +| 4:3 +| + +| 22 +| 576i +| 50Hz +| 16:9 +| + +| 23 +| 288p +| 50Hz +| 4:3 +| + +| 24 +| 288p +| 50Hz +| 16:9 +| + +| 25 +| 576i +| 50Hz +| 4:3 +| pixel quadrupling + +| 26 +| 576i +| 50Hz +| 16:9 +| pixel quadrupling + +| 27 +| 288p +| 50Hz +| 4:3 +| pixel quadrupling + +| 28 +| 288p +| 50Hz +| 16:9 +| pixel quadrupling + +| 29 +| 576p +| 50Hz +| 4:3 +| pixel doubling + +| 30 +| 576p +| 50Hz +| 16:9 +| pixel doubling + +| 31 +| 1080p +| 50Hz +| 16:9 +| + +| 32 +| 1080p +| 24Hz +| 16:9 +| + +| 33 +| 1080p +| 25Hz +| 16:9 +| + +| 34 +| 1080p +| 30Hz +| 16:9 +| + +| 35 +| 480p +| 60Hz +| 4:3 +| pixel quadrupling + +| 36 +| 480p +| 60Hz +| 16:9 +| pixel quadrupling + +| 37 +| 576p +| 50Hz +| 4:3 +| pixel quadrupling + +| 38 +| 576p +| 50Hz +| 16:9 +| pixel quadrupling + +| 39 +| 1080i +| 50Hz +| 16:9 +| reduced blanking + +| 40 +| 1080i +| 100Hz +| 16:9 +| + +| 41 +| 720p +| 100Hz +| 16:9 +| + +| 42 +| 576p +| 100Hz +| 4:3 +| + +| 43 +| 576p +| 100Hz +| 16:9 +| + +| 44 +| 576i +| 100Hz +| 4:3 +| + +| 45 +| 576i +| 100Hz +| 16:9 +| + +| 46 +| 1080i +| 120Hz +| 16:9 +| + +| 47 +| 720p +| 120Hz +| 16:9 +| + +| 48 +| 480p +| 120Hz +| 4:3 +| + +| 49 +| 480p +| 120Hz +| 16:9 +| + +| 50 +| 480i +| 120Hz +| 4:3 +| + +| 51 +| 480i +| 120Hz +| 16:9 +| + +| 52 +| 576p +| 200Hz +| 4:3 +| + +| 53 +| 576p +| 200Hz +| 16:9 +| + +| 54 +| 576i +| 200Hz +| 4:3 +| + +| 55 +| 576i +| 200Hz +| 16:9 +| + +| 56 +| 480p +| 240Hz +| 4:3 +| + +| 57 +| 480p +| 240Hz +| 16:9 +| + +| 58 +| 480i +| 240Hz +| 4:3 +| + +| 59 +| 480i +| 240Hz +| 16:9 +| + +| 60 +| 720p +| 24Hz +| 16:9 +| + +| 61 +| 720p +| 25Hz +| 16:9 +| + +| 62 +| 720p +| 30Hz +| 16:9 +| + +| 63 +| 1080p +| 120Hz +| 16:9 +| + +| 64 +| 1080p +| 100Hz +| 16:9 +| + +| 65 +| Custom +| +| +| + +| 66 +| 720p +| 25Hz +| 64:27 +| Pi 4 + +| 67 +| 720p +| 30Hz +| 64:27 +| Pi 4 + +| 68 +| 720p +| 50Hz +| 64:27 +| Pi 4 + +| 69 +| 720p +| 60Hz +| 64:27 +| Pi 4 + +| 70 +| 720p +| 100Hz +| 64:27 +| Pi 4 + +| 71 +| 720p +| 120Hz +| 64:27 +| Pi 4 + +| 72 +| 1080p +| 24Hz +| 64:27 +| Pi 4 + +| 73 +| 1080p +| 25Hz +| 64:27 +| Pi 4 + +| 74 +| 1080p +| 30Hz +| 64:27 +| Pi 4 + +| 75 +| 1080p +| 50Hz +| 64:27 +| Pi 4 + +| 76 +| 1080p +| 60Hz +| 64:27 +| Pi 4 + +| 77 +| 1080p +| 100Hz +| 64:27 +| Pi 4 + +| 78 +| 1080p +| 120Hz +| 64:27 +| Pi 4 + +| 79 +| 1680x720 +| 24Hz +| 64:27 +| Pi 4 + +| 80 +| 1680x720 +| 25z +| 64:27 +| Pi 4 + +| 81 +| 1680x720 +| 30Hz +| 64:27 +| Pi 4 + +| 82 +| 1680x720 +| 50Hz +| 64:27 +| Pi 4 + +| 83 +| 1680x720 +| 60Hz +| 64:27 +| Pi 4 + +| 84 +| 1680x720 +| 100Hz +| 64:27 +| Pi 4 + +| 85 +| 1680x720 +| 120Hz +| 64:27 +| Pi 4 + +| 86 +| 2560x720 +| 24Hz +| 64:27 +| Pi 4 + +| 87 +| 2560x720 +| 25Hz +| 64:27 +| Pi 4 + +| 88 +| 2560x720 +| 30Hz +| 64:27 +| Pi 4 + +| 89 +| 2560x720 +| 50Hz +| 64:27 +| Pi 4 + +| 90 +| 2560x720 +| 60Hz +| 64:27 +| Pi 4 + +| 91 +| 2560x720 +| 100Hz +| 64:27 +| Pi 4 + +| 92 +| 2560x720 +| 120Hz +| 64:27 +| Pi 4 + +| 93 +| 2160p +| 24Hz +| 16:9 +| Pi 4 + +| 94 +| 2160p +| 25Hz +| 16:9 +| Pi 4 + +| 95 +| 2160p +| 30Hz +| 16:9 +| Pi 4 + +| 96 +| 2160p +| 50Hz +| 16:9 +| Pi 4 + +| 97 +| 2160p +| 60Hz +| 16:9 +| Pi 4 + +| 98 +| 4096x2160 +| 24Hz +| 256:135 +| Pi 4 + +| 99 +| 4096x2160 +| 25Hz +| 256:135 +| Pi 4 + +| 100 +| 4096x2160 +| 30Hz +| 256:135 +| Pi 4 + +| 101 +| 4096x2160 +| 50Hz +| 256:135 +| Pi 4<> + +| 102 +| 4096x2160 +| 60Hz +| 256:135 +| Pi 4<> + +| 103 +| 2160p +| 24Hz +| 64:27 +| Pi 4 + +| 104 +| 2160p +| 25Hz +| 64:27 +| Pi 4 + +| 105 +| 2160p +| 30Hz +| 64:27 +| Pi 4 + +| 106 +| 2160p +| 50Hz +| 64:27 +| Pi 4 + +| 107 +| 2160p +| 60Hz +| 64:27 +| Pi 4 +|=== + +[[needsoverclock,^**1**^]] **1.** Only available with an overclocked core frequency: set `core_freq_min=600` and `core_freq=600`. See xref:config_txt.adoc#overclocking[overclocking]. + +Pixel doubling and quadrupling indicates a higher clock rate, with each pixel repeated two or four times respectively. + +These values are valid if `hdmi_group=2` (DMT): + +[cols=",,,^,"] +|=== +| hdmi_mode | Resolution | Frequency | Screen Aspect | Notes + +| 1 +| 640x350 +| 85Hz +| +| + +| 2 +| 640x400 +| 85Hz +| 16:10 +| + +| 3 +| 720x400 +| 85Hz +| +| + +| 4 +| 640x480 +| 60Hz +| 4:3 +| + +| 5 +| 640x480 +| 72Hz +| 4:3 +| + +| 6 +| 640x480 +| 75Hz +| 4:3 +| + +| 7 +| 640x480 +| 85Hz +| 4:3 +| + +| 8 +| 800x600 +| 56Hz +| 4:3 +| + +| 9 +| 800x600 +| 60Hz +| 4:3 +| + +| 10 +| 800x600 +| 72Hz +| 4:3 +| + +| 11 +| 800x600 +| 75Hz +| 4:3 +| + +| 12 +| 800x600 +| 85Hz +| 4:3 +| + +| 13 +| 800x600 +| 120Hz +| 4:3 +| + +| 14 +| 848x480 +| 60Hz +| 16:9 +| + +| 15 +| 1024x768 +| 43Hz +| 4:3 +| incompatible with Raspberry Pi + +| 16 +| 1024x768 +| 60Hz +| 4:3 +| + +| 17 +| 1024x768 +| 70Hz +| 4:3 +| + +| 18 +| 1024x768 +| 75Hz +| 4:3 +| + +| 19 +| 1024x768 +| 85Hz +| 4:3 +| + +| 20 +| 1024x768 +| 120Hz +| 4:3 +| + +| 21 +| 1152x864 +| 75Hz +| 4:3 +| + +| 22 +| 1280x768 +| 60Hz +| 15:9 +| reduced blanking + +| 23 +| 1280x768 +| 60Hz +| 15:9 +| + +| 24 +| 1280x768 +| 75Hz +| 15:9 +| + +| 25 +| 1280x768 +| 85Hz +| 15:9 +| + +| 26 +| 1280x768 +| 120Hz +| 15:9 +| reduced blanking + +| 27 +| 1280x800 +| 60 +| 16:10 +| reduced blanking + +| 28 +| 1280x800 +| 60Hz +| 16:10 +| + +| 29 +| 1280x800 +| 75Hz +| 16:10 +| + +| 30 +| 1280x800 +| 85Hz +| 16:10 +| + +| 31 +| 1280x800 +| 120Hz +| 16:10 +| reduced blanking + +| 32 +| 1280x960 +| 60Hz +| 4:3 +| + +| 33 +| 1280x960 +| 85Hz +| 4:3 +| + +| 34 +| 1280x960 +| 120Hz +| 4:3 +| reduced blanking + +| 35 +| 1280x1024 +| 60Hz +| 5:4 +| + +| 36 +| 1280x1024 +| 75Hz +| 5:4 +| + +| 37 +| 1280x1024 +| 85Hz +| 5:4 +| + +| 38 +| 1280x1024 +| 120Hz +| 5:4 +| reduced blanking + +| 39 +| 1360x768 +| 60Hz +| 16:9 +| + +| 40 +| 1360x768 +| 120Hz +| 16:9 +| reduced blanking + +| 41 +| 1400x1050 +| 60Hz +| 4:3 +| reduced blanking + +| 42 +| 1400x1050 +| 60Hz +| 4:3 +| + +| 43 +| 1400x1050 +| 75Hz +| 4:3 +| + +| 44 +| 1400x1050 +| 85Hz +| 4:3 +| + +| 45 +| 1400x1050 +| 120Hz +| 4:3 +| reduced blanking + +| 46 +| 1440x900 +| 60Hz +| 16:10 +| reduced blanking + +| 47 +| 1440x900 +| 60Hz +| 16:10 +| + +| 48 +| 1440x900 +| 75Hz +| 16:10 +| + +| 49 +| 1440x900 +| 85Hz +| 16:10 +| + +| 50 +| 1440x900 +| 120Hz +| 16:10 +| reduced blanking + +| 51 +| 1600x1200 +| 60Hz +| 4:3 +| + +| 52 +| 1600x1200 +| 65Hz +| 4:3 +| + +| 53 +| 1600x1200 +| 70Hz +| 4:3 +| + +| 54 +| 1600x1200 +| 75Hz +| 4:3 +| + +| 55 +| 1600x1200 +| 85Hz +| 4:3 +| + +| 56 +| 1600x1200 +| 120Hz +| 4:3 +| reduced blanking + +| 57 +| 1680x1050 +| 60Hz +| 16:10 +| reduced blanking + +| 58 +| 1680x1050 +| 60Hz +| 16:10 +| + +| 59 +| 1680x1050 +| 75Hz +| 16:10 +| + +| 60 +| 1680x1050 +| 85Hz +| 16:10 +| + +| 61 +| 1680x1050 +| 120Hz +| 16:10 +| reduced blanking + +| 62 +| 1792x1344 +| 60Hz +| 4:3 +| + +| 63 +| 1792x1344 +| 75Hz +| 4:3 +| + +| 64 +| 1792x1344 +| 120Hz +| 4:3 +| reduced blanking + +| 65 +| 1856x1392 +| 60Hz +| 4:3 +| + +| 66 +| 1856x1392 +| 75Hz +| 4:3 +| + +| 67 +| 1856x1392 +| 120Hz +| 4:3 +| reduced blanking + +| 68 +| 1920x1200 +| 60Hz +| 16:10 +| reduced blanking + +| 69 +| 1920x1200 +| 60Hz +| 16:10 +| + +| 70 +| 1920x1200 +| 75Hz +| 16:10 +| + +| 71 +| 1920x1200 +| 85Hz +| 16:10 +| + +| 72 +| 1920x1200 +| 120Hz +| 16:10 +| reduced blanking + +| 73 +| 1920x1440 +| 60Hz +| 4:3 +| + +| 74 +| 1920x1440 +| 75Hz +| 4:3 +| + +| 75 +| 1920x1440 +| 120Hz +| 4:3 +| reduced blanking + +| 76 +| 2560x1600 +| 60Hz +| 16:10 +| reduced blanking + +| 77 +| 2560x1600 +| 60Hz +| 16:10 +| + +| 78 +| 2560x1600 +| 75Hz +| 16:10 +| + +| 79 +| 2560x1600 +| 85Hz +| 16:10 +| + +| 80 +| 2560x1600 +| 120Hz +| 16:10 +| reduced blanking + +| 81 +| 1366x768 +| 60Hz +| 16:9 +| xref:legacy_config_txt.adoc#raspberry-pi-4-hdmi-pipeline[NOT on Raspberry Pi 4] + +| 82 +| 1920x1080 +| 60Hz +| 16:9 +| 1080p + +| 83 +| 1600x900 +| 60Hz +| 16:9 +| reduced blanking + +| 84 +| 2048x1152 +| 60Hz +| 16:9 +| reduced blanking + +| 85 +| 1280x720 +| 60Hz +| 16:9 +| 720p + +| 86 +| 1366x768 +| 60Hz +| 16:9 +| reduced blanking +|=== + +NOTE: There is a pixel clock limit. The highest supported mode on models prior to the Raspberry Pi 4 is 1920×1200 at 60Hz with reduced blanking, whilst the Raspberry Pi 4 can support up to 4096×2160 (colloquially 4k) at 60Hz. Also note that if you are using both HDMI ports of the Raspberry Pi 4 for 4k output, then you are limited to 30Hz on both. + +==== `hdmi_timings` + +This allows setting of raw HDMI timing values for a custom mode, selected using `hdmi_group=2` and `hdmi_mode=87`. + +[source] +---- +hdmi_timings= +---- + +[source] +---- + = horizontal pixels (width) + = invert hsync polarity + = horizontal forward padding from DE active edge + = hsync pulse width in pixel clocks + = vertical back padding from DE active edge + = vertical pixels height (lines) + = invert vsync polarity + = vertical forward padding from DE active edge + = vsync pulse width in pixel clocks + = vertical back padding from DE active edge + = leave at zero + = leave at zero + = leave at zero + = screen refresh rate in Hz + = leave at zero + = clock frequency (h_active_pixels + h_front_porch + h_sync_pulse + h_back_porch) + * (v_active_lines + v_front_porch + v_sync_pulse + v_back_porch) + * framerate + = [see footnote] +---- + +The aspect ratio can be set to one of eight values. Choose a value representing the aspect ratio most similar to your screen from the following: + +[cols="1,2,1"] +|=== +|Aspect Ratio |Name |Value + +| 4:3 +| HDMI_ASPECT_4_3 +| 1 + +| 14:9 +| HDMI_ASPECT_14_9 +| 2 + +| 16:9 +| HDMI_ASPECT_16_9 +| 3 + +| 5:4 +| HDMI_ASPECT_5_4 +| 4 + +| 16:10 +| HDMI_ASPECT_16_10 +| 5 + +| 15:9 +| HDMI_ASPECT_15_9 +| 6 + +| 21:9 +| HDMI_ASPECT_21_9 +| 7 + +| 64:27 +| HDMI_ASPECT_64_27 +| 8 +|=== + +==== `hdmi_force_mode` + +Setting to `1` will remove all other modes except the ones specified by `hdmi_mode` and `hdmi_group` from the internal list, meaning they will not appear in any enumerated lists of modes. This option may help if a display seems to be ignoring the `hdmi_mode` and `hdmi_group` settings. + +==== `edid_content_type` + +Forces the EDID content type to a specific value. + +The options are: + +* `0` = `EDID_ContentType_NODATA`, content type none +* `1` = `EDID_ContentType_Graphics`, content type graphics, ITC must be set to 1 +* `2` = `EDID_ContentType_Photo`, content type photo +* `3` = `EDID_ContentType_Cinema`, content type cinema +* `4` = `EDID_ContentType_Game`, content type game + +=== Which values are valid for my monitor? + +Your HDMI monitor may only support a limited set of formats. To find out which formats are supported, use the following method: + +* Set the output format to VGA 60Hz (`hdmi_group=1` and `hdmi_mode=1`) and boot up your Raspberry Pi +* Enter the following command to give a list of CEA-supported modes: `/opt/vc/bin/tvservice -m CEA` +* Enter the following command to give a list of DMT-supported modes: `/opt/vc/bin/tvservice -m DMT` +* Enter the following command to show your current state: `/opt/vc/bin/tvservice -s` +* Enter the following commands to dump more detailed information from your monitor: `/opt/vc/bin/tvservice -d edid.dat; /opt/vc/bin/edidparser edid.dat` + +The `edid.dat` should also be provided when troubleshooting problems with the default HDMI mode. + +[[custom-mode]] +=== Custom mode + +If your monitor requires a mode that is not in one of the tables above, then it's possible to define a custom CVT mode for it instead: + +[source] +---- +hdmi_cvt= +---- + +|=== +| Value | Default | Description + +| width +| (required) +| width in pixels + +| height +| (required) +| height in pixels + +| framerate +| (required) +| framerate in Hz + +| aspect +| 3 +| aspect ratio 1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10, 6=15:9 + +| margins +| 0 +| 0=margins disabled, 1=margins enabled + +| interlace +| 0 +| 0=progressive, 1=interlaced + +| rb +| 0 +| 0=normal, 1=reduced blanking +|=== + +Fields at the end can be omitted to use the default values. + +Note that this simply *creates* the mode (group 2 mode 87). In order to make the Raspberry Pi use this by default, you must add some additional settings. For example, to select an 800×480 resolution and enable audio drive: + +---- +hdmi_cvt=800 480 60 6 +hdmi_group=2 +hdmi_mode=87 +hdmi_drive=2 +---- + +This may not work if your monitor does not support standard CVT timings. + +=== Composite video mode + +==== `sdtv_mode` + +The `sdtv_mode` command defines the TV standard used for composite video output: + +|=== +| sdtv_mode | result + +| 0 (default) +| Normal NTSC + +| 1 +| Japanese version of NTSC -- no pedestal + +| 2 +| Normal PAL + +| 3 +| Brazilian version of PAL -- 525/60 rather than 625/50, different subcarrier + +| 16 +| Progressive scan NTSC + +| 18 +| Progressive scan PAL +|=== + +==== `sdtv_aspect` + +The `sdtv_aspect` command defines the aspect ratio for composite video output. The default value is `1`. + +|=== +| sdtv_aspect | result + +| 1 +| 4:3 + +| 2 +| 14:9 + +| 3 +| 16:9 +|=== + +==== `sdtv_disable_colourburst` + +Setting `sdtv_disable_colourburst` to `1` disables colourburst on composite video output. The picture will be displayed in monochrome, but it may appear sharper. + +=== LCD displays and touchscreens + +==== `display_default_lcd` + +If a Raspberry Pi Touch Display is detected it will be used as the default display and will show the framebuffer. Setting `display_default_lcd=0` will ensure the LCD is not the default display, which usually implies the HDMI output will be the default. The LCD can still be used by choosing its display number from supported applications, for example, omxplayer. + +==== `lcd_framerate` + +Specify the framerate of the Raspberry Pi Touch Display, in Hz/fps. Defaults to 60Hz. + +==== `lcd_rotate` + +This flips the display using the LCD's inbuilt flip functionality, which is a computationally cheaper operation than using the GPU-based rotate operation. + +For example, `lcd_rotate=2` will compensate for an upside-down display. + +==== `enable_dpi_lcd` + +Enable LCD displays attached to the DPI GPIOs. This is to allow the use of third-party LCD displays using the parallel display interface. + +==== `dpi_group`, `dpi_mode`, `dpi_output_format` + +The `dpi_group` and `dpi_mode` `config.txt` parameters are used to set either predetermined modes (DMT or CEA modes as used by HDMI above). A user can generate custom modes in much the same way as for HDMI (see `dpi_timings` section). + +`dpi_output_format` is a bitmask specifying various parameters used to set up the display format. + +==== `dpi_timings` + +This allows setting of raw DPI timing values for a custom mode, selected using `dpi_group=2` and `dpi_mode=87`. + +[source] +---- +dpi_timings= +---- + +[source] +---- + = horizontal pixels (width) + = invert hsync polarity + = horizontal forward padding from DE active edge + = hsync pulse width in pixel clocks + = vertical back padding from DE active edge + = vertical pixels height (lines) + = invert vsync polarity + = vertical forward padding from DE active edge + = vsync pulse width in pixel clocks + = vertical back padding from DE active edge + = leave at zero + = leave at zero + = leave at zero + = screen refresh rate in Hz + = leave at zero + = clock frequency (h_active_pixels + h_front_porch + h_sync_pulse + h_back_porch) + * (v_active_lines + v_front_porch + v_sync_pulse + v_back_porch) + * framerate + = [see footnote] +---- + +The aspect ratio can be set to one of eight values. Choose a value representing the aspect ratio most similar to your screen from the following: + +[cols="1,2,1"] +|=== +|Aspect ratio |Name |Value + +| 4:3 +| HDMI_ASPECT_4_3 +| 1 + +| 14:9 +| HDMI_ASPECT_14_9 +| 2 + +| 16:9 +| HDMI_ASPECT_16_9 +| 3 + +| 5:4 +| HDMI_ASPECT_5_4 +| 4 + +| 16:10 +| HDMI_ASPECT_16_10 +| 5 + +| 15:9 +| HDMI_ASPECT_15_9 +| 6 + +| 21:9 +| HDMI_ASPECT_21_9 +| 7 + +| 64:27 +| HDMI_ASPECT_64_27 +| 8 +|=== + +=== Generic display options + +==== `hdmi_force_hotplug` + +Setting `hdmi_force_hotplug` to `1` pretends that the HDMI hotplug signal is asserted, so it appears that a HDMI display is attached. In other words, HDMI output mode will be used, even if no HDMI monitor is detected. + +==== `hdmi_ignore_hotplug` + +Setting `hdmi_ignore_hotplug` to `1` pretends that the HDMI hotplug signal is not asserted, so it appears that a HDMI display is not attached. HDMI output will therefore be disabled, even if a monitor is connected. + +==== `disable_overscan` + +The default value for `disable_overscan` is `0` which gives default values of overscan for the left, right, top, and bottom edges of `48` for HD CEA modes, `32` for SD CEA modes, and `0` for DMT modes. + +Set `disable_overscan` to `1` to disable the default values of xref:configuration.adoc#underscan[overscan] that are set by the firmware. + +==== `overscan_left` + +The `overscan_left` command specifies the number of pixels to add to the firmware default value of overscan on the left edge of the screen. The default value is `0`. + +Increase this value if the text flows off the left edge of the screen; decrease it if there is a black border between the left edge of the screen and the text. + +==== `overscan_right` + +The `overscan_right` command specifies the number of pixels to add to the firmware default value of overscan on the right edge of the screen. The default value is `0`. + +Increase this value if the text flows off the right edge of the screen; decrease it if there is a black border between the right edge of the screen and the text. + +==== `overscan_top` + +The `overscan_top` command specifies the number of pixels to add to the firmware default value of overscan on the top edge of the screen. The default value is `0`. + +Increase this value if the text flows off the top edge of the screen; decrease it if there is a black border between the top edge of the screen and the text. + +==== `overscan_bottom` + +The `overscan_bottom` command specifies the number of pixels to add to the firmware default value of overscan on the bottom edge of the screen. The default value is `0`. + +Increase this value if the text flows off the bottom edge of the screen; decrease it if there is a black border between the bottom edge of the screen and the text. + +==== `overscan_scale` + +Set `overscan_scale` to `1` to force any non-framebuffer layers to conform to the overscan settings. The default value is `0`. + +NOTE: this feature is generally not recommended: it can reduce image quality because all layers on the display will be scaled by the GPU. Disabling overscan on the display itself is the recommended option to avoid images being scaled twice (by the GPU and the display). + +==== `framebuffer_width` + +The `framebuffer_width` command specifies the console framebuffer width in pixels. The default is the display width minus the total horizontal overscan. + +==== `framebuffer_height` + +The `framebuffer_height` command specifies the console framebuffer height in pixels. The default is the display height minus the total vertical overscan. + +==== `max_framebuffer_height`, `max_framebuffer_width` + +Specifies the maximum dimensions of the internal frame buffer. + +==== `framebuffer_depth` + +Use `framebuffer_depth` to specify the console framebuffer depth in bits per pixel. The default value is `16`. + +|=== +| framebuffer_depth | result | notes + +| 8 +| 8-bit framebuffer +| Default RGB palette makes screen unreadable + +| 16 +| 16-bit framebuffer +| + +| 24 +| 24-bit framebuffer +| May result in a corrupted display + +| 32 +| 32-bit framebuffer +| May need to be used in conjunction with `framebuffer_ignore_alpha=1` +|=== + +==== `framebuffer_ignore_alpha` + +Set `framebuffer_ignore_alpha` to `1` to disable the alpha channel. Can help with the display of a 32-bit `framebuffer_depth`. + +==== `framebuffer_priority` + +In a system with multiple displays, using the legacy (pre-KMS) graphics driver, this forces a specific internal display device to be the first Linux framebuffer (i.e. `/dev/fb0`). + +The options that can be set are: + +|=== +| Display | ID + +| Main LCD +| 0 + +| Secondary LCD +| 1 + +| HDMI 0 +| 2 + +| Composite +| 3 + +| HDMI 1 +| 7 +|=== + +==== `max_framebuffers` + +This configuration entry sets the maximum number of firmware framebuffers that can be created. Valid options are 0, 1, and 2. By default on devices before the Raspberry Pi 4 this is set to 1, so will need to be increased to 2 when using more than one display, for example HDMI and a DSI or DPI display. The Raspberry Pi 4 configuration sets this to 2 by default as it has two HDMI ports. + +It is safe to set this to 2 in most instances, as framebuffers will only be created when an attached device is actually detected. + +Setting this value to 0 can be used to reduce memory requirements when used in headless mode, as it will prevent any framebuffers from being allocated. + +==== `test_mode` + +The `test_mode` command displays a test image and sound during boot (over the composite video and analogue audio outputs only) for the given number of seconds, before continuing to boot the OS as normal. This is used as a manufacturing test; the default value is `0`. + +==== `display_hdmi_rotate` + +Use `display_hdmi_rotate` to rotate or flip the HDMI display orientation. The default value is `0`. + +|=== +| display_hdmi_rotate | result + +| 0 +| no rotation + +| 1 +| rotate 90 degrees clockwise + +| 2 +| rotate 180 degrees clockwise + +| 3 +| rotate 270 degrees clockwise + +| 0x10000 +| horizontal flip + +| 0x20000 +| vertical flip +|=== + +Note that the 90 and 270 degree rotation options require additional memory on the GPU, so these will not work with the 16MB GPU split. + +You can combine the rotation settings with the flips by adding them together. You can also have both horizontal and vertical flips in the same way. E.g. A 180 degree rotation with a vertical and horizontal flip will be 0x20000 + 0x10000 + 2 = 0x30002. + +==== `display_lcd_rotate` + +For the legacy graphics driver (default on models prior to the Raspberry Pi 4), use `display_lcd_rotate` to rotate or flip the LCD orientation. Parameters are the same as `display_hdmi_rotate`. See also `lcd_rotate`. + +==== `display_rotate` + +In the latest firmware, `display_rotate` is deprecated. It has only been retained for backwards compatibility. Please use `display_lcd_rotate` and `display_hdmi_rotate` instead. + +Use `display_rotate` to rotate or flip the screen orientation. Parameters are the same as `display_hdmi_rotate`. + +=== Other options + +==== `dispmanx_offline` + +Forces `dispmanx` composition to be done offline in two offscreen framebuffers. This can allow more `dispmanx` elements to be composited, but is slower and may limit screen framerate to around 30fps. diff --git a/documentation/asciidoc/computers/linux_kernel.adoc b/documentation/asciidoc/computers/linux_kernel.adoc index e9bd941d06..81bcb30d62 100644 --- a/documentation/asciidoc/computers/linux_kernel.adoc +++ b/documentation/asciidoc/computers/linux_kernel.adoc @@ -8,3 +8,4 @@ include::linux_kernel/patching.adoc[] include::linux_kernel/headers.adoc[] +include::linux_kernel/contribute.adoc[] diff --git a/documentation/asciidoc/computers/linux_kernel/about-kernel.adoc b/documentation/asciidoc/computers/linux_kernel/about-kernel.adoc index e1f4b3d1ba..4f9f871469 100644 --- a/documentation/asciidoc/computers/linux_kernel/about-kernel.adoc +++ b/documentation/asciidoc/computers/linux_kernel/about-kernel.adoc @@ -1,23 +1,8 @@ -== Kernel +[[kernel]] +== Introduction -The Raspberry Pi kernel is stored in GitHub and can be viewed at https://github.com/raspberrypi/linux[github.com/raspberrypi/linux]; it follows behind the main https://github.com/torvalds/linux[Linux kernel]. The main Linux kernel is continuously updating; we take long-term releases of the kernel, which are mentioned on the front page, and integrate the changes into the Raspberry Pi kernel. We then create a 'next' branch which contains an unstable port of the kernel; after extensive testing and discussion, we push this to the main branch. +The Raspberry Pi kernel is https://github.com/raspberrypi/linux[hosted on GitHub]; updates lag behind the upstream https://github.com/torvalds/linux[Linux kernel]. The upstream kernel updates continuously, whereas Raspberry Pi integrates **long-term releases** of the Linux kernel into the Raspberry Pi kernel. We generate a `next` branch in https://github.com/raspberrypi/firmware/[raspberrypi/firmware] for each long-term Linux kernel release. After extensive testing and discussion, we merge each `next` branch into the main branch of our repository. -=== Updating your Kernel +== Update -If you use the standard Raspberry Pi OS xref:os.adoc#updating-and-upgrading-raspberry-pi-os[update and upgrade process], this will automatically update the kernel to the latest stable version. This is the recommended procedure. However, in certain circumstances, you may wish to update to the latest 'bleeding edge' or test kernel. You should only do this if recommended to do so by a Raspberry Pi engineer, or if there is a specific feature only available in this latest software. - -=== Getting your Code into the Kernel - -There are many reasons you may want to put something into the kernel: - -* You've written some Raspberry Pi-specific code that you want everyone to benefit from -* You've written a generic Linux kernel driver for a device and want everyone to use it -* You've fixed a generic kernel bug -* You've fixed a Raspberry Pi-specific kernel bug - -Initially, you should fork the https://github.com/raspberrypi/linux[Linux repository] and clone that on your build system; this can be either on the Raspberry Pi or on a Linux machine you're using for cross-compiling. You can then make your changes, test them, and commit them into your fork. - -Next, depending upon whether the code is Raspberry Pi-specific or not: - -* For Pi-specific changes or bug fixes, submit a pull request to the kernel. -* For general Linux kernel changes (i.e. a new driver), these need to be submitted upstream first. Once they've been submitted upstream and accepted, submit the pull request and we'll receive it. +The usual Raspberry Pi OS xref:os.adoc#update-software[update process] automatically updates your kernel to the latest stable release. If you want to try the latest unstable test kernel, you can xref:os.adoc#rpi-update[manually update]. diff --git a/documentation/asciidoc/computers/linux_kernel/building.adoc b/documentation/asciidoc/computers/linux_kernel/building.adoc index 2a81e9ec15..6fe3f916f8 100644 --- a/documentation/asciidoc/computers/linux_kernel/building.adoc +++ b/documentation/asciidoc/computers/linux_kernel/building.adoc @@ -1,234 +1,409 @@ [[building]] -== Building the Kernel +== Build the kernel -The default compilers and linkers that come with an OS are configured to build executables to run on that OS - they are native tools - but that doesn't have to be the case. A cross-compiler is configured to build code for a target other than the one running the build process, and using it is called cross-compilation. +The default compilers and linkers distributed with an OS are configured to build executables to run on that OS. **Native builds** use these default compilers and linkers. **Cross-compilation** is the process of building code for a target other than the one running the build process. -Cross-compilation of the Raspberry Pi kernel is useful for two reasons: +Cross-compilation of the Raspberry Pi kernel allows you to build a 64-bit kernel from a 32-bit OS, and vice versa. Alternatively, you can cross-compile a 32-bit or 64-bit Raspberry Pi kernel from a device other than a Raspberry Pi. -* it allows a 64-bit kernel to be built using a 32-bit OS, and vice versa, and -* even a modest laptop can cross-compile a Pi kernel significantly faster than the Pi itself. +The instructions below are divided into native builds and cross-compilation. Choose the section appropriate for your situation; although the two processes share many steps, there are also some important differences. -The instructions below are divided into native builds and cross-compilation; choose the section appropriate for your situation - although there are many common steps between the two, there are also some important differences. +=== Download kernel source -=== Building the Kernel Locally +Before you can build for any target, you need the kernel source. To get the kernel source, you need Git. Begin by installing Git on your device, if you don't already have it: -On a Raspberry Pi, first install the latest version of https://www.raspberrypi.org/downloads/[Raspberry Pi OS]. Then boot your Pi, plug in Ethernet to give you access to the sources, and log in. +[source,console] +---- +$ sudo apt install git +---- -First install Git and the build dependencies: +Next, download the source code for the latest Raspberry Pi kernel: -[,bash] +[source,console] ---- -sudo apt install git bc bison flex libssl-dev make +$ git clone --depth=1 https://github.com/raspberrypi/linux ---- -Next get the sources, which will take some time: +This can take several minutes. + +[TIP] +==== +The `git clone` command above downloads the current active branch, which we build Raspberry Pi OS images from, without any history. Omit `--depth=1` to download the entire repository, including the full history of all branches. This takes much longer and occupies much more storage. + +To download a different branch with no history, add the `--branch` option to the command above, replacing `` with the name of the branch you wish to download: -[,bash] +[source,console] ---- -git clone --depth=1 https://github.com/raspberrypi/linux +$ git clone --depth=1 --branch https://github.com/raspberrypi/linux ---- -[[choosing_sources]] -==== Choosing Sources +For a full list of available branches, see the https://github.com/raspberrypi/linux[the Raspberry Pi kernel repository]. +==== -The `git clone` command above will download the current active branch (the one we are building Raspberry Pi OS images from) without any history. Omitting the `--depth=1` will download the entire repository, including the full history of all branches, but this takes much longer and occupies much more storage. +Now that you have the kernel source, build a fresh kernel xref:linux_kernel.adoc#natively-build-a-kernel[natively] or via xref:linux_kernel.adoc#cross-compile-the-kernel[cross-compilation]. -To download a different branch (again with no history), use the `--branch` option: +=== Natively build a kernel -[,bash] +This guide assumes that your Raspberry Pi runs the latest version of xref:os.adoc[Raspberry Pi OS]. + +First, install the build dependencies: + +[source,console] ---- -git clone --depth=1 --branch https://github.com/raspberrypi/linux +$ sudo apt install bc bison flex libssl-dev make ---- -where `` is the name of the branch that you wish to download. +[[native-build-configuration]] +==== Build configuration -Refer to the https://github.com/raspberrypi/linux[original GitHub repository] for information about the available branches. +This section describes how to apply the default configuration when you build a kernel. You can also configure your kernel in the following ways: -==== Kernel Configuration +* xref:linux_kernel.adoc#configure-the-kernel[enable and disable kernel features] +* xref:linux_kernel.adoc#patch-the-kernel[apply patches from another source] -Configure the kernel; as well as the default configuration, you may wish to xref:linux_kernel.adoc#configuring-the-kernel[configure your kernel in more detail] or xref:linux_kernel.adoc#patching-the-kernel[apply patches from another source], to add or remove required functionality. +To prepare the default configuration, run the appropriate commands from the table below for your Raspberry Pi model. -[[default_configuration]] -===== Apply the Default Configuration +[cols="8,<.^20a,60a"] +|=== +| Architecture | Model | Command + +.12+^.^| 64-bit +| Raspberry Pi 3 +.9+.^| +[source,console] +---- +$ cd linux +$ KERNEL=kernel8 +$ make bcm2711_defconfig +---- +| Compute Module 3 +| Raspberry Pi 3+ +| Compute Module 3+ +| Raspberry Pi Zero 2 W +| Raspberry Pi 4 +| Pi 400 +| Compute Module 4 +| Compute Module 4S -First, prepare the default configuration by running the following commands, depending on your Raspberry Pi version: -For Raspberry Pi 1, Pi Zero, Pi Zero W, and Compute Module default build configuration +.^| Raspberry Pi 5 +.3+.^| +[source,console] +---- +$ cd linux +$ KERNEL=kernel_2712 +$ make bcm2712_defconfig +---- +| Pi 500 +| Compute Module 5 -[,bash] +.14+^.^| 32-bit +| Raspberry Pi 1 +.4+.^| +[source,console] ---- -cd linux -KERNEL=kernel -make bcmrpi_defconfig +$ cd linux +$ KERNEL=kernel +$ make bcmrpi_defconfig ---- +| Compute Module 1 +| Zero +| Zero W -For Raspberry Pi 2, Pi 3, Pi 3+, and Compute Module 3 default build configuration -[,bash] +| Raspberry Pi 2 +.6+.^| +[source,console] ---- -cd linux -KERNEL=kernel7 -make bcm2709_defconfig +$ cd linux +$ KERNEL=kernel7 +$ make bcm2709_defconfig ---- +| Raspberry Pi 3 +| Compute Module 3 +| Raspberry Pi 3+ +| Compute Module 3+ +| Zero 2 W -For Raspberry Pi 4 default build configuration -[,bash] +| Raspberry Pi 4 +.4+.^| +[source,console] ---- -cd linux -KERNEL=kernel7l -make bcm2711_defconfig +$ cd linux +$ KERNEL=kernel7l +$ make bcm2711_defconfig ---- +| Pi 400 +| Compute Module 4 +| Compute Module 4S +|=== + +[NOTE] +==== +The 32-bit distribution of Raspberry Pi OS on 4-series devices uses a 32-bit userland, but a _64-bit kernel_. To build a 32-bit kernel, set `ARCH=arm`. To boot a 32-bit kernel, set `arm_64bit=0` in `config.txt`. +==== -===== Customising the Kernel version using `LOCALVERSION` +[[native-customisation]] +==== Customise the kernel version using `LOCALVERSION` -In addition to your kernel configuration changes, you may wish to adjust the `LOCALVERSION` to ensure your new kernel does not receive the same version string as the upstream kernel. This both clarifies you are running your own kernel in the output of `uname` and ensures existing modules in `/lib/modules` are not overwritten. +To prevent the kernel from overwriting existing modules in `/lib/modules` and to clarify that you run your own kernel in `uname` output, adjust `LOCALVERSION`. -To do so, change the following line in `.config`: +To adjust `LOCALVERSION`, change the following line in `.config`: +[source,ini] ---- CONFIG_LOCALVERSION="-v7l-MY_CUSTOM_KERNEL" ---- -You can also change that setting graphically as shown in xref:linux_kernel.adoc#configuring-the-kernel[the kernel configuration instructions]. It is located in "General setup" \=> "Local version - append to kernel release". +TIP: You can also change this setting graphically with `menuconfig` at *General setup* > *Local version - append to kernel release*. For more information about `menuconfig`, see xref:linux_kernel.adoc#configure-the-kernel[the kernel configuration instructions]. -==== Building the Kernel +[[native-build]] +==== Build -Build and install the kernel, modules, and Device Tree blobs; this step can take a *long* time depending on the Pi model in use: +Next, build the kernel. This step can take a long time, depending on your Raspberry Pi model. -[,bash] +* Run the following commands to build a 64-bit kernel: ++ +[source,console] ---- -make -j4 zImage modules dtbs -sudo make modules_install -sudo cp arch/arm/boot/dts/*.dtb /boot/ -sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ -sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ -sudo cp arch/arm/boot/zImage /boot/$KERNEL.img +$ make -j6 Image.gz modules dtbs ---- -NOTE: On a Raspberry Pi 2/3/4, the `-j4` flag splits the work between all four cores, speeding up compilation significantly. - -=== Cross-Compiling the Kernel +* Run the following command to build a 32-bit kernel: ++ +[source,console] +---- +$ make -j6 zImage modules dtbs +---- -First, you will need a suitable Linux cross-compilation host. We tend to use Ubuntu; since Raspberry Pi OS is -also a Debian distribution, it means many aspects are similar, such as the command lines. +TIP: On multi-core Raspberry Pi models, the `make -j` option distributes work between cores. This can speed up compilation significantly. Run `nproc` to see how many processors you have; we recommend passing a number 1.5x your number of processors. -You can either do this using VirtualBox (or VMWare) on Windows, or install it directly onto your computer. For reference, you can follow instructions online http://www.wikihow.com/Install-Ubuntu-on-VirtualBox[at Wikihow]. +[[native-install]] +==== Install the kernel -==== Install required dependencies and toolchain +Next, install the kernel modules onto the boot media: -To build the sources for cross-compilation, make sure you have the dependencies needed on your machine by executing: - -[,bash] +[source,console] ---- -sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev +$ sudo make -j6 modules_install ---- -If you find you need other things, please submit a pull request to change the documentation. +Then, install the kernel and Device Tree blobs into the boot partition, backing up your original kernel. + +TIP: If you don't want to install the freshly-compiled kernel onto the Raspberry Pi where you run this command, copy the compiled kernel to the boot partition of a separate boot media instead of `/boot/firmware/`. -===== Install the 32-bit toolchain for a 32-bit kernel +To install the 64-bit kernel: -[,bash] +* Run the following commands to create a backup image of the current kernel, install the fresh kernel image, overlays, README, and unmount the partitions: ++ +[source,console] ---- -sudo apt install crossbuild-essential-armhf +$ sudo cp /boot/firmware/$KERNEL.img /boot/firmware/$KERNEL-backup.img +$ sudo cp arch/arm64/boot/Image.gz /boot/firmware/$KERNEL.img +$ sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/firmware/ +$ sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/firmware/overlays/ +$ sudo cp arch/arm64/boot/dts/overlays/README /boot/firmware/overlays/ ---- -===== Or, install the 64-bit toolchain for a 64-bit kernel +To install the 32-bit kernel: -[,bash] +. Create a backup of your current kernel and install the fresh kernel image: ++ +[source,console] +---- +$ sudo cp /boot/firmware/$KERNEL.img /boot/firmware/$KERNEL-backup.img +$ sudo cp arch/arm/boot/zImage /boot/firmware/$KERNEL.img +---- +. Depending on your xref:linux_kernel.adoc#identify-your-kernel-version[kernel version], run the following command: + ** For kernels up to version 6.4: ++ +[source,console] +---- +$ sudo cp arch/arm/boot/dts/*.dtb /boot/firmware/ +---- +** For kernels version 6.5 and above: ++ +[source,console] +---- +$ sudo cp arch/arm/boot/dts/broadcom/*.dtb /boot/firmware/ +---- +. Finally, copy over the overlays and README: ++ +[source,console] ---- -sudo apt install crossbuild-essential-arm64 +$ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/firmware/overlays/ +$ sudo cp arch/arm/boot/dts/overlays/README /boot/firmware/overlays/ ---- -==== Get sources +Finally, run the following command to reboot your Raspberry Pi and run your freshly-compiled kernel: -To download the minimal source tree for the current branch, run: +[source,console] +---- +$ sudo reboot +---- -[,bash] +[TIP] +==== +Alternatively, copy the kernel with a different filename (e.g. `kernel-myconfig.img`) instead of overwriting the `kernel.img` file. Then, edit `config.txt` in the boot partition to select your kernel: + +[source,ini] ---- -git clone --depth=1 https://github.com/raspberrypi/linux +kernel=kernel-myconfig.img ---- -See <> above for instructions on how to choose a different branch. +Combine this approach with a custom `LOCALVERSION` to keep your custom kernel separate from the stock kernel image managed by the system. With this arrangement, you can quickly revert to a stock kernel in the event that your kernel cannot boot. +==== -==== Build sources +=== Cross-compile the kernel -Enter the following commands to build the sources and Device Tree files: +First, you will need a suitable Linux cross-compilation host. We tend to use Ubuntu; since Raspberry Pi OS is also a Debian distribution, compilation commands are similar. -===== 32-bit configs +[[cross-compiled-dependencies]] +==== Install required dependencies and toolchain -For Pi 1, Pi Zero, Pi Zero W, or Compute Module: +To build the sources for cross-compilation, install the required dependencies onto your device. Run the following command to install most dependencies: -[,bash] +[source,console] ---- -cd linux -KERNEL=kernel -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig +$ sudo apt install bc bison flex libssl-dev make libc6-dev libncurses5-dev ---- -For Pi 2, Pi 3, Pi 3+, or Compute Module 3: +Then, install the proper toolchain for the kernel architecture you wish to build: + +* To install the 64-bit toolchain to build a 64-bit kernel, run the following command: ++ +[source,console] +---- +$ sudo apt install crossbuild-essential-arm64 +---- -[,bash] +* To install the 32-bit toolchain to build a 32-bit kernel, run the following command: ++ +[source,console] ---- -cd linux -KERNEL=kernel7 -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig +$ sudo apt install crossbuild-essential-armhf ---- -For Raspberry Pi 4: +[[cross-compiled-build-configuration]] +==== Build configuration + +This section describes how to apply the default configuration when you build a kernel. You can also configure your kernel in the following ways: + +* xref:linux_kernel.adoc#configure-the-kernel[enable and disable kernel features] +* xref:linux_kernel.adoc#patch-the-kernel[apply patches from another source] + +Enter the following commands to build the sources and Device Tree files: + +[cols="8,<.^20a,60a"] +|=== +| Target Architecture | Target Model | Command + +.10+^.^| 64-bit +| Raspberry Pi 3 +.9+.^| [source,console] +---- +$ cd linux +$ KERNEL=kernel8 +$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig +---- +| Raspberry Pi Compute Module 3 +| Raspberry Pi 3+ +| Raspberry Pi Compute Module 3+ +| Raspberry Pi Zero 2 W +| Raspberry Pi 4 +| Raspberry Pi 400 +| Raspberry Pi Compute Module 4 +| Raspberry Pi Compute Module 4S -[,bash] +.^| Raspberry Pi 5 +.1+.^| +[source,console] ---- -cd linux -KERNEL=kernel7l -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2711_defconfig +$ cd linux +$ KERNEL=kernel_2712 +$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2712_defconfig ---- -===== 64-bit configs -For Pi 3, Pi 3+ or Compute Module 3: +.14+^.^| 32-bit -[,bash] +| Raspberry Pi 1 +.4+.^| [source,console] ---- -cd linux -KERNEL=kernel8 -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig +$ cd linux +$ KERNEL=kernel +$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig ---- +| Raspberry Pi Compute Module 1 +| Raspberry Pi Zero +| Raspberry Pi Zero W -For Raspberry Pi 4: +| Raspberry Pi 2 +.6+.^| +[source,console] +---- +$ cd linux +$ KERNEL=kernel7 +$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig +---- +| Raspberry Pi 3 +| Raspberry Pi Compute Module 3 +| Raspberry Pi 3+ +| Raspberry Pi Compute Module 3+ +| Raspberry Pi Zero 2 W -[,bash] +| Raspberry Pi 4 +.4+.^| +[source,console] ---- -cd linux -KERNEL=kernel8 -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig +$ cd linux +$ KERNEL=kernel7l +$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2711_defconfig ---- +| Raspberry Pi 400 +| Raspberry Pi Compute Module 4 +| Raspberry Pi Compute Module 4S +|=== -===== Build with configs +[[cross-compiled-customisation]] +==== Customise the kernel version using `LOCALVERSION` -NOTE: To speed up compilation on multiprocessor systems, and get some improvement on single processor ones, use `-j n`, where n is the number of processors * 1.5. Alternatively, feel free to experiment and see what works! +To prevent the kernel from overwriting existing modules in `/lib/modules` and to clarify that you run your own kernel in `uname` output, adjust `LOCALVERSION`. -====== For all 32-bit builds +To adjust `LOCALVERSION`, change the following line in `.config`: -[,bash] +[source,ini] ---- -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs +CONFIG_LOCALVERSION="-v7l-MY_CUSTOM_KERNEL" ---- -====== For all 64-bit builds +TIP: You can also change this setting graphically with `menuconfig` at *General setup* > *Local version - append to kernel release*. For more information about `menuconfig`, see xref:linux_kernel.adoc#configure-the-kernel[the kernel configuration instructions]. + +[[cross-compiled-build]] +==== Build -NOTE: Note the difference between Image target between 32 and 64-bit. +* Run the following command to build a 64-bit kernel: ++ +[source,console] +---- +$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs +---- -[,bash] +* Run the following command to build a 32-bit kernel: ++ +[source,console] ---- -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs +$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs ---- -==== Install directly onto the SD card +[[cross-compiled-install]] +==== Install the kernel -Having built the kernel, you need to copy it onto your Raspberry Pi and install the modules; this is best done directly using an SD card reader. +Having built the kernel, you need to copy it onto your Raspberry Pi boot media (likely an SD card or SSD) and install the modules. -First, use `lsblk` before and after plugging in your SD card to identify it. You should end up with something like this: +===== Find your boot media + +First, run `lsblk`. Then, connect your boot media. Run `lsblk` again; the new device represents your boot media. You should see output similar to the following: ---- sdb @@ -236,82 +411,100 @@ sdb sdb2 ---- -with `sdb1` being the FAT (boot) partition, and `sdb2` being the ext4 filesystem (root) partition. +If `sdb` represents your boot media, `sdb1` represents the the `FAT32`-formatted **boot partition** and `sdb2` represents the (likely `ext4`-formatted) **root partition**. -If it's a NOOBS card, you should see something like this: +First, mount these partitions as `mnt/boot` and `mnt/root`, adjusting the partition letter to match the location of your boot media: +[source,console] ---- -sdb - sdb1 - sdb2 - sdb5 - sdb6 - sdb7 +$ mkdir mnt +$ mkdir mnt/boot +$ mkdir mnt/root +$ sudo mount /dev/sdb1 mnt/boot +$ sudo mount /dev/sdb2 mnt/root ---- -with `sdb6` being the FAT (boot) partition, and `sdb7` being the ext4 filesystem (root) partition. +===== Install -Mount these first, adjusting the partition numbers for NOOBS cards (as necessary): +Next, install the kernel modules onto the boot media: -[,bash] +* For 64-bit kernels: ++ +[source,console] ---- -mkdir mnt -mkdir mnt/fat32 -mkdir mnt/ext4 -sudo mount /dev/sdb6 mnt/fat32 -sudo mount /dev/sdb7 mnt/ext4 +$ sudo env PATH=$PATH make -j12 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=mnt/root modules_install ---- -Next, install the kernel modules onto the SD card: - -===== For 32-bit - -[,bash] +* For 32-bit kernels: ++ +[source,console] ---- -sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install +$ sudo env PATH=$PATH make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/root modules_install ---- -===== For 64-bit +TIP: On multi-core devices, the `make -j` option distributes work between cores. This can speed up compilation significantly. Run `nproc` to see how many processors you have; we recommend passing a number 1.5x your number of processors. -[,bash] +Next, install the kernel and Device Tree blobs into the boot partition, backing up your original kernel. + +To install the 64-bit kernel: + +* Run the following commands to create a backup image of the current kernel, install the fresh kernel image, overlays, README, and unmount the partitions: ++ +[source,console] ---- -sudo env PATH=$PATH make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=mnt/ext4 modules_install +$ sudo cp mnt/boot/$KERNEL.img mnt/boot/$KERNEL-backup.img +$ sudo cp arch/arm64/boot/Image mnt/boot/$KERNEL.img +$ sudo cp arch/arm64/boot/dts/broadcom/*.dtb mnt/boot/ +$ sudo cp arch/arm64/boot/dts/overlays/*.dtb* mnt/boot/overlays/ +$ sudo cp arch/arm64/boot/dts/overlays/README mnt/boot/overlays/ +$ sudo umount mnt/boot +$ sudo umount mnt/root ---- -Finally, copy the kernel and Device Tree blobs onto the SD card, making sure to back up your old kernel: +To install the 32-bit kernel: -===== For 32-bit - -[,bash] +. Run the following commands to create a backup image of the current kernel and install the fresh kernel image: ++ +[source,console] ---- -sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img -sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img -sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/ -sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ -sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/ -sudo umount mnt/fat32 -sudo umount mnt/ext4 +$ sudo cp mnt/boot/$KERNEL.img mnt/boot/$KERNEL-backup.img +$ sudo cp arch/arm/boot/zImage mnt/boot/$KERNEL.img ---- -===== For 64-bit - -[,bash] +. Depending on your xref:linux_kernel.adoc#identify-your-kernel-version[kernel version], run the following command to install Device Tree blobs: + ** For kernels up to version 6.4: ++ +[source,console] ---- -sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img -sudo cp arch/arm64/boot/Image mnt/fat32/$KERNEL.img -sudo cp arch/arm64/boot/dts/broadcom/*.dtb mnt/fat32/ -sudo cp arch/arm64/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ -sudo cp arch/arm64/boot/dts/overlays/README mnt/fat32/overlays/ -sudo umount mnt/fat32 -sudo umount mnt/ext4 +$ sudo cp arch/arm/boot/dts/*.dtb mnt/boot/ +---- +** For kernels version 6.5 and above: ++ +[source,console] +---- +$ sudo cp arch/arm/boot/dts/broadcom/*.dtb mnt/boot/ +---- +. Finally, install the overlays and README, and unmount the partitions: ++ +[source,console] +---- +$ sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/boot/overlays/ +$ sudo cp arch/arm/boot/dts/overlays/README mnt/boot/overlays/ +$ sudo umount mnt/boot +$ sudo umount mnt/root ---- -Another option is to copy the kernel into the same place, but with a different filename - for instance, kernel-myconfig.img - rather than overwriting the kernel.img file. You can then edit the config.txt file to select the kernel that the Pi will boot into: +Finally, connect the boot media to your Raspberry Pi and connect it to power to run your freshly-compiled kernel. + +[TIP] +==== +Alternatively, copy the kernel with a different filename (e.g. `kernel-myconfig.img`) instead of overwriting the `kernel.img` file. Then, edit `config.txt` in the boot partition to select your kernel: + +[source,ini] ---- kernel=kernel-myconfig.img ---- -This has the advantage of keeping your kernel separate from the kernel image managed by the system and any automatic update tools, and allowing you to easily revert to a stock kernel in the event that your kernel cannot boot. - -Finally, plug the card into the Pi and boot it! +Combine this approach with a custom `LOCALVERSION` to keep your custom kernel separate from the stock kernel image managed by the system. With this arrangement, you can quickly revert to a stock kernel in the event that your kernel cannot boot. +==== diff --git a/documentation/asciidoc/computers/linux_kernel/configuring.adoc b/documentation/asciidoc/computers/linux_kernel/configuring.adoc index 0fc4710ecf..f0bd89da6d 100644 --- a/documentation/asciidoc/computers/linux_kernel/configuring.adoc +++ b/documentation/asciidoc/computers/linux_kernel/configuring.adoc @@ -1,41 +1,56 @@ -== Configuring the Kernel +== Configure the kernel -The Linux kernel is highly configurable; advanced users may wish to modify the default configuration to customise it to their needs, such as enabling a new or experimental network protocol, or enabling support for new hardware. +The Linux kernel is highly configurable. Advanced users may wish to modify the default configuration to customise it to their needs, such as enabling a new or experimental network protocol, or enabling support for new hardware. -Configuration is most commonly done through the `make menuconfig` interface. Alternatively, you can modify your `.config` file manually, but this can be more difficult for new users. +Configuration is most commonly done through the `make menuconfig` interface. Alternatively, you can modify your `.config` file manually, but this can be more difficult. -=== Preparing to Configure +=== Prepare to configure -The `menuconfig` tool requires the `ncurses` development headers to compile properly. These can be installed with the following command: +The `menuconfig` tool requires the `ncurses` development headers to compile properly. To install these headers, run the following command: - $ sudo apt install libncurses5-dev +[source,console] +---- +$ sudo apt install libncurses5-dev +---- -You'll also need to download and prepare your kernel sources, as described in the xref:linux_kernel.adoc#choosing_sources[build guide]. In particular, ensure you have installed the xref:linux_kernel.adoc#default_configuration[default configuration]. +Next, xref:linux_kernel.adoc#download-kernel-source[download your kernel sources]. In particular, ensure you have installed the xref:linux_kernel.adoc#native-build-configuration[default native configuration] or xref:linux_kernel.adoc#cross-compiled-build-configuration[default cross-compilation configuration]. -=== Using `menuconfig` +=== `menuconfig` -Once you've got everything set up and ready to go, you can compile and run the `menuconfig` utility as follows: +Once you've got everything set up, you can compile and run the `menuconfig` utility as follows: - $ make menuconfig +[source,console] +---- +$ make menuconfig +---- -If you're cross-compiling a 32-bit kernel: +To cross-compile a 64-bit kernel: +[source,console] ---- -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig +$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig ---- -Or, if you are cross-compiling a 64-bit kernel: +To cross-compile a 32-bit kernel: +[source,console] ---- -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig +$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig ---- -The `menuconfig` utility has simple keyboard navigation. After a brief compilation, you'll be presented with a list of submenus containing all the options you can configure; there's a lot, so take your time to read through them and get acquainted. +To navigate the `menuconfig` utility, use your keyboard: + +* to navigate directionally, use the *arrow keys* +* to enter a submenu (indicated by `+--->+`), press the *Enter* key +* to go up a level or exit, press *Escape* twice +* to toggle the state of a binary option, press the *space bar* +* to select the state of a multiple choice option, press *Enter* to open a submenu, the *arrow keys* to navigate the submenu, and press *Enter* again to select a state +* to get help with an option or menu, press the *H* key -Use the arrow keys to navigate, the Enter key to enter a submenu (indicated by `+--->+`), Escape twice to go up a level or exit, and the space bar to cycle the state of an option. Some options have multiple choices, in which case they'll appear as a submenu and the Enter key will select an option. You can press `h` on most entries to get help about that specific option or menu. +After a brief compilation, `menuconfig` presents a list of submenus containing all the options you can configure. There are many options, so take your time to read through them. Resist the temptation to enable or disable a lot of things on your first attempt; it's relatively easy to break your configuration, so start small and get comfortable with the configuration and build process. -Resist the temptation to enable or disable a lot of things on your first attempt; it's relatively easy to break your configuration, so start small and get comfortable with the configuration and build process. +=== Save your changes -=== Saving your Changes +Once you're done making changes, press *Escape* until you're prompted to save your new configuration. By default, this saves to the `.config` file. You can save and load configurations by copying this file. -Once you're done making the changes you want, press Escape until you're prompted to save your new configuration. By default, this will save to the `.config` file. You can save and load configurations by copying this file around. +After customising, you should now be ready to xref:linux_kernel.adoc#building[build the kernel]. diff --git a/documentation/asciidoc/computers/linux_kernel/contribute.adoc b/documentation/asciidoc/computers/linux_kernel/contribute.adoc new file mode 100644 index 0000000000..74d03d865e --- /dev/null +++ b/documentation/asciidoc/computers/linux_kernel/contribute.adoc @@ -0,0 +1,24 @@ +== Contribute + +There are many reasons you may want to put something into the kernel: + +* You've written some Raspberry Pi-specific code that you want everyone to benefit from +* You've written a generic Linux kernel driver for a device and want everyone to use it +* You've fixed a generic kernel bug +* You've fixed a Raspberry Pi-specific kernel bug + +For Raspberry Pi-specific changes or bug fixes, submit a pull request to the Raspberry Pi kernel. +For general Linux kernel changes (i.e. a new driver), submit a pull request to the upstream Linux kernel first. Once the Linux kernel accepts your change, we'll receive it. + +=== Contribute to the Raspberry Pi Kernel + +First, fork the https://github.com/raspberrypi/linux[Raspberry Pi kernel repository] and clone it to your development device. You can then make your changes, test them, and commit them into your fork. + +Then, submit a pull request containing your changes to the https://github.com/raspberrypi/linux[Raspberry Pi kernel repository]. Raspberry Pi engineers will review your contribution and suggest improvements. Once approved, we'll merge in your changes, and they'll eventually make their way to the stable release of the Raspberry Pi kernel. + +=== Contribute to the Linux kernel + +First, clone the https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git[Linux kernel tree] to your development device. You can then make your changes, test them, and commit them into your local tree. + +Once your change is ready you can submit it to the Linux kernel community. Linux kernel development happens on mailing lists, rather than on GitHub. In order for your change to become part of Linux, please email it to the community as a patch. Please follow https://www.kernel.org/doc/html/latest/process/submitting-patches.html[Submitting patches: the essential guide to getting your code into the kernel] and https://www.kernel.org/doc/html/latest/process/coding-style.html[Linux kernel coding style] in the Linux kernel documentation. +Linux kernel contributors will review your contribution and suggest improvements. Once approved, they'll merge in your changes. Eventually, they'll make their way into a long-term release of the Linux kernel. Once we've tested that long-term release for compatibility with the Raspberry Pi kernel, your changes will make their way into a stable release of the Raspberry Pi kernel. diff --git a/documentation/asciidoc/computers/linux_kernel/headers.adoc b/documentation/asciidoc/computers/linux_kernel/headers.adoc index d72c3f69b0..eae5281eb5 100644 --- a/documentation/asciidoc/computers/linux_kernel/headers.adoc +++ b/documentation/asciidoc/computers/linux_kernel/headers.adoc @@ -1,14 +1,23 @@ -== Kernel Headers +== Kernel headers -If you are compiling a kernel module or similar, you will need the Linux Kernel headers. These provide the various function and structure definitions required when compiling code that interfaces with the kernel. +To compile a kernel module, you need the Linux kernel headers. These provide the function and structure definitions required to compile code that interfaces with the kernel. -If you have cloned the entire kernel from github, the headers are already included in the source tree. If you don't need all the extra files, it is possible to install only the kernel headers from the Raspberry Pi OS repo. +If you cloned the entire kernel from GitHub, the headers are already included in the source tree. If you don't need all the extra files, you can instead install only the kernel headers with `apt`. -[source] +TIP: When a new kernel is released, you need the headers that match that kernel version. It can take several weeks to update the `apt` package to reflect the latest kernel version. For the latest header versions, xref:linux_kernel.adoc#building[clone the kernel]. + +If you use a 64-bit version of Raspberry Pi OS, run the following command to install the kernel headers: + +[source,console] ---- -$ sudo apt install raspberrypi-kernel-headers +$ sudo apt install linux-headers-rpi-v8 ---- -NOTE: It can take quite a while for this command to complete, as it installs a lot of small files. There is no progress indicator. +If you use a 32-bit version of Raspberry Pi OS, run the following command to install the kernel headers: + +[source,console] +---- +$ sudo apt install linux-headers-rpi-{v6,v7,v7l} +---- -When a new kernel release is made, you will need the headers that match that kernel version. It can take several weeks for the repo to be updated to reflect the latest kernel version. If this happens, the best approach is to clone the kernel as described in the xref:linux_kernel.adoc#building[Build Section]. +NOTE: Installation can take several minutes. There is no progress indicator. diff --git a/documentation/asciidoc/computers/linux_kernel/patching.adoc b/documentation/asciidoc/computers/linux_kernel/patching.adoc index c15a1dda78..29cf2bb1b9 100644 --- a/documentation/asciidoc/computers/linux_kernel/patching.adoc +++ b/documentation/asciidoc/computers/linux_kernel/patching.adoc @@ -1,49 +1,67 @@ -== Patching the Kernel +== Patch the kernel -When xref:linux_kernel.adoc#building[building] your custom kernel you may wish to apply patches, or collections of patches ('patchsets'), to the Linux kernel. +When building your custom kernel, you may wish to apply patches or collections of patches (patchsets) to the Linux kernel. -Patchsets are often provided with newer hardware as a temporary measure, before the patches are applied to the upstream Linux kernel ('mainline') and then propagated down to the Raspberry Pi kernel sources. However, patchsets for other purposes exist, for instance to enable a fully pre-emptible kernel for real-time usage. +Hardware makers sometimes provide patchsets as a temporary measure to support new hardware before the patches make it into the Linux kernel and the Raspberry Pi kernel. However, patchsets for other purposes exist, for instance to enable a fully pre-emptible kernel for real-time usage. -=== Version Identification +=== Identify your kernel version -It's important to check what version of the kernel you have when downloading and applying patches. In a kernel source directory, the following command will show you the version the sources relate to: +To check the kernel version currently running on your device, run the following command: -[source] +[source,console] ---- -$ head Makefile -n 3 -VERSION = 3 -PATCHLEVEL = 10 -SUBLEVEL = 25 +$ uname -r ---- - -In this instance, the sources are for a 3.10.25 kernel. You can see what version you're running on your system with the `uname -r` command. -=== Applying Patches +Always check your version of the kernel before applying patches. In a kernel source directory, run the following command to see the kernel version: -How you apply patches depends on the format in which the patches are made available. Most patches are a single file, and applied with the `patch` utility. For example, let's download and patch our example kernel version with the real-time kernel patches: +[source,console] +---- +$ head Makefile -n 4 +---- + +You should see output similar to the following: + +---- +# SPDX-License-Identifier: GPL-2.0 +VERSION = 6 +PATCHLEVEL = 1 +SUBLEVEL = 38 +---- + +In this instance, the sources are for a 6.1.38 kernel. + +=== Apply patches + +The application of patches depends on the format used to distribute the patch. + +Developers distribute most patches as a single file. Use the `patch` utility to apply these patches. The following commands download, uncompress, and patch our example kernel version with real-time kernel patches: -[source] +[source,console] ---- -$ wget https://www.kernel.org/pub/linux/kernel/projects/rt/3.10/older/patch-3.10.25-rt23.patch.gz -$ gunzip patch-3.10.25-rt23.patch.gz -$ cat patch-3.10.25-rt23.patch | patch -p1 +$ wget https://www.kernel.org/pub/linux/kernel/projects/rt/6.1/patch-6.1.38-rt13-rc1.patch.gz +$ gunzip patch-6.1.38-rt13-rc1.patch.gz +$ cat patch-6.1.38-rt13-rc1.patch | patch -p1 ---- -In our example we simply download the file, uncompress it, and then pass it to the `patch` utility using the `cat` tool and a Unix pipe. +Some developers distribute patches in the *mailbox format*, a folder containing multiple patch files. Use Git to apply these patches. -Some patchsets come as mailbox-format patchsets, arranged as a folder of patch files. We can use Git to apply these patches to our kernel, but first we must configure Git to let it know who we are when we make these changes: +[NOTE] +==== +Before using Git to apply mailbox patches, configure your local Git installation with a name and email: -[source] +[source,console] ---- -$ git config --global user.name "Your name" -$ git config --global user.email "your email in here" +$ git config --global user.name "your name" +$ git config --global user.email "your email" ---- +==== -Once we've done this we can apply the patches: +To apply the mailbox formatted patches with Git, run the following command: -[source] +[source,console] ---- $ git am -3 /path/to/patches/* ---- -If in doubt, consult with the distributor of the patches, who should tell you how to apply them. Some patchsets will require a specific commit to patch against; follow the details provided by the patch distributor. +Always follow the instructions provided by the patch distributor. For instance, some patchsets require patching against a specific commit. diff --git a/documentation/asciidoc/computers/os.adoc b/documentation/asciidoc/computers/os.adoc index 28e2ed7ec2..bdabf4fa4a 100644 --- a/documentation/asciidoc/computers/os.adoc +++ b/documentation/asciidoc/computers/os.adoc @@ -4,10 +4,10 @@ include::os/updating.adoc[] include::os/playing-audio-and-video.adoc[] -include::os/using-webcams.adoc[] - include::os/graphics-utilities.adoc[] +include::os/accessibility.adoc[] + include::os/using-python.adoc[] include::os/using-gpio.adoc[] @@ -15,3 +15,4 @@ include::os/using-gpio.adoc[] + diff --git a/documentation/asciidoc/computers/os/accessibility.adoc b/documentation/asciidoc/computers/os/accessibility.adoc new file mode 100644 index 0000000000..4535571626 --- /dev/null +++ b/documentation/asciidoc/computers/os/accessibility.adoc @@ -0,0 +1,13 @@ +== Accessibility options + +=== Visual aids + +Users of Raspberry Pi OS with visual impairments can find helpful tools in the *Recommended Software* menu. + +We offer https://help.gnome.org/users/orca/stable/introduction.html.en[Orca screen reader] to ease navigation of Raspberry Pi Desktop. Additionally, we offer screen magnifier to increase the readability of UI and screen elements. + +==== Orca screen reader + +You can install Orca screen reader from the *Recommended Software* section of the main Raspberry Pi menu. Alternatively, press *Ctrl* + *Alt* + *Space* to automatically install Orca. + +When booting Raspberry Pi OS for the first time after installing a new image, an automatic spoken reminder plays after 30 seconds. This reminder provides instructions on how to install Orca. diff --git a/documentation/asciidoc/computers/os/graphics-utilities.adoc b/documentation/asciidoc/computers/os/graphics-utilities.adoc index 4bf28d945f..b37e8ab81c 100644 --- a/documentation/asciidoc/computers/os/graphics-utilities.adoc +++ b/documentation/asciidoc/computers/os/graphics-utilities.adoc @@ -1,349 +1,178 @@ -== Useful Utilties +== Utilities -There are several useful command line +There are several useful command-line utilities pre-installed in Raspberry Pi OS. -=== tvservice +=== `kmsprint` -`tvservice` is a command line application used to get and set information about the display, targeted mainly at HDMI video and audio. +The `kmsprint` tool can be used to list the display-modes supported by the monitors attached to the Raspberry Pi. Use `kmsprint` to see details of the monitors connected to the Raspberry Pi, and `kmsprint -m` to see a list of all the display modes supported by each monitor. You can find source code for the `kmsprint` utility https://github.com/tomba/kmsxx[on Github]. -Typing `tvservice` by itself will display a list of available command line options. +=== `vclog` -==== -p, --preferred +`vclog` displays log messages from the VideoCore GPU from Linux running on the Arm. It needs to be run as root. -Power on the HDMI output with preferred settings. +`sudo vclog --msg` prints out the message log, whilst `sudo vclog --assert` prints out the assertion log. -==== -o, --off +=== `vcgencmd` -Powers off the display output. +The `vcgencmd` tool is used to output information from the VideoCore GPU on the Raspberry Pi. You can find source code for the `vcgencmd` utility https://github.com/raspberrypi/utils/tree/master/vcgencmd[on GitHub]. -NOTE: Powering off the output using this command will also destroy any framebuffers/dispmanx layers associated with the display. These are NOT re-established with a subsequent power on, so will result in a blank screen. +To get a list of all commands supported by `vcgencmd`, use `vcgencmd commands`. Some useful commands and their required parameters are listed below. -A better option is to use the xref:os.adoc#vcgencmd[vcgencmd display_power] option, as this will retain any framebuffers, so when the power is turned back on the display will be the returned to the previous power on state. - -==== -e, --explicit="Group Mode Drive" - -Power on the HDMI with the specified settings - -Group can be one of `CEA`, `DMT`, `CEA_3D_SBS`, `CEA_3D_TB`, `CEA_3D_FP`, `CEA_3D_FS`. + -Mode is one of the modes returned from the `-m, --modes` option. + -Drive can be one of `HDMI`, `DVI`. - -==== -t, --ntsc - -Use 59.94Hz (NTSC frequency) rather than 60Hz for HDMI mode. - -==== -c, --sdtvon="Mode Aspect [P]" - -Power on the SDTV (composite output) with the specified mode, `PAL` or `NTSC`, and the specified aspect, `4:3`, `14:9`, `16:9`. The optional `P` parameter can be used to specify progressive mode. - -==== -m, --modes=Group - -where Group is `CEA` or `DMT`. - -Shows a list of display modes available in the specified group. - -==== -M, --monitor - -Monitors for any HDMI events, for example unplugging or attaching. - -==== -s, --status - -Shows the current settings for the display mode, including mode, resolution, and frequency. - -==== -a, --audio - -Shows the current settings for the audio mode, including channels, sample rate and sample size. - -==== -d, --dumpid=filename - -Save the current EDID to the specified filename. You can then use `edidparser ` to display the data in a human readable form. - -==== -j, --json - -When used in combination with the `--modes` options, displays the mode information in JSON format. - -==== -n, --name - -Extracts the display name from the EDID data and shows it. - -==== -l, --list - -Lists all attached displays and their display ID. - -==== -v, --device=display - -Specifies the ID of the device to use; see the output of `--list` for available IDs. - -=== vcgencmd - -The `vcgencmd` tool is used to output information from the VideoCore GPU on the Raspberry Pi. You can find source code for the `vcgencmd` utility https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/gencmd[on Github]. - -To get a list of all commands which `vcgencmd` supports, use `vcgencmd commands`. Some useful commands and their required parameters are listed below. - -==== vcos +==== `vcos` The `vcos` command has two useful sub-commands: * `version` displays the build date and version of the firmware on the VideoCore * `log status` displays the error log status of the various VideoCore firmware areas -==== version +==== `version` Displays the build date and version of the VideoCore firmware. -==== get_camera - -Displays the enabled and detected state of the Raspberry Pi camera: `1` means yes, `0` means no. Whilst all firmware except cutdown versions support the camera, this support needs to be enabled by using xref:configuration.adoc#raspi-config[raspi-config]. +==== `get_throttled` -==== get_throttled - -Returns the throttled state of the system. This is a bit pattern - a bit being set indicates the following meanings: +Returns the throttled state of the system. This is a bit pattern. A bit being set indicates the following meanings: [cols="^,,"] |=== -| Bit | Hex value | Meaning +| Bit | Hexadecimal value | Meaning | 0 -| 0x1 -| Under-voltage detected +| `0x1` +| Undervoltage detected | 1 -| 0x2 +| `0x2` | Arm frequency capped | 2 -| 0x4 +| `0x4` | Currently throttled | 3 -| 0x8 +| `0x8` | Soft temperature limit active | 16 -| 0x10000 -| Under-voltage has occurred +| `0x10000` +| Undervoltage has occurred | 17 -| 0x20000 +| `0x20000` | Arm frequency capping has occurred | 18 -| 0x40000 +| `0x40000` | Throttling has occurred | 19 -| 0x80000 +| `0x80000` | Soft temperature limit has occurred |=== -==== measure_temp +==== `measure_temp` -Returns the temperature of the SoC as measured by the on-board temperature sensor. +Returns the temperature of the SoC as measured by its internal temperature sensor. +On Raspberry Pi 4, `measure_temp pmic` returns the temperature of the PMIC. -==== measure_clock [clock] +==== `measure_clock [clock]` -This returns the current frequency of the specified clock. The options are: +This returns the current frequency of the specified clock. Accepts the following clock values: [cols="^,"] |=== | clock | Description -| arm +| `arm` | ARM core(s) -| core +| `core` | GPU core -| H264 +| `h264` | H.264 block -| isp +| `isp` | Image Sensor Pipeline -| v3d +| `v3d` | 3D block -| uart +| `uart` | UART -| pwm +| `pwm` | PWM block (analogue audio output) -| emmc +| `emmc` | SD card interface -| pixel +| `pixel` | Pixel valves -| vec +| `vec` | Analogue video encoder -| hdmi +| `hdmi` | HDMI -| dpi +| `dpi` | Display Parallel Interface |=== e.g. `vcgencmd measure_clock arm` -==== measure_volts [block] +==== `measure_volts [block]` -Displays the current voltages used by the specific block. +Displays the current voltages used by the specific block. Accepts the following block values: [cols="^,"] |=== | block | Description -| core +| `core` | VC4 core voltage -| sdram_c +| `sdram_c` | SDRAM Core Voltage -| sdram_i +| `sdram_i` | SDRAM I/O voltage -| sdram_p +| `sdram_p` | SDRAM Phy Voltage |=== -==== otp_dump +==== `otp_dump` -Displays the content of the OTP (one-time programmable) memory inside the SoC. These are 32 bit values, indexed from 8 to 64. See the xref:raspberry-pi.adoc#otp-register-and-bit-definitions[OTP bits page] for more details. +Displays the content of the OTP (one-time programmable) memory inside the SoC. These are 32-bit values, indexed from 8 to 64. See the xref:raspberry-pi.adoc#otp-register-and-bit-definitions[OTP bits page] for more details. [[getconfig]] -==== get_config [configuration item|int|str] +==== `get_config [configuration item|int|str]` -Display value of the configuration setting specified: alternatively, specify either `int` (integer) or `str` (string) to see all configuration items of the given type. For example: +Displays the value of the configuration setting specified: alternatively, specify either `int` (integer) or `str` (string) to see all configuration items of the given type. For example, the following command returns the total memory on the device in megabytes: +[source,console] ---- -vcgencmd get_config total_mem +$ vcgencmd get_config total_mem ---- -returns the total memory on the device in megabytes. - -==== get_mem type +==== `get_mem type` -Reports on the amount of memory addressable by the ARM and the GPU. To show the amount of ARM-addressable memory use `vcgencmd get_mem arm`; to show the amount of GPU-addressable memory use `vcgencmd get_mem gpu`. Note that on devices with more than 1GB of memory the `arm` parameter will always return 1GB minus the `gpu` memory value, since the GPU firmware is only aware of the first 1GB of memory. To get an accurate report of the total memory on the device, see the `total_mem` configuration item - see <> section above. +Reports on the amount of memory addressable by the Arm and the GPU. To show the amount of Arm-addressable memory, use `vcgencmd get_mem arm`; to show the amount of GPU-addressable memory, use `vcgencmd get_mem gpu`. On devices with more than 1GB of memory, the `arm` parameter will always return 1GB minus the `gpu` memory value, since the GPU firmware is only aware of the first 1GB of memory. To get an accurate report of the total memory on the device, see the `total_mem` configuration item and the <> section above. -===== codec_enabled [type] +===== `codec_enabled [type]` -Reports whether the specified CODEC type is enabled. Possible options for type are AGIF, FLAC, H263, H264, MJPA, MJPB, MJPG, *MPG2*, MPG4, MVC0, PCM, THRA, VORB, VP6, VP8, *WMV9*, *WVC1*. Those highlighted currently require a paid for licence (see the xref:config_txt.adoc#licence-key-and-codec-options[this config.txt section] for more info), except on the Pi 4 and 400, where these hardware codecs are disabled in preference to software decoding, which requires no licence. Note that because the H.265 HW block on the Raspberry Pi 4 and 400 is not part of the VideoCore GPU, its status is not accessed via this command. +Reports whether the specified codec type is enabled. Possible options for type are AGIF, FLAC, H263, H264, MJPA, MJPB, MJPG, MPG2, MPG4, MVC0, PCM, THRA, VORB, VP6, VP8, WMV9, WVC1. Because the H.265 HW block on the Raspberry Pi 4 and Pi 400 is not part of the VideoCore GPU, its status is not accessed via this command. -===== get_lcd_info +===== `mem_oom` -Displays the resolution and colour depth of any attached display. +Displays statistics on any OOM (out of memory) events occurring in the VideoCore memory space. -===== mem_oom - -Displays statistics on any OOM (out of memory) events occuring in the VideoCore memory space. - -===== mem_reloc_stats +===== `mem_reloc_stats` Displays statistics from the relocatable memory allocator on the VideoCore. -===== read_ring_osc - -Returns the curent speed voltage and temperature of the ring oscillator. - -===== hdmi_timings - -Displays the current HDMI settings timings. See xref:config_txt.adoc#video-options[Video Config] for details of the values returned. - -===== dispmanx_list - -Dump a list of all dispmanx items currently being displayed. - -===== display_power [0 | 1 | -1] [display] - -Show current display power state, or set the display power state. `vcgencmd display_power 0` will turn off power to the current display. `vcgencmd display_power 1` will turn on power to the display. If no parameter is set, this will display the current power state. The final parameter is an optional display ID, as returned by `tvservice -l` or from the table below, which allows a specific display to be turned on or off. - -Note that for the 7" Raspberry Pi Touch Display this simply turns the backlight on and off. The touch functionality continues to operate as normal. - -`vcgencmd display_power 0 7` will turn off power to display ID 7, which is HDMI 1 on a Raspberry Pi 4. - -|=== -| Display | ID - -| Main LCD -| 0 - -| Secondary LCD -| 1 - -| HDMI 0 -| 2 - -| Composite -| 3 - -| HDMI 1 -| 7 -|=== - -To determine if a specific display ID is on or off, use -1 as the first parameter. - -`vcgencmd display_power -1 7` will return 0 if display ID 7 is off, 1 if display ID 7 is on, or -1 if display ID 7 is in an unknown state, for example undetected. - -=== vcdbg - -`vcdbg` is an application to help with debugging the VideoCore GPU from Linux running on the the ARM. It needs to be run as root. This application is mostly of use to Raspberry Pi engineers, although there are some commands that general users may find useful. - -`sudo vcdbg help` will give a list of available commands. - -NOTE: Only options of use to end users have been listed. - -==== version - -Shows various items of version information from the VideoCore. - -==== log - -Dumps logs from the specified subsystem. Possible options are: - -|=== -| log | Description - -| msg -| Prints out the message log - -| assert -| Prints out the assertion log - -| ex -| Prints out the exception log - -| info -| Prints out information from the logging headers - -| level -| Sets the VCOS logging level for the specified category, n\|e\|w\|i\|t - -| list -| List the VCOS logging levels -|=== - -e.g. To print out the current contents of the message log: - -`vcdbg log msg` - -==== malloc - -List all memory allocations current in the VideoCore heap. - -==== pools - -List the current status of the pool allocator - -==== reloc - -Without any further parameters, lists the current status of the relocatable allocator. Use `sudo vcdbg reloc small` to list small allocations as well. - -Use the subcommand `sudo vcdbg reloc stats` to list statistics for the relocatable allocator. - -==== hist - -Commands related to task history. +===== `read_ring_osc` -Use `sudo vcdbg hist gnuplot` to dump task history in gnuplot format to task.gpt and task.dat +Returns the current speed, voltage and temperature of the ring oscillator. diff --git a/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.jpg b/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.jpg new file mode 100644 index 0000000000..24a06d3379 Binary files /dev/null and b/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.jpg differ diff --git a/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.png b/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.png new file mode 100644 index 0000000000..5ef0a9b329 Binary files /dev/null and b/documentation/asciidoc/computers/os/images/simple-electronics-with-gpio-zero.png differ diff --git a/documentation/asciidoc/computers/os/images/thonny-venv.png b/documentation/asciidoc/computers/os/images/thonny-venv.png new file mode 100644 index 0000000000..5025e4fd2d Binary files /dev/null and b/documentation/asciidoc/computers/os/images/thonny-venv.png differ diff --git a/documentation/asciidoc/computers/os/playing-audio-and-video.adoc b/documentation/asciidoc/computers/os/playing-audio-and-video.adoc index a8d184acf8..d6db63ed50 100644 --- a/documentation/asciidoc/computers/os/playing-audio-and-video.adoc +++ b/documentation/asciidoc/computers/os/playing-audio-and-video.adoc @@ -1,171 +1,159 @@ -== Playing Audio and Video +== Play audio and video -The simplest way of playing audio and video on Raspberry Pi is to use the installed OMXPlayer application. +Raspberry Pi OS comes with https://www.videolan.org/[VLC media player] pre-installed. You can use VLC to play video and audio files. VLC uses hardware acceleration in Raspberry Pi OS, and supports many popular audio and video file formats. -This is hardware accelerated, and can play back many popular audio and video file formats. OMXPlayer uses the OpenMAX (`omx`) hardware acceleration interface (API) which is the officially supported media API on Raspberry Pi. OMXPlayer was developed by the Kodi Project's Edgar Hucek. +=== VLC media player -=== The OMXPlayer Application +==== VLC GUI -The simplest command line is `omxplayer `. The media file can be audio or video or both. For the examples below, we used an H264 video file that is included with the standard Raspberry Pi OS installation. +To play an audio or video file from Raspberry Pi Desktop, double-click on a file in the file manager. This automatically launches VLC to play the file. Alternatively, from the *Sound & Video* menu, launch *VLC Media Player*. Then, from the *Media* menu, select *Open File...* and navigate to the file you want to play. ----- -omxplayer /opt/vc/src/hello_pi/hello_video/test.h264 ----- +By default, Raspberry Pi OS sends audio to your monitor over HDMI. To output audio to a different interface, such as the headphone jack or USB speakers, right-click on the speaker icon in the system tray and select an option. -By default the audio is sent to the analog port. If you are using a HDMI-equipped display device with speakers, you need to tell omxplayer to send the audio signal over the HDMI link. +==== `vlc` CLI +You can also launch VLC from the command line. For the examples below, we used a short clip from Big Buck Bunny. To download this clip from Raspberry Pi, run the following command: + +[source,console] ---- -omxplayer --adev hdmi /opt/vc/src/hello_pi/hello_video/test.h264 +$ wget --trust-server-names http://rptl.io/big-buck-bunny ---- -When displaying video, the whole display will be used as output. You can specify which part of the display you want the video to be on using the window option. +To play the clip in VLC from the command line, run the following command: +[source,console] ---- -omxplayer --win 0,0,640,480 /opt/vc/src/hello_pi/hello_video/test.h264 +$ vlc big-buck-bunny-1080p.mp4 ---- -You can also specify which part of the video you want to be displayed: this is called a crop window. This portion of the video will be scaled up to match the display, unless you also use the window option. +To prevent the VLC GUI staying open after your file has finished playing, add the `--play-and-exit` flag: +[source,console] ---- -omxplayer --crop 100,100,300,300 /opt/vc/src/hello_pi/hello_video/test.h264 +$ vlc --play-and-exit big-buck-bunny-1080p.mp4 ---- -If you are using the Raspberry Pi Foundation's touchscreen display, and you want to use it for video output, use the display option to specify which display to use. `n` is 5 for HDMI, 4 for the touchscreen. With the Raspberry Pi 4 you have two options for HDMI output. `n` is 2 for HDMI0 and 7 for HDMI1. +To play a video in fullscreen mode (which can result in smoother playback in some circumstances), add the `--fullscreen` flag: +[source,console] ---- -omxplayer --display n /opt/vc/src/hello_pi/hello_video/test.h264 +$ vlc --play-and-exit --fullscreen big-buck-bunny-1080p.mp4 ---- -=== How to Play Audio +==== Use `cvlc` to play media without a GUI -To play an MP3 file, navigate to the location of the `.mp3` file in the terminal using `cd` and then type the following command: +If you use `cvlc` instead of `vlc` with any of these commands, then the VLC GUI won't be shown: -[,bash] +[source,console] ---- -omxplayer example.mp3 +$ cvlc --play-and-exit big-buck-bunny-1080p.mp4 ---- -This will play the audio file `example.mp3` through either your monitor's built-in speakers or your headphones, connected via the headphone jack. +=== Play audio and video on Raspberry Pi OS Lite -If you need an example file you can download one from here using the following command: +Unlike the full version of Raspberry Pi OS, VLC doesn't come pre-installed on Raspberry Pi OS Lite. To play video and audio on Raspberry Pi OS Lite with VLC, install the required packages for playback without a desktop: -[,bash] +[source,console] ---- -wget https://raw.githubusercontent.com/raspberrypilearning/burping-jelly-baby/master/data/la.mp3 -O example.mp3 --no-check-certificate +$ sudo apt install --no-install-recommends vlc-bin vlc-plugin-base ---- -If you cannot hear anything, make sure your headphones or speakers are connected correctly. Note that omxplayer doesn't use ALSA and so ignores the xref:configuration.adoc#audio-configuration[audio configuration] set by `raspi-config` or `amixer`. - -If omxplayer's auto-detection of the correct audio output device fails, you can force output over HDMI with: +For the examples below, we used a short audio clip. To download this clip from Raspberry Pi, run the following command: -[,bash] +[source,console] ---- -omxplayer -o hdmi example.mp3 +$ wget --trust-server-names http://rptl.io/startup-music ---- -Alternatively, you can force output over the headphone jack with: +To play the clip in VLC from the command line, run the following command: -[,bash] +[source,console] ---- -omxplayer -o local example.mp3 +$ cvlc --play-and-exit computer-startup-music.mp3 ---- -You can even force output over both the headphone jack and HDMI with: +=== Specify an audio output device -[,bash] +To force audio output to a particular device, pass the `alsa` value to the the `-A` option to use https://www.alsa-project.org/wiki/Main_Page[ALSA] audio output, and the `--alsa-audio-device` option to specify an audio output device: + +[source,console] ---- -omxplayer -o both example.mp3 +$ cvlc --play-and-exit -A alsa --alsa-audio-device computer-startup-music.mp3 ---- -=== How to Play Video +Replace the `` placeholder with one of the following options: -To play a video, navigate to the location of your video file in the terminal using `cd`, then type the following command: +|=== +| ALSA device | Description -[,bash] ----- -omxplayer example.mp4 ----- +| `sysdefault:CARD=Headphones` | The headphone jack -This will play the `example.mp4` in full screen. Hit `Ctrl + C` to exit. +| `sysdefault:CARD=vc4hdmi` | The HDMI output on devices with a single HDMI port (Zero models, CM4S, Compute Modules prior to CM4, and Flagship models prior to Raspberry Pi 4) -On the Pi 4, hardware support for MPEG2 and VC-1 codecs has been removed, so we recommend the use of the VLC application, which supports these formats in software. In addition, VLC has hardware support for H264 and the new HEVC codec. +| `sysdefault:CARD=vc4hdmi0` | The HDMI0 output on Flagship models since Raspberry Pi 4B, Compute Modules since CM4, and Keyboard models -==== An Example Video +| `sysdefault:CARD=vc4hdmi1` | The HDMI1 output on Flagship models since Raspberry Pi 4B, Compute Modules since CM4, and Keyboard models -A video sample of the animated film _Big Buck Bunny_ is available on your Raspberry Pi. To play it enter the following command into a terminal window: +|=== -[,bash] +[TIP] +==== +Use the following command to get a list of all ALSA devices on your Raspberry Pi: + +[source,console] ---- -omxplayer /opt/vc/src/hello_pi/hello_video/test.h264 +$ aplay -L | grep sysdefault ---- +==== + +=== Specify a video output device -On a Pi 4, use the following command for H264 files: +To force the video output to a particular device, use the `--drm-vout-display` option to specify a video output device: -[,bash] +[source,console] ---- -omxplayer /opt/vc/src/hello_pi/hello_video/test.h264 +$ cvlc --play-and-exit --drm-vout-display big-buck-bunny-1080p.mp4 ---- -or for H264, VC1, or MPEG2 +Replace the `` placeholder with one of the following options: -[,bash] ----- -vlc /opt/vc/src/hello_pi/hello_video/test.h264 ----- +|=== +| DRM device | Description + +| `HDMI-A-1` | The HDMI output on a Raspberry Pi Zero, or Raspberry Pi Model 1, 2 or 3; *or* the HDMI0 output on a Raspberry Pi 4, 5, or 400 -When using VLC, you can improve playback performance by encapsulating the raw H264 stream, for example from the Raspberry Pi Camera Module. This is easily done using `ffmpeg`. Playback is also improved if VLC is run full screen; either select fullscreen from the user interface, or you can add the `--fullscreen` options to the `vlc` command line. +| `HDMI-A-2` | The HDMI1 output on Flagship models since Raspberry Pi 4B, Compute Modules since CM4 (including CM4S), and Keyboard models -This example command converts `video.h264` to a containerised `video.mp4` at 30 fps: +| `DSI-1` | The Raspberry Pi Touch Display or Raspberry Pi Touch Display 2 -`ffmpeg -r 30 -i video.h264 -c:v copy video.mp4` +| `DSI-2` | The second DSI output for models with multiple DSI ports (Flagship models since Raspberry Pi 5, and Compute Module models since CM5) -=== Options During Playback +|=== -There are a number of options available during playback, actioned by pressing the appropriate key. Not all options will be available on all files. The list of key bindings can be displayed using `omxplayer --keys`: +[TIP] +==== +Use the following command to get a list of all DRM devices on your Raspberry Pi: +[source,console] ---- - 1 decrease speed - 2 increase speed - < rewind - > fast forward - z show info - j previous audio stream - k next audio stream - i previous chapter - o next chapter - n previous subtitle stream - m next subtitle stream - s toggle subtitles - w show subtitles - x hide subtitles - d decrease subtitle delay (- 250 ms) - f increase subtitle delay (+ 250 ms) - q exit omxplayer - p / space pause/resume - - decrease volume - + / = increase volume - left arrow seek -30 seconds - right arrow seek +30 seconds - down arrow seek -600 seconds - up arrow seek +600 seconds +$ kmsprint | grep Connector ---- +==== -=== Playing in the Background +=== Specify both audio and video output devices -`omxplayer` will close immediately if run in the background without tty (user input), so to run successfully, you need to tell `omxplayer` not to require any user input using the `--no-keys` option. +You can combine audio and video output options. For example, to direct video output to the touchscreen, and audio output to the headphone jack, use the following combination of the commands above: -[,bash] +[source,console] ---- -omxplayer --no-keys example.mp3 & +$ cvlc --play-and-exit --fullscreen --drm-vout-display DSI-1 -A alsa --alsa-audio-device sysdefault:CARD=Headphones your_video.mp4 ---- -Adding the `&` at the end of the command runs the job in the background. You can then check the status of this background job using the `jobs` command. By default, the job will complete when `omxplayer` finishes playing, but if necessary, you can stop it at any point using the `kill` command. +=== Improve stream playback performance + +If you have a raw H.264 stream, like those captured from a Raspberry Pi Camera Module, you can improve playback performance in VLC by wrapping the stream inside a container format such as MP4. You can use `ffmpeg` to convert stream content into a container file. For example, the following command converts a stream named `video.h264` to a MP4 container named `video.mp4` at 30fps: -[,bash] +[source,console] ---- -$ jobs -[1]- Running omxplayer --no-keys example.mp3 & -$ kill %1 -$ -[1]- Terminated omxplayer --no-keys example.mp3 & +$ ffmpeg -r 30 -i video.h264 -c:v copy video.mp4 ---- diff --git a/documentation/asciidoc/computers/os/rpi-os-introduction.adoc b/documentation/asciidoc/computers/os/rpi-os-introduction.adoc index 43aba7b9d7..f2ab3376e8 100644 --- a/documentation/asciidoc/computers/os/rpi-os-introduction.adoc +++ b/documentation/asciidoc/computers/os/rpi-os-introduction.adoc @@ -1,5 +1,9 @@ == Introduction -Raspberry Pi OS is a free operating system based on Debian, optimised for the Raspberry Pi hardware, and is the recommended operating system for normal use on a Raspberry Pi. The OS comes with over 35,000 packages: precompiled software bundled in a nice format for easy installation on your Raspberry Pi. +Raspberry Pi OS is a free, Debian-based operating system optimised for the Raspberry Pi hardware. Raspberry Pi OS supports over 35,000 Debian packages. We recommend Raspberry Pi OS for most Raspberry Pi use cases. -Raspberry Pi OS is under active development, with an emphasis on improving the stability and performance of as many Debian packages as possible on Raspberry Pi. +Because Raspberry Pi OS is derived from Debian, it follows a staggered version of the https://wiki.debian.org/DebianReleases[Debian release cycle]. Releases happen roughly every 2 years. + +The latest version of Raspberry Pi OS is based on https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/[Debian Bookworm]. The previous version was based on https://www.raspberrypi.com/news/raspberry-pi-os-debian-bullseye/[Debian Bullseye]. + +You can find images of Raspberry Pi OS at https://www.raspberrypi.com/software/operating-systems/[raspberrypi.com/software/operating-systems/] diff --git a/documentation/asciidoc/computers/os/updating.adoc b/documentation/asciidoc/computers/os/updating.adoc index a2191bd7f3..6078bdde60 100644 --- a/documentation/asciidoc/computers/os/updating.adoc +++ b/documentation/asciidoc/computers/os/updating.adoc @@ -1,171 +1,188 @@ -== Updating and Upgrading Raspberry Pi OS +== Update software -It's important to keep your Raspberry Pi up to date. The first and probably the most important reason is security. A device running Raspberry Pi OS contains millions of lines of code that you rely on. Over time, these millions of lines of code will expose well-known vulnerabilities, which are documented in https://cve.mitre.org/index.html[publicly available databases] meaning that they are easy to exploit. The only way to mitigate these exploits as a user of Raspberry Pi OS is to keep your software up to date, as the upstream repositories track CVEs closely and try to mitigate them quickly. +Always keep the software running on your Raspberry Pi updated to the latest version. This keeps your device secure from https://cve.mitre.org/index.html[vulnerabilities] and ensures that you get the latest bug fixes. -The second reason, related to the first, is that the software you are running on your device most certainly contains bugs. Some bugs are CVEs, but bugs could also be affecting the desired functionality without being related to security. By keeping your software up to date, you are lowering the chances of hitting these bugs. +=== Manage software packages with APT -=== Using APT +https://en.wikipedia.org/wiki/APT_(software)[Advanced Package Tool (APT)] is the recommended way to install, update, and remove software in Raspberry Pi OS. You can access APT through the `apt` CLI. -The easiest way to manage installing, upgrading, and removing software is using APT (Advanced Packaging Tool) from Debian. To update software in Raspberry Pi OS, you can use the `apt` tool from a Terminal window. +==== Install updates -==== Keeping your Operating System up to Date +`apt` stores a list of software sources in a file at `/etc/apt/sources.list`. Before installing software, run the following command to *update* your local list of packages using `/etc/apt/sources.list`: -APT keeps a list of software sources on your Pi in a file at `/etc/apt/sources.list`. Before installing software, you should update your package list with `apt update`. Go ahead and open a Terminal window and type: - -[,bash] +[source,console] ---- -sudo apt update +$ sudo apt update ---- -Next, *upgrade* all your installed packages to their latest versions with the following command: +Run the following command to *upgrade* all your installed packages to their latest versions: -[,bash] +[source,console] ---- -sudo apt full-upgrade +$ sudo apt full-upgrade ---- -Note that `full-upgrade` is used in preference to a simple `upgrade`, as it also picks up any dependency changes that may have been made. - -Generally speaking, doing this regularly will keep your installation up to date for the particular major Raspberry Pi OS release you are using (e.g. Stretch). It will not update from one major release to another, for example, Stretch to Buster. - -However, there are occasional changes made in the Foundation's Raspberry Pi OS image that require manual intervention, for example a newly introduced package. These are not installed with an upgrade, as this command only updates the packages you already have installed. - -NOTE: The kernel and firmware are installed as a Debian package, and so will also get updates when using the procedure above. These packages are updated infrequently and after extensive testing. - -==== Running Out of Space +TIP: Unlike Debian, Raspberry Pi OS is under continual development. As a result, package dependencies sometimes change, so you should always use `full-upgrade` instead of the standard `upgrade`. -When running `sudo apt full-upgrade`, it will show how much data will be downloaded and how much space it will take up on the SD card. It's worth checking with `df -h` that you have enough free disk space, as unfortunately `apt` will not do this for you. Also be aware that downloaded package files (`.deb` files) are kept in `/var/cache/apt/archives`. You can remove these in order to free up space with `sudo apt clean` (`sudo apt-get clean` in older releases of apt). +Run these commands regularly to keep your software up-to-date. Using `apt` to keep Raspberry Pi OS up to date also keeps your Linux kernel and firmware up to date, since Raspberry Pi distributes them as Debian packages. -==== Upgrading from Operating System Versions +When Raspberry Pi releases a new major version of Raspberry Pi OS, the above commands won't upgrade your operating system to that new major version. To upgrade to a new major version, follow our xref:os.adoc#upgrade-your-operating-system-to-a-new-major-version[OS upgrade instructions]. -WARNING: Upgrading an existing image is possible, but is not guaranteed to work in every circumstance and we do not recommend it. If you do wish to try upgrading your operating system version, we strongly suggest making a backup first -- we can accept no responsibility for loss of data from a failed update. +==== Search for software -The latest version of Raspberry Pi OS is based on Debian Buster. The previous version was based on Stretch. To upgrade, first modify the files `/etc/apt/sources.list` and `/etc/apt/sources.list.d/raspi.list`. In both files, change every occurrence of the word `stretch` to `buster`. (Both files will require sudo to edit.) +To search the archives for a package, pass a search keyword to `apt-cache search`: -Then open a terminal window and execute: - -[,bash] +[source,console] ---- -sudo apt update -sudo apt -y dist-upgrade +$ apt-cache search ---- -Answer 'yes' to any prompts. There may also be a point at which the install pauses while a page of information is shown on the screen -- hold the ++++++space++++++ key to scroll through all of this and then press ++++++q++++++ to continue. - -Finally, if you are not using PulseAudio for anything other than Bluetooth audio, remove it from the image by entering: +For example, consider the following search for the keyword "raspi": -[,bash] +[source,console] ---- -sudo apt -y purge "pulseaudio*" +$ apt-cache search raspi +raspi3-firmware - Raspberry Pi 2 and 3 GPU firmware and bootloaders +libcamera-apps - libcamera-apps +libcamera-apps-lite - libcamera-apps-lite +python-picamera - Pure Python interface to the Raspberry Pi's camera module. +python-picamera-docs - Documentation for the Python interface to the RPi's camera module. +python3-picamera - Pure Python interface to the Raspberry Pi's camera module. +raspi-config - Raspberry Pi configuration tool +raspi-gpio - Dump the state of the BCM270x GPIOs +raspi-gpio-dbgsym - debug symbols for raspi-gpio +raspinfo - Dump information about the Pi +rc-gui - raspi-config GUI +raspi-copies-and-fills - ARM-accelerated versions of selected functions from string.h +raspi-copies-and-fills-dbgsym - debug symbols for raspi-copies-and-fills ---- -If moving to a new Raspberry Pi model (for example the Pi 3B+), you may also need to update the kernel and the firmware using the instructions above. - -==== Searching for Software +The search returned multiple packages with names or descriptions that included the keyword. -You can search the archives for a package with a given keyword with `apt-cache search`: +Use the following command to view detailed information about a package: -[,bash] +[source,console] ---- -apt-cache search locomotive -sl - Correct you if you type `sl' by mistake +$ apt-cache show ---- -You can view more information about a package before installing it with `apt-cache show`: +For example, consider the following query for the "raspi-config" package: -[,bash] +[source,console] ---- -apt-cache show sl -Package: sl -Version: 3.03-17 -Architecture: armhf -Maintainer: Hiroyuki Yamamoto -Installed-Size: 114 -Depends: libc6 (>= 2.4), libncurses5 (>= 5.5-5~), libtinfo5 -Homepage: http://www.tkl.iis.u-tokyo.ac.jp/~toyoda/index_e.html +$ apt-cache show raspi-config +Package: raspi-config +Version: 20210212 +Architecture: all +Maintainer: Serge Schneider +Installed-Size: 121 +Depends: whiptail, parted, lua5.1, alsa-utils, psmisc, initramfs-tools +Recommends: triggerhappy, iw Priority: optional -Section: games -Filename: pool/main/s/sl/sl_3.03-17_armhf.deb -Size: 26246 -SHA256: 42dea9d7c618af8fe9f3c810b3d551102832bf217a5bcdba310f119f62117dfb -SHA1: b08039acccecd721fc3e6faf264fe59e56118e74 -MD5sum: 450b21cc998dc9026313f72b4bd9807b -Description: Correct you if you type `sl' by mistake - Sl is a program that can display animations aimed to correct you - if you type 'sl' by mistake. - SL stands for Steam Locomotive. +Section: utils +Filename: pool/main/r/raspi-config/raspi-config_20210212_all.deb +Size: 27976 +SHA256: 772d4fd3c6d8c9da47ac56012b74e7828b53c8521ff1c47266bb38ec71750c10 +SHA1: 08254c976a8260bde914c2df72f92ffb9317fef6 +MD5sum: 80aaac13be6a9b455c822edb91cf8ea2 +Description: Raspberry Pi configuration tool + A simple configuration tool for common Raspberry Pi administrative tasks +Description-md5: 19630c04463bfe7193152448b53d85a0 ---- -==== Installing a Package with APT +Use this command to verify that the maintainer, version, and size match your expectations for a package. + +==== Install a package + +To install a package on your Raspberry Pi, pass the name of the package to the following command: -[,bash] +[source,console] ---- -sudo apt install tree +$ sudo apt install ---- -Typing this command should inform the user how much disk space the package will take up and asks for confirmation of the package installation. Entering `Y` (or just pressing `Enter`, as yes is the default action) will allow the installation to occur. This can be bypassed by adding the `-y` flag to the command: +`apt` will display the amount of disk space the package will consume. Enter *Y* and press **Enter** to confirm installation of the package. You can skip this confirmation step by adding the `-y` flag to the command above. -[,bash] +==== Uninstall a package + +To uninstall a package from your Raspberry Pi, pass the name of the package to the following command: + +[source,console] ---- -sudo apt install tree -y +$ sudo apt remove ---- -Installing this package makes `tree` available for the user. +TIP: To completely remove all traces of the package, including configuration files, use `purge` instead of `remove`. + +`apt` will display the amount of disk space removing the package will free up. +Enter *Y* and press **Enter** to confirm removal of the package. You can skip this confirmation step by adding the `-y` flag to the command above. -==== Uninstalling a Package with APT +==== Manage `apt` disk usage -You can uninstall a package with `apt remove`: +Before running, `sudo apt full-upgrade` shows the amount of data you'll need to download and store on disk to complete an upgrade. To check that you have enough free disk space, run the following command: -[,bash] +[source,console] ---- -sudo apt remove tree +$ df -h ---- -The user is prompted to confirm the removal. Again, the `-y` flag will auto-confirm. +`apt` stores downloaded package (`.deb`) files in `/var/cache/apt/archives`. During installation, `apt` downloads these packages, then copies files from the packages to the correct installation locations. Depending on the software you have installed, package files can take up significant amounts of space. To delete any lingering package files, run the following command: -You can also choose to completely remove the package and its associated configuration files with `apt purge`: - -[,bash] +[source,console] ---- -sudo apt purge tree +$ sudo apt clean ---- -[[rpi-update]] -=== Using `rpi-update` +=== Upgrade your operating system to a new major version -`rpi-update` is a command line application that will update your Raspberry Pi OS kernel and VideoCore firmware to the latest pre-release versions. +WARNING: Before attempting a major version upgrade, make a backup. -WARNING: Pre-release versions of software are not guaranteed to work. You should not use `rpi-update` on any system unless recommended to do so by a Raspberry Pi engineer. It may leave your system unreliable or even completely broken. It should not be used as part of any regular update process. +To update the operating system to a new major release on your Raspberry Pi, image a second SD card with the new release. Use a USB SD card reader or network storage to copy files and configuration from your current installation to the new SD card. Then, swap the new SD card into the slot on your Raspberry Pi, and boot. -The `rpi-update` script is supplied by a third party, "Hexxeh", and also supported by Raspberry Pi engineers. The script source can be found on GitHub at https://github.com/Hexxeh/rpi-update +[[rpi-update]] +=== Upgrade your firmware -==== What it does +WARNING: Before attempting a firmware upgrade, make a backup. -`rpi-update` will download the latest pre-release version of the linux kernel, its matching modules, device tree files, along with the latest versions of the VideoCore firmware. It will then install these files to relevant locations on the SD card, overwriting any previous versions. +WARNING: Pre-release versions of software are not guaranteed to work. Do not use `rpi-update` on any system unless recommended to do so by a Raspberry Pi engineer. It could leave your system unreliable or broken. Do not use `rpi-update` as part of any regular update process. -All the source data used by `rpi-update` comes from the GitHub repo https://github.com/Hexxeh/rpi-firmware. This repository simply contains a subset of the data from the https://github.com/raspberrypi/firmware[official firmware repository], as not all the data from that repo is required. +To update the firmware on your Raspberry Pi to the latest version, use https://github.com/raspberrypi/rpi-update[`rpi-update`]. -==== Running `rpi-update` +`rpi-update` downloads the latest pre-release version of the Linux kernel, its matching modules, device tree files, and the latest versions of the VideoCore firmware. It then installs these files into an existing Raspberry Pi OS install. -If you are sure that you need to use `rpi-update`, it is advisable to take a backup of your current system first as running `rpi-update` could result in a non-booting system. +All the source data used by `rpi-update` comes from the https://github.com/raspberrypi/rpi-firmware[`rpi-firmware` repository]. This repository contains a subset of the data from the https://github.com/raspberrypi/firmware[official firmware repository]. -`rpi-update` needs to be run as root. Once the update is complete you will need to reboot. +Run `rpi-update` as root to initiate the update. Once the update is complete, reboot your Raspberry Pi for these changes to take effect: +[source,console] ---- -sudo rpi-update -sudo reboot +$ sudo rpi-update +$ sudo reboot ---- -It has a number of options, which are documented at the Hexxeh GitHub repository at https://github.com/Hexxeh/rpi-update +[.whitepaper, title="Updating Raspberry Pi firmware", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003476-WP/Updating-Pi-firmware.pdf] +**** +This whitepaper documents how to update the VideoCore firmware in a Raspberry Pi OS image. +**** -==== How to get back to safety +=== Downgrade firmware to the last stable release -If you have done an `rpi-update` and things are not working as you wish, if your Raspberry Pi is still bootable you can return to the stable release using: +If you update your firmware to the latest release and experience an issue, use the following command to return to the last stable firmware release: +[source,console] ---- -sudo apt-get update -sudo apt install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} raspberrypi-bootloader raspberrypi-kernel +$ sudo apt update +$ sudo apt install --reinstall raspi-firmware ---- -You will need to reboot your Raspberry Pi for these changes to take effect. +[NOTE] +==== +If you still run Raspberry Pi OS Bullseye, you must instead reinstall `raspberrypi-kernel` using the following command: + +[source,console] +---- +$ sudo apt install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} raspberrypi-{kernel,bootloader} +---- +Reboot your Raspberry Pi with `sudo reboot` to put these changes into effect. +==== diff --git a/documentation/asciidoc/computers/os/using-gpio.adoc b/documentation/asciidoc/computers/os/using-gpio.adoc index ae87c78661..b04f8ec6f0 100644 --- a/documentation/asciidoc/computers/os/using-gpio.adoc +++ b/documentation/asciidoc/computers/os/using-gpio.adoc @@ -1,70 +1,12 @@ -== GPIO and the 40-pin Header -:pp: {plus}{plus} +== Use GPIO from Python -A powerful feature of the Raspberry Pi is the row of GPIO (general-purpose input/output) pins along the top edge of the board. A 40-pin GPIO header is found on all current Raspberry Pi boards (unpopulated on Pi Zero and Pi Zero W). Prior to the Pi 1 Model B+ (2014), boards comprised a shorter 26-pin header. +Using the https://gpiozero.readthedocs.io/[GPIO Zero] library makes it easy to control GPIO devices with Python. The library is comprehensively documented at https://gpiozero.readthedocs.io/[gpiozero.readthedocs.io]. -image::images/GPIO-Pinout-Diagram-2.png[GPIO pins] +For information about GPIO hardware, see xref:../computers/raspberry-pi.adoc#gpio[GPIO hardware]. -Any of the GPIO pins can be designated (in software) as an input or output pin and used for a wide range of purposes. +=== LED control -image::images/GPIO.png[GPIO layout] - -NOTE: the numbering of the GPIO pins is not in numerical order; GPIO pins 0 and 1 are present on the board (physical pins 27 and 28) but are reserved for advanced use (see below). - -=== Voltages - -Two 5V pins and two 3V3 pins are present on the board, as well as a number of ground pins (0V), which are unconfigurable. The remaining pins are all general purpose 3V3 pins, meaning outputs are set to 3V3 and inputs are 3V3-tolerant. - -=== Outputs - -A GPIO pin designated as an output pin can be set to high (3V3) or low (0V). - -=== Inputs - -A GPIO pin designated as an input pin can be read as high (3V3) or low (0V). This is made easier with the use of internal pull-up or pull-down resistors. Pins GPIO2 and GPIO3 have fixed pull-up resistors, but for other pins this can be configured in software. - -=== More - -As well as simple input and output devices, the GPIO pins can be used with a variety of alternative functions, some are available on all pins, others on specific pins. - -* PWM (pulse-width modulation) - ** Software PWM available on all pins - ** Hardware PWM available on GPIO12, GPIO13, GPIO18, GPIO19 -* SPI - ** SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7) - ** SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16) -* I2C - ** Data: (GPIO2); Clock (GPIO3) - ** EEPROM Data: (GPIO0); EEPROM Clock (GPIO1) -* Serial - ** TX (GPIO14); RX (GPIO15) - -=== GPIO pinout - -A handy reference can be accessed on the Raspberry Pi by opening a terminal window and running the command `pinout`. This tool is provided by the https://gpiozero.readthedocs.io/[GPIO Zero] Python library, which is installed by default on the Raspberry Pi OS desktop image, but not on Raspberry Pi OS Lite. - -image::images/gpiozero-pinout.png[] - -For more details on the advanced capabilities of the GPIO pins see gadgetoid's http://pinout.xyz/[interactive pinout diagram]. - -WARNING: while connecting up simple components to the GPIO pins is perfectly safe, it's important to be careful how you wire things up. LEDs should have resistors to limit the current passing through them. Do not use 5V for 3V3 components. Do not connect motors directly to the GPIO pins, instead use an https://projects.raspberrypi.org/en/projects/physical-computing/16[H-bridge circuit or a motor controller board]. - -=== Permissions - -In order to use the GPIO ports your user must be a member of the `gpio` group. The `pi` user is a member by default, other users need to be added manually. - -[,bash] ----- -sudo usermod -a -G gpio ----- - -=== GPIO in Python - -Using the https://gpiozero.readthedocs.io/[GPIO Zero] library makes it easy to get started with controlling GPIO devices with Python. The library is comprehensively documented at https://gpiozero.readthedocs.io/[gpiozero.readthedocs.io]. - -==== LED - -To control an LED connected to GPIO17, you can use this code: +The following example code controls an LED connected to GPIO17: [,python] ---- @@ -84,9 +26,9 @@ Run this in an IDE like Thonny, and the LED will blink on and off repeatedly. LED methods include `on()`, `off()`, `toggle()`, and `blink()`. -==== Button +=== Read button state -To read the state of a button connected to GPIO2, you can use this code: +The following example code reads the state of a button connected to GPIO2: [,python] ---- @@ -105,11 +47,11 @@ while True: Button functionality includes the properties `is_pressed` and `is_held`; callbacks `when_pressed`, `when_released`, and `when_held`; and methods `wait_for_press()` and `wait_for_release`. -==== Button + LED +=== Control an LED with a button -To connect the LED and button together, you can use this code: +The following example code reads the state of a button connected to GPIO2, and lights an LED connected to GPIO17 when the button is pressed: -[,python] +[source,python] ---- from gpiozero import LED, Button @@ -125,7 +67,7 @@ while True: Alternatively: -[,python] +[source,python] ---- from gpiozero import LED, Button @@ -141,7 +83,7 @@ while True: or: -[,python] +[source,python] ---- from gpiozero import LED, Button diff --git a/documentation/asciidoc/computers/os/using-python.adoc b/documentation/asciidoc/computers/os/using-python.adoc index e371ea2180..38dd9e20e3 100644 --- a/documentation/asciidoc/computers/os/using-python.adoc +++ b/documentation/asciidoc/computers/os/using-python.adoc @@ -1,353 +1,190 @@ -== Python -:pp: {plus}{plus} +== Use Python on a Raspberry Pi -Python is a powerful programming language that's easy to use easy to read and write and, with Raspberry Pi, lets you connect your project to the real world. Python syntax is clean, with an emphasis on readability, and uses standard English keywords. +Raspberry Pi OS comes with Python 3 pre-installed. Interfering with the system Python installation can cause problems for your operating system. When you install third-party Python libraries, always use the correct package-management tools. -=== Thonny +On Linux, you can install `python` dependencies in two ways: -The easiest introduction to Python is through https://thonny.org/[Thonny], a Python 3 development environment. You can open Thonny from the Desktop or applications menu. +* use `apt` to install pre-configured system packages +* use `pip` to install libraries using Python's dependency manager _in a virtual environment_ ++ +IMPORTANT: Starting in Raspberry Pi OS _Bookworm_, you can only use `pip` to install into a Python Virtual Environment (`venv`). This change was introduced by the Python community, not by Raspberry Pi: for more information, see https://peps.python.org/pep-0668/[PEP 668]. -Thonny gives you a REPL (Read-Evaluate-Print-Loop), which is a prompt you can enter Python commands into. Because it's a REPL, you even get the output of commands printed to the screen without using `print`. In the Thonny application, this is called the Shell window. +=== Install Python packages using `apt` -You can use variables if you need to but you can even use it like a calculator. For example: +Packages installed via `apt` are packaged specifically for Raspberry Pi OS. These packages usually come pre-compiled, so they install faster. Because `apt` manages dependencies for all packages, installing with this method includes all of the sub-dependencies needed to run the package. And `apt` ensures that you don't break other packages if you uninstall. -[,python] ----- ->>> 1 + 2 -3 ->>> name = "Sarah" ->>> "Hello " + name -'Hello Sarah' ----- - -Thonny also has syntax highlighting built in and some support for autocompletion. You can look back on the history of the commands you've entered in the REPL with `Alt + P` (previous) and `Alt + N` (next). +For instance, to install the Python 3 library that supports the Raspberry Pi xref:../accessories/build-hat.adoc[Build HAT], run the following command: -=== Basic Python usage - -Hello world in Python: - -[,python] +[source,console] ---- -print("Hello world") +$ sudo apt install python3-build-hat ---- -Simple as that! +To find Python packages distributed with `apt`, xref:os.adoc#search-for-software[use `apt search`]. In most cases, Python packages use the prefix `python-` or `python3-`: for instance, you can find the `numpy` package under the name `python3-numpy`. -==== Indentation +=== Install Python libraries using `pip` -Some languages use curly braces `{` and `}` to wrap around lines of code which belong together, and leave it to the writer to indent these lines to appear visually nested. However, Python does not use curly braces but instead requires indentation for nesting. For example a `for` loop in Python: +[[python-on-raspberry-pi]] -[,python] ----- -for i in range(10): - print("Hello") ----- +==== Bookworm changes to `pip` installation -The indentation is necessary here. A second line indented would be a part of the loop, and a second line not indented would be outside of the loop. For example: +In older versions of Raspberry Pi OS, you could install libraries directly into the system version of Python using `pip`. Since Raspberry Pi OS _Bookworm_, users cannot install libraries directly into the system version of Python. -[,python] ----- -for i in range(2): - print("A") - print("B") ----- +Instead, xref:os.adoc#use-pip-with-virtual-environments[install libraries into a virtual environment (`venv`)]. To install a library at the system level for all users, xref:os.adoc#install-python-packages-using-apt[install it with `apt`]. -would print: +Attempting to install a Python package system-wide outputs an error similar to the following: +[source,console] ---- -A -B -A -B ----- +$ pip install buildhat +error: externally-managed-environment -whereas the following: +× This environment is externally managed +╰─> To install Python packages system-wide, try apt install + python3-xyz, where xyz is the package you are trying to + install. -[,python] ----- -for i in range(2): - print("A") -print("B") ----- + If you wish to install a non-Debian-packaged Python package, + create a virtual environment using python3 -m venv path/to/venv. + Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make + sure you have python3-full installed. -would print: + For more information visit http://rptl.io/venv ----- -A -A -B +note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. +hint: See PEP 668 for the detailed specification. ---- -==== Variables +Python users have long dealt with conflicts between OS package managers like `apt` and Python-specific package management tools like `pip`. These conflicts include both Python-level API incompatibilities and conflicts over file ownership. -To save a value to a variable, assign it like so: +Starting in Raspberry Pi OS _Bookworm_, packages installed via `pip` _must be installed into a Python virtual environment_ (``venv``). A virtual environment is a container where you can safely install third-party modules so they won't interfere with your system Python. -[,python] ----- -name = "Bob" -age = 15 ----- +==== Use `pip` with virtual environments -Note that data types were not specified with these variables, as types are inferred, and can be changed later. +To use a virtual environment, create a container to store the environment. There are several ways you can do this depending on how you want to work with Python: -[,python] +[tabs] +====== +per-project environments:: ++ +Many users create separate virtual environments for each Python project. Locate the virtual environment in the root folder of each project, typically with a shared name like `env`. Run the following command from the root folder of each project to create a virtual environment configuration folder: ++ +[source,console] ---- -age = 15 -age += 1 # increment age by 1 -print(age) +$ python -m venv env ---- - -This time I used comments beside the increment command. - -==== Comments - -Comments are ignored in the program but there for you to leave notes, and are denoted by the hash `#` symbol. Multi-line comments use triple quotes like so: - -[,python] ++ +Before you work on a project, run the following command from the root of the project to start using the virtual environment: ++ +[source,console] ---- -""" -This is a very simple Python program that prints "Hello". -That's all it does. -""" - -print("Hello") +$ source env/bin/activate ---- - -==== Lists - -Python also has lists (called arrays in some languages) which are collections of data of any type: - -[,python] ++ +You should then see a prompt similar to the following: ++ +[source,console?prompt=(env) $] ---- -numbers = [1, 2, 3] +(env) $ ---- - -Lists are denoted by the use of square brackets `[]` and each item is separated by a comma. - -==== Iteration - -Some data types are iterable, which means you can loop over the values they contain. For example a list: - -[,python] ++ +When you finish working on a project, run the following command from any directory to leave the virtual environment: ++ +[source,console?prompt=(env) $] ---- -numbers = [1, 2, 3] - -for number in numbers: - print(number) +(env) $ deactivate ---- -This takes each item in the list `numbers` and prints out the item: - ----- -1 -2 -3 ----- - -Note I used the word `number` to denote each item. This is merely the word I chose for this - it's recommended you choose descriptive words for variables - using plurals for lists, and singular for each item makes sense. It makes it easier to understand when reading. - -Other data types are iterable, for example the string: - -[,python] +per-user environments:: ++ +Instead of creating a virtual environment for each of your Python projects, you can create a single virtual environment for your user account. **Activate that virtual environment before running any of your Python code.** This approach can be more convenient for workflows that share many libraries across projects. ++ +When creating a virtual environment for multiple projects across an entire user account, consider locating the virtual environment configuration files in your home directory. Store your configuration in a https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory#Unix_and_Unix-like_environments[folder whose name begins with a period] to hide the folder by default, preventing it from cluttering your home folder. ++ +Use the following command to create a virtual environment in a hidden folder in the current user's home directory: ++ +[source,console] ---- -dog_name = "BINGO" - -for char in dog_name: - print(char) +$ python -m venv ~/.env ---- - -This loops over each character and prints them out: - ++ +Run the following command from any directory to start using the virtual environment: ++ +[source,console] ---- -B -I -N -G -O +$ source ~/.env/bin/activate ---- - -==== Range - -The integer data type is not iterable and trying to iterate over it will produce an error. For example: - -[,python] ++ +You should then see a prompt similar to the following: ++ +[source,console?prompt=(.env) $] ---- -for i in 3: - print(i) +(.env) $ ---- - -will produce: - -[,python] ++ +To leave the virtual environment, run the following command from any directory: ++ +[source,console?prompt=(.env) $] ---- -TypeError: 'int' object is not iterable +(.env) $ deactivate ---- +====== -image::images/python-error.png[Python error] +===== Create a virtual environment -However you can make an iterable object using the `range` function: +Run the following command to create a virtual environment configuration folder, replacing `` with the name you would like to use for the virtual environment (e.g. `env`): -[,python] +[source,console] ---- -for i in range(3): - print(i) +$ python -m venv ---- -`range(5)` contains the numbers `0`, `1`, `2`, `3` and `4` (five numbers in total). To get the numbers `1` to `5` (inclusive) use `range(1, 6)`. +TIP: Pass the `--system-site-packages` flag before the folder name to preload all of the currently installed packages in your system Python installation into the virtual environment. -==== Length +===== Enter a virtual environment -You can use functions like `len` to find the length of a string or a list: +Then, execute the `bin/activate` script in the virtual environment configuration folder to enter the virtual environment: -[,python] +[source,console] ---- -name = "Jamie" -print(len(name)) # 5 - -names = ["Bob", "Jane", "James", "Alice"] -print(len(names)) # 4 +$ source /bin/activate ---- -==== If statements +You should then see a prompt similar to the following: -You can use `if` statements for control flow: - -[,python] +[source,console?prompt=() $] ---- -name = "Joe" - -if len(name) > 3: - print("Nice name,") - print(name) -else: - print("That's a short name,") - print(name) +() $ ---- -=== Python files in Thonny - -To create a Python file in Thonny, click `File > New` and you'll be given a ++++++window. This is an empty file, not a Python prompt. You write a Python file in this window, save it, then run it and you'll see the output in the other window.++++++ +The `()` command prompt prefix indicates that the current terminal session is in a virtual environment named ``. -For example, in the new window, type: +To check that you're in a virtual environment, use `pip list` to view the list of installed packages: -[,python] +[source,console?prompt=() $] ---- -n = 0 - -for i in range(1, 101): - n += i - -print("The sum of the numbers 1 to 100 is:") -print(n) ----- - -Then save this file (`File > Save` or `Ctrl + S`) and run (`Run > Run Module` or hit `F5`) and you'll see the output in your original Python window. - -=== Using the Command Line - -You can write a Python file in a standard xref:using_linux.adoc#text-editors[editor], and run it as a Python script from the command line. Just navigate to the directory the file is saved in (use `cd` and `ls` for guidance) and run with `python3`, e.g. `python3 hello.py`. - -image::images/run-python.png[Python command line] - -=== Other Ways of Using Python - -The standard built-in Python shell is accessed by typing `python3` in the terminal. - -This shell is a prompt ready for Python commands to be entered. You can use this in the same way as Thonny, but it does not have syntax highlighting or autocompletion. You can look back on the history of the commands you've entered in the REPL by using the ++++++Up/Down++++++ keys. Use `Ctrl + D` to exit. - -==== IPython - -IPython is an interactive Python shell with syntax highlighting, autocompletion, pretty printing, built-in documentation, and more. IPython is not installed by default. Install with: - -[,bash] ----- -sudo pip3 install ipython ----- - -Then run with `ipython` from the command line. It works like the standard `python3`, but has more features. Try typing `len?` and hitting `Enter`. You're shown information including the docstring for the `len` function: - -[,python] ----- -Type: builtin_function_or_method -String Form: -Namespace: Python builtin -Docstring: -len(object) -> integer - -Return the number of items of a sequence or mapping. ----- - -Try the following dictionary comprehension: - -[,python] +() $ pip list +Package Version +---------- ------- +pip 23.0.1 +setuptools 66.1.1 ---- -{i: i ** 3 for i in range(12)} ----- - -This will pretty print the following: - -[,python] ----- -{0: 0, - 1: 1, - 2: 8, - 3: 27, - 4: 64, - 5: 125, - 6: 216, - 7: 343, - 8: 512, - 9: 729, - 10: 1000, - 11: 1331} ----- - -In the standard Python shell, this would have printed on one line: - -[,python] ----- -{0: 0, 1: 1, 2: 8, 3: 27, 4: 64, 5: 125, 6: 216, 7: 343, 8: 512, 9: 729, 10: 1000, 11: 1331} ----- - -image::images/python-vs-ipython.png[Python vs ipython] - -You can look back on the history of the commands you've entered in the REPL by using the ++++++Up/Down++++++ keys like in `python`. The history also persists to the next session, so you can exit `ipython` and return (or switch between v2/3) and the history remains. Use `Ctrl + D` to exit. -=== Installing Python Libraries +The list should be much shorter than the list of packages installed in your system Python. You can now safely install packages with `pip`. Any packages you install with `pip` while in a virtual environment only install to that virtual environment. In a virtual environment, the `python` or `python3` commands automatically use the virtual environment's version of Python and installed packages instead of the system Python. -==== apt - -Some Python packages can be found in the Raspberry Pi OS archives, and can be installed using apt, for example: - -[,bash] ----- -sudo apt update -sudo apt install python-picamera ----- - -This is a preferable method of installing, as it means that the modules you install can be kept up to date easily with the usual `sudo apt update` and `sudo apt full-upgrade` commands. - -==== pip - -Not all Python packages are available in the Raspberry Pi OS archives, and those that are can sometimes be out of date. If you can't find a suitable version in the Raspberry Pi OS archives, you can install packages from the http://pypi.python.org/[Python Package Index] (known as PyPI). - -To do so, install pip: - -[,bash] ----- -sudo apt install python3-pip ----- +===== Exit a virtual environment -Then install Python packages (e.g. `simplejson`) with `pip3`: +To leave a virtual environment, run the following command: -[,bash] +[source,console?prompt=() $] ---- -sudo pip3 install simplejson +() $ deactivate ---- -===== piwheels +=== Use the Thonny editor -The official Python Package Index (PyPI) hosts files uploaded by package maintainers. Some packages require compilation (compiling C/C{pp} or similar code) in order to install them, which can be a time-consuming task, particlarly on the single-core Raspberry Pi 1 or Pi Zero. +We recommend https://thonny.org/[Thonny] for editing Python code on the Raspberry Pi. -piwheels is a service providing pre-compiled packages (called _Python wheels_) ready for use on the Raspberry Pi. Raspberry Pi OS is pre-configured to use piwheels for pip. Read more about the piwheels project at https://www.piwheels.org/[www.piwheels.org]. +By default, Thonny uses the system Python. However, you can switch to using a Python virtual environment by clicking on the **interpreter menu** in the bottom right of the Thonny window. Select a configured environment or configure a new virtual environment with `Configure interpreter...`. +image::images/thonny-venv.png[width="100%"] diff --git a/documentation/asciidoc/computers/os/using-webcams.adoc b/documentation/asciidoc/computers/os/using-webcams.adoc deleted file mode 100644 index c59e2e3c46..0000000000 --- a/documentation/asciidoc/computers/os/using-webcams.adoc +++ /dev/null @@ -1,178 +0,0 @@ -== Using a USB webcam - -Rather than using the Raspberry Pi xref:../accessories/camera.adoc#camera-modules[camera module], you can use a standard USB webcam to take pictures and video on your Raspberry Pi. - -NOTE: The quality and configurability of the camera module is highly superior to a standard USB webcam. - -First, install the `fswebcam` package: - -[,bash] ----- -sudo apt install fswebcam ----- - -If you are not using the default `pi` user account, you need to add your username to the `video` group, otherwise you will see 'permission denied' errors. - -[,bash] ----- -sudo usermod -a -G video ----- - -To check that the user has been added to the group correctly, use the `groups` command. - -=== Basic Usage - -Enter the command `fswebcam` followed by a filename and a picture will be taken using the webcam, and saved to the filename specified: - -[,bash] ----- -fswebcam image.jpg ----- - -This command will show the following information: - ----- ---- Opening /dev/video0... -Trying source module v4l2... -/dev/video0 opened. -No input was specified, using the first. -Adjusting resolution from 384x288 to 352x288. ---- Capturing frame... -Corrupt JPEG data: 2 extraneous bytes before marker 0xd4 -Captured frame in 0.00 seconds. ---- Processing captured image... -Writing JPEG image to 'image.jpg'. ----- - -image::images/image.jpg[Basic image capture] - -NOTE: The small default resolution used, and the presence of a banner showing the timestamp. - -The webcam used in this example has a resolution of `1280 x 720` so to specify the resolution I want the image to be taken at, use the `-r` flag: - -[,bash] ----- -fswebcam -r 1280x720 image2.jpg ----- - -This command will show the following information: - ----- ---- Opening /dev/video0... -Trying source module v4l2... -/dev/video0 opened. -No input was specified, using the first. ---- Capturing frame... -Corrupt JPEG data: 1 extraneous bytes before marker 0xd5 -Captured frame in 0.00 seconds. ---- Processing captured image... -Writing JPEG image to 'image2.jpg'. ----- - -image::images/image2.jpg[Full resolution image] - -Picture now taken at the full resolution of the webcam, with the banner present. - -==== Removing the Banner - -Now add the `--no-banner` flag: - -[,bash] ----- -fswebcam -r 1280x720 --no-banner image3.jpg ----- - -which shows the following information: - ----- ---- Opening /dev/video0... -Trying source module v4l2... -/dev/video0 opened. -No input was specified, using the first. ---- Capturing frame... -Corrupt JPEG data: 2 extraneous bytes before marker 0xd6 -Captured frame in 0.00 seconds. ---- Processing captured image... -Disabling banner. -Writing JPEG image to 'image3.jpg'. ----- - -image::images/image3.jpg[Full resolution image with no banner] - -Now the picture is taken at full resolution with no banner. - -=== Automating Image Capture - -You can write a Bash script which takes a picture with the webcam. The script below saves the images in the `/home/pi/webcam` directory, so create the `webcam` subdirectory first with: - -[,bash] ----- -mkdir webcam ----- - -To create a script, open up your editor of choice and write the following example code: - -[,bash] ----- -#!/bin/bash - -DATE=$(date +"%Y-%m-%d_%H%M") - -fswebcam -r 1280x720 --no-banner /home/pi/webcam/$DATE.jpg ----- - -This script will take a picture and name the file with a timestamp. Say we saved it as `webcam.sh`, we would first make the file executable: - -[,bash] ----- -chmod +x webcam.sh ----- - -Then run with: - -[,bash] ----- -./webcam.sh ----- - -Which would run the commands in the file and give the usual output: - ----- ---- Opening /dev/video0... -Trying source module v4l2... -/dev/video0 opened. -No input was specified, using the first. ---- Capturing frame... -Corrupt JPEG data: 2 extraneous bytes before marker 0xd6 -Captured frame in 0.00 seconds. ---- Processing captured image... -Disabling banner. -Writing JPEG image to '/home/pi/webcam/2013-06-07_2338.jpg'. ----- - -=== Time-Lapse Captures - -You can use `cron` to schedule taking a picture at a given interval, such as every minute to capture a time-lapse. - -First open the cron table for editing: - ----- -crontab -e ----- - -This will either ask which editor you would like to use, or open in your default editor. Once you have the file open in an editor, add the following line to schedule taking a picture every minute (referring to the Bash script from above): - -[,bash] ----- -* * * * * /home/pi/webcam.sh 2>&1 ----- - -Save and exit and you should see the message: - -[,bash] ----- -crontab: installing new crontab ----- - -Ensure your script does not save each picture taken with the same filename. This will overwrite the picture each time. - diff --git a/documentation/asciidoc/computers/processors.adoc b/documentation/asciidoc/computers/processors.adoc index fc70ac698a..97a361ba5c 100644 --- a/documentation/asciidoc/computers/processors.adoc +++ b/documentation/asciidoc/computers/processors.adoc @@ -8,3 +8,6 @@ include::processors/bcm2837b0.adoc[] include::processors/bcm2711.adoc[] +include::processors/bcm2712.adoc[] + +include::processors/rp3a0.adoc[] diff --git a/documentation/asciidoc/computers/processors/bcm2711.adoc b/documentation/asciidoc/computers/processors/bcm2711.adoc index a7ef98d5c3..70ea47ee8b 100644 --- a/documentation/asciidoc/computers/processors/bcm2711.adoc +++ b/documentation/asciidoc/computers/processors/bcm2711.adoc @@ -1,8 +1,8 @@ == BCM2711 -This is the Broadcom chip used in the Raspberry Pi 4 Model B. The architecture of the BCM2711 is a considerable upgrade on that used by the SoCs in earlier Raspberry Pi models. It continues the quad-core CPU design of the BCM2837, but uses the more powerful ARM A72 core. It has a greatly improved GPU feature set with much faster input/output, due to the incorporation of a PCIe link that connects the USB 2 and USB 3 ports, and a natively attached Ethernet controller. It is also capable of addressing more memory than the SoCs used before. +This is the Broadcom chip used in the Raspberry Pi 4 Model B, Compute Module 4, and Pi 400. The architecture of the BCM2711 is a considerable upgrade on that used by the SoCs in earlier Raspberry Pi models. It continues the quad-core CPU design of the BCM2837, but uses the more powerful ARM A72 core. It has a greatly improved GPU feature set with much faster input/output, due to the incorporation of a PCIe link that connects the USB 2 and USB 3 ports, and a natively attached Ethernet controller. It is also capable of addressing more memory than the SoCs used before. -The ARM cores are capable of running at up to 1.5 GHz, making the Pi 4 about 50% faster than the Raspberry Pi 3B+. The new VideoCore VI 3D unit now runs at up to 500 MHz. The ARM cores are 64-bit, and while the VideoCore is 32-bit, there is a new Memory Management Unit, which means it can access more memory than previous versions. +The ARM cores are capable of running at up to 1.5 GHz, making the Raspberry Pi 4 about 50% faster than the Raspberry Pi 3B+. The new VideoCore VI 3D unit now runs at up to 500 MHz. The ARM cores are 64-bit, and while the VideoCore is 32-bit, there is a new Memory Management Unit, which means it can access more memory than previous versions. The BCM2711 chip continues to use the heat spreading technology started with the BCM2837B0, which provides better thermal management. @@ -10,10 +10,10 @@ The BCM2711 chip continues to use the heat spreading technology started with the *Memory:* Accesses up to 8GB LPDDR4-2400 SDRAM (depending on model) -*Caches:* 32 KB data + 48 KB instruction L1 cache per core. 1MB L2 cache. +*Caches:* 32kB data + 48kB instruction L1 cache per core. 1MB L2 cache. *Multimedia:* H.265 (4Kp60 decode); H.264 (1080p60 decode, 1080p30 encode); OpenGL ES, 3.0 graphics *I/O:* PCIe bus, onboard Ethernet port, 2 × DSI ports (only one exposed on Raspberry Pi 4B), 2 × CSI ports (only one exposed on Raspberry Pi 4B), up to 6 × I2C, up to 6 × UART (muxed with I2C), up to 6 × SPI (only five exposed on Raspberry Pi 4B), dual HDMI video output, composite video output. -The https://datasheets.raspberrypi.org/bcm2711/bcm2711-peripherals.pdf[datasheet for the BCM2711] contains further details. +The https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf[datasheet for the BCM2711] contains further details. diff --git a/documentation/asciidoc/computers/processors/bcm2712.adoc b/documentation/asciidoc/computers/processors/bcm2712.adoc new file mode 100644 index 0000000000..66d86f307a --- /dev/null +++ b/documentation/asciidoc/computers/processors/bcm2712.adoc @@ -0,0 +1,43 @@ +== BCM2712 + +Broadcom BCM2712 is the 16nm application processor used in Raspberry Pi 5, Compute Module 5, and Pi 500. It is the successor to the BCM2711 device used in Raspberry Pi 4, and shares many common architectural features with other devices in the BCM27xx family, used on earlier Raspberry Pi products. + +Built around a quad-core Arm Cortex-A76 CPU cluster, clocked at up to 2.4GHz, with 512KB per-core L2 caches and a 2MB shared L3 cache, it integrates an improved 12-core VideoCore VII GPU; a hardware video scaler and HDMI controller capable of driving dual 4Kp60 displays; and a Raspberry Pi-developed HEVC decoder and Image Signal Processor. A 32-bit LPDDR4X memory interface provides up to 17GB/s of memory bandwidth, while ×1 and ×4 PCI Express interfaces support high-bandwidth external peripherals; on Raspberry Pi 5 the latter is used to connect to the Raspberry Pi RP1 south bridge, which provides the bulk of the external-facing I/O functionality on the platform. + +Headline features include: + +* Quad-core Arm Cortex-A76 @ 2.4GHz +** ARMv8-A ISA +** 64KByte I and D caches +** 512KB L2 per core, 2MB shared L3 +* New Raspberry Pi-developed ISP +** 1 gigapixel/sec +* Improved HVS and display pipeline +** Dual 4Kp60 support +* VideoCore V3D VII +** ~2-2.5× faster (more hardware, 1GHz versus 600MHz on Pi 4) +** OpenGL ES 3.1, Vulkan 1.3 +* 4Kp60 HEVC hardware decode +** Other CODECs run in software +** H264 1080p24 decode ~10–20% of CPU +** H264 1080p60 decode ~50–60% of CPU +** H264 1080p30 encode (from ISP) ~30–40% CPU + +In aggregate, the new features present in BCM2712 deliver a performance uplift of 2-3× over Raspberry Pi 4 for common CPU or I/O-intensive use cases. + +=== Vulnerabilities and mitigations + +The Cortex-A76 CPU used in the BCM2712 SoC has known vulnerabilites that are all mitigated in Raspberry Pi OS. + +To determine the full list of vulnerabilities and the mitigations, you can use the following command line which will list all those in place. + +```bash +$ lscpu | grep Vulnerability | grep -v "Not affected" +Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl +Vulnerability Spectre v1: Mitigation; __user pointer sanitization +Vulnerability Spectre v2: Mitigation; CSV2, BHB +``` + +WARNING: The list above was correct as of April 2025 but may have been superceded. You should use `lscpu` on your Raspberry Pi to get up to date information. This is especially important when using a third-party operating system, as these may not include all the latest mitigations in their Linux kernel builds. The Arm processors used by Raspberry Pi Ltd do not use microcode, so all mitigations are at the kernel level. + +The vulnerability information reported by `lscpu` is based on the currently executing kernel's detection scheme. It may not accurately reflect the true vulnerability status of the hardware, especially if the OS lacks recent kernel updates. Further vulnerability information on the CPU vendor advisories can be obtained from https://developer.arm.com/Arm%20Security%20Center/Speculative%20Processor%20Vulnerability referencing the Vendor ID and Model name reported by `lscpu`. diff --git a/documentation/asciidoc/computers/processors/bcm2835.adoc b/documentation/asciidoc/computers/processors/bcm2835.adoc index bb6ce5fc18..284f8fbd91 100644 --- a/documentation/asciidoc/computers/processors/bcm2835.adoc +++ b/documentation/asciidoc/computers/processors/bcm2835.adoc @@ -1,12 +1,11 @@ == BCM2835 -The BCM2835 is the Broadcom chip used in the Raspberry Pi Model A, B, B+, the Compute Module, and the Raspberry Pi Zero. Details of chip can be found in the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[Peripheral specification] document. +The BCM2835 is the Broadcom chip used in the Raspberry Pi 1 Models A, A+, B, B+, the Raspberry Pi Zero, the Raspberry Pi Zero W, and the Raspberry Pi Compute Module 1. Some details of the chip can be found in the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[peripheral specification] document. It contains a single-core ARM1176JZF-S processor. -NOTE: This document contains a number of errors. However there is a list of currently known https://elinux.org/BCM2835_datasheet_errata[errata]. +NOTE: The peripheral specification document contains a number of errors. However there is a list of currently known https://elinux.org/BCM2835_datasheet_errata[errata]. Other information regarding the processor can be found in the following documents; * https://docs.broadcom.com/docs/12358545[GPU documentation] and https://docs.broadcom.com/docs/12358546[open-source driver] -* https://www.arm.com/products/processors/classic/arm11/arm1176.php[ARM1176 processor] -* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0301h/index.html[ARM1176JZF-S] +* https://developer.arm.com/documentation/ddi0301[ARM1176JZF-S] diff --git a/documentation/asciidoc/computers/processors/bcm2836.adoc b/documentation/asciidoc/computers/processors/bcm2836.adoc index d2e0e58c11..bd5b8c9092 100644 --- a/documentation/asciidoc/computers/processors/bcm2836.adoc +++ b/documentation/asciidoc/computers/processors/bcm2836.adoc @@ -4,5 +4,5 @@ The Broadcom chip used in the Raspberry Pi 2 Model B. The underlying architectur You should refer to: -* https://datasheets.raspberrypi.org/bcm2836/bcm2836-peripherals.pdf[BCM2836 ARM-local peripherals] -* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0464f/index.html[Cortex-A7 MPcore Processor Reference Manual] +* https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf[BCM2836 ARM-local peripherals] +* https://developer.arm.com/documentation/ddi0464/f/[Cortex-A7 MPcore Processor Reference Manual] diff --git a/documentation/asciidoc/computers/processors/bcm2837.adoc b/documentation/asciidoc/computers/processors/bcm2837.adoc index f82c144f83..16694e5f9f 100644 --- a/documentation/asciidoc/computers/processors/bcm2837.adoc +++ b/documentation/asciidoc/computers/processors/bcm2837.adoc @@ -1,10 +1,10 @@ == BCM2837 -This is the Broadcom chip used in the Raspberry Pi 3, and in later models of the Raspberry Pi 2. The underlying architecture of the BCM2837 is identical to the BCM2836. The only significant difference is the replacement of the ARMv7 quad core cluster with a quad-core ARM Cortex A53 (ARMv8) cluster. +This is the Broadcom chip used in the Raspberry Pi 3 Model B, later models of the Raspberry Pi 2 Model B, and the Raspberry Pi Compute Module 3. The underlying architecture of the BCM2837 is identical to the BCM2836. The only significant difference is the replacement of the ARMv7 quad core cluster with a quad-core ARM Cortex A53 (ARMv8) cluster. The ARM cores run at 1.2GHz, making the device about 50% faster than the Raspberry Pi 2. The VideoCore IV runs at 400MHz. Please refer to the following BCM2836 document for details on the ARM peripherals specification, which also applies to the BCM2837. -* https://datasheets.raspberrypi.org/bcm2836/bcm2836-peripherals.pdf[BCM2836 ARM-local peripherals] +* https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf[BCM2836 ARM-local peripherals] * https://developer.arm.com/documentation/ddi0500/latest/[Cortex-A53 MPCore Processor Technical Reference Manual] diff --git a/documentation/asciidoc/computers/processors/bcm2837b0.adoc b/documentation/asciidoc/computers/processors/bcm2837b0.adoc index de169f4a9a..3589bdf10a 100644 --- a/documentation/asciidoc/computers/processors/bcm2837b0.adoc +++ b/documentation/asciidoc/computers/processors/bcm2837b0.adoc @@ -1,9 +1,9 @@ == BCM2837B0 -This is the Broadcom chip used in the Raspberry Pi 3B+ and 3A+. The underlying architecture of the BCM2837B0 is identical to the BCM2837A0 chip used in other versions of the Pi. The ARM core hardware is the same, only the frequency is rated higher. +This is the Broadcom chip used in the Raspberry Pi 3 Models A+, B+, and the Raspberry Pi Compute Module 3+. The underlying architecture of the BCM2837B0 is identical to the BCM2837 chip used in other versions of the Raspberry Pi. The ARM core hardware is the same, only the frequency is rated higher. The ARM cores are capable of running at up to 1.4GHz, making the 3B+/3A+ about 17% faster than the original Raspberry Pi 3. The VideoCore IV runs at 400MHz. The ARM core is 64-bit, while the VideoCore IV is 32-bit. -The BCM2837B0 chip is packaged slightly differently to the BCM2837A0, and most notably includes a heat spreader for better thermals. These allow higher clock frequencies (or running at lower voltages to reduce power consumption), and more accurate monitoring and control of the chip's temperature. +The BCM2837B0 chip is packaged slightly differently to the BCM2837, and most notably includes a heat spreader for better thermals. This allows higher clock frequencies, and more accurate monitoring and control of the chip's temperature. -https://www.raspberrypi.org/blog/raspberry-pi-3-model-bplus-sale-now-35/[This post on the Raspberry Pi blog] goes into further detail about the BCM2837B0 chip. +This https://www.raspberrypi.com/news/raspberry-pi-3-model-bplus-sale-now-35/[post on the Raspberry Pi blog] goes into further detail about the BCM2837B0 chip. diff --git a/documentation/asciidoc/computers/processors/images/POP-crosssection.png b/documentation/asciidoc/computers/processors/images/POP-crosssection.png new file mode 100644 index 0000000000..5615c2dc7f Binary files /dev/null and b/documentation/asciidoc/computers/processors/images/POP-crosssection.png differ diff --git a/documentation/asciidoc/computers/processors/images/RP3A0-crosssection.png b/documentation/asciidoc/computers/processors/images/RP3A0-crosssection.png new file mode 100644 index 0000000000..9b8baace90 Binary files /dev/null and b/documentation/asciidoc/computers/processors/images/RP3A0-crosssection.png differ diff --git a/documentation/asciidoc/computers/processors/rp3a0.adoc b/documentation/asciidoc/computers/processors/rp3a0.adoc new file mode 100644 index 0000000000..4ec33136a4 --- /dev/null +++ b/documentation/asciidoc/computers/processors/rp3a0.adoc @@ -0,0 +1,19 @@ +== RP3A0 + +The Raspberry Pi RP3A0 is our first System-in-Package (SiP) consisting of a Broadcom BCM2710A1 — which is the silicon die packaged inside the Broadcom xref:processors.adoc#bcm2837[BCM2837] chip which is used on the xref:raspberry-pi.adoc#raspberry-pi-3-model-b-2[Raspberry Pi 3] — along with 512MB of DRAM. + +It is used by the xref:raspberry-pi.adoc#raspberry-pi-zero-2-w[Raspberry Pi Zero 2 W]. + +image:images/RP3A0-crosssection.png[width="70%"] + +The RP3A0 is a Quad-core 64-bit Arm Cortex A53 CPU clocked at 1 GHz, although with a heat sink or other cooling solution in place, the chip can be potentially overclocked to 1.2 GHz. + +Please refer to the following BCM2836 document for details on the ARM peripherals specification, which also applies to the BCM2837 and RP3A0. + +* https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf[BCM2836 ARM-local peripherals] +* https://developer.arm.com/documentation/ddi0500/latest/[Cortex-A53 MPCore Processor Technical Reference Manual] + +[NOTE] +==== +The original xref:raspberry-pi.adoc#raspberry-pi-zero[Raspberry Pi Zero] uses Package-on-Package (PoP) DRAM, where the DRAM is soldered directly on top of the xref:processors.adoc#bcm2835[BCM2835] chip. +==== diff --git a/documentation/asciidoc/computers/raspberry-pi.adoc b/documentation/asciidoc/computers/raspberry-pi.adoc index ef496df7d8..3c152ab591 100644 --- a/documentation/asciidoc/computers/raspberry-pi.adoc +++ b/documentation/asciidoc/computers/raspberry-pi.adoc @@ -1,3 +1,4 @@ +include::raspberry-pi/introduction.adoc[] include::raspberry-pi/raspberry-pi-schematics.adoc[] @@ -5,18 +6,12 @@ include::raspberry-pi/raspberry-pi-compliance.adoc[] include::raspberry-pi/frequency-management.adoc[] -include::raspberry-pi/boot-eeprom-rpi4.adoc[] +include::raspberry-pi/boot-eeprom.adoc[] -include::raspberry-pi/boot-diagnostics-rpi4.adoc[] +include::raspberry-pi/boot-eeprom-diagnostics.adoc[] include::raspberry-pi/bootmodes.adoc[] -include::raspberry-pi/bootflow-legacy.adoc[] - -include::raspberry-pi/bootflow-2711.adoc[] - -include::raspberry-pi/bcm2711-bootloader.adoc[] - include::raspberry-pi/boot-usb.adoc[] include::raspberry-pi/boot-msd.adoc[] @@ -27,20 +22,32 @@ include::raspberry-pi/boot-gpio.adoc[] include::raspberry-pi/boot-nvme.adoc[] +include::raspberry-pi/boot-http.adoc[] + +include::raspberry-pi/bootflow-legacy.adoc[] + +include::raspberry-pi/bootflow-eeprom.adoc[] + +include::raspberry-pi/eeprom-bootloader.adoc[] + include::raspberry-pi/display-parallel-interface.adoc[] include::raspberry-pi/gpio-on-raspberry-pi.adoc[] include::raspberry-pi/gpio-pad-controls.adoc[] -include::raspberry-pi/peripheral_addresses.adoc[] - include::raspberry-pi/raspberry-pi-industrial.adoc[] include::raspberry-pi/otp-bits.adoc[] +include::raspberry-pi/pcie.adoc[] + +include::raspberry-pi/power-button.adoc[] + include::raspberry-pi/power-supplies.adoc[] +include::raspberry-pi/rtc.adoc[] + include::raspberry-pi/spi-bus-on-raspberry-pi.adoc[] include::raspberry-pi/usb-bus-on-raspberry-pi.adoc[] diff --git a/documentation/asciidoc/computers/raspberry-pi/bcm2711-bootloader.adoc b/documentation/asciidoc/computers/raspberry-pi/bcm2711-bootloader.adoc deleted file mode 100644 index e68e815d5e..0000000000 --- a/documentation/asciidoc/computers/raspberry-pi/bcm2711-bootloader.adoc +++ /dev/null @@ -1,455 +0,0 @@ -== Raspberry Pi 4 Bootloader Configuration - -=== Editing the Configuration - -Before editing the bootloader configuration, xref:os.adoc#updating-and-upgrading-raspberry-pi-os[update your system] to get the latest version of the `rpi-eeprom` package. Releases prior to the 2020-09-03 default/critical release will not support all features listed here. - -To view the current EEPROM configuration: + -`rpi-eeprom-config` - -To edit it and apply the updates to latest EEPROM release: + -`sudo -E rpi-eeprom-config --edit` - -Please see the xref:raspberry-pi.adoc#raspberry-pi-4-boot-eeprom[boot EEPROM] page for more information about the EEPROM update process. - -=== Configuration Properties - -This section describes all the configuration items available in the bootloader. The syntax is the same as xref:config_txt.adoc[config.txt] but the properties are specific to the bootloader. xref:config_txt.adoc#conditional-filters[Conditional filters] are also supported except for EDID. - -[[BOOT_UART]] -==== BOOT_UART - -If `1` then enable UART debug output on GPIO 14 and 15. Configure the receiving debug terminal at 115200bps, 8 bits, no parity bits, 1 stop bit. - -Default: `0` - -[[WAKE_ON_GPIO]] -==== WAKE_ON_GPIO - -If `1` then `sudo halt` will run in a lower power mode until either GPIO3 or GLOBAL_EN are shorted to ground. - -Default: `1` (`0` in original version of bootloader 2019-05-10) - -[[POWER_OFF_ON_HALT]] -==== POWER_OFF_ON_HALT - -If `1` and `WAKE_ON_GPIO=0` then `sudo halt` will switch off all PMIC outputs. This is lowest possible power state for halt but may cause problems with some HATs because 5V will still be on. `GLOBAL_EN` must be shorted to ground to boot. - -Pi 400 has a dedicated power button which operates even if the processor is switched off. This behaviour is enabled by default, however, `WAKE_ON_GPIO=2` may be set to use an external GPIO power button instead of the dedicated power button. - -Default: `0` - -[[BOOT_ORDER]] -==== BOOT_ORDER - -The `BOOT_ORDER` setting allows flexible configuration for the priority of different boot modes. It is represented as 32bit unsigned integer where each nibble represents a boot mode. The boot modes are attempted in lowest significant nibble to highest significant nibble order. - -The minimum supported bootloader version for custom boot modes is 2020-09-03. - -[discrete] -====== `BOOT_ORDER` fields - -The BOOT_ORDER property defines the sequence for the different boot modes. It is read right to left and up to 8 digits may be defined. - -|=== -| Value | Mode | Description - -| 0x0 -| SD CARD DETECT -| Try SD then wait for card-detect to indicate that the card has changed - deprecated now that 0xf (RESTART) is available. - -| 0x1 -| SD CARD -| SD card (or eMMC on Compute Module 4). - -| 0x2 -| NETWORK -| Network boot - See xref:remote-access.adoc#network-boot-your-raspberry-pi[Network boot server tutorial] - -| 0x3 -| RPIBOOT -| RPIBOOT - See https://github.com/raspberrypi/usbboot[usbboot] - -| 0x4 -| USB-MSD -| USB mass storage boot - See xref:raspberry-pi.adoc#usb-mass-storage-boot[USB mass storage boot] - -| 0x5 -| BCM-USB-MSD -| USB 2.0 boot from USB Type C socket (CM4: USB type A socket on CM IO board, using bootloader EEPROM from 2020-12-14 onwards). - -| 0x6 -| NVME -| CM4 only: boot from an NVMe SSD connected to the PCIe interface. See xref:raspberry-pi.adoc#nvme-ssd-boot[NVMe boot] for more details. - -| 0xe -| STOP -| Stop and display error pattern. A power cycle is required to exit this state. - -| 0xf -| RESTART -| Restart from the first boot-mode in the BOOT_ORDER field i.e. loop -|=== - -`RPIBOOT` is intended for use with Compute Module 4 to load a custom debug image (e.g. a Linux RAM-disk) instead of the normal boot. This should be the last boot option because it does not currently support timeouts or retries. - -[discrete] -====== `BOOT_ORDER` examples - -|=== -| BOOT_ORDER | Description - -| 0xf41 -| Try SD first, followed by USB-MSD then repeat (default if BOOT_ORDER is empty) - -| 0xf14 -| Try USB first, followed by SD then repeat - -| 0xf21 -| Try SD first, followed by NETWORK then repeat -|=== - -[[MAX_RESTARTS]] -==== MAX_RESTARTS - -If the RESTART (`0xf`) boot mode is encountered more than MAX_RESTARTS times then a watchdog reset is triggered. This isn't recommended for general use but may be useful for test or remote systems where a full reset is needed to resolve issues with hardware or network interfaces. - -Default: `-1` (infinite) - -[[SD_BOOT_MAX_RETRIES]] -==== SD_BOOT_MAX_RETRIES - -The number of times that SD boot will be retried after failure before moving to the next boot mode defined by `BOOT_ORDER`. + -`-1` means infinite retries. - -Default: `0` - -[[NET_BOOT_MAX_RETRIES]] -==== NET_BOOT_MAX_RETRIES - -The number of times that network boot will be retried after failure before moving to the next boot mode defined by `BOOT_ORDER`. + -`-1` means infinite retries. - -Default: `0` - -[[DHCP_TIMEOUT]] -==== DHCP_TIMEOUT - -The timeout in milliseconds for the entire DHCP sequence before failing the current iteration. - -Minimum: `5000` + -Default: `45000` - -[[DHCP_REQ_TIMEOUT]] -==== DHCP_REQ_TIMEOUT - -The timeout in milliseconds before retrying DHCP DISCOVER or DHCP REQ. - -Minimum: `500` + -Default: `4000` - -[[TFTP_FILE_TIMEOUT]] -==== TFTP_FILE_TIMEOUT - -The timeout in milliseconds for an individual file download via TFTP. - -Minimum: `5000` + -Default: `30000` - -[[TFTP_IP]] -==== TFTP_IP - -Optional dotted decimal ip address (e.g. `192.168.1.99`) for the TFTP server which overrides the server-ip from the DHCP request. + -This may be useful on home networks because tftpd-hpa can be used instead of dnsmasq where broadband router is the DHCP server. - -Default: "" - -[[TFTP_PREFIX]] -==== TFTP_PREFIX - -In order to support unique TFTP boot directories for each Pi the bootloader prefixes the filenames with a device specific directory. If neither start4.elf nor start.elf are found in the prefixed directory then the prefix is cleared. -On earlier models the serial number is used as the prefix, however, on Pi 4 the MAC address is no longer generated from the serial number making it difficult to automatically create tftpboot directories on the server by inspecting DHCPDISCOVER packets. To support this the TFTP_PREFIX may be customized to either be the MAC address, a fixed value or the serial number (default). - -|=== -| Value | Description - -| 0 -| Use the serial number e.g. `9ffefdef/` - -| 1 -| Use the string specified by TFTP_PREFIX_STR - -| 2 -| Use the MAC address e.g. `dc-a6-32-01-36-c2/` -|=== - -Default: 0 - -[[TFTP_PREFIX_STR]] -==== TFTP_PREFIX_STR - -Specify the custom directory prefix string used when `TFTP_PREFIX` is set to 1. For example:- `TFTP_PREFIX_STR=tftp_test/` - -Default: "" + -Max length: 32 characters - -[[PXE_OPTION43]] -==== PXE_OPTION43 - -Overrides the PXE Option43 match string with a different string. It's normally better to apply customisations to the DHCP server than change the client behaviour but this option is provided in case that's not possible. - -Default: `Raspberry Pi Boot` - -[[DHCP_OPTION97]] -==== DHCP_OPTION97 - -In earlier releases the client GUID (Option97) was just the serial number repeated 4 times. By default, the new GUID format is -the concatenation of the fourcc for RPi4 (0x34695052 - little endian), the board revision (e.g. 0x00c03111) (4-bytes), the least significant 4 bytes of the mac address and the 4-byte serial number. -This is intended to be unique but also provide structured information to the DHCP server, allowing Raspberry Pi4 computers to be identified without relying upon the Ethernet MAC OUID. - -Specify DHCP_OPTION97=0 to revert the the old behaviour or a non-zero hex-value to specify a custom 4-byte prefix. - -Default: `0x34695052` - -==== Static IP address configuration - -If TFTP_IP and the following options are set then DHCP is skipped and the static IP configuration is applied. If the TFTP server is on the same subnet as the client then GATEWAY may be omitted. - -[[CLIENT_IP]] -===== CLIENT_IP - -The IP address of the client e.g. `192.168.0.32` - -Default: "" - -[[SUBNET]] -===== SUBNET - -The subnet address mask e.g. `255.255.255.0` - -Default: "" - -[[GATEWAY]] -===== GATEWAY - -The gateway address to use if the TFTP server is on a differenet subnet e.g. `192.168.0.1` - -Default: "" - -[[MAC_ADDRESS]] -===== MAC_ADDRESS - -Overrides the Ethernet MAC address with the given value. e.g. `dc:a6:32:01:36:c2` - -Default: "" - -[[DISABLE_HDMI]] -==== DISABLE_HDMI - -The xref:raspberry-pi.adoc#boot-diagnostics-on-the-raspberry-pi-4[HDMI boot diagnostics] display is disabled if `DISABLE_HDMI=1`. Other non-zero values are reserved for future use. - -Default: `0` - -[[HDMI_DELAY]] -==== HDMI_DELAY - -Skip rendering of the HDMI diagnostics display for up to N seconds (default 5) unless a fatal error occurs. The default behaviour is designed to avoid the bootloader diagnostics screen from briefly appearing during a normal SD / USB boot. - -Default: `5` - -[[ENABLE_SELF_UPDATE]] -==== ENABLE_SELF_UPDATE - -Enables the bootloader to update itself from a TFTP or USB mass storage device (MSD) boot filesystem. - -If self update is enabled then the bootloader will look for the update files (.sig/.upd) in the boot file system. If the update image differs from the current image then the update is applied and system is reset. Otherwise, if the EEPROM images are byte-for-byte identical then boot continues as normal. - -Notes:- - -* Self-update is not enabled in SD boot; the ROM can already load recovery.bin from the SD card. -* Before self-update can be used the bootloader must have already been updated to a version which supports self update. The recommended approach would be to use the Raspberry Pi Imager and a spare SD card to update to pieeprom-2020-09-03 then use self-update for subsequent updates. -* For network boot make sure that the TFTP `boot` directory can be mounted via NFS and that `rpi-eeprom-update` can write to it. - -Default: `1` (`0` in versions prior to 2020-09-03) - -[[FREEZE_VERSION]] -==== FREEZE_VERSION - -Previously this property was only checked by the `rpi-eeprom-update` script. However, now that self-update is enabled the bootloader will also check this property. If set to 1, this overrides `ENABLE_SELF_UPDATE` to stop automatic updates. To disable `FREEZE_VERSION` you will have to use an SD card boot with recovery.bin. - -*Custom EEPROM update scripts must also check this flag.* - -Default: `0` - -[[NETCONSOLE]] -==== NETCONSOLE - advanced logging - -`NETCONSOLE` duplicates debug messages to the network interface. The IP addresses and ports are defined by the `NETCONSOLE` string. - -N.B. NETCONSOLE blocks until the ethernet link is established or a timeout occurs. The timeout value is `DHCP_TIMEOUT` although DHCP is not attempted unless network boot is requested. - -===== Format - -See https://wiki.archlinux.org/index.php/Netconsole - ----- -src_port@src_ip/dev_name,dst_port@dst_ip/dst_mac -E.g. 6665@169.254.1.1/,6666@/ ----- - -In order to simplify parsing, the bootloader requires every field separator to be present. The source ip address must be specified but the following fields may be left blank and assigned default values. - -* src_port - 6665 -* dev_name - "" (the device name is always ignored) -* dst_port - 6666 -* dst_ip - 255.255.255.255 -* dst_mac - 00:00:00:00:00 - -One way to view the data is to connect the test Pi 4 to another Pi running WireShark and select "`udp.srcport == 6665`" as a filter and select `+Analyze -> Follow -> UDP stream+` to view as an ASCII log. - -`NETCONSOLE` should not be enabled by default because it may cause network problems. It can be enabled on demand via a GPIO filter e.g. - ----- -# Enable debug if GPIO 7 is pulled low -[gpio7=0] -NETCONSOLE=6665@169.254.1.1/,6666@/ ----- - -Default: "" (not enabled) + -Max length: 32 characters - -[[USB_MSD_EXCLUDE_VID_PID]] -==== USB_MSD_EXCLUDE_VID_PID - -A list of up to 4 VID/PID pairs specifying devices which the bootloader should ignore. If this matches a HUB then the HUB won't be enumerated, causing all downstream devices to be excluded. -This is intended to allow problematic (e.g. very slow to enumerate) devices to be ignored during boot enumeration. This is specific to the bootloader and is not passed to the OS. - -The format is a comma-separated list of hexadecimal values with the VID as most significant nibble. Spaces are not allowed. -E.g. `034700a0,a4231234` - -Default: "" - -[[USB_MSD_DISCOVER_TIMEOUT]] -==== USB_MSD_DISCOVER_TIMEOUT - -If no USB mass storage devices are found within this timeout then USB-MSD is stopped and the next boot mode is selected - -Default: `20000` (20 seconds) + -Version: 2020-09-03 - -[[USB_MSD_LUN_TIMEOUT]] -==== USB_MSD_LUN_TIMEOUT - -How long to wait in milliseconds before advancing to the next LUN e.g. a multi-slot SD-CARD reader. This is still being tweaked but may help speed up boot if old/slow devices are connected as well as a fast USB-MSD device containing the OS. - -Default: `2000` (2 seconds) - -[[USB_MSD_PWR_OFF_TIME]] -==== USB_MSD_PWR_OFF_TIME - -During USB mass storage boot, power to the USB ports is switched off for a short time to ensure the correct operation of USB mass storage devices. Most devices work correctly using the default setting: change this only if you have problems booting from a particular device. Setting `USB_MSD_PWR_OFF_TIME=0` will prevent power to the USB ports being switched off during USB mass storage boot. - -Minimum: `250` + -Maximum: `5000` + -Default: `1000` (1 second) - -[[XHCI_DEBUG]] -==== XHCI_DEBUG - -This property is a bit field which controls the verbosity of USB debug messages for mass storage boot mode. Enabling all of these messages generates a huge amount of log data which will slow down booting and may even cause boot to fail. For verbose logs it's best to use `NETCONSOLE`. - -|=== -| Value | Log - -| 0x1 -| USB descriptors - -| 0x2 -| Mass storage mode state machine - -| 0x4 -| Mass storage mode state machine - verbose - -| 0x8 -| All USB requests - -| 0x10 -| Device and hub state machines - -| 0x20 -| All xHCI TRBs (VERY VERBOSE) - -| 0x40 -| All xHCI events (VERY VERBOSE) -|=== - -To combine values, add them together. For example: - ----- -# Enable mass storage and USB descriptor logging -XHCI_DEBUG=0x3 ----- - -Default: `0x0` (no USB debug messages enabled) - -=== Configuration Properties in `config.txt` - -[[boot_load_flags]] -==== boot_load_flags - -Experimental property for custom firmware (bare metal). - -Bit 0 (0x1) indicates that the .elf file is custom firmware. This disables any compatibility checks (e.g. is USB MSD boot supported) and resets PCIe before starting the executable. - -Default: `0x0` - -[[uart_2ndstage]] -==== uart_2ndstage - -If set to 0x1 then enable debug logging to the UART. In newer firmware versions (Raspberry Pi OS 2020-08-20 and later) UART logging is also automatically enabled in start.elf. This is also described on the xref:config_txt.adoc#boot-options[Boot options] page. - -The `BOOT_UART` property also enables bootloader UART logging but does not enable UART logging in `start.elf` unless `uart_2ndstage=1` is also set. - -Default: `0` - -[[eeprom_write_protect]] -==== eeprom_write_protect - -The `2020-09-03` `recovery.bin` EEPROM updater provides a feature to configure the EEPROM `Write Status Register`. This can be set to either mark the entire EEPROM as write-protected or clear write-protection. - -This option must be used in conjunction with the EEPROM `/WP` pin which controls updates to the EEPROM `Write Status Register`. Pulling `/WP` low (CM4 `EEPROM_nEP` or Pi4B `TP5`) does NOT write-protect the EEPROM unless the `Write Status Register` has also been configured. - -See: https://www.winbond.com/resource-files/w25x40cl_f%2020140325.pdf[Winbond W25x40cl datasheet] - -`eeprom_write_protect` settings in `config.txt` for `recovery.bin`. - -|=== -| Value | Description - -| 1 -| Configures the write protect regions to cover the entire EEPROM. - -| 0 -| Clears the write protect regions. - -| -1 -| Do nothing. -|=== - -N.B `flashrom` does not support clearing of the write-protect regions and will fail to update the EEPROM if write-protect regions are defined. - -Default: `-1` - -[[bootloader_update]] -==== bootloader_update - -This option may be set to 0 to block self-update without requiring the EEPROM configuration to be updated. This is sometimes useful when updating multiple Pis via network boot because this option can be controlled per Raspberry Pi (e.g. via a serial number filter in `config.txt`). - -Default: `1` (`0` in versions prior to 2020-09-03) - -[[config_txt]] -==== config.txt section - -From Raspberry Pi OS 2021-01-11, the firmware now reads the bootloader configuration from the EEPROM. If a section called `[config.txt]` is found then the contents from the start of this section to the end of the file is appended in memory, to the contents of the `config.txt` file read from the boot partition. This can be used to automatically apply settings to every operating system, for example, dtoverlays. - -If an invalid configuration which causes boot to fail is specified then an EEPROM recovery image or RPIBOOT will be required to restore the EEPROM to factory defaults. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-diagnostics-rpi4.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-diagnostics-rpi4.adoc deleted file mode 100644 index 920234e7ed..0000000000 --- a/documentation/asciidoc/computers/raspberry-pi/boot-diagnostics-rpi4.adoc +++ /dev/null @@ -1,45 +0,0 @@ -== Boot Diagnostics on the Raspberry Pi 4 - -Starting with version 2020-04-16 of the Raspberry Pi 4 bootloader, diagnostic information can be displayed at boot time on an HDMI display. To see this diagnostic information, power down the Raspberry Pi 4, remove the SD card, then power back up. A diagnostic display similar to below should appear on the attached display. - -image::images/bootloader-diagnostics.png[Boot Diagnostics Screen] - -This diagnostics page will also appear if the bootloader is unable to boot from an inserted SD card, or is unable to network boot; for example, if there is no bootable image on the card, or it is defective, or the network boot parameters are incorrect. - -Once the diagnostics page is displayed, a reboot is only possible by power cycling the device (i.e. unplug then re-plug the power supply). - -The top line describes the model of Pi and its memory capacity. The QR code is a link to the https://raspberrypi.org/downloads[Downloads Page]. - -The diagnostic information is as follows: - -|=== -| Line: | Information - -| bootloader -| Bootloader version - build date - -| board -| Board revision - Serial Number - Ethernet MAC address - -| boot -| mode: (ROM boot mode - 6 SPI), order: EEPROM config xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[BOOT_ORDER], RSTS: PM_RSTS register - -| SD CID -| SD Card Identifier defined by SD-CARD manufacturer - -| part -| Master Boot Record primary partitions type:LBA - -| fw -| Filename for start.elf and fixup.dat if present (e.g. start4x.elf, fixup4x.dat) - -| net -| Network boot: - Link status (up/down) client IP address (ip), Subnet (sn), Default gateway (gw) - -| tftp -| Network boot: TFTP server IP address -|=== - -This display can be disabled using the `DISABLE_HDMI` option, see xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[Bootloader Configuration]. - -NOTE: This is purely for diagnosing boot failures; it is not an interactive bootloader. If you require an interactive bootloader, consider using a tool such as U-Boot. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-diagnostics.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-diagnostics.adoc new file mode 100644 index 0000000000..04c7921910 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-diagnostics.adoc @@ -0,0 +1,53 @@ +== Boot diagnostics + +The bootloader on Raspberry Pi 4 or later flagship models can display diagnostic information at boot time on an HDMI display. To see this diagnostic information, power down the Raspberry Pi, disconnect the boot media (typically an SD card or SSD), then power back up. If your Raspberry Pi is connected to a display, you should see diagnostics similar to the following: + +image::images/bootloader-diagnostics.png[Boot diagnostics screen] + +This diagnostics page will also appear if the bootloader is unable to boot from any boot media or network boot. This can happen if there is no bootable image on the boot media, if the boot media is defective, or if network boot parameters are incorrect. + +To reboot while displaying the diagnostics page, power cycle the device. You can disconnect, then reconnect the power supply, or press and hold the power button, if your device has one. + +The top line describes the model of Raspberry Pi and its memory capacity. The QR code is a link to the https://www.raspberrypi.com/software/[downloads page]. + +The diagnostic information is as follows: + +[cols="1m,4"] +|=== +| Line | Information + +| bootloader +| Bootloader git version - RO (if EEPROM is write protected) - software build date + +| update-ts +| the timestamp corresponding to when the EEPROM configuration was updated; this timestamp is checked in xref:raspberry-pi.adoc#ENABLE_SELF_UPDATE[self-update] mode to avoid updating to an old configuration + +| secure-boot +| If xref:raspberry-pi.adoc#secure-boot[secure-boot] is enabled, displays the processor revision (B0/C0) and xref:configuration.adoc#part4[signed-boot status flags]; otherwise, this line is blank + +| board +| xref:raspberry-pi.adoc#raspberry-pi-revision-codes[Board revision] - serial number - Ethernet MAC address + +| boot +| *mode* (current boot mode name and number) *order* (the xref:raspberry-pi.adoc#BOOT_ORDER[BOOT ORDER] configuration) *retry* (retry count in the current boot mode) *restart* (number of cycles through the list of boot modes) + +| SD +| The SD card detect status (detected/not detected). + +| part +| Master Boot Record primary partitions type:LBA + +| fw +| Filename for `start.elf` and `fixup.dat` if present (e.g. `start4x.elf`, `fixup4x.dat`) + +| net +| Network boot: link status (up/down), client IP address (ip), subnet (sn), default gateway (gw) + +| tftp +| Network boot: TFTP server IP address + +| display +| Indicates whether hotplug was detected (`HPD=1`) and if so whether the EDID was read successfully (`EDID=ok`) for each HDMI output +|=== + +To disable this diagnostics display, use the `DISABLE_HDMI` option in the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration]. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-rpi4.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-rpi4.adoc deleted file mode 100644 index ad63b365d7..0000000000 --- a/documentation/asciidoc/computers/raspberry-pi/boot-eeprom-rpi4.adoc +++ /dev/null @@ -1,211 +0,0 @@ -== Raspberry Pi 4 Boot EEPROM - -The Raspberry Pi 4 has an SPI-attached EEPROM (4MBits/512KB), which contains code to boot up the system and replaces `bootcode.bin` previously found in the boot partition of the SD card. Note that if a `bootcode.bin` is present in the boot partition of the SD card in a Pi 4, it is ignored. - -NOTE: The scripts and pre-compiled binaries used to create the `rpi-eeprom` package which is used to update the Raspberry Pi 4 bootloader and VLI USB controller EEPROMs is available https://github.com/raspberrypi/rpi-eeprom/[on Github]. - -=== Boot Diagnostics - -If an error occurs during boot then an xref:configuration.adoc#led-warning-flash-codes[error code] will be displayed via the green LED. Newer versions of the bootloader will display a xref:raspberry-pi.adoc#boot-diagnostics-on-the-raspberry-pi-4[diagnostic message] which will be shown on both HDMI displays. - -=== Updating the Bootloader - -==== Raspberry Pi 4 and Raspberry Pi 400 - -Raspberry Pi OS automatically updates the bootloader for critical bug fixes. The recommended methods for manually updating the bootloader or changing the boot modes are https://www.raspberrypi.org/downloads[Raspberry Pi Imager] and xref:configuration.adoc#raspi-config[raspi-config] - -[[imager]] -==== Using Raspberry Pi Imager to update the bootloader - -IMPORTANT: This is the recommended route to updating the bootloader. - -Raspberry Pi Imager provides a GUI for updating the bootloader and selecting the boot mode. - -. Download https://www.raspberrypi.org/downloads/[Raspberry Pi Imager] -. Select a spare SD card. The contents will get overwritten! -. Launch `Raspberry Pi Imager` -. Select `Misc utility images` under `Operating System` -. Select `Bootloader` -. Select a boot-mode i.e. `SD` (recommended), `USB` or `Network`. -. Select `SD card` and then `Write` -. Boot the Raspberry Pi with the new image and wait for at least 10 seconds. -. The green activity LED will blink with a steady pattern and the HDMI display will be green on success. -. Power off the Raspberry Pi and remove the SD card. - -[[raspi-config]] -==== Using raspi-config to update the bootloader - -To change the boot-mode or bootloader version from within Raspberry Pi OS run xref:configuration.adoc#raspi-config[raspi-config] - -. xref:os.adoc#updating-and-upgrading-raspberry-pi-os[Update] Raspberry Pi OS to get the latest version of the `rpi-eeprom` package. -. Run `sudo raspi-config` -. Select `Advanced Options` -. Select `Bootloader Version` -. Select `Default` for factory default settings or `Latest` for the latest stable bootloader release. -. Reboot - -=== Updating the EEPROM Configuration - -The boot behaviour (e.g. SD or USB boot) is controlled by a configuration file embedded in the EEPROM image and can be modified via the `rpi-eeprom-config` tool. - -Please see the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[Bootloader Configuration] sections for details of the configuration. - -==== Reading the current EEPROM configuration - -To view the configuration used by the current bootloader during the last boot run `rpi-eeprom-config` or `vcgencmd bootloader_config`. - -==== Reading the configuration from an EEPROM image - -To read the configuration from an EEPROM image: - -[,bash] ----- -rpi-eeprom-config pieeprom.bin ----- - -==== Editing the current bootloader configuration - -The following command loads the current EEPROM configuration into a text editor. When the editor is closed, `rpi-eeprom-config` applies the updated configuration to latest available EEPROM release and uses `rpi-eeprom-update` to schedule an update when the system is rebooted: - -[,bash] ----- -sudo -E rpi-eeprom-config --edit -sudo reboot ----- - -If the updated configuration is identical or empty then no changes are made. - -The editor is selected by the `EDITOR` environment variable. - -==== Applying a saved configuration - -The following command applies `boot.conf` to the latest available EEPROM image and uses `rpi-eeprom-update` to schedule an update when the system is rebooted. - ----- -sudo rpi-eeprom-config --apply boot.conf -sudo reboot ----- - -[[automaticupdates]] -=== Automatic Updates - -The `rpi-eeprom-update` `systemd` service runs at startup and applies an update if a new image is available, automatically migrating the current bootloader configuration. - -To disable automatic updates: - -[,bash] ----- -sudo systemctl mask rpi-eeprom-update ----- - -To re-enable automatic updates: - -[,bash] ----- -sudo systemctl unmask rpi-eeprom-update ----- - -NOTE: If the xref:raspberry-pi.adoc#FREEZE_VERSION[FREEZE_VERSION] bootloader EEPROM config is set then the EEPROM update service will skip any automatic updates. This removes the need to individually disable the EEPROM update service if there are multiple operating systems installed or when swapping SD-cards. - -==== `rpi-eeprom-update` - -Raspberry Pi OS uses the `rpi-eeprom-update` script to implement an <> service. The script can also be run interactively or wrapped to create a custom bootloader update service. - -Reading the current EEPROM version: - -[,bash] ----- -vcgencmd bootloader_version ----- - -Check if an update is available: - -[,bash] ----- -sudo rpi-eeprom-update ----- - -Install the update: - ----- -sudo rpi-eeprom-update -a -sudo reboot ----- - -Cancel the pending update: - -[,bash] ----- -sudo rpi-eeprom-update -r ----- - -Installing a specific bootloader EEPROM image: - -[,bash] ----- -sudo rpi-eeprom-update -d -f pieeprom.bin ----- - -The `-d` flag instructs `rpi-eeprom-update` to use the configuration in the specified image file instead of automatically migrating the current configuration. - -Display the built-in documentation: - ----- -rpi-eeprom-update -h ----- - - -[[bootloader-release]] -=== Bootloader Release Status - -The firmware release status corresponds to a particular subdirectory of bootloader firmware images (`+/lib/firmware/raspberrypi/bootloader/...+`), and can be changed to select a different release stream. - -* `default` - Updated for new hardware support, critical bug fixes and periodic update for new features that have been tested via the `latest` release. -* `latest` - Updated when new features have been successfully beta tested. -* `beta` - New or experimental features are tested here first. - -Since the release status string is just a subdirectory name, then it is possible to create your own release streams e.g. a pinned release or custom network boot configuration. - -N.B. `default` and `latest` are symbolic links to the older release names of `critical` and `stable`. - -==== Changing the bootloader release - -NOTE: You can change which release stream is to be used during an update by editing the `/etc/default/rpi-eeprom-update` file and changing the `FIRMWARE_RELEASE_STATUS` entry to the appropriate stream. - -==== Updating the bootloader configuration in an EEPROM image file - -The following command replaces the bootloader configuration in `pieeprom.bin` with `boot.conf` and writes the new image to `new.bin`: - -[,bash] ----- -rpi-eeprom-config --config boot.conf --out new.bin pieeprom.bin ----- - -==== recovery.bin - -At power on, the BCM2711 ROM looks for a file called `recovery.bin` in the root directory of the boot partition on the SD card. If a valid `recovery.bin` is found then the ROM executes this instead of the SPI EEPROM image. This mechanism ensures that the bootloader SPI EEPROM can always be reset to a valid image with factory default settings. - -See also xref:raspberry-pi.adoc#raspberry-pi-4-boot-flow[Raspberry Pi 4 boot-flow] - -==== EEPROM update files - -| Filename | Purpose | -|-------|------| -| recovery.bin | VideoCore EEPROM recovery executable | -| pieeprom.upd | Bootloader EEPROM image | -| pieeprom.bin | Bootloader EEPROM image - same as pieeprom.upd but changes recovery.bin behaviour | -| pieeprom.sig | The sha256 checksum of bootloader image (pieeprom.upd/pieeprom.bin) | -| vl805.bin | The VLI805 USB firmware EEPROM image - ignored on 1.4 board revision which does not have a dedicated VLI EEPROM| -| vl805.sig | The sha256 checksum of vl805.bin | - -* If the bootloader update image is called `pieeprom.upd` then `recovery.bin` renames itself to `recovery.000` and resets the CPU. Since `recovery.bin` is no longer present the ROM loads the newly updated bootloader from SPI EEPROM and the OS is booted as normal. -* If the bootloader update image is called `pieeprom.bin` the `recovery.bin` will stop after the update has completed. On success the HDMI output will be green and the green activity LED is flashed rapidly. Otherwise, the HDMI output will be red and an xref:configuration.adoc#led-warning-flash-codes[error code] will be displayed via the activity LED. -* The `.sig` files should just contain the sha256 checksum (in hex) of the corresponding image file. Other fields may be added in the future. -* The BCM2711 ROM does not support loading `recovery.bin` from USB mass storage or TFTP. Instead, newer versions of the bootloader support a self-update mechanism where the SPI bootloader is able to reflash the SPI EEPROM itself. See `ENABLE_SELF_UPDATE` on the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[bootloader configuration] page. -* The temporary EEPROM update files are automatically deleted by the `rpi-eeprom-update` service at startup. - -For more information about the `rpi-eeprom-update` configuration file please run `rpi-eeprom-update -h`. - -==== EEPROM write protect - -Both the bootloader and VLI SPI EEPROMs support hardware write-protection. See the xref:raspberry-pi.adoc#eeprom_write_protect[eeprom_write_protect] option for more information about how to enable this when flashing the EEPROMs. \ No newline at end of file diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-eeprom.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-eeprom.adoc new file mode 100644 index 0000000000..0e27031dc7 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/boot-eeprom.adoc @@ -0,0 +1,302 @@ +== Raspberry Pi boot EEPROM + +The following Raspberry Pi models use an EEPROM to boot the system: + +* Flagship models since Raspberry Pi 4B +* Compute Module models since CM4 (including CM4S) +* Keyboard models since Pi 400 + +All other models of Raspberry Pi computer use the `bootcode.bin` file located in the boot filesystem. + +NOTE: You can find the scripts and pre-compiled binaries used to create `rpi-eeprom` in the https://github.com/raspberrypi/rpi-eeprom/[rpi-eeprom GitHub repository]. + +=== Diagnostics + +If an error occurs during boot, then an xref:configuration.adoc#led-warning-flash-codes[error code] will be displayed via the green LED. Newer versions of the bootloader will display a xref:raspberry-pi.adoc#boot-diagnostics[diagnostic message] on all HDMI displays. + +[[bootloader_update_stable]] +=== Update the bootloader + +There are multiple ways to update the bootloader of your Raspberry Pi. + +==== Flagship models since Raspberry Pi 4B; Compute Modules since CM5; Keyboard models since Pi 400 + +Raspberry Pi OS automatically updates the bootloader for important bug fixes. To manually update the bootloader or change the boot order, use xref:configuration.adoc#raspi-config[raspi-config]. + +NOTE: Compute Module 4 and Compute Module 4S do not support automatic bootloader updates because the bootrom cannot load the `recovery.bin` file from eMMC. The recommended update mechanism is `rpiboot` or via `flashrom` - see `rpi-eeprom-update -h` for more information. + +[[imager]] +==== Use Raspberry Pi Imager to update the bootloader + +Raspberry Pi Imager provides a GUI for updating the bootloader and selecting the boot mode. + +. Download https://www.raspberrypi.com/software/[Raspberry Pi Imager] +. Select a spare SD card (bootloader images overwrite the entire card) +. Launch Raspberry Pi Imager +. Select `Choose OS` +. Select `Misc utility images` ++ +image::images/misc-utility-images.png[alt="Select Misc utility images",width="60%"] +. Select `Bootloader` for your version of Raspberry Pi (Pi 400 is part of the 4 family) ++ +image::images/bootloader-family-select.png[alt="Choose a family for your bootloader",width="60%"] +. Select a boot mode: `SD` (recommended), `USB` or `Network` ++ +image::images/bootloader-storage-select.png[alt="Choose the storage from which you'd like to boot",width="60%"] +. Select `SD card` and then `Write` +. Click `Yes` to continue +. Boot the Raspberry Pi with the new image and wait for at least ten seconds +. When the green activity LED blinks with a steady pattern and the HDMI display shows a green screen, you have successfully written the bootloader +. Power off the Raspberry Pi and remove the SD card + +[[raspi-config]] +==== Use `raspi-config` to update the bootloader + +To change the boot-mode or bootloader version from within Raspberry Pi OS, run xref:configuration.adoc#raspi-config[raspi-config]. + +. xref:os.adoc#update-software[Update] Raspberry Pi OS to get the latest version of the `rpi-eeprom` package. +. Run `sudo raspi-config`. +. Select `Advanced Options`. +. Select `Bootloader Version`. +. Select `Default` for factory default settings or `Latest` for the latest bootloader release. +. Reboot with `sudo reboot`. + +=== Update the bootloader configuration + +The `default` version of the bootloader represents the latest factory default firmware image. It updates to provide critical bug fixes, hardware support and periodically after features have been tested in the `latest` release. +The `latest` bootloader updates more often to include the latest fixes and improvements. + +Advanced users can switch to the `latest` bootloader to get the latest functionality. + +First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: + +[source,console] +---- +$ sudo apt update && sudo apt full-upgrade +---- + +Next, run the following command to open `raspi-config`: + +[source,console] +---- +$ sudo raspi-config +---- + +Navigate to `Advanced Options` > `Bootloader Version`. Select `Latest`, then choose `Yes` to confirm. Select `Finish` and confirm that you want to reboot. + +If you run `sudo rpi-eeprom-update`, you should see that a more recent version of the bootloader is available and it's the `latest` release. + +---- +*** UPDATE AVAILABLE *** +BOOTLOADER: update available + CURRENT: Thu 18 Jan 13:59:23 UTC 2024 (1705586363) + LATEST: Mon 22 Jan 10:41:21 UTC 2024 (1705920081) + RELEASE: latest (/lib/firmware/raspberrypi/bootloader-2711/latest) + Use raspi-config to change the release. + + VL805_FW: Using bootloader EEPROM + VL805: up to date + CURRENT: 000138c0 + LATEST: 000138c0 +---- + +Now you can update your bootloader. + +[source,console] +---- +$ sudo rpi-eeprom-update -a +$ sudo reboot +---- + +Reboot, then run `sudo rpi-eeprom-update`. You should now see that the `CURRENT` date has updated to the latest version of the bootloader: + +---- +BOOTLOADER: up to date + CURRENT: Mon 22 Jan 10:41:21 UTC 2024 (1705920081) + LATEST: Mon 22 Jan 10:41:21 UTC 2024 (1705920081) + RELEASE: latest (/lib/firmware/raspberrypi/bootloader-2711/latest) + Use raspi-config to change the release. + + VL805_FW: Using bootloader EEPROM + VL805: up to date + CURRENT: 000138c0 + LATEST: 000138c0 +---- + +==== Read the current bootloader configuration + +To view the configuration used by the current running bootloader, run the following command: + +[source,console] +---- +$ rpi-eeprom-config +---- + +==== Read the configuration from an bootloader image + +To read the configuration from a bootloader image: + +[source,console] +---- +$ rpi-eeprom-config pieeprom.bin +---- + +==== Editing the current bootloader configuration + +The following command loads the current bootloader configuration into a text editor. When the editor is closed, `rpi-eeprom-config` applies the updated configuration to latest available bootloader release and uses `rpi-eeprom-update` to schedule an update when the system is rebooted: + +[source,console] +---- +$ sudo -E rpi-eeprom-config --edit +$ sudo reboot +---- + +If the updated configuration is identical or empty, then no changes are made. + +The editor is selected by the `EDITOR` environment variable. + +==== Applying a saved configuration + +The following command applies `boot.conf` to the latest available bootloader image and uses `rpi-eeprom-update` to schedule an update when the system is rebooted. + +[source,console] +---- +$ sudo rpi-eeprom-config --apply boot.conf +$ sudo reboot +---- + +[[automaticupdates]] +=== Automatic updates + +The `rpi-eeprom-update` `systemd` service runs at startup and applies an update if a new image is available, automatically migrating the current bootloader configuration. + +To disable automatic updates: + +[source,console] +---- +$ sudo systemctl mask rpi-eeprom-update +---- + +To re-enable automatic updates: + +[source,console] +---- +$ sudo systemctl unmask rpi-eeprom-update +---- + +NOTE: If the xref:raspberry-pi.adoc#FREEZE_VERSION[FREEZE_VERSION] bootloader config is set then the update service will skip any automatic updates. This removes the need to individually disable the update service if there are multiple operating systems installed, or when swapping SD cards. + +==== `rpi-eeprom-update` + +Raspberry Pi OS uses the `rpi-eeprom-update` script to implement an <> service. The script can also be run interactively or wrapped to create a custom bootloader update service. + +Reading the current bootloader version: + +[source,console] +---- +$ vcgencmd bootloader_version +---- + +Check if an update is available: + +[source,console] +---- +$ sudo rpi-eeprom-update +---- + +Install the update: + +[source,console] +---- +$ sudo rpi-eeprom-update -a +$ sudo reboot +---- + +Cancel the pending update: + +[source,console] +---- +$ sudo rpi-eeprom-update -r +---- + +Installing a specific bootloader image: + +[source,console] +---- +$ sudo rpi-eeprom-update -d -f pieeprom.bin +---- + +The `-d` flag instructs `rpi-eeprom-update` to use the configuration in the specified image file instead of automatically migrating the current configuration. + +Display the built-in documentation: + +[source,console] +---- +$ rpi-eeprom-update -h +---- + +[[bootloader-release]] +=== Bootloader release status + +The firmware release status corresponds to a particular subdirectory of bootloader firmware images (`+/lib/firmware/raspberrypi/bootloader/...+`), and can be changed to select a different release stream. + +* `default` - Updated for new hardware support, critical bug fixes and periodic update for new features that have been tested via the `latest` release +* `latest` - Updated when new features are available + +Since the release status string is just a subdirectory name, it is possible to create your own release streams e.g. a pinned release or custom network boot configuration. + +==== Changing the bootloader release + +NOTE: You can change which release stream is to be used during an update by editing the `/etc/default/rpi-eeprom-update` file and changing the `FIRMWARE_RELEASE_STATUS` entry to the appropriate stream. + +==== Updating the bootloader configuration in an bootloader image file + +The following command replaces the bootloader configuration in `pieeprom.bin` with `boot.conf` and writes the new image to `new.bin`: + +[source,console] +---- +$ rpi-eeprom-config --config boot.conf --out new.bin pieeprom.bin +---- + +==== `recovery.bin` + +At power on, the ROM found on BCM2711 and BCM2712 looks for a file called `recovery.bin` in the root directory of the boot partition on the SD card. If a valid `recovery.bin` is found then the ROM executes this instead of the contents of the EEPROM. This mechanism ensures that the bootloader flash image can always be reset to a valid image with factory default settings. + +For more information, see xref:raspberry-pi.adoc#eeprom-boot-flow[EEPROM bootflow]. + +==== Bootloader update files + +[cols="1,1"] +|=== +| Filename | Purpose + +| `recovery.bin` +| Bootloader recovery executable + +| `pieeprom.upd` +| Bootloader EEPROM image + +| `pieeprom.bin` +| Bootloader EEPROM image - same as `pieeprom.upd` but changes `recovery.bin` behaviour to not rename itself to `RECOVERY.000`. + +| `pieeprom.sig` +| The sha256 checksum of bootloader image (pieeprom.upd/pieeprom.bin) + +| `vl805.bin` +| The VLI805 USB firmware EEPROM image - Raspberry Pi 4B revision 1.3 and earlier only. + +| `vl805.sig` +| The sha256 checksum of vl805.bin +|=== + +* If the bootloader update image is called `pieeprom.upd` then `recovery.bin` is renamed to `recovery.000` once the update has completed, then the system is rebooted. Since `recovery.bin` is no longer present the ROM loads the newly updated bootloader from SPI flash and the OS is booted as normal. +* If the bootloader update image is called `pieeprom.bin` then `recovery.bin` will stop after the update has completed. On success the HDMI output will be green and the green activity LED is flashed rapidly. If the update fails, the HDMI output will be red and an xref:configuration.adoc#led-warning-flash-codes[error code] will be displayed via the activity LED. +* The `.sig` files contain the hexadecimal sha256 checksum of the corresponding image file; additional fields may be added in the future. +* The ROM found on BCM2711 and BCM2712 does not support loading `recovery.bin` from USB mass storage or TFTP. Instead, newer versions of the bootloader support a self-update mechanism where the bootloader is able to reflash the SPI flash itself. See `ENABLE_SELF_UPDATE` on the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration] page. +* The temporary EEPROM update files are automatically deleted by the `rpi-eeprom-update` service at startup. + +For more information about the `rpi-eeprom-update` configuration file see `rpi-eeprom-update -h`. + +==== EEPROM write protect + +Both the bootloader and VLI EEPROMs support hardware write protection. See the xref:config_txt.adoc#eeprom_write_protect[`eeprom_write_protect`] option for more information about how to enable this when flashing the EEPROMs. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-gpio.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-gpio.adoc index e0a7c09efa..6545bc3c90 100644 --- a/documentation/asciidoc/computers/raspberry-pi/boot-gpio.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/boot-gpio.adoc @@ -1,20 +1,21 @@ -== GPIO Boot Mode +== GPIO boot mode NOTE: GPIO boot mode is only available on the Raspberry Pi 3A+, 3B, 3B+, Compute Module 3 and 3+. -The Raspberry Pi can be configured to allow the boot mode to be selected at power on using hardware attached to the GPIO connector: this is GPIO boot mode. This is done by setting bits in the OTP memory of the SoC. Once the bits are set, they permanently allocate 5 GPIOs to allow this selection to be made. Once the OTP bits are set they cannot be unset so you should think carefully about enabling this, since those 5 GPIO lines will always control booting. Although you can use the GPIOs for some other function once the Pi has booted, you must set them up so that they enable the desired boot modes when the Pi boots. +Earlier Raspberry Pis can be configured to allow the boot mode to be selected at power-on using hardware attached to the GPIO connector. This is done by setting bits in the OTP memory of the SoC. Once the bits are set, they permanently allocate five GPIOs to allow this selection to be made. Once the OTP bits are set, they cannot be unset. You should think carefully about enabling this, since those five GPIO lines will always control booting. Although you can use the GPIOs for some other function once the Raspberry Pi has booted, you must set them up so that they enable the desired boot modes when the Raspberry Pi boots. To enable GPIO boot mode, add the following line to the `config.txt` file: +[source,ini] ---- program_gpio_bootmode=n ---- -Where n is the bank of GPIOs which you wish to use. Then reboot the Pi once to program the OTP with this setting. Bank 1 is GPIOs 22-26, bank 2 is GPIOs 39-43. Unless you have a Compute Module, you must use bank 1: the GPIOs in bank 2 are only available on the Compute Module. Because of the way the OTP bits are arranged, if you first program GPIO boot mode for bank 1, you then have the option of selecting bank 2 later. The reverse is not true: once bank 2 has been selected for GPIO boot mode, you cannot select bank 1. +Where `n` is the bank of GPIOs which you wish to use. Then reboot the Raspberry Pi once to program the OTP with this setting. Bank 1 is GPIOs 22-26, Bank 2 is GPIOs 39-43. Unless you have a Compute Module, you must use bank 1: the GPIOs in Bank 2 are only available on the Compute Module. Because of the way the OTP bits are arranged, if you first program GPIO boot mode for Bank 1, you then have the option of selecting Bank 2 later. The reverse is not true: once Bank 2 has been selected for GPIO boot mode, you cannot select Bank 1. -Once GPIO boot mode is enabled, the Raspberry Pi will no longer boot. You must pull up at least one boot mode GPIO pin in order for the Pi to boot. +Once GPIO boot mode is enabled, the Raspberry Pi will no longer boot. You must pull up at least one boot-mode GPIO pin in order for the Raspberry Pi to boot. -=== Pin Assignments +=== Pin assignments ==== Raspberry Pi 3B and Compute Module 3 @@ -43,9 +44,9 @@ Once GPIO boot mode is enabled, the Raspberry Pi will no longer boot. You must p | USB |=== -USB in the table above selects both USB device boot mode and USB host boot mode. In order to use a USB boot mode, it must by enabled in the OTP memory. For more information, see xref:raspberry-pi.adoc#usb-device-boot-mode[USB device boot] and xref:raspberry-pi.adoc#usb-host-boot-mode[USB host boot]. +USB in the table above selects both USB device boot mode and USB host boot mode. In order to use a USB boot mode, it must be enabled in the OTP memory. For more information, see xref:raspberry-pi.adoc#usb-device-boot-mode[USB device boot] and xref:raspberry-pi.adoc#usb-host-boot-mode[USB host boot]. -==== Raspberry Pi 3A+, 3B+ and Compute Module 3+ +==== Later Raspberry Pi 3B (BCM2837B0 with the metal lid), Raspberry Pi 3A+, 3B+ and Compute Module 3+ [cols="^,^,^"] |=== @@ -77,13 +78,13 @@ USB in the table above selects both USB device boot mode and USB host boot mode. | 26 | 43 -| USB host - ethernet +| USB host - Ethernet |=== NOTE: The various boot modes are attempted in the numerical order of the GPIO lines, i.e. SD0, then SD1, then NAND and so on. -=== Boot Flow +=== Boot flow -SD0 is the Broadcom SD card / MMC interface. When the boot ROM within the SoC runs, it always connects SD0 to the built-in microSD card slot. On Compute Modules with an eMMC device, SD0 is connected to that; on the Compute Module Lite SD0 is available on the edge connector and connects to the microSD card slot in the CMIO carrier board. SD1 is the Arasan SD card / MMC interface which is also capable of SDIO. All Raspberry Pi models with built-in wireless LAN use SD1 to connect to the wireless chip via SDIO. +SD0 is the Broadcom SD card/MMC interface. When the boot ROM within the SoC runs, it always connects SD0 to the built-in microSD card slot. On Compute Modules with an eMMC device, SD0 is connected to that; on the Compute Module Lite SD0 is available on the edge connector and connects to the microSD card slot in the CMIO carrier board. SD1 is the Arasan SD card/MMC interface which is also capable of SDIO. All Raspberry Pi models with built-in wireless LAN use SD1 to connect to the wireless chip via SDIO. -The default pull resistance on the GPIO lines is 50K ohm, as documented on page 102 of the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[BCM2835 ARM peripherals datasheet]. A pull resistance of 5K ohm is recommended to pull a GPIO line up: this will allow the GPIO to function but not consume too much power. +The default pull resistance on the GPIO lines is 50KΩ, as documented on page 102 of the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[BCM2835 ARM peripherals datasheet]. A pull resistance of 5KΩ is recommended to pull a GPIO line up: this will allow the GPIO to function but not consume too much power. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-http.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-http.adoc new file mode 100644 index 0000000000..f062624dc2 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/boot-http.adoc @@ -0,0 +1,138 @@ +== HTTP boot + +The network install feature uses HTTP over Ethernet to boot the Raspberry Pi into embedded xref:getting-started.adoc#raspberry-pi-imager[Raspberry Pi Imager]. + +In addition to network install, you can explicitly boot your device with files downloaded via HTTP with xref:raspberry-pi.adoc#BOOT_ORDER[boot-mode] `7`. You can still use this even if xref:raspberry-pi.adoc#NET_INSTALL_ENABLED[network install on boot is disabled]. + +You could, for example, add this to your `BOOT_ORDER` as a fall-back boot method, or put it behind a GPIO conditional to initiate HTTP boot from your own server when a GPIO pin is pulled low. + +For example, if you added the following to your EEPROM config and GPIO 8 (which has a default state of 1 or HIGH) were to be pulled low, the files `\http://downloads.raspberrypi.org:80/net_install/boot.img` and `\http://downloads.raspberrypi.org:80/net_install/boot.sig` would be downloaded. If network install on boot were enabled, it would use the same URL. If GPIO 8 were not pulled low the behaviour would be unchanged. + +[source,ini] +---- +[gpio8=0] +BOOT_ORDER=0xf7 +HTTP_HOST=downloads.raspberrypi.org +NET_INSTALL_ENABLED=0 +---- + +`boot.img` and the `boot.sig` signature file is a ram disk containing a boot file system. For more details, see xref:config_txt.adoc#boot_ramdisk[boot_ramdisk]. + +HTTP in the `BOOT_ORDER` will be ignored if secure boot is enabled and xref:raspberry-pi.adoc#HTTP_HOST[HTTP_HOST] is not set. + +=== Requirements + +To use HTTP boot, xref:raspberry-pi.adoc#bootloader_update_stable[update] to a bootloader released 10th March 2022 or later. HTTP boot requires a wired Ethernet connection. + +To use custom CA certificates, xref:raspberry-pi.adoc#bootloader_update_stable[update] to a bootloader released 5th April 2024 or later. Only devices running the BCM2712 CPU support custom CA certificates. + +=== Keys + +All HTTP downloads must be signed. The bootloader includes a public key for the files on the default host `fw-download-alias1.raspberrypi.com`. This key will be used to verify the network install image, _unless_ you set xref:raspberry-pi.adoc#HTTP_HOST[HTTP_HOST] _and_ include a public key in the EEPROM. This allows you to host the Raspberry Pi network install images on your own server. + +WARNING: Using your own network install image will require you to sign the image and add your public key to the EEPROM. If you then apply a public EEPROM update, your key will be lost and will need to be re-added. + +https://github.com/raspberrypi/usbboot/blob/master/Readme.md[`USBBOOT`] has all the tools needed to program public keys. + +Use the following command to add your public key to the EEPROM. `boot.conf` contains your modifications: + +[source,console] +---- +$ rpi-eeprom-config -c boot.conf -p mypubkey.pem -o pieeprom.upd pieeprom.original.bin +---- + +Use the following command to generate a signature for your EEPROM: + +[source,console] +---- +$ rpi-eeprom-digest -i pieeprom.upd -o pieeprom.sig +---- + +Then, use the following command to sign the network install image with your private key: + +[source,console] +---- +$ rpi-eeprom-digest -i boot.img -o boot.sig -k myprivkey.pem +---- + +Finally, put `boot.img` and `boot.sig` on your web server to use your own signed network install image. + +=== Certificates + +For security, Network Install uses HTTPS to download OS images from the Raspberry Pi website. This feature uses our own CA root included in the bootloader to verify the host. + +You can add your own custom CA certificate to your device EEPROM to securely download images from your own website. Use the `--cacertder` option of the `rpi-eeprom-config` tool to add the DER-encoded certificate. You must place a hash of the certificate in the EEPROM config settings to ensure that the certificate is not modified. + +Run the following command to generate a DER-encoded certificate: + +[source,console] +---- +$ openssl x509 -in your_ca_root_cert.pem -out cert.der -outform DER +---- + +Then, run the following command to generate a SHA-256 hash of the certificate: + +[source,console] +---- +$ sha256sum cert.der +---- + +You should see output similar to the following: + +---- +701bd97f67b0f5483a9734e6e5cf72f9a123407b346088638f597878563193fc cert.der +---- + +Next, update `boot.conf` to include the hash of the certificate: + +[source,console] +---- +$ sudo rpi-eeprom-config --edit +---- + +Configure the following settings in the `[gpio8=0]` section, replacing: + +* `` with xref:raspberry-pi.adoc#HTTP_HOST[your website], e.g. `yourserver.org` +* `` with the xref:raspberry-pi.adoc#HTTP_PATH[path to your OS image] hosted on your website, e.g. `path/to/files` +* `` with the hash value you generated above, e.g. `701bd97f67b0f5483a9734e6e5cf72f9a123407b346088638f597878563193fc` + +[source,ini] +---- +[all] +BOOT_UART=1 +POWER_OFF_ON_HALT=0 +BOOT_ORDER=0xf461 + +[gpio8=0] +BOOT_ORDER=0xf7 +NET_INSTALL_ENABLED=0 +HTTP_HOST= +HTTP_PATH= +HTTP_CACERT_HASH= +---- + +When you specify a `HTTP_CACERT_HASH`, Network Install downloads the image using HTTPS over port 443. Without a hash, Network install downloads the image using HTTP over port 80. + +Finally, use the following commands to load everything into EEPROM: + +[source,console] +---- +$ rpi-eeprom-config -c boot.conf -p mypubkey.pem -o pieeprom.bin --cacertder cert.der pieeprom.original.bin +$ rpi-eeprom-digest -k myprivkey.pem -i pieeprom.bin -o pieeprom.sig +---- + +During network boot, your Raspberry Pi should use HTTPS instead of HTTP. To see the full HTTPS URL resolved by Network Install for the download, check the boot output: + +---- +Loading boot.img ... +HTTP: GET request for https://yourserver.org:443/path/to/files/boot.sig +HTTP: GET request for https://yourserver.org:443/path/to/files/boot.img +---- + +=== Secure boot + +If secure boot is enabled, then the Raspberry Pi can only run code signed by the customer's private key. So if you want to use network install or HTTP boot mode with secure boot, you must sign `boot.img` and generate `boot.sig` with your own key and host these files somewhere for download. The public key in the EEPROM will be used to verify the image. + +If secure boot is enabled and xref:raspberry-pi.adoc#HTTP_HOST[HTTP_HOST] is not set, then network install and HTTP boot will be disabled. + +For more information about secure boot see https://github.com/raspberrypi/usbboot/blob/master/secure-boot-recovery/README.md[`USBBOOT`]. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-msd.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-msd.adoc index 97dc80665a..21b4689baa 100644 --- a/documentation/asciidoc/computers/raspberry-pi/boot-msd.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/boot-msd.adoc @@ -1,96 +1,92 @@ -== USB Mass Storage Boot +== USB mass storage boot -NOTE: Available on Raspberry Pi 2B v1.2, 3A+, 3B, 3B+, 4B, 400, Compute Module 3, Compute Module 3+ and Compute Module 4 only. +NOTE: Available on the xref:raspberry-pi.adoc#compute-module-series[Compute Module series since Compute Module 3], xref:raspberry-pi.adoc#zero-series[Zero series since Zero 2 W], and xref:raspberry-pi.adoc#flagship-series[all flagship series devices since Raspberry Pi 2B (version 1.2)]. -This page explains how to boot your Raspberry Pi from a USB mass storage device such as a flash drive or a USB hard disk. When attaching USB devices, particularly hard disks and SSDs, be mindful of their power requirements. If you wish to attach more than one SSD or hard disk to the Pi, this normally requires external power - either a powered hard disk enclosure, or a powered USB hub. Note that models prior to the Pi 4B have known issues which prevent booting with some USB devices. +USB mass storage boot enables you to boot your Raspberry Pi from a USB mass storage device such as a flash drive or USB disk. When attaching USB devices, particularly hard disks and SSDs, be mindful of their power requirements. Attaching more than one disk typically requires additional external power from either a powered disk enclosure or a powered USB hub. -[[pi4]] -=== Raspberry Pi 4B and Raspberry Pi 400 - -The Raspberry Pi Pi 400 and newer Raspberry Pi 4B boards support USB boot by default. On earlier Raspberry Pi 4B boards, or to select alternate boot modes, the bootloader must be updated. +NOTE: Models prior to Raspberry Pi 4B have known issues which prevent booting with some USB devices. -See:- +=== Devices with an EEPROM bootloader -* Instructions for changing the boot mode via the xref:raspberry-pi.adoc#imager[Raspberry Pi Imager]. -* Instructions for changing the boot mode via the xref:raspberry-pi.adoc#raspi-config[raspi-config]. -* The xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[bootloader configuration] page for other boot configuration options. +[[pi4]] [[cm4]] -=== Compute Module 4 -Please see the xref:compute-module.adoc#flashing-the-compute-module-emmc[Flashing the Compute Module eMMC] for bootloader update instructions. +Raspberry Pi 4 and newer flagship series devices and Compute module devices since Compute Module 4 and 4S support USB boot by default, as long as you specify USB boot in the xref:raspberry-pi.adoc#BOOT_ORDER[`BOOT_ORDER`] configuration. + +NOTE: Early editions of Raspberry Pi 4 may require a xref:raspberry-pi.adoc#raspi-config[bootloader update] to boot from USB. + +NOTE: Early editions of Compute Module 4 may require a xref:compute-module.adoc#update-the-compute-module-bootloader[bootloader update] to boot from USB. === Raspberry Pi 3B+ The Raspberry Pi 3B+ supports USB mass storage boot out of the box. -=== Raspberry Pi 2B, 3A+, 3B, CM 3, 3+ +=== Raspberry Pi 2B, 3A+, 3B, CM3, CM3+, Zero 2 W -On the Raspberry Pi 2B v1.2, 3A+, 3B, and Compute Module 3, 3+ you must first enable xref:raspberry-pi.adoc#usb-host-boot-mode[USB host boot mode]. This is to allow USB mass storage boot, and xref:raspberry-pi.adoc#network-booting[network boot]. Note that network boot is not supported on the Raspberry Pi 3A+. +On Raspberry Pi 2B v1.2, 3A+, 3B, Zero 2 W, and Compute Module 3 and 3+, you must first enable xref:raspberry-pi.adoc#usb-host-boot-mode[USB host boot mode]. This allows USB mass storage boot and xref:raspberry-pi.adoc#network-booting[network boot]. -To enable USB host boot mode, the Raspberry Pi needs to be booted from an SD card with a special option to set the USB host boot mode bit in the one-time programmable (OTP) memory. Once this bit has been set, the SD card is no longer required. +NOTE: Raspberry Pi 3A+ and Zero 2 W do not support network boot. -IMPORTANT: Any change you make to the OTP is permanent and cannot be undone. +To enable USB host boot mode on these devices, set the USB host bit in OTP (one-time programmable) memory. To set the bit, boot from an SD card where xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] contains the line `program_usb_boot_mode=1`. Once you set the bit, you can boot from USB without the SD card. -NOTE: On the Raspberry Pi 3A+, setting the OTP bit to enable USB host boot mode will permanently prevent that Pi from booting in USB device mode. +==== Enable USB host boot mode with OTP -You can use any SD card running Raspberry Pi OS to program the OTP bit. +[WARNING] +==== +Any change you make to OTP (one-time programmable) memory is permanent and cannot be undone. -Enable USB host boot mode with this code: +On Raspberry Pi 3A+, setting the OTP bit to enable USB host boot mode will permanently prevent that Raspberry Pi from booting in USB device mode. +==== -[,bash] ----- -echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt ----- +Use any SD card flashed with Raspberry Pi OS to program the OTP bit. -This adds `program_usb_boot_mode=1` to the end of `/boot/config.txt`. +To enable USB host boot mode, add the following line to `config.txt`: -Note that although the option is named `program_usb_boot_mode`, it only enables USB _host_ boot mode. USB _device_ boot mode is only available on certain models of Raspberry Pi - see xref:raspberry-pi.adoc#usb-device-boot-mode[USB device boot mode]. +[source,ini] +---- +program_usb_boot_mode=1 +---- -The next step is to reboot the Raspberry Pi with `sudo reboot` and check that the OTP has been programmed with: +Then, use `sudo reboot` to reboot your Raspberry Pi. To check that the OTP has been programmed correctly, run the following command: -[,bash] +[source,console] ---- -vcgencmd otp_dump | grep 17: +$ vcgencmd otp_dump | grep 17: 17:3020000a ---- -Check that the output `0x3020000a` is shown. If it is not, then the OTP bit has not been successfully programmed. In this case, go through the programming procedure again. If the bit is still not set, this may indicate a fault in the Pi hardware itself. +If the output reads `0x3020000a`, the OTP has been successfully programmed. If you see different output, try the programming procedure again. Make sure there is no blank line at the end of `config.txt`. -If you wish, you can remove the `program_usb_boot_mode` line from `config.txt`, so that if you put the SD card into another Raspberry Pi, it won't program USB host boot mode. Make sure there is no blank line at the end of `config.txt`. +You can now boot from a USB mass storage device in the same way as booting from an SD card. See the following section for further information. -You can now boot from a USB mass storage device in the same way as booting from an SD card - see the following section for further information. +=== Boot from USB mass storage -=== Booting from USB Mass Storage +The xref:getting-started.adoc#installing-the-operating-system[procedure] is the same as for SD cards - flash the USB storage device with the operating system image. -The xref:getting-started.adoc#installing-the-operating-system[procedure] is the same as for SD cards - simply image the USB storage device with the operating system image. +After preparing the storage device, connect the drive and power up the Raspberry Pi, being aware of the extra USB power requirements of the external drive. -After preparing the storage device, connect the drive to the Raspberry Pi and power up the Pi, being aware of the extra USB power requirements of the external drive. -After five to ten seconds, the Raspberry Pi should begin booting and show the rainbow splash screen on an attached display. Make sure that you do not have an SD card inserted in the Pi, since if you do, it will boot from that first. +After five to ten seconds, the Raspberry Pi should begin booting and show the rainbow splash screen on an attached display. Make sure that you do not have an SD card inserted in the Raspberry Pi, since if you do, it will boot from that first. -See the xref:raspberry-pi.adoc#raspberry-pi-boot-modes[bootmodes documentation] for the boot sequence and alternative boot modes (network, USB device, GPIO or SD boot). +See the xref:raspberry-pi.adoc#raspberry-pi-boot-modes[boot modes documentation] for the boot sequence and alternative boot modes (network, USB device, GPIO or SD boot). -=== Known Issues +=== Known issues -IMPORTANT: These do *not* apply to Raspberry Pi 4, Model B. - -* The default timeout for checking bootable USB devices is 2 seconds. Some flash drives and hard disks power up too slowly. It is possible to extend this timeout to five seconds (add a new file `timeout` to the SD card), but note that some devices take even longer to respond. +* The default timeout for checking bootable USB devices is two seconds. Some flash drives and hard disks power up too slowly. It is possible to extend this timeout to five seconds (add a new file `timeout` to the SD card), but note that some devices take even longer to respond. * Some flash drives have a very specific protocol requirement that is not handled by the bootcode and may thus be incompatible. -=== Special `bootcode.bin`-only Boot Mode - -IMPORTANT: This do *not* apply to Raspberry Pi 4, Model B. +=== Special `bootcode.bin`-only boot mode -If you are unable to use a particular USB device to boot your Raspberry Pi, an alternative for the Pi 2B v1.2, 3A+, 3B and 3B+ is to use the special xref:raspberry-pi.adoc#raspberry-pi-boot-modes[bootcode.bin-only] boot mode. The Raspberry Pi will still boot from the SD card, but `bootcode.bin` is the only file read from it. +On Raspberry Pi 2B v1.2, 3A+, 3B and 3B+, if you are unable to use a particular USB device to boot your Raspberry Pi, you can instead use xref:raspberry-pi.adoc#raspberry-pi-boot-modes[`bootcode.bin`-only] boot mode. The Raspberry Pi will still boot from the SD card, but only reads `bootcode.bin` from the SD card; the rest of your operating system lives on the USB device. -=== Hardware Compatibility +=== Hardware compatibility -Before attempting to boot from a USB mass storage device it is advisable to verify that the device works correctly under Linux. Boot using an SD card and plug in the USB mass storage device. This should appears as a removable drive. This is especially important with USB SATA adapters which may be supported by the bootloader in mass storage mode but fail if Linux selects https://en.wikipedia.org/wiki/USB_Attached_SCSI[USB Attached SCSI - UAS] mode. See this https://www.raspberrypi.org/forums/viewtopic.php?t=245931[forum thread] about UAS and how to add https://www.kernel.org/doc/html/v5.0/admin-guide/kernel-parameters.html[usb-storage.quirks] to workaround this issue. +Before booting from a USB mass storage device, verify that the device works correctly under Linux. Boot using an SD card and plug in the USB mass storage device. This should appear as a removable drive. This is especially important with USB SATA adapters, which may be supported by the bootloader in mass storage mode, but fail if Linux selects https://en.wikipedia.org/wiki/USB_Attached_SCSI[USB Attached SCSI-UAS] mode. -Spinning hard disk drives nearly always require a powered USB hub. Even if it appears to work you are likely to encounter intermittent failures without a powered USB HUB. +Hard disk drives (HDDs) typically require a powered USB hub. Even if everything appears to work, you may encounter intermittent failures without a powered USB hub. -=== Multiple Bootable Drives +=== Multiple bootable drives -When searching for a bootable partition the bootloader scans all USB mass storage devices in parallel and will select the first to respond. If the boot partition does not contain a suitable `start.elf` file the next available device is selected. There is no method for specifying the boot device according to the USB topology because this would slow down boot and adds unnecessary and hard to support configuration complexity. +When searching for a bootable partition, the bootloader scans all USB mass storage devices in parallel and selects the first to respond. If the boot partition does not contain a suitable `start.elf` file, the bootloader attempts the next available device. There is no method for specifying the boot device according to the USB topology; this would slow down boot and adds unnecessary configuration complexity. -NOTE: The `config.txt` file xref:config_txt.adoc#conditional-filters[conditional filters] can be used to select alternate firmware in complex device configurations. +NOTE: Use `config.txt` file xref:config_txt.adoc#conditional-filters[conditional filters] to select alternate firmware in complex device configurations. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-net.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-net.adoc index 5d797a89ec..48b60a21fc 100644 --- a/documentation/asciidoc/computers/raspberry-pi/boot-net.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/boot-net.adoc @@ -1,47 +1,57 @@ -== Network Booting +== Network booting -This section describes how network booting works on the Raspberry Pi 3B, 3B+ and 2B v1.2. On the Raspberry Pi 4 network booting is implemented in the second stage bootloader in the EEPROM. Please see the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[Pi 4 Bootloader Configuration] page for more information. -We also have a xref:remote-access.adoc#network-boot-your-raspberry-pi[tutorial about setting up a network boot system]. Network booting works only for the wired adapter built into the above models of Raspberry Pi. Booting over wireless LAN is not supported, nor is booting from any other wired network device. +This section describes how network booting works on Raspberry Pi 3B, 3B+ and 2B v1.2. + +On Pi 4 and Pi 5, network booting is implemented in the second stage bootloader in the EEPROM. For more information, see xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[Raspberry Pi bootloader configuration]. + +We also have a xref:remote-access.adoc#network-boot-your-raspberry-pi[tutorial about setting up a network boot system]. + +Network booting works only for the wired adapter built into the above models of Raspberry Pi. Booting over wireless LAN is not supported, nor is booting from any other wired network device. + +=== Network boot flow To network boot, the boot ROM does the following: * Initialise on-board Ethernet device (Microchip LAN9500 or LAN7500) -* Send DHCP request (with Vendor Class identifier DHCP option 60 set to 'PXEClient:Arch:00000:UNDI:002001') +* Send DHCP request (with Vendor Class identifier DHCP option 60 set to `PXEClient:Arch:00000:UNDI:002001`) * Receive DHCP reply * (optional) Receive DHCP proxy reply * ARP to tftpboot server * ARP reply includes tftpboot server ethernet address -* TFTP RRQ 'bootcode.bin' +* TFTP RRQ `bootcode.bin` ** File not found: Server replies with TFTP error response with textual error message ** File exists: Server will reply with the first block (512 bytes) of data for the file with a block number in the header - *** Pi replies with TFTP ACK packet containing the block number, and repeats until the last block which is not 512 bytes -* TFTP RRQ 'bootsig.bin' + *** Raspberry Pi replies with TFTP ACK packet containing the block number, and repeats until the last block which is not 512 bytes +* TFTP RRQ `bootsig.bin` ** This will normally result in an error `file not found`. This is to be expected, and TFTP boot servers should be able to handle it. -From this point the `bootcode.bin` code continues to load the system. The first file it will try to access is [`serial_number`]/start.elf. If this does not result in a error then any other files to be read will be pre-pended with the `serial_number`. This is useful because it enables you to create separate directories with separate start.elf / kernels for your Pis +From this point the `bootcode.bin` code continues to load the system. The first file it will try to access is `/start.elf`. If this does not result in an error then any other files to be read will be prepended with the `serial_number`. This is useful because it enables you to create separate directories with separate `start.elf` / kernels for your Raspberry Pis. + To get the serial number for the device you can either try this boot mode and see what file is accessed using tcpdump / wireshark, or you can run a standard Raspberry Pi OS SD card and `cat /proc/cpuinfo`. -If you put all your files into the root of your tftp directory then all following files will be accessed from there. +If you put all your files into the root of your TFTP directory then all following files will be accessed from there. -=== Debugging Network Boot Mode +=== Debugging network boot mode -The first thing to check is that the OTP bit is correctly programmed. To do this, you need to add `program_usb_boot_mode=1` to config.txt and reboot (with a standard SD card that boots correctly into Raspberry Pi OS). Once you've done this, you should be able to do: +The first thing to check is that the OTP bit is correctly programmed. To do this, you need to add `program_usb_boot_mode=1` to `config.txt` and reboot (with a standard SD card that boots correctly into Raspberry Pi OS). Once you've done this, you should be able to do: - $ vcgencmd otp_dump | grep 17: - 17:3020000a +[source,console] +---- +$ vcgencmd otp_dump | grep 17: +---- -If row 17 contains that value then the OTP is correctly programmed. You should now be able to remove the SD card, plug in Ethernet, -and then the Ethernet LEDs should light up around 5 seconds after the Pi powers up. +If row 17 contains `3020000a` then the OTP is correctly programmed. You should now be able to remove the SD card, plug in Ethernet, and then the Ethernet LEDs should light up around 5 seconds after the Raspberry Pi powers up. -To capture the ethernet packets on the server, use tcpdump on the tftpboot server (or DHCP server if they are different). You will need to capture the packets there otherwise you will not be able to see packets that get sent directly because network switches are not hubs! +To capture the Ethernet packets on the server, use tcpdump on the tftpboot server (or DHCP server if they are different). You will need to capture the packets there otherwise you will not be able to see packets that get sent directly because network switches are not hubs! +[source,console] ---- -sudo tcpdump -i eth0 -w dump.pcap +$ sudo tcpdump -i eth0 -w dump.pcap ---- -This will write everything from eth0 to a file dump.pcap you can then post process it or upload it to cloudshark.com for communication +This will write everything from eth0 to a file named `dump.pcap`. You can then post-process or upload the packets to cloudshark for communication. -==== DHCP Request / Reply +==== DHCP request / reply As a minimum you should see a DHCP request and reply which looks like the following: @@ -81,12 +91,11 @@ As a minimum you should see a DHCP request and reply which looks like the follow END Option 255, length 0 ---- -The important part of the reply is the Vendor-Option Option 43. This needs to contain the string "Raspberry Pi Boot", although, due -to a bug in the boot ROM, you may need to add three spaces to the end of the string. +`Vendor-Option Option 43` contains the important part of the reply. This must contain the string "Raspberry Pi Boot". Due to a bug in the boot ROM, you may need to add three spaces to the end of the string. ==== TFTP file read -You will know whether the Vendor Option is correctly specified: if it is, you'll see a subsequent TFTP RRQ packet being sent. RRQs can be replied to by either the first block of data or an error saying file not found. In a couple of cases they even receive the first packet and then the transmission is aborted by the Pi (this happens when checking whether a file exists). The example below is just three packets: the original read request, the first data block (which is always 516 bytes containing a header and 512 bytes of data, although the last block is always less than 512 bytes and may be zero length), and the third packet (the ACK which contains a frame number to match the frame number in the data block). +When the Vendor Option is correctly specified, you'll see a subsequent TFTP RRQ packet being sent. RRQs can be replied to by either the first block of data or an error saying file not found. In a couple of cases they even receive the first packet and then the transmission is aborted by the Raspberry Pi (this happens when checking whether a file exists). The example below is just three packets: the original read request, the first data block (which is always 516 bytes containing a header and 512 bytes of data, although the last block is always less than 512 bytes and may be zero length), and the third packet (the ACK which contains a frame number to match the frame number in the data block). ---- 16:44:41.224964 IP (tos 0x0, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 49) @@ -97,13 +106,13 @@ You will know whether the Vendor Option is correctly specified: if it is, you'll 192.168.1.139.49152 > 192.168.1.1.55985: [no cksum] UDP, length 4 ---- -=== Known Problems +=== Known problems -There are a number of known problems with the Ethernet boot mode. Since the implementation of the boot modes is in the chip itself, there are no workarounds other than to use an SD card with just the bootcode.bin file. +There are a number of known problems with the Ethernet boot mode. Since the implementation of the boot modes is in the chip itself, there are no workarounds other than to use an SD card with just the `bootcode.bin` file. ==== DHCP requests time out after five tries -The Raspberry Pi will attempt a DHCP request five times with five seconds in between, for a total period of 25 seconds. If the server is not available to respond in this time, then the Pi will drop into a low-power state. There is no workaround for this other than bootcode.bin on an SD card. +The Raspberry Pi will attempt a DHCP request five times with five seconds in between, for a total period of 25 seconds. If the server is not available to respond in this time, then the Raspberry Pi will drop into a low-power state. There is no workaround for this other than bootcode.bin on an SD card. ==== TFTP server on separate subnet not supported @@ -115,11 +124,11 @@ The DHCP check also checked if the hops value was `1`, which it wouldn't be with Fixed in Raspberry Pi 3 Model B+. -==== Raspberry Pi Boot string +==== Raspberry Pi boot string The "Raspberry Pi Boot " string in the DHCP reply requires the extra three spaces due to an error calculating the string length. -Fixed in Raspberry Pi 3 Model B+ +Fixed in Raspberry Pi 3 Model B+. ==== DHCP UUID constant @@ -129,12 +138,12 @@ Fixed in Raspberry Pi 3 Model B+; the value is set to the 32-bit serial number. ==== ARP check can fail to respond in the middle of TFTP transaction -The Raspberry Pi will only respond to ARP requests when it is in the initialsation phase; once it has begun transferring data, it'll fail to continue reponding. +The Raspberry Pi will only respond to ARP requests when it is in the initialisation phase; once it has begun transferring data, it'll fail to continue responding. Fixed in Raspberry Pi 3 Model B+. ==== DHCP request/reply/ack sequence not correctly implemented -At boot time, Raspberry Pi broadcasts a DHCPDISCOVER packet. The DHCP server replies with a DHCPOFFER packet. The Pi then continues booting without doing a DHCPREQUEST or waiting for DHCPACK. This may result in two separate devices being offered the same IP address and using it without it being properly assigned to the client. +At boot time, Raspberry Pi broadcasts a DHCPDISCOVER packet. The DHCP server replies with a DHCPOFFER packet. The Raspberry Pi then continues booting without doing a DHCPREQUEST or waiting for DHCPACK. This may result in two separate devices being offered the same IP address and using it without it being properly assigned to the client. Different DHCP servers have different behaviours in this situation. dnsmasq (depending upon settings) will hash the MAC address to determine the IP address, and ping the IP address to make sure it isn't already in use. This reduces the chances of this happening because it requires a collision in the hash. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-nvme.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-nvme.adoc index a1c4dedf76..ba6390ea7b 100644 --- a/documentation/asciidoc/computers/raspberry-pi/boot-nvme.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/boot-nvme.adoc @@ -1,83 +1,55 @@ -== NVMe SSD Boot +== NVMe SSD boot -IMPORTANT: As if August 2021 booting from an NVMe SDD is in *BETA*. +NVMe (Non-Volatile Memory express) is a standard for external storage access over a PCIe bus. You can connect NVMe drives via the PCIe slot on Compute Module 4 IO Board, the M.2 slot on Compute Module 5 IO Board, and Raspberry Pi 5 using an M.2 HAT+. With some additional configuration, you can boot from an NVMe drive. -NVMe (non-volatile memory express) is a standard for accessing solid state drives (SSDs) via a PCIe bus. You can connect these drives via the PCIe slot on a Compute Module 4 (CM4) IO board, allowing a CM4 to boot from SSD. +=== Prerequisites -=== Required Hardware +==== Hardware -You need an NVMe M.2 SSD. You cannot plug an M.2 SSD directly into the PCIe slot on the IO board - an adaptor is needed. Be careful to get the correct type: a suitable adaptor can be found online by searching for 'PCI-E 3.0 x1 Lane to M.2 NGFF M-Key SSD Nvme PCI Express Adapter Card'. +* NVMe M.2 SSD +* an adapter to convert from PCIe to an M.2 standard. +** For Raspberry Pi 5, we recommend the xref:../accessories/m2-hat-plus.adoc[M.2 HAT+], which converts from the Raspberry Pi's *PCIe FFC* slot to an M Key interface. +** For the CM4, search for a "PCI-E 3.0 ×1 lane to M.2 NGFF M-Key SSD NVMe PCI Express adapter card" -Raspberry Pi OS supports accessing NVMe drives, although booting from NVMe is currently only supported using pre-release software (see 'required software' below). To check that your NVMe drive is connected correctly, boot Raspberry Pi OS from another drive and run `ls -l /dev/nvme*`; example output is shown below. +To check that your NVMe drive is connected correctly, boot your Raspberry Pi from another storage device (such as an SD card) and run `ls -l /dev/nvme*`. Example output is shown below. ---- crw------- 1 root root 245, 0 Mar 9 14:58 /dev/nvme0 brw-rw---- 1 root disk 259, 0 Mar 9 14:58 /dev/nvme0n1 ---- -If you need to connect the NVMe drive to a PC or Mac you can use a USB adaptor: search for 'NVME PCI-E M-Key Solid State Drive External Enclosure'. The enclosure must support M key SSDs. +==== Software -=== Required Software - -To boot from NVMe you need pre-release versions of the bootloader, VideoCore firmware and Raspberry Pi OS Linux kernel. - -==== Bootloader - -You need to use `rpiboot` to update the CM4 bootloader. Instructions for building `rpiboot` and configuring the IO board to switch the ROM to usbboot mode are in the https://github.com/raspberrypi/usbboot[usbboot Github repository]. - -If you are using a CM4 with an eMMC then you must change the BOOT_ORDER to give NVMe priority, otherwise the CM4 will continue to boot from eMMC. For example: +First, ensure that your Raspberry Pi runs the latest software. Run the following command to update: +[source,console] ---- -cd usbboot/nvme -sed -i 's/\(BOOT_ORDER=.*\)6\(.*\)/\1\26/' boot.conf -./update-pieeprom.sh -cd .. +$ sudo apt update && sudo apt full-upgrade ---- -You can then update your bootloader to support NVMe boot with `./rpiboot -d nvme`; example output is shown below. +=== Edit the bootloader boot priority + +Use the Raspberry Pi Software Configuration Tool to update the bootloader: +[source,console] ---- -Loading: nvme/bootcode4.bin -Waiting for BCM2835/6/7/2711... -Loading: nvme/bootcode4.bin -Sending bootcode.bin -Successful read 4 bytes -Waiting for BCM2835/6/7/2711... -Loading: nvme/bootcode4.bin -Second stage boot server -Loading: nvme/config.txt -File read: config.txt -Loading: nvme/pieeprom.bin -Loading: nvme/pieeprom.bin -Loading: nvme/pieeprom.sig -File read: pieeprom.sig -Loading: nvme/pieeprom.bin -File read: pieeprom.bin -Second stage boot server done +$ sudo raspi-config ---- -==== Firmware and kernel +Under `Advanced Options` > `Boot Order`, specify an option that includes NVMe. It will then write these changes to the bootloader and return to the Config Tool, in which you can `Finish` and reboot. Your Raspberry Pi will use the new boot order now. -You must load pre-release versions of the VideoCore firmware and Raspberry Pi OS Linux kernel to the NVMe disk. When this software is officially released you can simply write the software to the NVMe disk directly with the Raspberry Pi Imager app; until then the easiest way to perform the update is: +For CM4, use `rpiboot` to update the bootloader. You can find instructions for building `rpiboot` and configuring the IO board to switch the ROM to usbboot mode in the https://github.com/raspberrypi/usbboot[USB boot GitHub repository]. -. Boot the CM4 with a blank SSD connected to the PCIe slot -. Use the `SD Card Copier` application on the desktop to copy the running OS image to the NVMe disk, making sure to enable the "new partition ids" option. -. Update the firmware and kernel on the NVMe disk to the latest pre-release versions using xref:os.adoc#rpi-update[rpi-update]: -+ ----- -mkdir mnt -mkdir mnt/fat32 -mkdir mnt/ext4 -sudo mount /dev/nvme0n1p1 mnt/fat32 -sudo mount /dev/nvme0n1p2 mnt/ext4 -sudo ROOT_PATH=mnt/ext4 BOOT_PATH=mnt/fat32 rpi-update ----- +For versions of CM4 with an eMMC, make sure you have set NVMe first in the boot order. Remember to add the NVMe boot mode `6` to `BOOT_ORDER` in `recovery/boot.conf`. + +CM4 Lite automatically boots from NVMe when the SD card slot is empty. -Finally, if you are using CM4 lite, remove the SD card and the board will boot from the NVMe disk. For versions of CM4 with an eMMC, make sure you have set NVMe first in the boot order. +=== NVMe `BOOT_ORDER` -==== NVMe BOOT_ORDER +The `BOOT_ORDER` setting in EEPROM configuration controls boot behaviour. +For NVMe boot, use boot mode `6`. For more information, see xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[Raspberry Pi bootloader configuration]. -This boot behaviour is controlled via the `BOOT_ORDER` setting in the EEPROM configuration: we have added a new boot mode `6` for NVMe. See xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[Raspberry Pi 4 Bootloader Configuration]. +=== Example Below is an example of UART output when the bootloader detects the NVMe drive: @@ -108,44 +80,10 @@ In Linux the SSD appears as `/dev/nvme0` and the "namespace" as `/dev/nvme0n1`. ---- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 259:0 0 232.9G 0 disk -├─nvme0n1p1 259:1 0 256M 0 part /boot +├─nvme0n1p1 259:1 0 256M 0 part /boot/firmware └─nvme0n1p2 259:2 0 232.6G 0 part / ---- === Troubleshooting -If the boot process fails, please file an issue on the https://github.com/raspberrypi/rpi-eeprom[rpi-eeprom Github repository], including a copy of the console and anything displayed on the screen during boot. - -You can enable logging in the bootloader, and update the bootloader with this configuration, using `rpiboot`: - ----- -cd usbboot/nvme -sed -i 's/BOOT_UART=0/BOOT_UART=1/' boot.conf -./update-pieeprom.sh -cd .. -./rpiboot -d nvme ----- - -Enable UART logging in `/boot/config.txt` to allow you to capture logs from the serial port: - ----- -# UART console -enable_uart=1 - -# UART from firmware -uart_2ndstage=1 ----- - -Ensure that you have used `rpi-update` to get the latest pre-release versions of the firmware and Linux kernel; boot from NVMe will not work without these. - -There may be compatibility issues with some SSDs. You can use the following commands to investigate: - ----- -sudo apt-get install nvme-cli -sudo nvme list -sudo nvme id-ctrl -H /dev/nvme0 -sudo nvme list-ns /dev/nvme0 -sudo nvme id-ns -H /dev/nvme0 --namespace-id=1 ----- - -Please post the output of these commands in any error report. +If the boot process fails, please file an issue on the https://github.com/raspberrypi/rpi-eeprom[rpi-eeprom GitHub repository], being sure to attach a copy of the console and anything displayed on the screen during boot. diff --git a/documentation/asciidoc/computers/raspberry-pi/boot-usb.adoc b/documentation/asciidoc/computers/raspberry-pi/boot-usb.adoc index af91201923..f5225e7abf 100644 --- a/documentation/asciidoc/computers/raspberry-pi/boot-usb.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/boot-usb.adoc @@ -1,46 +1,56 @@ -== USB Boot Modes +== USB boot modes -WARNING: The default way of using a Raspberry Pi is to boot it using an SD card. This is the recommended method for new and inexperienced users. +There are two separate boot modes for USB: -There are two separate boot modes for USB; USB device boot and USB host boot. +* USB device boot +* USB host boot -The choice between the two boot modes is made by the firmware at boot time when it reads the OTP bits. There are two bits to control USB boot: the first enables USB device boot and is enabled by default. The second enables USB host boot; if the USB host boot mode bit is set, then the processor reads the OTGID pin to decide whether to boot as a host (driven to zero as on the Raspberry Pi Model B) or as a device (left floating). The Pi Zero has access to this pin through the OTGID pin on the USB connector, and the Compute Module has access to this pin on the edge connector. +The firmware chooses between the two modes at boot time based on the OTP bits. Two bits control USB boot. The first enables USB device boot and is enabled by default; the second enables USB host boot. -There are also OTP bits that allow certain GPIO pins to be used for selecting which boot modes the Pi should attempt to use. +If the USB host boot mode bit is set, the processor reads the OTGID pin to decide whether to boot as a host (driven to zero as on any Raspberry Pi Model B/B+) or as a device (left floating). The Raspberry Pi Zero has access to the OTGID pin through the USB connector; the Compute Module has access to the OTGID pin on the edge connector. -NOTE: USB boot modes only available on certain models. +Some other OTP bits allow certain GPIO pins to select the boot modes. -=== USB Device Boot Mode +=== USB device boot mode -NOTE: Device boot is available on Raspberry Pi Compute Module, Compute Module 3, Raspberry Pi Zero, Zero W, A, A+, and 3A+ only. +NOTE: USB device boot is available on the xref:raspberry-pi.adoc#compute-module-series[Compute Module series], xref:raspberry-pi.adoc#zero-series[Zero series], and xref:raspberry-pi.adoc#flagship-series[Model A variants of the flagship series]. -When this boot mode is activated (usually after a failure to boot from the SD card), the Raspberry Pi puts its USB port into device mode and awaits a USB reset from the host. Example code showing how the host needs to talk to the Pi can be found https://github.com/raspberrypi/usbboot[on Github]. +When this boot mode is activated (usually after a failure to boot from the SD card), the Raspberry Pi puts its USB port into device mode and awaits a USB reset from the host. Example code showing how the host needs to talk to the Raspberry Pi can be found https://github.com/raspberrypi/usbboot[on Github]. -The host first sends a structure to the device down control endpoint 0. This contains the size and signature for the boot (security is not enabled so no signature is required). Secondly, code is transmitted down endpoint 1 (bootcode.bin). Finally, the device will reply with a success code of: +The host first sends a structure to the device down control endpoint 0. This contains the size and signature for the boot (security is not enabled, so no signature is required). Secondly, code is transmitted down endpoint 1 (`bootcode.bin`). Finally, the device will reply with one of the following codes: -* 0 - Success -* 0x80 - Failed +* `0` - Success +* `0x80` - Failure -=== USB Host Boot Mode +=== USB host boot mode -NOTE: Host boot is available on Raspberry Pi 3B, 3B+, 3A+, and 2B v1.2 only. Raspberry Pi 3A+ only supports mass storage boot, not network boot. +NOTE: Host boot is available on the xref:raspberry-pi.adoc#compute-module-series[Compute Module series since Compute Module 3], xref:raspberry-pi.adoc#zero-series[Zero series since Zero 2 W], Raspberry Pi 2B (version 1.2), Raspberry Pi 3B, and xref:raspberry-pi.adoc#flagship-series[all flagship series devices since Raspberry Pi 3B+]. Raspberry Pi 3A+ supports mass storage boot, but not network boot. -The USB host boot mode follows this sequence: +USB host boot mode uses the following logic: -* Enable the USB port and wait for D+ line to be pulled high indicating a USB 2.0 device (we only support USB2.0) -* If the device is a hub: - ** Enable power to all downstream ports of the hub - ** For each port, loop for a maximum of two seconds (or five seconds if `program_usb_boot_timeout=1` has been set) - *** Release from reset and wait for D+ to be driven high to indicate that a device is connected - *** If a device is detected: - **** Send "Get Device Descriptor" - ***** If VID == SMSC && PID == 9500 - ****** Add device to Ethernet device list - **** If class interface == mass storage class - ***** Add device to mass storage device list -* Else - ** Enumerate single device -* Go through mass storage device list - ** Boot from xref:raspberry-pi.adoc#usb-mass-storage-boot[mass storage device] -* Go through Ethernet device list - ** Boot from xref:raspberry-pi.adoc#network-booting[Ethernet] +. Enable the USB port and wait for D+ line to be pulled high indicating a USB 2.0 device (we only support USB2.0) +. If the device is a hub: +.. Enable power to all downstream ports of the hub +.. For each port, loop for a maximum of two seconds (or five seconds if `program_usb_boot_timeout=1` has been set) +... Release from reset and wait for D+ to be driven high to indicate that a device is connected +... If a device is detected: +.... Send "Get Device Descriptor" +..... If `VID == SMSC` && `PID == 9500` +...... Add device to Ethernet device list +.... If the class interface is mass storage class +..... Add device to mass storage device list +. Else +.. Enumerate single device +. Go through mass storage device list +.. Boot from xref:raspberry-pi.adoc#usb-mass-storage-boot[mass storage device] +. Go through Ethernet device list +.. Boot from xref:raspberry-pi.adoc#network-booting[Ethernet] + +On Raspberry Pi 3B, 3A+, and 3B+, host boot is disabled by default. To enable USB host boot, add a line containing `program_usb_boot_mode=1` to the end of xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]. + +[WARNING] +==== +Any change you make to the OTP is permanent and cannot be undone. + +On Raspberry Pi 3A+, setting the OTP bit to enable USB host boot mode will permanently prevent that Raspberry Pi from booting in USB device mode. +==== diff --git a/documentation/asciidoc/computers/raspberry-pi/bootflow-2711.adoc b/documentation/asciidoc/computers/raspberry-pi/bootflow-2711.adoc deleted file mode 100644 index aa1070f2c7..0000000000 --- a/documentation/asciidoc/computers/raspberry-pi/bootflow-2711.adoc +++ /dev/null @@ -1,75 +0,0 @@ -== Raspberry Pi 4 Boot Flow - -The main difference betweeen this and previous products is that the second stage bootloader is loaded from an SPI flash xref:raspberry-pi.adoc#raspberry-pi-4-boot-eeprom[EEPROM] instead of the `bootcode.bin` file on previous products. - -=== First Stage Bootloader - -The boot flow for the ROM (first stage) is as follows:- - -* BCM2711 SoC powers up -* Read OTP to determine if the `nRPIBOOT` GPIO is configured -* If `nRPIBOOT` GPIO is high or OTP does NOT define `nRPIBOOT` GPIO - ** Check OTP to see if `recovery.bin` can be loaded from SD/EMMC - *** If SD recovery.bin is enabled then check primary SD/EMMC for `recovery.bin` - **** Success - run `recovery.bin` and update the SPI EEPROM - **** Fail - continue - ** Check SPI EEPROM for second stage loader - *** Success - run second stage bootloader - *** Fail - continue -* While True - ** Attempt to load recovery.bin from xref:compute-module.adoc#flashing-the-compute-module-emmc[USB device boot] - *** Success - run `recovery.bin` and update the SPI EEPROM or switch to USB mass storage device mode - *** Fail - retry USB device boot - -NOTE: Currently only CM4 reserves a GPIO for `nRPIBOOT`. - -NOTE: `recovery.bin` is a minimal second stage program used to reflash the bootloader SPI EEPROM image. - -=== Second Stage Bootloader - -This section describes the high-level flow of the second stage bootloader. - -Please see the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[bootloader configuration] page for more information about each boot mode and the xref:configuration.adoc#the-boot-folder[boot folder] page for a description of the GPU firmware files loaded by this stage. - -* Initialise clocks and SDRAM -* Read the EEPROM configuration file -* Check `PM_RSTS` register to determine if HALT is requested - ** Check `POWER_OFF_ON_HALT` and `WAKE_ON_GPIO` EEPROM configuration settings. - ** If `POWER_OFF_ON_HALT` is `1` and `WAKE_ON_GPIO` is `0` then - *** Use PMIC to power off system - ** else if `WAKE_ON_GPIO` is `1` - *** Enable fall-edge interrupts on GPIO3 to wake-up if GPIO3 is pulled low - ** sleep -* While True - ** Read the next boot-mode from the BOOT_ORDER parameter in the EEPROM config file. - ** If boot-mode == `RESTART` - *** Jump back to the first boot-mode in the `BOOT_ORDER` field - ** else if boot-mode == `STOP` - *** Display start.elf not found xref:configuration.adoc#led-warning-flash-codes[error pattern] and wait forever. - ** else if boot-mode == `SD CARD` - *** Attempt to load firmware from the SD card - **** Success - run the firmware - **** Failure - continue - ** else if boot-mode == `NETWORK` then - *** Use DHCP protocol to request IP address - *** Load firmware from the DHCP or statically defined TFTP server - *** If the firmware is not found or a timeout or network error occurs then continue - ** else if boot-mode == `USB-MSD` or boot-mode == `BCM-USB-MSD` then - *** While USB discover has not timed out - **** Check for USB mass storage devices - **** If a new mass storage device is found then - ***** For each drive (LUN) - ****** Attempt to load firmware - ******* Success - run the firmware - ******* Failed - advance to next LUN - ** else if boot-mode == `NVME` then - *** Scan PCIe for an NVMe device and if found - **** Attempt to load firmware from the NVMe device - ***** Success - run the firmware - ***** Failure - continue - ** else if boot-mode == `RPIBOOT` then - *** Attempt to load firmware using USB device mode from the USB OTG port - see https://github.com/raspberrypi/usbboot[usbboot]. There is no timeout for `RPIBOOT` mode. - -=== Bootloader Updates - -The bootloader may also be updated before the firmware is started if a `pieeprom.upd` file is found. Please see the xref:raspberry-pi.adoc#raspberry-pi-4-boot-eeprom[bootloader EEPROM] page for more information about bootloader updates. diff --git a/documentation/asciidoc/computers/raspberry-pi/bootflow-eeprom.adoc b/documentation/asciidoc/computers/raspberry-pi/bootflow-eeprom.adoc new file mode 100644 index 0000000000..8d65dd8249 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/bootflow-eeprom.adoc @@ -0,0 +1,101 @@ +== EEPROM boot flow + +Since Raspberry Pi 4, Raspberry Pi flagship devices use an EEPROM bootloader. +The main difference between these and previous products is that the second-stage bootloader is loaded from SPI flash xref:raspberry-pi.adoc#raspberry-pi-boot-eeprom[EEPROM] instead of the `bootcode.bin` file used on previous products. + +=== First stage bootloader + +The boot flow for the ROM (first stage) is as follows: + +* SoC powers up +* Read OTP to determine if the `nRPIBOOT` GPIO is configured +* If `nRPIBOOT` GPIO is high or OTP does NOT define `nRPIBOOT` GPIO + ** Check OTP to see if `recovery.bin` can be loaded from SD/EMMC + *** If SD recovery.bin is enabled then check primary SD/EMMC for `recovery.bin` + **** Success - run `recovery.bin` and update the SPI EEPROM + **** Fail - continue + ** Check SPI EEPROM for second stage loader + *** Success - run second stage bootloader + *** Fail - continue +* While True + ** Attempt to load `recovery.bin` from xref:compute-module.adoc#flash-compute-module-emmc[USB device boot] + *** Success - run `recovery.bin` and update the SPI EEPROM or switch to USB mass storage device mode + *** Fail - retry USB device boot + +NOTE: `recovery.bin` is a minimal second stage program used to reflash the bootloader SPI EEPROM image. + +=== Second stage bootloader + +This section describes the high-level flow of the second stage bootloader. + +Please see the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration] page for more information about each boot mode, and the xref:configuration.adoc#boot-folder-contents[boot folder] page for a description of the GPU firmware files loaded by this stage. + +* Initialise clocks and SDRAM +* Read the EEPROM configuration file +* Check `PM_RSTS` register to determine if HALT is requested + ** Check `POWER_OFF_ON_HALT` and `WAKE_ON_GPIO` EEPROM configuration settings + ** If `POWER_OFF_ON_HALT` is `1` and `WAKE_ON_GPIO` is `0` then + *** Use PMIC to power off system + ** Else if `WAKE_ON_GPIO` is `1` + *** Enable fall-edge interrupts on GPIO3 to wake-up if GPIO3 is pulled low + ** Sleep +* While True + ** Read the next boot-mode from the BOOT_ORDER parameter in the EEPROM config file. + ** If boot-mode == `RESTART` + *** Jump back to the first boot-mode in the `BOOT_ORDER` field + ** Else if boot-mode == `STOP` + *** Display start.elf not found xref:configuration.adoc#led-warning-flash-codes[error pattern] and wait forever. + ** Else if boot-mode == `SD CARD` + *** Attempt to load firmware from the SD card + **** Success - run the firmware + **** Failure - continue + ** Else if boot-mode == `NETWORK` then + *** Use DHCP protocol to request IP address + *** Load firmware from the DHCP or statically defined TFTP server + *** If the firmware is not found or a timeout or network error occurs then continue + ** Else if boot-mode == `USB-MSD` or boot-mode == `BCM-USB-MSD` then + *** While USB discover has not timed out + **** Check for USB mass storage devices + **** If a new mass storage device is found then + ***** For each drive (LUN) + ****** Attempt to load firmware + ******* Success - run the firmware + ******* Failed - advance to next LUN + ** Else if boot-mode == `NVME` then + *** Scan PCIe for an NVMe device and if found + **** Attempt to load firmware from the NVMe device + ***** Success - run the firmware + ***** Failure - continue + ** Else if boot-mode == `RPIBOOT` then + *** Attempt to load firmware using USB device mode from the USB OTG port - see https://github.com/raspberrypi/usbboot[USB boot]. There is no timeout for `RPIBOOT` mode. + +==== Differences on Raspberry Pi 5 + +* The power button is used to wake up from PMIC `STANDBY` or `HALT` instead of `GPIO 3`. +* Instead of loading `start.elf`, the firmware loads the Linux kernel. Effectively, the bootloader has an embedded version of `start.elf`. +* USB boot is disabled by default when connected to a 3A power supply. Set `usb_max_current_enable=1` in `/boot/firmware/config.txt` to enable USB boot. Alternatively, you can press the power button a single time on a failed USB boot to temporarily enable `usb_max_current_enable` and continue booting. However, this setting will not persist after a reboot if enabled by pressing the power button. + +=== Bootloader updates + +The bootloader may also be updated before the firmware is started if a `pieeprom.upd` file is found. See the xref:raspberry-pi.adoc#raspberry-pi-boot-eeprom[bootloader EEPROM] page for more information about bootloader updates. + +=== Fail-safe OS updates (`tryboot`) + +The bootloader/firmware provide a one-shot flag which, if set, is cleared but causes `tryboot.txt` to be loaded instead of `config.txt`. This alternate config would specify the pending OS update firmware, cmdline, kernel and os_prefix parameters. Since the flag is cleared before starting the firmware, a crash or reset will cause the original `config.txt` file to be loaded on the next reboot. + +To set the `tryboot` flag, add `tryboot` after the partition number in the `reboot` command. Normally, the partition number defaults to zero but it must be specified if extra arguments are added. Always use quotes when passing arguments to `reboot`: it accepts only a single argument: + +[source,console] +---- +$ sudo reboot '0 tryboot' +---- + +All Raspberry Pi models support `tryboot`, however, on Raspberry Pi 4 Model B revision 1.0 and 1.1 the EEPROM must not be write protected. This is because older Raspberry Pi 4B devices have to reset the power supply (losing the tryboot state), so this is stored inside the EEPROM instead. + +If `secure-boot` is enabled, then `tryboot` mode will cause `tryboot.img` to be loaded instead of `boot.img`. + +=== `tryboot_a_b` mode +If the `tryboot_a_b` property in xref:config_txt.adoc#autoboot-txt[autoboot.txt] is set to `1` then `config.txt` is loaded instead of `tryboot.txt`. This is because the `tryboot` switch has already been made at a higher level (the partition), so it's unnecessary to have a `tryboot.txt` file within alternate partition itself. + +The `tryboot_a_b` property is implicitly set to `1` when loading files from within a `boot.img` ramdisk. + diff --git a/documentation/asciidoc/computers/raspberry-pi/bootflow-legacy.adoc b/documentation/asciidoc/computers/raspberry-pi/bootflow-legacy.adoc index 1257344086..29e7c821d4 100644 --- a/documentation/asciidoc/computers/raspberry-pi/bootflow-legacy.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/bootflow-legacy.adoc @@ -1,21 +1,21 @@ == Boot sequence -IMPORTANT: The following boot sequence applies to the BCM2837 and BCM2837B0 based models of Raspberry Pi only. On models prior to this, the Raspberry Pi will try SD card boot, followed by xref:raspberry-pi.adoc#usb-device-boot-mode[USB device mode boot]. For the Raspberry Pi4 boot sequence please see the xref:raspberry-pi.adoc#raspberry-pi-4-boot-flow[Raspberry Pi 4 boot flow] section. +IMPORTANT: The following boot sequence applies to the BCM2837 and BCM2837B0 based models of Raspberry Pi only. On models prior to this, the Raspberry Pi will try SD card boot, followed by xref:raspberry-pi.adoc#usb-device-boot-mode[USB device mode boot]. For the Raspberry Pi 4 and Raspberry Pi 5 boot sequence please see the xref:raspberry-pi.adoc#eeprom-boot-flow[EEPROM bootflow] section. -USB boot defaults on the Raspberry Pi 3 will depend on which version is being used. See this xref:raspberry-pi.adoc#usb-mass-storage-boot[page] for information on enabling USB boot modes when not enabled by default. +USB boot defaults on Raspberry Pi 3 will depend on which version is being used. See this xref:raspberry-pi.adoc#usb-mass-storage-boot[page] for information on enabling USB boot modes when not enabled by default. -When the BCM2837 boots, it uses two different sources to determine which boot modes to enable. Firstly, the OTP (one-time programmable) memory block is checked to see which boot modes are enabled. If the GPIO boot mode setting is enabled, then the relevant GPIO lines are tested to select which of the OTP-enabled boot modes should be attempted. Note that GPIO boot mode can only be used to select boot modes that are already enabled in the OTP. See xref:raspberry-pi.adoc#gpio-boot-mode[GPIO boot mode] for details on configuring GPIO boot mode. GPIO boot mode is disabled by default. +When the BCM2837 boots, it uses two different sources to determine which boot modes to enable. Firstly, the one-time-programmable (OTP) memory block is checked to see which boot modes are enabled. If the GPIO boot mode setting is enabled, then the relevant GPIO lines are tested to select which of the OTP-enabled boot modes should be attempted. Note that GPIO boot mode can only be used to select boot modes that are already enabled in the OTP. See xref:raspberry-pi.adoc#gpio-boot-mode[GPIO boot mode] for details on configuring GPIO boot mode. GPIO boot mode is disabled by default. -Next, the boot ROM checks each of the boot sources for a file called bootcode.bin; if it is successful it will load the code into the local 128K cache and jump to it. The overall boot mode process is as follows: +Next, the boot ROM checks each of the boot sources for a file called `bootcode.bin`; if it is successful it will load the code into the local 128K cache and jump to it. The overall boot mode process is as follows: * BCM2837 boots * Read OTP to determine which boot modes to enable * If GPIO boot mode enabled, use GPIO boot mode to refine list of enabled boot modes -* If enabled: check primary SD for bootcode.bin on GPIO 48-53 - ** Success - Boot +* If enabled: check primary SD for `bootcode.bin` on GPIO 48-53 + ** Success - boot ** Fail - timeout (five seconds) * If enabled: check secondary SD - ** Success - Boot + ** Success - boot ** Fail - timeout (five seconds) * If enabled: check NAND * If enabled: check SPI @@ -31,26 +31,26 @@ Next, the boot ROM checks each of the boot sources for a file called bootcode.bi **** If bootcode.bin found boot *** Recurse through each LAN951x **** DHCP / TFTP boot - ** else (Device mode boot) + ** Else (device mode boot) *** Enable device mode and wait for host PC to enumerate - *** We reply to PC with VID: 0a5c PID: 0x2763 (Pi 1 or Pi 2) or 0x2764 (Pi 3) + *** We reply to PC with VID: `0a5c` PID: `0x2763` (Raspberry Pi 1 or Raspberry Pi 2) or `0x2764` (Raspberry Pi 3) [NOTE] -====== +==== * If there is no SD card inserted, the SD boot mode takes five seconds to fail. To reduce this and fall back to USB more quickly, you can either insert an SD card with nothing on it or use the GPIO bootmode OTP setting described above to only enable USB. -* The default pull for the GPIOs is defined on page 102 of the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[ARM Peripherals datasheet]. If the value at boot time does not equal the default pull, then that boot mode is enabled. +* The default pull for the GPIOs is defined on page 102 of the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[ARM Peripherals datasheet]. If the value at boot time does not equal the default pull, then that boot mode is enabled. * USB enumeration is a means of enabling power to the downstream devices on a hub, then waiting for the device to pull the D+ and D- lines to indicate if it is either USB 1 or USB 2. This can take time: on some devices it can take up to three seconds for a hard disk drive to spin up and start the enumeration process. Because this is the only way of detecting that the hardware is attached, we have to wait for a minimum amount of time (two seconds). If the device fails to respond after this maximum timeout, it is possible to increase the timeout to five seconds using `program_usb_boot_timeout=1` in `config.txt`. * MSD boot takes precedence over Ethernet boot. * It is no longer necessary for the first partition to be the FAT partition, as the MSD boot will continue to search for a FAT partition beyond the first one. * The boot ROM also now supports GUID partitioning and has been tested with hard drives partitioned using Mac, Windows, and Linux. -* The LAN951x is detected using the Vendor ID 0x0424 and Product ID 0xec00: this is different to the standalone LAN9500 device, which has a product ID of 0x9500 or 0x9e00. To use the standalone LAN9500, an I2C EEPROM would need to be added to change these IDs to match the LAN951x. -====== +* The LAN951x is detected using the Vendor ID `0x0424` and Product ID `0xec00`: this is different to the standalone LAN9500 device, which has a product ID of `0x9500` or `0x9e00`. To use the standalone LAN9500, an I2C EEPROM would need to be added to change these IDs to match the LAN951x. +==== The primary SD card boot mode is, as standard, set to be GPIOs 49-53. It is possible to boot from the secondary SD card on a second set of pins, i.e. to add a secondary SD card to the GPIO pins. However, we have not yet enabled this ability. NAND boot and SPI boot modes do work, although they do not yet have full GPU support. -The USB device boot mode is enabled by default at the time of manufacture, but the USB host boot mode is only enabled with `program_usb_boot_mode=1`. Once enabled, the processor will use the value of the OTGID pin on the processor to decide between the two modes. On a Raspberry Pi Model B, the OTGID pin is driven to '0' and therefore will only boot via host mode once enabled (it is not possible to boot through device mode because the LAN9515 device is in the way). +The USB device boot mode is enabled by default at the time of manufacture, but the USB host boot mode is only enabled with `program_usb_boot_mode=1`. Once enabled, the processor will use the value of the OTGID pin on the processor to decide between the two modes. On any Raspberry Pi Model B/B+, the OTGID pin is driven to 0 and therefore will only boot via host mode once enabled (it is not possible to boot through device mode because the LAN951x device is in the way). -The USB will boot as a USB device on the Pi Zero or Compute Module if the OTGID pin is left floating (when plugged into a PC for example), so you can 'squirt' the bootcode.bin into the device. The code for doing this is https://github.com/raspberrypi/usbboot[`usbboot`] and available on Github. +The USB will boot as a USB device on the Raspberry Pi Zero or Compute Module if the OTGID pin is left floating (when plugged into a PC for example), so you can push the `bootcode.bin` into the device. The `usbboot` code for doing this is https://github.com/raspberrypi/usbboot[available on GitHub]. diff --git a/documentation/asciidoc/computers/raspberry-pi/bootmodes.adoc b/documentation/asciidoc/computers/raspberry-pi/bootmodes.adoc index 42a593a228..4c4601a2ad 100644 --- a/documentation/asciidoc/computers/raspberry-pi/bootmodes.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/bootmodes.adoc @@ -1,42 +1,41 @@ -== Raspberry Pi Boot Modes +== Raspberry Pi boot modes The Raspberry Pi has a number of different stages of booting. This document explains how the boot modes work, and which ones are supported for Linux booting. === Special `bootcode.bin`-only boot mode -USB host and Ethernet boot can be performed by BCM2837-based Raspberry Pis - that is, Pi 2B version 1.2, Pi 3B, and Pi 3B+ (Raspberry Pi 3A+ cannot net boot since it does not have a built-in Ethernet interface). In addition, all Raspberry Pi models *except Pi 4B* can use a new `bootcode.bin`-only method to enable USB host boot. +USB host and Ethernet boot can be performed by BCM2837-based Raspberry Pis - that is, Raspberry Pi 2B version 1.2, Raspberry Pi 3B, and Raspberry Pi 3B+ (Raspberry Pi 3A+ cannot net boot since it does not have a built-in Ethernet interface). In addition, all Raspberry Pi models prior to Raspberry Pi 4 can use a `bootcode.bin`-only method to enable USB host boot. -NOTE: The Raspberry Pi 4B does not use the bootcode.bin file - instead the bootloader is located in an on-board EEPROM chip. The Pi 4B bootloader currently only supports booting from an SD card. Support for USB host mode boot and Ethernet boot will be added by a future software update. See xref:raspberry-pi.adoc#raspberry-pi-4-boot-flow[Raspberry Pi 4 Bootflow] and xref:raspberry-pi.adoc#raspberry-pi-4-boot-eeprom[SPI Boot EEPROM]. +NOTE: Since Raspberry Pi 4, flagship devices do not use the `bootcode.bin` file. Instead, these devices use a bootloader located in an on-board EEPROM chip. For more information, see the documentation on xref:raspberry-pi.adoc#eeprom-boot-flow[EEPROM bootflow] and xref:raspberry-pi.adoc#raspberry-pi-boot-eeprom[SPI boot EEPROM]. -Format an SD card as FAT32 and copy on the latest https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin[`bootcode.bin`]. The SD card must be present in the Pi for it to boot. Once bootcode.bin is loaded from the SD card, the Pi continues booting using USB host mode. +Format an SD card as FAT32 and copy over the latest https://github.com/raspberrypi/firmware/blob/master/boot/bootcode.bin[`bootcode.bin`]. The SD card must be present in the Raspberry Pi for it to boot. Once `bootcode.bin` is loaded from the SD card, the Raspberry Pi continues booting using USB host mode. -This is useful for the Raspberry Pi 1, 2, and Zero models, which are based on the BCM2835 and BCM2836 chips, and in situations where a Pi 3 fails to boot (the latest bootcode.bin includes additional bugfixes for the Pi 3B, compared to the boot code burned into the BCM2837A0). +This is useful for the Raspberry Pi 1, 2, and Zero models, which are based on the BCM2835 and BCM2836 chips, and in situations where a Raspberry Pi 3 fails to boot (the latest `bootcode.bin` includes additional bugfixes for the Raspberry Pi 3B, compared to the boot code burned into the BCM2837A0). -If you have a problem with a mass storage device still not working, even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This will extend to six seconds the time for which it waits for the mass storage device to initialise. +If you have a problem with a mass storage device still not working, even with this `bootcode.bin`, then add a new file called "timeout" to the SD card. This will extend to six seconds the time for which it waits for the mass storage device to initialise. === `bootcode.bin` UART Enable -NOTE: For boards pre-Raspberry Pi 4, Model B. +NOTE: For boards released prior to Raspberry Pi 4. -For information on enabling the UART on the Pi4 bootloader, please see xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[this page]. +For information on enabling UART with the EEPROM bootloader, see the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader configuration] documentation. -It is possible to enable an early stage UART to debug booting issues (useful with the above bootcode.bin only boot mode). To do this, make sure you've got a recent version of the firmware (including bootcode.bin). To check if UART is supported in your current firmware: +It is possible to enable an early stage UART to debug booting issues (useful with the above `bootcode.bin` only boot mode). To do this, make sure you've got a recent version of the firmware (including `bootcode.bin`). To check if UART is supported in your current firmware: -[source] +[source,console] ---- - $ strings bootcode.bin | grep BOOT_UART - BOOT_UART=0 +$ strings bootcode.bin | grep BOOT_UART ---- -To enable UART from bootcode.bin use: +To enable UART from `bootcode.bin`: -[source] +[source,console] ---- -sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin +$ sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin ---- -Next, connect a suitable USB serial cable to your host computer (a Raspberry Pi will work, although I find the easiest path is to use a USB serial cable since it'll work out the box without any pesky config.txt settings). Use the standard pins 6, 8 and 10 (GND, GPIO14, GPIO15) on a Pi or CM board. +Next, connect a suitable USB serial cable to your host computer (a Raspberry Pi will work, although you may find that the easiest path is to use a USB serial cable, since it'll work out the box without any pesky config.txt settings). Use the standard pins 6, 8 and 10 (GND, GPIO14, GPIO15) on a Raspberry Pi or Compute Module. -Then use `screen` on linux or a Mac or `putty` on windows to connect to the serial. +Then use `screen` on Linux or macOS or `putty` on Windows to connect to the serial. -Setup your serial to receive at 115200-8-N-1, and then boot your Pi / Compute module. You should get an immediate serial output from the device as bootcode.bin runs. +Set up your serial to receive at 115200-8-N-1, and then boot your Raspberry Pi. You should get an immediate serial output from the device as `bootcode.bin` runs. diff --git a/documentation/asciidoc/computers/raspberry-pi/display-parallel-interface.adoc b/documentation/asciidoc/computers/raspberry-pi/display-parallel-interface.adoc index 4c32b7bc59..a5d615ee36 100644 --- a/documentation/asciidoc/computers/raspberry-pi/display-parallel-interface.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/display-parallel-interface.adoc @@ -1,177 +1,451 @@ -== Parallel Display Interface (DPI) +== Display Parallel Interface (DPI) + +[.whitepaper, title="Using a DPI Display on the Raspberry Pi", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003471-WP/Using-a-DPI-display.pdf] +**** +Display Parallel Interface (DPI) displays can be connected to Raspberry Pi devices via the 40-pin general-purpose input/output (GPIO) connector as an alternative to using the dedicated Display Serial Interface (DSI) or High-Definition Multimedia Interface (HDMI) ports. +**** An up-to-24-bit parallel RGB interface is available on all Raspberry Pi boards with the 40 way header and the Compute Modules. This interface allows parallel RGB displays to be attached to the Raspberry Pi GPIO either in RGB24 (8 bits for red, green and blue) or RGB666 (6 bits per colour) or RGB565 (5 bits red, 6 green, and 5 blue). -This interface is controlled by the GPU firmware and can be programmed by a user via special config.txt parameters and by enabling the correct Linux Device Tree overlay. +This interface is controlled by the GPU firmware and can be programmed by a user via special `config.txt` parameters and by enabling the correct Linux Device Tree overlay. -=== GPIO Pins +=== GPIO pins -One of the alternate functions selectable on bank 0 of the Raspberry Pi GPIO is DPI (Display Parallel Interface) which is a simple clocked parallel interface (up to 8 bits of R, G and B; clock, enable, hsync, and vsync). This interface is available as alternate function 2 (ALT2) on GPIO bank 0: +One of the alternate functions selectable on Bank 0 of the Raspberry Pi GPIO is DPI (Display Parallel Interface) which is a simple clocked parallel interface (up to 8 bits of R, G and B; clock, enable, hsync, and vsync). This interface is available as alternate function 2 (ALT2) on GPIO Bank 0: -image::images/dpi-altfn2.png[DPI Alternate GPIO function] +[cols="1m,1m"] +|=== +|GPIO |ALT2 -NOTE: There are various ways that the colour values can be presented on the DPI output pins in either 565, 666, or 24-bit modes (see the following table and the `output_format` part of the `dpi_output_format` parameter below): +|GPIO0 +|PCLK + +|GPIO1 +|DE + +|GPIO2 +|LCD_VSYNC + +|GPIO3 +|LCD_HSYNC + +|GPIO4 +|DPI_D0 + +|GPIO5 +|DPI_D1 + +|GPIO6 +|DPI_D2 + +|GPIO7 +|DPI_D3 + +|GPIO8 +|DPI_D4 + +|GPIO9 +|DPI_D5 + +|GPIO10 +|DPI_D6 + +|GPIO11 +|DPI_D7 + +|GPIO12 +|DPI_D8 + +|GPIO13 +|DPI_D9 + +|GPIO14 +|DPI_D10 + +|GPIO15 +|DPI_D11 + +|GPIO16 +|DPI_D12 + +|GPIO17 +|DPI_D13 + +|GPIO18 +|DPI_D14 + +|GPIO19 +|DPI_D15 + +|GPIO20 +|DPI_D16 + +|GPIO21 +|DPI_D17 -image::images/dpi-packing.png[DPI Colour Output] +|GPIO22 +|DPI_D18 -=== Disable Other GPIO Peripherals +|GPIO23 +|DPI_D19 -Note that all other peripheral overlays that use conflicting GPIO pins must be disabled. In config.txt, take care to comment out or invert any dtparams that enable I2C or SPI: +|GPIO24 +|DPI_D20 +|GPIO25 +|DPI_D21 + +|GPIO26 +|DPI_D22 + +|GPIO27 +|DPI_D23 +|=== + +NOTE: There are various ways that the colour values can be presented on the DPI output pins in either 565, 666, or 24-bit modes (see the following table and the `output_format` part of the `dpi_output_format` parameter below): + +[cols="1,1,^1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"] +|=== +.2+h|*Mode* .2+h|*RGB bits* 24+h|*GPIO* +h|*27* h|*26* h|*25* h|*24* h|*23* h|*22* h|*21* h|*20* h|*19* h|*18* h|*17* h|*16* h|*15* h|*14* h|*13* h|*12* h|*11* h|*10* h|*9* h|*8* h|*7* h|*6* h|*5* h|*4* + +|1 +{set:cellbgcolor:!} +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- +|- + +|2 +|565 +|- +|- +|- +|- +|- +|- +|- +|- +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 + +|3 +{set:cellbgcolor:!} +|565 +|- +|- +|- +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|- +{set:cellbgcolor:!} +|- +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|- +{set:cellbgcolor:!} +|- +|- +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 + +|4 +{set:cellbgcolor:!} +|565 +|- +|- +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|- +{set:cellbgcolor:!} +|- +|- +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|- +{set:cellbgcolor:!} +|- +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 +|- +{set:cellbgcolor:!} + +|5 +|666 +|- +|- +|- +|- +|- +|- +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|2 +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 +|2 + +|6 +{set:cellbgcolor:!} +|666 +|- +|- +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|2 +|- +{set:cellbgcolor:!} +|- +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|- +{set:cellbgcolor:!} +|- +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 +|2 + +|7 +{set:cellbgcolor:!} +|888 +|7 +{set:cellbgcolor:#E20000} +|6 +|5 +|4 +|3 +|2 +|1 +|0 +|7 +{set:cellbgcolor:#05FF0B} +|6 +|5 +|4 +|3 +|2 +|1 +|0 +|7 +{set:cellbgcolor:#5D6CFF} +|6 +|5 +|4 +|3 +|2 +|1 +|0 + +|=== +{set:cellbgcolor:!} + +=== Disable other GPIO peripherals + +All other peripheral overlays that use conflicting GPIO pins must be disabled. In `config.txt`, take care to comment out or invert any dtparams that enable I2C or SPI: + +[source,ini] ---- dtparam=i2c_arm=off dtparam=spi=off ---- -=== Controlling Output Format +=== Configure a display + +The https://en.wikipedia.org/wiki/Direct_Rendering_Manager#Kernel_mode_setting[Kernel Mode Setting (KMS)] generic display interface enables output to arbitrary displays, as long as you have an appropriate driver. -The output format (clock, colour format, sync polarity, enable) can be controlled with a magic number (unsigned integer or hex value prefixed with 0x) passed to the `dpi_output_format` parameter in config.txt created from the following fields: +==== Auto detect +Auto detect allows your Raspberry Pi to connect with a display without a manually configured device tree overlay. +Auto detection is enabled by default. You can enable display auto detect by adding the following line to `config.txt`: + +[source,ini] ---- -output_format = (dpi_output_format >> 0) & 0xf; -rgb_order = (dpi_output_format >> 4) & 0xf; - -output_enable_mode = (dpi_output_format >> 8) & 0x1; -invert_pixel_clock = (dpi_output_format >> 9) & 0x1; - -hsync_disable = (dpi_output_format >> 12) & 0x1; -vsync_disable = (dpi_output_format >> 13) & 0x1; -output_enable_disable = (dpi_output_format >> 14) & 0x1; - -hsync_polarity = (dpi_output_format >> 16) & 0x1; -vsync_polarity = (dpi_output_format >> 17) & 0x1; -output_enable_polarity = (dpi_output_format >> 18) & 0x1; - -hsync_phase = (dpi_output_format >> 20) & 0x1; -vsync_phase = (dpi_output_format >> 21) & 0x1; -output_enable_phase = (dpi_output_format >> 22) & 0x1; - -output_format: - 1: DPI_OUTPUT_FORMAT_9BIT_666 - 2: DPI_OUTPUT_FORMAT_16BIT_565_CFG1 - 3: DPI_OUTPUT_FORMAT_16BIT_565_CFG2 - 4: DPI_OUTPUT_FORMAT_16BIT_565_CFG3 - 5: DPI_OUTPUT_FORMAT_18BIT_666_CFG1 - 6: DPI_OUTPUT_FORMAT_18BIT_666_CFG2 - 7: DPI_OUTPUT_FORMAT_24BIT_888 - -rgb_order: - 1: DPI_RGB_ORDER_RGB - 2: DPI_RGB_ORDER_BGR - 3: DPI_RGB_ORDER_GRB - 4: DPI_RGB_ORDER_BRG - -output_enable_mode: - 0: DPI_OUTPUT_ENABLE_MODE_DATA_VALID - 1: DPI_OUTPUT_ENABLE_MODE_COMBINED_SYNCS - -invert_pixel_clock: - 0: RGB Data changes on rising edge and is stable at falling edge - 1: RGB Data changes on falling edge and is stable at rising edge. - -hsync/vsync/output_enable_polarity: - 0: default for HDMI mode - 1: inverted - -hsync/vsync/oe phases: - 0: DPI_PHASE_POSEDGE - 1: DPI_PHASE_NEGEDGE +display_auto_detect=1 ---- -NB the single bit fields all act as an "invert default behaviour". - -=== Controlling Timings and Resolutions +Replace the `1` with a `0` to disable auto detect. +When you connect the official Raspberry Pi display with auto detect enabled, KMS determines the display model automatically and configures the appropriate display settings. -In firmware dated August 2018 or later, the `hdmi_timings` config.txt entry that was previously used to set up the DPI timings has be superceded by a new `dpi_timings` parameter. If the `dpi_timings` parameter is not present, the system will fall back to using the `hdmi_timings` parameter to ensure backwards compatibility. If neither are present and a custom mode is requested, then a default set of parameters for VGAp60 is used. +==== Manually configure a display -The `dpi_group` and `dpi_mode` config.txt parameters are used to set either predetermined modes (DMT or CEA modes as used by HDMI) or a user can generate https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=24679[custom modes]. +NOTE: In Raspberry Pi OS _Bookworm_ or later, the `dpi_output_format` and `dpi_timings` entries in `config.txt` previously used to set up DPI have been superseded by the `vc4-kms-dpi-generic` overlay. -If you set up a custom DPI mode, then in config.txt use: +To use any display other than the official Raspberry Pi display, you must specify a `dtoverlay` entry in `config.txt`. The panel manufacturer should configure timings for your display in Linux kernel code and provide an overlay to enable those settings. See the https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/vc4-kms-kippah-7inch-overlay.dts[Adafruit Kippah display entry] for an example. The following example demonstrates how to set a `dtoverlay` entry for the Kippah display in your xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] file: +[source,ini] ---- -dpi_group=2 -dpi_mode=87 +dtoverlay=vc4-kms-kippah-7inch-overlay ---- -This will tell the driver to use the custom `dpi_timings` (older firmware uses `hdmi_timings`) timings for the DPI panel. +Display timings are usually defined in the kernel, but you can also define them in the provided `panel-dpi` driver. If your panel lacks a defined overlay in kernel code, you can use the `panel-dpi` driver to define display timings as parameters. This enables you to manually configure a device tree entry for any display. -The `dpi_timings` parameters are specified as a space-delimited set of parameters: +The following example demonstrates how you can define timings using device tree parameters: +[source,ini] ---- -dpi_timings= - - = horizontal pixels (width) - = invert hsync polarity - = horizontal forward padding from DE acitve edge - = hsync pulse width in pixel clocks - = vertical back padding from DE active edge - = vertical pixels height (lines) - = invert vsync polarity - = vertical forward padding from DE active edge - = vsync pulse width in pixel clocks - = vertical back padding from DE active edge - = leave at zero - = leave at zero - = leave at zero - = screen refresh rate in Hz - = leave at zero - = clock frequency (width*height*framerate) - = * - -* The aspect ratio can be set to one of eight values (choose closest for your screen): - -HDMI_ASPECT_4_3 = 1 -HDMI_ASPECT_14_9 = 2 -HDMI_ASPECT_16_9 = 3 -HDMI_ASPECT_5_4 = 4 -HDMI_ASPECT_16_10 = 5 -HDMI_ASPECT_15_9 = 6 -HDMI_ASPECT_21_9 = 7 -HDMI_ASPECT_64_27 = 8 +dtoverlay=vc4-kms-v3d +dtoverlay=vc4-kms-dpi-generic,hactive=480,hfp=26,hsync=16,hbp=10 +dtparam=vactive=640,vfp=25,vsync=10,vbp=16 +dtparam=clock-frequency=32000000,rgb666-padhi ---- -=== Overlays +NOTE: Device tree line length must not exceed 80 characters. When a setting requires a line longer than 80 characters, split the assignment of that parameter across multiple lines. -A Linux Device Tree overlay is used to switch the GPIO pins into the correct mode (alt function 2). As previously mentioned, the GPU is responsible for driving the DPI display. Hence there is no Linux driver; the overlay simply sets the GPIO alt functions correctly. +Parameter display tree definitions support the following options: -A 'full fat' DPI overlay (dpi24.dtb) is provided which sets all 28 GPIOs to ALT2 mode, providing the full 24 bits of colour bus as well as the h and v-sync, enable and pixel clock. Note this uses *all* of the bank 0 GPIO pins. +[cols="1,2"] +|=== +| Option | Description -A second overlay (vga666.dtb) is provided for driving VGA monitor signals in 666 mode which don't need the clock and DE pins (GPIO 0 and 1) and only require GPIOs 4-21 for colour (using mode 5). +| `clock-frequency` +| Display clock frequency (Hz) -These overlays are fairly trivial and a user can edit them to create a custom overlay to enable just the pins required for their specific use case. For example, if one was using a DPI display using vsync, hsync, pclk, and de but in RGB565 mode (mode 2), then the dpi24.dtb overlay could be edited so that GPIOs 20-27 were not switched to DPI mode and hence could be used for other purposes. +| `hactive` +| Horizontal active pixels -=== Example `config.txt` Settings +| `hfp` +| Horizontal front porch -==== Gert VGA666 adaptor +| `hsync` +| Horizontal sync pulse width -This setup is for the https://github.com/fenlogic/vga666[Gert VGA adaptor]. +| `hbp` +| Horizontal back porch -Note that the instructions provided in the documentation in the above GitHub link are somewhat out of date, so please use the settings below. +| `vactive` +| Vertical active lines ----- -dtoverlay=vga666 -enable_dpi_lcd=1 -display_default_lcd=1 -dpi_group=2 -dpi_mode=82 ----- +| `vfp` +| Vertical front porch -==== 800x480 LCD panel +| `vsync` +| Vertical sync pulse width -NOTE: This was tested with Adafruit's https://www.adafruit.com/products/2453[DPI add-on board] and an 800x480 LCD panel. +| `vbp` +| Vertical back porch ----- -dtoverlay=dpi24 -overscan_left=0 -overscan_right=0 -overscan_top=0 -overscan_bottom=0 -framebuffer_width=800 -framebuffer_height=480 -enable_dpi_lcd=1 -display_default_lcd=1 -dpi_group=2 -dpi_mode=87 -dpi_output_format=0x6f005 -dpi_timings=800 0 40 48 88 480 0 13 3 32 0 0 0 60 0 32000000 6 ----- +| `hsync-invert` +| Horizontal sync active low + +| `vsync-invert` +| Vertical sync active low + +| `de-invert` +| Data Enable active low + +| `pixclk-invert` +| Negative edge pixel clock + +| `width-mm` +| Defines the screen width in millimetres + +| `height-mm` +| Defines the screen height in millimetres + +| `rgb565` +| Change to RGB565 output on GPIOs 0-19 + +| `rgb666-padhi` +| Change to RGB666 output on GPIOs 0-9, 12-17, and 20-25 + +| `rgb888` +| Change to RGB888 output on GPIOs 0-27 + +| `bus-format` +| Override the bus format for a MEDIA_BUS_FMT_* value, also overridden by rgbXXX overrides + +| `backlight-gpio` +| Defines a GPIO to be used for backlight control (default value: none) +|=== diff --git a/documentation/asciidoc/computers/raspberry-pi/eeprom-bootloader.adoc b/documentation/asciidoc/computers/raspberry-pi/eeprom-bootloader.adoc new file mode 100644 index 0000000000..bfa9560982 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/eeprom-bootloader.adoc @@ -0,0 +1,660 @@ +== Raspberry Pi bootloader configuration + +=== Edit the configuration + +Before editing the bootloader configuration, xref:os.adoc#update-software[update your system] to get the latest version of the `rpi-eeprom` package. + +To view the current EEPROM configuration, run the following command: + +[source,console] +---- +$ rpi-eeprom-config +---- + +To edit the current EEPROM configuration and apply the updates to latest EEPROM release, run the following command: + +[source,console] +---- +$ sudo -E rpi-eeprom-config --edit +---- + +For more information about the EEPROM update process, see xref:raspberry-pi.adoc#raspberry-pi-boot-eeprom[boot EEPROM]. + +=== Configuration properties + +This section describes all the configuration items available in the bootloader. The syntax is the same as xref:config_txt.adoc[config.txt] but the properties are specific to the bootloader. xref:config_txt.adoc#conditional-filters[Conditional filters] are also supported except for EDID. + +[[BOOT_UART]] +==== `BOOT_UART` + +If `1` then enable UART debug output on GPIO 14 and 15. Configure the receiving debug terminal at 115200bps, 8 bits, no parity bits, 1 stop bit. + +Default: `0` + +[[UART_BAUD]] +==== `UART_BAUD` + +Flagship models since Raspberry Pi 5 only. + +Changes the baud rate for the bootloader UART. + +Supported values: `9600`, `19200`, `38400`, `57600`, `115200`, `230400`, `460800`, `921600` + +Default: `115200` + +[[WAKE_ON_GPIO]] +==== `WAKE_ON_GPIO` + +If `1` then `sudo halt` will run in a lower power mode until either GPIO3 or GLOBAL_EN are shorted to ground. + +This setting is not relevant on Flagship models since Raspberry Pi 5, Compute Modules since CM5, and Keyboard models since Pi 500 because the xref:raspberry-pi.adoc#power-button[dedicated power button] may always be used to wake from `HALT` or `STANDBY`. + +Default: `1` + +[[POWER_OFF_ON_HALT]] +==== `POWER_OFF_ON_HALT` + +If `1` and `WAKE_ON_GPIO=0` then `sudo halt` will switch off all PMIC outputs. This is lowest possible power state for halt but may cause problems with some HATs because 5V will still be on. `GLOBAL_EN` must be shorted to ground to boot. + +The dedicated power button on Pi 400 operates even if the processor is switched off. This behaviour is enabled by default, however, `WAKE_ON_GPIO=2` may be set to use an external GPIO power button instead of the dedicated power button. + +On Flagship models since Raspberry Pi 5 and Keyboard models since Pi 500, this places the PMIC in `STANDBY` mode where all outputs are switched off. There is no need to set `WAKE_ON_GPIO` and pressing the xref:raspberry-pi.adoc#power-button[dedicated power button] boots the device. + +Default: `1` on Compute Modules since CM5 and Keyboard models; otherwise `0` + +[[WAIT_FOR_POWER_BUTTON]] +==== `WAIT_FOR_POWER_BUTTON` + +Flagship models since Raspberry Pi 5 only. + +If this property and `POWER_OFF_ON_HALT` are both set to `1` then the bootloader will immediately power-off and wait for the power to be pressed on the first boot after the power supply has been removed. This means that instead of booting immediately after power-loss the system will wait for the power button to be pressed. + +Default: `0` + +[[BOOT_ORDER]] +==== `BOOT_ORDER` + +The `BOOT_ORDER` setting allows flexible configuration for the priority of different boot modes. It is represented as a 32-bit unsigned integer where each nibble represents a boot-mode. The boot modes are attempted in lowest significant nibble to highest significant nibble order. + +===== `BOOT_ORDER` fields + +The `BOOT_ORDER` property defines the sequence for the different boot modes. It is read right to left, and up to eight digits may be defined. + +[cols="1m,1m,2"] +|=== +| Value | Mode | Description + +| 0x0 +| SD CARD DETECT +| Try SD then wait for card-detect to indicate that the card has changed. Deprecated now that `0xf` (`RESTART`) is available. + +| 0x1 +| SD CARD +| SD card (or eMMC on Compute Module 4). + +| 0x2 +| NETWORK +| Network boot - See xref:remote-access.adoc#network-boot-your-raspberry-pi[Network boot server tutorial]. + +| 0x3 +| RPIBOOT +| RPIBOOT - See https://github.com/raspberrypi/usbboot[usbboot]. + +| 0x4 +| USB-MSD +| USB mass storage boot - See xref:raspberry-pi.adoc#usb-mass-storage-boot[USB mass storage boot]. + +| 0x5 +| BCM-USB-MSD +| USB 2.0 boot from USB Type C socket (CM4: USB type A socket on CM4IO board). Not available on Raspberry Pi 5. + +| 0x6 +| NVME +| CM4 and Pi 5 only: boot from an NVMe SSD connected to the PCIe interface. See xref:raspberry-pi.adoc#nvme-ssd-boot[NVMe boot] for more details. + +| 0x7 +| HTTP +| HTTP boot over ethernet. See xref:raspberry-pi.adoc#http-boot[HTTP boot] for more details. + +| 0xe +| STOP +| Stop and display error pattern. A power cycle is required to exit this state. + +| 0xf +| RESTART +| Restart from the first boot-mode in the `BOOT_ORDER` field i.e. loop. +|=== + +`RPIBOOT` is intended for use with Compute Module 4 to load a custom debug image (e.g. a Linux RAM-disk) instead of the normal boot. This should be the last boot option because it does not currently support timeouts or retries. + +===== `BOOT_ORDER` examples + +[cols="1m,2"] +|=== +| BOOT_ORDER | Description + +| 0xf41 +| Try SD first, followed by USB-MSD then repeat (default if `BOOT_ORDER` is empty) + +| 0xf14 +| Try USB first, followed by SD then repeat + +| 0xf21 +| Try SD first, followed by NETWORK then repeat + +| 0xf46 +| Try NVMe first, followed by USB-MSD then repeat +|=== + +[[MAX_RESTARTS]] +==== `MAX_RESTARTS` + +If the RESTART (`0xf`) boot-mode is encountered more than MAX_RESTARTS times then a watchdog reset is triggered. This isn't recommended for general use but may be useful for test or remote systems where a full reset is needed to resolve issues with hardware or network interfaces. + +Default: `-1` (infinite) + +[[SD_BOOT_MAX_RETRIES]] +==== `SD_BOOT_MAX_RETRIES` + +The number of times that SD boot will be retried after failure before moving to the next boot-mode defined by `BOOT_ORDER`. + +`-1` means infinite retries. + +Default: `0` + +[[SD_QUIRKS]] +==== `SD_QUIRKS` + +The `SD_QUIRKS` property provides a set of options to support device bringup and workaround interoperability issues. + +The flags are implemented as a bit-field. Undefined bits are reserved for future use and should be set to zero. + +[cols="1m,3"] +|=== +| Value | Behaviour + +| 0x1 +| Disable SD High Speed modes. The card clock is limited to 12.5 MHz +|=== + + +Default: `0` + +[[NET_BOOT_MAX_RETRIES]] +==== `NET_BOOT_MAX_RETRIES` + +The number of times that network boot will be retried after failure before moving to the next boot-mode defined by `BOOT_ORDER`. + +`-1` means infinite retries. + +Default: `0` + +[[DHCP_TIMEOUT]] +==== `DHCP_TIMEOUT` + +The timeout in milliseconds for the entire DHCP sequence before failing the current iteration. + +Minimum: `5000` + +Default: `45000` + +[[DHCP_REQ_TIMEOUT]] +==== `DHCP_REQ_TIMEOUT` + +The timeout in milliseconds before retrying DHCP DISCOVER or DHCP REQ. + +Minimum: `500` + +Default: `4000` + +[[TFTP_FILE_TIMEOUT]] +==== `TFTP_FILE_TIMEOUT` + +The timeout in milliseconds for an individual file download via TFTP. + +Minimum: `5000` + +Default: `30000` + +[[TFTP_IP]] +==== `TFTP_IP` + +Optional dotted decimal ip address (e.g. `192.168.1.99`) for the TFTP server which overrides the server-ip from the DHCP request. + +This may be useful on home networks because tftpd-hpa can be used instead of dnsmasq where broadband router is the DHCP server. + +Default: `""` + +[[TFTP_PREFIX]] +==== `TFTP_PREFIX` + +In order to support unique TFTP boot directories for each Raspberry Pi, the bootloader prefixes the filenames with a device-specific directory. If neither start4.elf nor start.elf are found in the prefixed directory then the prefix is cleared. + +On earlier models the serial number is used as the prefix, however on Raspberry Pi 4 and 5 the MAC address is no longer generated from the serial number, making it difficult to automatically create tftpboot directories on the server by inspecting DHCPDISCOVER packets. To support this the TFTP_PREFIX may be customized to either be the MAC address, a fixed value or the serial number (default). + +|=== +| Value | Description + +| 0 +| Use the serial number e.g. `9ffefdef/` + +| 1 +| Use the string specified by `TFTP_PREFIX_STR` + +| 2 +| Use the MAC address e.g. `dc-a6-32-01-36-c2/` +|=== + +Default: 0 + +[[TFTP_PREFIX_STR]] +==== `TFTP_PREFIX_STR` + +Specify the custom directory prefix string used when `TFTP_PREFIX` is set to 1. For example:- `TFTP_PREFIX_STR=tftp_test/` + +Default: `""` + +Max length: 32 characters + +[[PXE_OPTION43]] +==== `PXE_OPTION43` + +Overrides the PXE Option43 match string with a different string. It's normally better to apply customisations to the DHCP server than change the client behaviour, but this option is provided in case that's not possible. + +Default: `Raspberry Pi Boot` + +[[DHCP_OPTION97]] +==== `DHCP_OPTION97` + +In earlier releases the client GUID (Option97) was just the serial number repeated four times. By default, the new GUID format is the concatenation of the four-character code (FourCC) (`RPi4` `0x34695052` for Raspberry Pi 4 or `RPi5` `0x35695052` for Raspberry Pi 5), the board revision (e.g. `0x00c03111` or `0x00d04170`) (4-bytes), the least significant 4 bytes of the mac address and the 4-byte serial number. +This is intended to be unique but also provides structured information to the DHCP server, allowing Raspberry Pi 4 and 5 computers to be identified without relying upon the Ethernet MAC OUID. + +Specify `DHCP_OPTION97=0` to revert the old behaviour or a non-zero hex-value to specify a custom 4-byte prefix. + +Default: `0x34695052` + +[[MAC_ADDRESS]] +==== `MAC_ADDRESS` + +Overrides the Raspberry Pi Ethernet MAC address with the given value. e.g. `dc:a6:32:01:36:c2` + +Default: `""` + +[[MAC_ADDRESS_OTP]] +==== `MAC_ADDRESS_OTP` + +Overrides the Raspberry Pi Ethernet MAC address with a value stored in the xref:raspberry-pi.adoc#write-and-read-customer-otp-values[Customer OTP] registers. + +For example, to use a MAC address stored in rows 0 and 1 of the `Customer OTP`. + +[source,ini] +---- +MAC_ADDRESS_OTP=0,1 +---- + +The first value (row 0 in the example) contains the OUI and the most significant 8 bits of the MAC address. The second value (row 1 in the example) stores the remaining 16-bits of the MAC address. +This is the same format as used for the Raspberry Pi MAC address programmed at manufacture. + +Any two customer rows may be selected and combined in either order. + +The `Customer OTP` rows are OTP registers 36 to 43 in the `vcgencmd otp_dump` output so if the first two rows are programmed as follows then `MAC_ADDRESS_OTP=0,1` would give a MAC address of `e4:5f:01:20:24:7e`. + +---- +36:247e0000 +37:e45f0120 +---- + +Default: `""` + +==== Static IP address configuration + +If TFTP_IP and the following options are set then DHCP is skipped and the static IP configuration is applied. If the TFTP server is on the same subnet as the client then GATEWAY may be omitted. + +[[CLIENT_IP]] +===== `CLIENT_IP` + +The IP address of the client e.g. `192.168.0.32` + +Default: `""` + +[[SUBNET]] +===== `SUBNET` + +The subnet address mask e.g. `255.255.255.0` + +Default: `""` + +[[GATEWAY]] +===== `GATEWAY` + +The gateway address to use if the TFTP server is on a different subnet e.g. `192.168.0.1` + +Default: `""` + +[[DISABLE_HDMI]] +==== `DISABLE_HDMI` + +The xref:raspberry-pi.adoc#boot-diagnostics[HDMI boot diagnostics] display is disabled if `DISABLE_HDMI=1`. Other non-zero values are reserved for future use. + +Default: `0` + +[[HDMI_DELAY]] +==== `HDMI_DELAY` + +Skip rendering of the HDMI diagnostics display for up to N seconds (default 5) unless a fatal error occurs. The default behaviour is designed to avoid the bootloader diagnostics screen from briefly appearing during a normal SD/USB boot. + +Default: `5` + +[[ENABLE_SELF_UPDATE]] +==== `ENABLE_SELF_UPDATE` + +Enables the bootloader to update itself from a TFTP or USB mass storage device (MSD) boot filesystem. + +If self-update is enabled then the bootloader will look for the update files (.sig/.upd) in the boot file system. If the update image differs from the current image then the update is applied and system is reset. Otherwise, if the EEPROM images are byte-for-byte identical then boot continues as normal. + +Notes: + +* Bootloader releases prior to 2021 do not support `self-update`. +* Prior to 2022, self-update was not enabled in SD boot. On a Raspberry Pi 4, the ROM can already load recovery.bin from the SD card. On a CM4, neither self-update nor recovery.bin have any effect and USB boot is required (see the xref:compute-module.adoc#compute-module-eeprom-bootloader[Compute Module EEPROM bootloader docs]). +* Starting in 2022 (https://github.com/raspberrypi/rpi-eeprom/blob/master/firmware-2711/release-notes.md#2022-02-04---network-install---beta[beta] and https://github.com/raspberrypi/rpi-eeprom/blob/master/firmware-2711/release-notes.md#2022-03-10---promote-the-2022-03-10-beta-release-to-lateststable[stable]), self-update from an SD card is enabled. +* For network boot make sure that the TFTP `boot` directory can be mounted via NFS and that `rpi-eeprom-update` can write to it. + +Default: `1` + +[[FREEZE_VERSION]] +==== `FREEZE_VERSION` + +Previously this property was only checked by the `rpi-eeprom-update` script. However, now that self-update is enabled the bootloader will also check this property. If set to 1, this overrides `ENABLE_SELF_UPDATE` to stop automatic updates. To disable `FREEZE_VERSION` you will have to use SD card boot with recovery.bin. + +Custom EEPROM update scripts must also check this flag. + +Default: `0` + +[[HTTP_HOST]] +==== `HTTP_HOST` + +If network install or HTTP boot is initiated, `boot.img` and `boot.sig` are downloaded from this server. + +Invalid host names will be ignored. They should only contain lower case alphanumeric characters and `-` or `.`. +If `HTTP_HOST` is set then HTTPS is disabled and plain HTTP used instead. +You can specify an IP address to avoid the need for a DNS lookup. +Don`t include the HTTP scheme or any forward slashes in the hostname. + +Default: `fw-download-alias1.raspberrypi.com` + +[[HTTP_PORT]] +==== `HTTP_PORT` + +You can use this property to change the port used for network install and HTTP boot. HTTPS is enabled when using the default host `fw-download-alias1.raspberrypi.com`. If `HTTP_HOST` is changed then HTTPS is disabled and plain HTTP will be used instead. + +When HTTPS is disabled, plain HTTP will still be used even if `HTTP_PORT` is changed to `443`. + +Default: `443` if HTTPS is enabled otherwise `80` + +[[HTTP_PATH]] +==== `HTTP_PATH` + +The path used for network install and HTTP boot. + +Case-sensitive. +Use forward (Linux) slashes for the path separator. +Leading and trailing forward slashes are not required. + +If `HTTP_HOST` is not set, `HTTP_PATH` is ignored and the URL will be `\https://fw-download-alias1.raspberrypi.com:443/net_install/boot.img`. If `HTTP_HOST` is set the URL will be `\http://://boot.img` + +Default: `net_install` + +[[IMAGER_REPO_URL]] +==== `IMAGER_REPO_URL` + +The embedded Raspberry Pi Imager application is configured with a JSON file downloaded at startup. + +You can change the URL of the JSON file used by the embedded Raspberry Pi Imager application to get it to offer your own images. +You can test this with the standard https://www.raspberrypi.com/software/[Raspberry Pi Imager] application by passing the URL via the `--repo` argument. + +Default: `\http://downloads.raspberrypi.org/os_list_imagingutility_v3.json` + +[[NET_INSTALL_ENABLED]] +==== `NET_INSTALL_ENABLED` + +When network install is enabled, the bootloader displays the network install screen on boot if it detects a keyboard. + +To enable network install, add `NET_INSTALL_ENABLED=1`, or to disable network install add `NET_INSTALL_ENABLED=0`. + +This setting is ignored and network install is disabled if `DISABLE_HDMI=1` is set. + +In order to detect the keyboard, network install must initialise the USB controller and enumerate devices. This increases boot time by approximately 1 second so it may be advantageous to disable network install in some embedded applications. + +Default: `1` on Flagship models since Raspberry Pi 4B and Keyboard models; `0` on Compute Modules since CM4 (including CM4S). + +[[NET_INSTALL_AT_POWER_ON]] +==== `NET_INSTALL_AT_POWER_ON` + +When set to `1`, displays the network install UI briefly after a cold boot to make this feature more obvious to new users. Overrides `NET_INSTALL_ENABLED` if the settings conflict. + +The default bootloader images set this value to `1` in the bootloader config. To disable the brief network install UI display, use the `Advanced Options` menu in `raspi-config` or manually delete this line in `rpi-eeprom-config`: + +[source,console] +---- +$ sudo rpi-eeprom-config --edit +---- + + +Default: `0` + +[[NET_INSTALL_KEYBOARD_WAIT]] +==== `NET_INSTALL_KEYBOARD_WAIT` + +If network install is enabled, the bootloader attempts to detect a keyboard and the `SHIFT` key to initiate network install. You can change the length of this wait in milliseconds with this property. + +Setting this to `0` disables the keyboard wait, although network install can still be initiated if no boot files are found and USB boot-mode `4` is in `BOOT_ORDER`. + +NOTE: Testing suggests keyboard and SHIFT detection takes at least 750ms. + +Default: `900` + +[[NETCONSOLE]] +==== `NETCONSOLE` - advanced logging + +`NETCONSOLE` duplicates debug messages to the network interface. The IP addresses and ports are defined by the `NETCONSOLE` string. + +NOTE: NETCONSOLE blocks until the Ethernet link is established or a timeout occurs. The timeout value is `DHCP_TIMEOUT` although DHCP is not attempted unless network boot is requested. + +===== Format + +For more information, see the https://wiki.archlinux.org/index.php/Netconsole[Netconsole documentation]. + +[source] +---- +src_port@src_ip/dev_name,dst_port@dst_ip/dst_mac +E.g. 6665@169.254.1.1/,6666@/ +---- + +In order to simplify parsing, the bootloader requires every field separator to be present. You must specify the source IP address, but you can leave the following fields blank to use their default values: + +* `src_port` - `6665` +* `dev_name` - `""` (the device name is always ignored) +* `dst_port` - `6666` +* `dst_ip` - `255.255.255.255` +* `dst_mac` - `00:00:00:00:00` + +One way to view the data is to connect the test Raspberry Pi 4 to another Raspberry Pi running WireShark and select `udp.srcport == 6665` as a filter and select *Analyze -> Follow -> UDP stream* to view as an ASCII log. + +`NETCONSOLE` should not be enabled by default because it may cause network problems. It can be enabled on demand via a GPIO filter: + +[source,ini] +---- +# Enable debug if GPIO 7 is pulled low +[gpio7=0] +NETCONSOLE=6665@169.254.1.1/,6666@/ +---- + +Default: `""` (not enabled) + +Max length: 32 characters + +[[PARTITION]] +==== `PARTITION` + +The `PARTITION` option may be used to specify the boot partition number, if it has not explicitly been set by the `reboot` command (e.g. `sudo reboot N`) or by `boot_partition=N` in `autoboot.txt`. +This could be used to boot from a rescue partition if the user presses a button. + +The latest firmware also allows high partition numbers (> 31) to be overriden. This allows a custom setup of the system hardware watchdog to trigger a reboot with a special high partition number (e.g. 62) which can be detected by the bootloader (using a conditional filter) and remapped to a recovery partition. + +Example: +[source,ini] +---- +# System watchdog fired - boot the rescue partition with additional options +# Disable SD high speed mode and enable HDMI diagnostics immediately. +[partition=62] +PARTITION=2 +HDMI_DELAY=0 +SD_QUIRKS=1 +---- + +[source,ini] +---- +# Boot from partition 2 if GPIO 7 is pulled low +[gpio7=0] +PARTITION=2 +---- + +Default: 0 + +[[PARTITION_WALK]] +==== `PARTITION_WALK` +This property is designed to improve the reliability of `A/B` boot schemes using `autoboot.txt` by searching for bootable partitions if the specified partition does not appear to be bootable. If `PARTITION_WALK=1` and the requested partition is not bootable and does not have a valid `autoboot.txt` then the bootloader will check each partition in turn (up to 8 and wrapping to 0) to see if it is bootable (contains `start4.elf` on a Pi4, or `config.txt` and a suitable device-tree on Pi 5 or newer). + +During the "partition walk" `autoboot.txt` files are not processed to avoid cycling dependencies. It is assumed that the requested boot partition has failed and the system is attempting recovery. + +Default: `0` + +[[PSU_MAX_CURRENT]] +==== `PSU_MAX_CURRENT` + +Raspberry Pi 5 only. + +If set, this property instructions the firmware to skip USB power-delivery negotiation and assume that it is connected to a power supply with the given current rating. +Typically, this would either be set to `3000` or `5000` i.e. low or high-current capable power supply. + +Default: `""` + +[[USB_MSD_EXCLUDE_VID_PID]] +==== `USB_MSD_EXCLUDE_VID_PID` + +A list of up to four VID/PID pairs specifying devices which the bootloader should ignore. If this matches a HUB then the HUB won't be enumerated, causing all downstream devices to be excluded. +This is intended to allow problematic (e.g. very slow to enumerate) devices to be ignored during boot enumeration. This is specific to the bootloader and is not passed to the OS. + +The format is a comma-separated list of hexadecimal values with the VID as most significant nibble. Spaces are not allowed. +E.g. `034700a0,a4231234` + +Default: `""` + +[[USB_MSD_DISCOVER_TIMEOUT]] +==== `USB_MSD_DISCOVER_TIMEOUT` + +If no USB mass storage devices are found within this timeout then USB-MSD is stopped and the next boot-mode is selected. + +Minimum: `5000` (5 seconds) + +Default: `20000` (20 seconds) + +[[USB_MSD_LUN_TIMEOUT]] +==== `USB_MSD_LUN_TIMEOUT` + +How long to wait in milliseconds before advancing to the next LUN e.g. a multi-slot SD-CARD reader. This is still being tweaked but may help speed up boot if old/slow devices are connected as well as a fast USB-MSD device containing the OS. + +Minimum: `100` + +Default: `2000` (2 seconds) + +[[USB_MSD_PWR_OFF_TIME]] +==== `USB_MSD_PWR_OFF_TIME` + +Raspberry Pi 4 only. + +When the Pi is rebooted power USB power is switched off by the hardware. A short power off time can cause problems with some USB devices so this parameter may be used to force a longer power off as though the cable was physically removed. + +On RaspberryPi 4 version 1.3 and older, the configurable/long power off requires the XHCI controller to be enabled so there is actually a short power off followed by a longer configurable power off. The longer configurable power off may be skipped by setting this parameter to zero. + +On newer revisions the hardware ensures that USB power is off from reboot and the bootloader only enables power after this timeout has elapsed. This is happens after memory is initialised ensuring that USB power is off for at least two seconds. Therefore, this parameter generally has no effect on newer hardware revisions. + +Minimum: `0` + +Maximum: `5000` + +Default: `1000` (1 second) + +[[USB_MSD_STARTUP_DELAY]] +==== `USB_MSD_STARTUP_DELAY` + +If defined, delays USB enumeration for the given timeout after the USB host controller has initialised. If a USB hard disk drive takes a long time to initialise and triggers USB timeouts then this delay can be used to give the driver additional time to initialise. It may also be necessary to increase the overall USB timeout (`USB_MSD_DISCOVER_TIMEOUT`). + +Minimum: `0` + +Maximum: `30000` (30 seconds) + +Default: `0` + +[[VL805]] +==== `VL805` + +Compute Module 4 only. + +If the `VL805` property is set to `1` then the bootloader will search for a VL805 PCIe XHCI controller and attempt to initialise it with VL805 firmware embedded in the bootloader EEPROM. This enables industrial designs to use VL805 XHCI controllers without providing a dedicated SPI EEPROM for the VL805 firmware. + +* On Compute Module 4 the bootloader never writes to the dedicated VL805 SPI EEPROM. This option just configures the controller to load the firmware from SDRAM. +* Do not use this option if the VL805 XHCI controller has a dedicated EEPROM. It will fail to initialise because the VL805 ROM will attempt to use a dedicated SPI EEPROM if fitted. +* The embedded VL805 firmware assumes the same USB configuration as Raspberry Pi 4B (two USB 3.0 ports and four USB 2.0 ports). There is no support for loading alternate VL805 firmware images, a dedicated VL805 SPI EEPROM should be used instead for such configurations. + +Default: `0` + +[[XHCI_DEBUG]] +==== `XHCI_DEBUG` + +This property is a bit-field which controls the verbosity of USB debug messages for mass storage boot-mode. Enabling all of these messages generates a huge amount of log data which will slow down booting and may even cause boot to fail. For verbose logs it's best to use `NETCONSOLE`. + +[cols="1m,3"] +|=== +| Value | Log + +| 0x1 +| USB descriptors + +| 0x2 +| Mass storage mode state machine + +| 0x4 +| Mass storage mode state machine - verbose + +| 0x8 +| All USB requests + +| 0x10 +| Device and hub state machines + +| 0x20 +| All xHCI TRBs (VERY VERBOSE) + +| 0x40 +| All xHCI events (VERY VERBOSE) +|=== + +To combine values, add them together. For example: + +[source,ini] +---- +# Enable mass storage and USB descriptor logging +XHCI_DEBUG=0x3 +---- + +Default: `0x0` (no USB debug messages enabled) + +[[config_txt]] +==== `[config.txt]` section + +After reading `config.txt` the GPU firmware `start4.elf` reads the bootloader EEPROM config and checks for a section called `[config.txt]`. If the `[config.txt]` section exists then the contents from the start of this section to the end of the file is appended in memory, to the contents of the `config.txt` file read from the boot partition. This can be used to automatically apply settings to every operating system, for example, dtoverlays. + +WARNING: If you configure the bootloader with an invalid configuration that fails to boot, you must re-flash the bootloader EEPROM with a valid configuration to boot. + +TIP: Some configuration properties live in `config.txt`. For more information about those properties, see xref:config_txt.adoc#configuration-properties[configuration properties]. diff --git a/documentation/asciidoc/computers/raspberry-pi/frequency-management.adoc b/documentation/asciidoc/computers/raspberry-pi/frequency-management.adoc index 410f410896..cb57b7099e 100644 --- a/documentation/asciidoc/computers/raspberry-pi/frequency-management.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/frequency-management.adoc @@ -1,54 +1,103 @@ -== Frequency Management and Thermal Control +== Frequency management and thermal control -All Raspberry Pi models perform a degree of thermal management to avoid overheating under heavy load. The SoCs have an internal temperature sensor, which software on the GPU polls to ensure that temperatures do not exceed a predefined limit; this is 85°C on all models. It is possible to set this to a lower value, but not to a higher one. As the device approaches the limit, various frequencies and sometimes voltages used on the chip (ARM, GPU) are reduced. This reduces the amount of heat generated, keeping the temperature under control. +All Raspberry Pi models perform a degree of thermal management to avoid overheating under heavy load. The SoCs have an internal temperature sensor, which software on the GPU polls to ensure that temperatures do not exceed a limit which we define as 85°C on all models. It is possible to set this to a lower value, but not to a higher one. As the device approaches the limit, various frequencies and sometimes voltages used on the chip (Arm, GPU) are reduced. This reduces the amount of heat generated, keeping the temperature under control. -When the core temperature is between 80°C and 85°C, a warning icon showing a red half-filled thermometer will be displayed, and the ARM cores will be progressively throttled back. If the temperature reaches 85°C, an icon showing a fully filled thermometer will be displayed, and both the ARM cores and the GPU will be throttled back. See the page on xref:configuration.adoc#firmware-warning-icons[warning icons] for images of the icons. +When the core temperature is between 80°C and 85°C, the Arm cores will be progressively throttled back. If the temperature reaches 85°C, both the Arm cores and the GPU will be throttled back. For Raspberry Pi 3 Model B+, the PCB technology has been changed to provide better heat dissipation and increased thermal mass. In addition, a soft temperature limit has been introduced, with the goal of maximising the time for which a device can "sprint" before reaching the hard limit at 85°C. When the soft limit is reached, the clock speed is reduced from 1.4GHz to 1.2GHz, and the operating voltage is reduced slightly. This reduces the rate of temperature increase: we trade a short period at 1.4GHz for a longer period at 1.2GHz. By default, the soft limit is 60°C, and this can be changed via the `temp_soft_limit` setting in xref:config_txt.adoc#overclocking-options[config.txt]. -The Raspberry Pi 4, Model B, continues with the same PCB technology as the Raspberry Pi 3, Model B+, to help dissipate excess heat. There is currently *no soft limit defined*. +The Raspberry Pi 4 Model B continues with the same PCB technology as the Raspberry Pi 3 Model B+, to help dissipate excess heat. There is currently no soft limit defined. -=== Using DVFS +=== Use DVFS -NOTE: Discussion of DVFS applies to Raspberry Pi 4, Model B, Raspbery Pi 400, and Compute Module 4 *ONLY*. +NOTE: Discussion of DVFS applies to 4-series devices only (Raspberry Pi 4, Compute Module 4, and Pi 400). -Raspberry Pi 4 devices implement Dynamic Voltage and Frequency Scaling (DVFS). This technique allows Raspberry Pi 4 devices to run at lower temperatures whilst still providing the same performance. +Raspberry Pi 4 devices implement dynamic voltage and frequency scaling (DVFS). This technique allows 4-series devices to run at lower temperatures whilst still providing the same performance. -Various clocks (e.g. ARM, Core, V3D, ISP, H264, HEVC) inside the SoC are monitored by the firmware, and whenever they are not running at full speed, the voltage supplied to the particular part of the chip driven by the clock is reduced relative to the reduction from full speed. In effect, only enough voltage is supplied to keep the block running correctly at the specific speed at which it is running. This can result in significant reductions in power used by the SoC, and therefore in the overall heat being produced. +Various clocks (e.g. Arm, Core, V3D, ISP, H264, HEVC) inside the SoC are monitored by the firmware, and whenever they are not running at full speed, the voltage supplied to the particular part of the chip driven by the clock is reduced relative to the reduction from full speed. In effect, only enough voltage is supplied to keep the block running correctly at the specific speed at which it is running. This can result in significant reductions in power used by the SoC, and therefore in the overall heat being produced. -Due to possible system stability problems involved with running an undervoltage, especially when using undervoltaged fixed clock peripherals (eg. PCIe), three DVFS modes are available and can be configured in `/boot/config.txt` with the below properties. Most systems should use `dvfs=3`, headless systems may benefit from a small power reduction with `dvfs=1` at the risk of PCIe stability issues. +Due to possible system stability problems involved with running an undervoltage, especially when using undervoltaged fixed clock peripherals (eg. PCIe), three DVFS modes are available and can be configured in xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`] with the below properties. Most systems should use `dvfs=3`, headless systems may benefit from a small power reduction with `dvfs=1` at the risk of PCIe stability issues. +[cols="1m,3"] |=== | property=value | Description | dvfs=1 -| allow under-voltage +| allow undervoltage | dvfs=2 -| fixed voltage for default operating frequencies. +| fixed voltage for default operating frequencies | dvfs=3 -| scale voltage up on demand for over-clocking (default). If `over_voltage` is specified in `config.txt` then the dynamic voltage scaling id disabled causing the system to revert to `dvfs=2`. +| scale voltage up on demand for over clocking (default). If `over_voltage` is specified in `config.txt` then dynamic voltage scaling is disabled causing the system to revert to `dvfs=2`. |=== +NOTE: This setting has been removed on 5-series devices and is effectively always mode 3. + In addition, a more stepped CPU governor is also used to produce finer-grained control of ARM core frequencies, which means the DVFS is more effective. The steps are now 1500MHz, 1000MHz, 750MHz, and 600MHz. These steps can also help when the SoC is being throttled, and mean that throttling all the way back to 600MHz is much less likely, giving an overall increase in fully loaded performance. -The default CPU governor is `ondemand`, the governor can be manually changed with the `cpufreq-set` command (from the `cpufrequtils` package) to reduce idle power consumption: +The default CPU governor is `ondemand`. The governor can be manually changed with the `cpufreq-set` command (from the `cpufrequtils` package) to reduce idle power consumption: +[source,console] ---- $ sudo apt install cpufrequtils $ sudo cpufreq-set -g powersave ---- -=== Measuring Temperatures +=== Measure temperatures -Due to the architecture of the SoCs used on the Raspberry Pi range, and the use of the upstream temperature monitoring code in the Raspberry Pi OS distribution, Linux-based temperature measurements can be inaccurate. However the `vcgencmd` command can provide an accurate and instantaneous reading of the current SoC temperature as it communicates with the GPU directly: +Due to the architecture of the SoCs used on Raspberry Pi devices, and the use of the upstream temperature monitoring code in the Raspberry Pi OS distribution, Linux-based temperature measurements can be inaccurate. However, the `vcgencmd` command provides an accurate and instantaneous reading of the current SoC temperature, as it communicates with the GPU directly: -[source] +[source,console] ---- $ vcgencmd measure_temp ---- -=== Adding a Heatsinks +=== Add heat sinks + +Thanks to built-in throttling, heatsinks are not necessary to prevent overheating damage to the SoC. However, a heatsink or small fan can reduce thermal throttling and improve performance. Mount the Raspberry Pi vertically for the best airflow and thus slightly improved heat dissipation. + +=== Fan cases + +To ensure the best performance for your Raspberry Pi, use an active cooling solution such as a fan. Raspberry Pi firmware manages fan speeds for all official fans. + +==== Raspberry Pi 4 fan + +For Raspberry Pi 4, add the https://www.raspberrypi.com/products/raspberry-pi-4-case-fan/[Raspberry Pi 4 Case Fan] to the lid of the Raspberry Pi 4 case. + +==== Raspberry Pi 5 fans + +For Raspberry Pi 5, use one of the official fan options: + +* https://www.raspberrypi.com/products/active-cooler/[Active Cooler] +* https://www.raspberrypi.com/products/raspberry-pi-5-case/[Case for Raspberry Pi 5] + +Both of the Raspberry Pi 5 fan options plug into the four-pin JST-SH PWM fan connector located in the upper right of the board between the 40-pin GPIO header and the USB 2 ports. The fan connector pulls from the same current limit as USB peripherals. We recommend the Active Cooler case for overclockers, since it provides better cooling performance. + +As the temperature of the Raspberry Pi 5 increases, the fan reacts in the following way: + +* below 50°C, the fan does not spin at all (0% speed) +* at 50°C, the fan turns on at a low speed (30% speed) +* at 60°C, the fan speed increases to a medium speed (50% speed) +* at 67.5°C, the fan speed increases to a high speed (70% speed) +* at 75°C the fan increases to full speed (100% speed) + +Temperature decreases use the same mapping with a 5°C **hysteresis**; fan speed decreases when the temperature drops to 5°C below each of the above thresholds. + +At boot the fan is turned on, and the tachometer input is checked to see if the fan is spinning. If it is, then the `cooling_fan` device tree overlay is enabled. This overlay is in `bcm2712-rpi-5-b.dtb` by default, but with `status=disabled`. + +==== Raspberry Pi 5 fan connector pinout + +The Raspberry Pi 5 fan connector is a 1mm pitch JST-SH socket containing the following four pins: + +[cols="1,2,2",width="50"%"] +|=== +| Pin | Function | Wire colour + +| 1 | +5V | Red +| 2 | PWM | Blue +| 3 | GND | Black +| 4 | Tach | Yellow +|=== + -Whilst heatsinks are not necessary to prevent overheating damage to the SoC — the thermal throttling mechanism handles that — a heatsink or small fan will help if you wish to reduce the amount of thermal throttling that takes place. Depending on the exact circumstances, mounting the Pi vertically can also help with heat dissipation, as doing so can improve air flow. diff --git a/documentation/asciidoc/computers/raspberry-pi/gpio-on-raspberry-pi.adoc b/documentation/asciidoc/computers/raspberry-pi/gpio-on-raspberry-pi.adoc index dd24fe14f1..e74ec7baa5 100644 --- a/documentation/asciidoc/computers/raspberry-pi/gpio-on-raspberry-pi.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/gpio-on-raspberry-pi.adoc @@ -1,17 +1,44 @@ [[gpio]] -== General Purpose I/O (GPIO) +== GPIO and the 40-pin header + +You can find a 40-pin GPIO (general-purpose input/output) header on all current Raspberry Pi boards. The GPIO headers on all boards have a 0.1in (2.54mm) pin pitch. + +NOTE: The header is unpopulated (has no headers) on Zero and Pico devices that lack the "H" suffix. + +image::images/GPIO-Pinout-Diagram-2.png[alt="GPIO pinout diagram",width="100%"] General Purpose I/O (GPIO) pins can be configured as either general-purpose input, general-purpose output, or as one of up to six special alternate settings, the functions of which are pin-dependent. -There are three GPIO banks on BCM2835. Each of the three banks has its own VDD input pin. On Raspberry Pi, all GPIO banks are supplied from 3.3V. +image::images/GPIO.png[alt="GPIO layout",width="100%"] + +NOTE: The GPIO pin numbering scheme is not in numerical order. GPIO pins 0 and 1 are present on the board (physical pins 27 and 28), but are reserved for advanced use. + +=== Outputs + +A GPIO pin designated as an output pin can be set to high (3.3V) or low (0V). + +=== Inputs + +A GPIO pin designated as an input pin can be read as high (3.3V) or low (0V). This is made easier with the use of internal pull-up or pull-down resistors. Pins GPIO2 and GPIO3 have fixed pull-up resistors, but for other pins this can be configured in software. -WARNING: Connection of a GPIO to a voltage higher than 3.3V will likely destroy the GPIO block within the SoC. +=== View a GPIO pinout for your Raspberry Pi -A selection of pins from Bank 0 is available on the P1 header on Raspberry Pi. +A GPIO reference can be accessed on your Raspberry Pi by opening a terminal window and running the command `pinout`. This tool is provided by the https://gpiozero.readthedocs.io/[GPIO Zero] Python library, which is installed by default in Raspberry Pi OS. -=== GPIO Pads +WARNING: While connecting simple components to GPIO pins is safe, be careful how you wire things up. LEDs should have resistors to limit the current passing through them. Do not use 5V for 3.3V components. Do not connect motors directly to the GPIO pins, instead use an https://projects.raspberrypi.org/en/projects/physical-computing/14[H-bridge circuit or a motor controller board]. -The GPIO connections on the BCM2835 package are sometimes referred to in the peripherals data sheet as "pads" -- a semiconductor design term meaning 'chip connection to outside world'. +=== Permissions + +In order to use the GPIO ports, your user must be a member of the `gpio` group. The default user account is a member by default, but you must add other users manually using the following command: + +[source,console] +---- +$ sudo usermod -a -G gpio +---- + +=== GPIO pads + +The GPIO connections on the BCM2835 package are sometimes referred to in the peripherals data sheet as "pads" -- a semiconductor design term meaning "chip connection to outside world". The pads are configurable CMOS push-pull output drivers/input buffers. Register-based control settings are available for: @@ -21,11 +48,11 @@ The pads are configurable CMOS push-pull output drivers/input buffers. Register- ==== Power-on states -All GPIO pins revert to general-purpose inputs on power-on reset. The default pull states are also applied, which are detailed in the alternate function table in the ARM peripherals datasheet. Most GPIOs have a default pull applied. +All GPIO pins revert to general-purpose inputs on power-on reset. The default pull states are also applied, which are detailed in the alternate function table in the Arm peripherals datasheet. Most GPIOs have a default pull applied. === Interrupts -Each GPIO pin, when configured as a general-purpose input, can be configured as an interrupt source to the ARM. Several interrupt generation sources are configurable: +Each GPIO pin, when configured as a general-purpose input, can be configured as an interrupt source to the Arm. Several interrupt generation sources are configurable: * Level-sensitive (high/low) * Rising/falling edge @@ -33,62 +60,46 @@ Each GPIO pin, when configured as a general-purpose input, can be configured as Level interrupts maintain the interrupt status until the level has been cleared by system software (e.g. by servicing the attached peripheral generating the interrupt). -The normal rising/falling edge detection has a small amount of synchronisation built into the detection. At the system clock frequency, the pin is sampled with the criteria for generation of an interrupt being a stable transition within a three-cycle window, i.e. a record of '1 0 0' or '0 1 1'. Asynchronous detection bypasses this synchronisation to enable the detection of very narrow events. +The normal rising/falling edge detection has a small amount of synchronisation built into the detection. At the system clock frequency, the pin is sampled with the criteria for generation of an interrupt being a stable transition within a three-cycle window, i.e. a record of 1 0 0 or 0 1 1. Asynchronous detection bypasses this synchronisation to enable the detection of very narrow events. + +=== Alternative functions + +Almost all of the GPIO pins have alternative functions. Peripheral blocks internal to the SoC can be selected to appear on one or more of a set of GPIO pins, for example the I2C buses can be configured to at least three separate locations. xref:raspberry-pi.adoc#gpio-pads-control[Pad control], such as drive strength or Schmitt filtering, still applies when the pin is configured as an alternate function. + +Some functions are available on all pins, others on specific pins: -=== Alternative Functions +* PWM (pulse-width modulation) + ** Software PWM available on all pins + ** Hardware PWM available on GPIO12, GPIO13, GPIO18, GPIO19 +* SPI + ** SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7) + ** SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16) +* I2C + ** Data: (GPIO2); Clock (GPIO3) + ** EEPROM Data: (GPIO0); EEPROM Clock (GPIO1) +* Serial + ** TX (GPIO14); RX (GPIO15) -Almost all of the GPIO pins have alternative functions. Peripheral blocks internal to BCM2835 can be selected to appear on one or more of a set of GPIO pins, for example the I2C busses can be configured to at least 3 separate locations. Pad control, such as drive strength or Schmitt filtering, still applies when the pin is configured as an alternate function. +=== Voltage specifications -=== Voltage Specifications +Two 5V pins and two 3.3V pins are present on the board, as well as a number of ground pins (GND), which can not be reconfigured. The remaining pins are all general-purpose 3.3V pins, meaning outputs are set to 3.3V and inputs are 3.3V-tolerant. -The following table gives the various voltage specifications for the GPIO pins, it was extracted from the xref:compute-module.adoc#datasheets-and-schematics[Compute Module datasheet]. +The table below gives the various voltage specifications for the GPIO pins for BCM2835, BCM2836, BCM2837 and RP3A0-based products (e.g. Raspberry Pi Zero or Raspberry Pi 3+). For information about Compute Modules you should see the xref:compute-module.adoc#specifications[relevant datasheets]. |=== | Symbol | Parameter | Conditions   | Min | Typical | Max | Unit | V~IL~ | Input Low Voltage -| VDD IO = 1.8V | - | - -| 0.6 -| V - -| -| -| VDD IO = 2.7V -| - -| - -| 0.8 -| V - -| -| -| VDD IO = 3.3V -| - | - | 0.9 | V | V~IH~ | Input high voltage^a^ -| VDD IO = 1.8V -| 1.0 -| - | - -| V - -| -| -| VDD IO = 2.7V -| 1.3 -| - -| - -| V - -| -| -| VDD IO = 3.3V | 1.6 | - | - @@ -112,96 +123,114 @@ The following table gives the various voltage specifications for the GPIO pins, | V~OL~ | Output low voltage^b^ -| VDD IO = 1.8V, IOL = -2mA +| IOL = -2mA | - | - -| 0.2 +| 0.14 | V -| -| -| VDD IO = 2.7V, IOL = -2mA +| V~OH~ +| Output high voltage^b^ +| IOH = 2mA +| 3.0 | - | - -| 0.15 | V -| -| -| VDD IO = 3.3V, IOL = -2mA +| I~OL~ +| Output low current^c^ +| VO = 0.4V +| 18 | - | - -| 0.14 -| V +| mA -| V~OH~ -| Output high voltage^b^ -| VDD IO = 1.8V, IOH = 2mA -| 1.6 +| I~OH~ +| Output high current^c^ +| VO = 2.3V +| 17 | - | - -| V +| mA -| -| -| VDD IO = 2.7V, IOH = 2mA -| 2.5 +| R~PU~ +| Pullup resistor | - +| 50 | - -| V +| 65 +| kΩ -| -| -| VDD IO = 3.3V, IOH = 2mA -| 3.0 +| R~PD~ +| Pulldown resistor +| - +| 50 +| - +| 65 +| kΩ +|=== + +^a^ Hysteresis enabled + +^b^ Default drive strength (8mA) + +^c^ Maximum drive strength (16mA) + +The table below gives the voltage specifications for the GPIO pins on BCM2711-based products (4-series devices). For information about Compute Modules you should see the xref:compute-module.adoc#specifications[relevant datasheets]. + +|=== +| Symbol | Parameter | Conditions   | Min | Typical | Max | Unit + +| V~IL~ +| Input Low Voltage +| - | - | - +| 0.8 | V -| I~OL~ -| Output low current^c^ -| VDD IO = 1.8V, VO = 0.4V -| 12 +| V~IH~ +| Input high voltage^a^ | - +| 2.0 | - -| mA +| - +| V -| -| -| VDD IO = 2.7V, VO = 0.4V -| 17 +| I~IL~ +| Input leakage current +| TA = +85◦C | - | - -| mA +| 10 +| µA -| -| -| VDD IO = 3.3V, VO = 0.4V -| 18 +| V~OL~ +| Output low voltage^b^ +| IOL = -4mA | - | - -| mA +| 0.4 +| V -| I~OH~ -| Output high current^c^ -| VDD IO = 1.8V, VO = 1.4V -| 10 +| V~OH~ +| Output high voltage^b^ +| IOH = 4mA +| 2.6 | - | - -| mA +| V -| -| -| VDD IO = 2.7V, VO = 2.3V -| 16 +| I~OL~ +| Output low current^c^ +| VO = 0.4V +| 7 | - | - | mA -| -| -| VDD IO = 3.3V, VO = 2.3V -| 17 +| I~OH~ +| Output high current^c^ +| VO = 2.6V +| 7 | - | - | mA @@ -209,20 +238,20 @@ The following table gives the various voltage specifications for the GPIO pins, | R~PU~ | Pullup resistor | - -| 50 +| 33 | - -| 65 +| 73 | kΩ | R~PD~ | Pulldown resistor | - -| 50 +| 33 | - -| 65 +| 73 | kΩ |=== ^a^ Hysteresis enabled + -^b^ Default drive strength (8mA) + -^c^ Maximum drive strength (16mA) +^b^ Default drive strength (4mA) + +^c^ Maximum drive strength (8mA) diff --git a/documentation/asciidoc/computers/raspberry-pi/gpio-pad-controls.adoc b/documentation/asciidoc/computers/raspberry-pi/gpio-pad-controls.adoc index 2e8d0a33a6..5379d9e053 100644 --- a/documentation/asciidoc/computers/raspberry-pi/gpio-pad-controls.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/gpio-pad-controls.adoc @@ -1,62 +1,51 @@ -== GPIO Pads Control +== GPIO pads control GPIO drive strengths do not indicate a maximum current, but a maximum current under which the pad will still meet the specification. You should set the GPIO drive strengths to match the device being attached in order for the device to work correctly. -[discrete] -=== How Drive Strength is Controlled +=== Control drive strength -Inside the pad are a number of drivers in parallel. If the drive strength is set low (000) most of these are tri-stated so they do not add anything to the output current. If the drive strength is increased, more and more drivers are put in parallel. The following diagram shows that behaviour: +Inside the pad are a number of drivers in parallel. If the drive strength is set low (`0b000`), most of these are tri-stated so they do not add anything to the output current. If the drive strength is increased, more and more drivers are put in parallel. The diagram shows that behaviour. -image::images/pi_gpio_drive_strength_diagram.png[GPIO Drive Strength Diagram] +WARNING: On 4-series devices, the current level is half the value shown in the diagram. -[discrete] -=== What does the current value mean? +image::images/pi_gpio_drive_strength_diagram.png[GPIO drive strength diagram] -NOTE: The current value specifies the maximum current under which the pad will still meet the specification. +=== Current value -. It is *not* the current that the pad will deliver -. It is *not* a current limit so the pad will not blow up +The current value specifies the maximum current under which the pad will still meet the specification. + +Current value is _not_ the current that the pad will deliver, and is _not_ a current limit. The pad output is a voltage source: -* If set high,the pad will try to drive the output to the rail voltage, which on the Raspberry Pi is 3V3 (3.3 volts) -* If set low, the pad will try to drive the output to ground (0 volts) +* If set high, the pad will try to drive the output to the rail voltage (3.3V) +* If set low, the pad will try to drive the output to ground (0V) -The pad will try to drive the output high or low. Success will depend on the requirements of what is connected. If the pad is shorted to ground, it will not be able to drive high. It will actually try to deliver as much current as it can, and the current is only limited by the internal resistance. +The pad will try to drive the output high or low. Success will depend on the requirements of what is connected. If the pad is shorted to ground, it will not be able to drive high. It will try to deliver as much current as it can, and the current is only limited by the internal resistance. -If the pad is driven high and it is shorted to ground, in due time it will fail. The same holds true if you connect it to 3V3 and drive it low. +If the pad is driven high and it is shorted to ground, in due time it will fail. The same holds true if you connect it to 3.3V and drive it low. Meeting the specification is determined by the guaranteed voltage levels. Because the pads are digital, there are two voltage levels, high and low. The I/O ports have two parameters which deal with the output level: -* V~IL~, the maximum low-level voltage (0.9V at 3V3 VDD IO) -* V~IH~, the minimum high-level voltage (1.6V at 3V3 VDD IO) - -V~IL~=0.9V means that if the output is Low, it will be \<= 0.9V. -V~IH~=1.6V means that if the output is High, it will be >= 1.6V. +* V~OL~, the maximum low-level voltage (0.14V at 3.3V VDD IO) +* V~OH~, the minimum high-level voltage (3.0V at 3.3V VDD IO) -Thus a drive strength of 16mA means: +V~OL~=0.14V means that if the output is Low, it will be \<= 0.14V. +V~OH~=3.0V means that if the output is High, it will be >= 3.0V. -If you set the pad high, you can draw up to 16mA, and the output voltage is guaranteed to be >=V~IH~. This also means that if you set a drive strength of 2mA and you draw 16mA, the voltage will *not* be V~IH~ but lower. In fact, it may not be high enough to be seen as high by an external device. +As an example, a drive strength of 16mA means that if you set the pad high, you can draw up to 16mA, and the output voltage is guaranteed to be >=V~OH~. This also means that if you set a drive strength of 2mA and you draw 16mA, the voltage will *not* be V~OH~ but lower. In fact, it may not be high enough to be seen as high by an external device. There is more information on the xref:raspberry-pi.adoc#gpio[physical characteristics] of the GPIO pins. -NOTE: On the Compute Module devices, it is possible to change the VDD IO from the standard 3V3. In this case, V~IL~ and V~IH~ will change according to the table on the linked page. - -[discrete] -=== Why don't I set all my pads to the maximum current? - -Two reasons: +NOTE: On the Compute Module devices, it is possible to change the VDD IO from the standard 3.3V. In this case, V~OL~ and V~OH~ will change according to the table in the xref:raspberry-pi.adoc#gpio[GPIO] section. -. The Raspberry Pi 3V3 supply was designed with a maximum current of ~3mA per GPIO pin. If you load each pin with 16mA, the total current is 272mA. The 3V3 supply will collapse under that level of load. -. Big current spikes will happen, especially if you have a capacitive load. That will "bounce" around all the other pins near it. It is likely to cause interference with the SD card or even the SDRAM behaviour. +The Raspberry Pi 3.3V supply was designed with a maximum current of ~3mA per GPIO pin. If you load each pin with 16mA, the total current is 272mA. The 3.3V supply will collapse under that level of load. Big current spikes will happen, especially if you have a capacitive load. Spikes will bounce around all the other pins near them. This is likely to cause interference with the SD card, or even the SDRAM behaviour. -[discrete] -=== What is a safe current? +=== Safe current -All the electronics of the pads are designed for 16mA. That is a safe value under which you will not damage the device. Even if you set the drive strength to 2mA and then load it so 16mA comes out, this will not damage the device. Other than that, there is no guaranteed maximum safe current. +All the electronics of the pads are designed for 16mA. This is a safe value under which you will not damage the device. Even if you set the drive strength to 2mA and then load it so 16mA comes out, this will not damage the device. Other than that, there is no guaranteed maximum safe current. -[discrete] -=== GPIO Addresses +=== GPIO addresses * 0x 7e10 002c PADS (GPIO 0-27) * 0x 7e10 0030 PADS (GPIO 28-45) @@ -67,7 +56,7 @@ All the electronics of the pads are designed for 16mA. That is a safe value unde | 31:24 | PASSWRD -| Must be 5A when writing; accidental write protect password +| Must be 0x5A when writing; accidental write protect password | W | 0 @@ -96,9 +85,8 @@ All the electronics of the pads are designed for 16mA. That is a safe value unde | 0x3 |=== -Beware of SSO (Simultaneous Switching Outputs) limitations which are device-dependent as well as dependent on the quality and layout of the PCB, the amount and quality of the decoupling capacitors, the type of load on the pads (resistance, capacitance), and other factors beyond the control of Raspberry Pi. +Beware of Simultaneous Switching Outputs (SSO) limitations which are device-dependent as well as dependent on the quality and layout of the PCB, the amount and quality of the decoupling capacitors, the type of load on the pads (resistance, capacitance), and other factors beyond the control of Raspberry Pi. -[discrete] === Drive strength list * 0 = 2mA diff --git a/documentation/asciidoc/computers/raspberry-pi/images/2-model-b.jpg b/documentation/asciidoc/computers/raspberry-pi/images/2-model-b.jpg new file mode 100644 index 0000000000..0374da3185 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/2-model-b.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/3-model-a-plus.jpg b/documentation/asciidoc/computers/raspberry-pi/images/3-model-a-plus.jpg new file mode 100644 index 0000000000..084fb1f824 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/3-model-a-plus.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/3-model-b-plus.jpg b/documentation/asciidoc/computers/raspberry-pi/images/3-model-b-plus.jpg new file mode 100644 index 0000000000..b36dcb63d7 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/3-model-b-plus.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/3-model-b.jpg b/documentation/asciidoc/computers/raspberry-pi/images/3-model-b.jpg new file mode 100644 index 0000000000..56be0d94b3 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/3-model-b.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/4-model-b.jpg b/documentation/asciidoc/computers/raspberry-pi/images/4-model-b.jpg new file mode 100644 index 0000000000..fcf8e39429 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/4-model-b.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/400.jpg b/documentation/asciidoc/computers/raspberry-pi/images/400.jpg new file mode 100644 index 0000000000..392696b3a1 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/400.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/5.jpg b/documentation/asciidoc/computers/raspberry-pi/images/5.jpg new file mode 100644 index 0000000000..2fe9e165fa Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/5.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/500.png b/documentation/asciidoc/computers/raspberry-pi/images/500.png new file mode 100644 index 0000000000..d4965dc0bc Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/500.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/GPIO-Pinout-Diagram-2.png b/documentation/asciidoc/computers/raspberry-pi/images/GPIO-Pinout-Diagram-2.png new file mode 100644 index 0000000000..24238cc23d Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/GPIO-Pinout-Diagram-2.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/GPIO.png b/documentation/asciidoc/computers/raspberry-pi/images/GPIO.png new file mode 100644 index 0000000000..1f466a43b2 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/GPIO.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/bootloader-diagnostics.png b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-diagnostics.png index 77cd8b7ee9..f96e278251 100644 Binary files a/documentation/asciidoc/computers/raspberry-pi/images/bootloader-diagnostics.png and b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-diagnostics.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/bootloader-family-select.png b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-family-select.png new file mode 100644 index 0000000000..67811b1c62 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-family-select.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/bootloader-storage-select.png b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-storage-select.png new file mode 100644 index 0000000000..91f00cbfe0 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/bootloader-storage-select.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-1.jpg b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-1.jpg new file mode 100644 index 0000000000..caa01fec3a Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-1.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3-plus.jpg b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3-plus.jpg new file mode 100644 index 0000000000..dc266211b8 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3-plus.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3.jpg b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3.jpg new file mode 100644 index 0000000000..c82500604a Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-3.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4.jpg b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4.jpg new file mode 100644 index 0000000000..74141b492b Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4s.jpg b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4s.jpg new file mode 100644 index 0000000000..7119617d8e Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-4s.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/compute-module-5.png b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-5.png new file mode 100644 index 0000000000..70140e593e Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/compute-module-5.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/dpi-altfn2.png b/documentation/asciidoc/computers/raspberry-pi/images/dpi-altfn2.png deleted file mode 100644 index 9eef39afa1..0000000000 Binary files a/documentation/asciidoc/computers/raspberry-pi/images/dpi-altfn2.png and /dev/null differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/dpi-packing.png b/documentation/asciidoc/computers/raspberry-pi/images/dpi-packing.png deleted file mode 100644 index 93d2964c9a..0000000000 Binary files a/documentation/asciidoc/computers/raspberry-pi/images/dpi-packing.png and /dev/null differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/j2.jpg b/documentation/asciidoc/computers/raspberry-pi/images/j2.jpg new file mode 100644 index 0000000000..2851c88378 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/j2.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/j5.png b/documentation/asciidoc/computers/raspberry-pi/images/j5.png new file mode 100644 index 0000000000..1de24e5717 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/j5.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/misc-utility-images.png b/documentation/asciidoc/computers/raspberry-pi/images/misc-utility-images.png new file mode 100644 index 0000000000..016ed706db Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/misc-utility-images.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/model-a-plus.jpg b/documentation/asciidoc/computers/raspberry-pi/images/model-a-plus.jpg new file mode 100644 index 0000000000..40f8231a5f Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/model-a-plus.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/model-a.jpg b/documentation/asciidoc/computers/raspberry-pi/images/model-a.jpg new file mode 100644 index 0000000000..3a20cbf823 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/model-a.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/model-b-plus.jpg b/documentation/asciidoc/computers/raspberry-pi/images/model-b-plus.jpg new file mode 100644 index 0000000000..acab61b8e7 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/model-b-plus.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/model-b.jpg b/documentation/asciidoc/computers/raspberry-pi/images/model-b.jpg new file mode 100644 index 0000000000..5f8bc84fd8 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/model-b.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pcie.jpg b/documentation/asciidoc/computers/raspberry-pi/images/pcie.jpg new file mode 100644 index 0000000000..610060f81f Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pcie.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico-2-w.png b/documentation/asciidoc/computers/raspberry-pi/images/pico-2-w.png new file mode 100644 index 0000000000..77466f9874 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico-2-w.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico-2.png b/documentation/asciidoc/computers/raspberry-pi/images/pico-2.png new file mode 100644 index 0000000000..f3fe1bac9c Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico-2.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico-h.png b/documentation/asciidoc/computers/raspberry-pi/images/pico-h.png new file mode 100644 index 0000000000..4e9c6895e6 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico-h.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico-w.png b/documentation/asciidoc/computers/raspberry-pi/images/pico-w.png new file mode 100644 index 0000000000..2d42d02cef Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico-w.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico-wh.png b/documentation/asciidoc/computers/raspberry-pi/images/pico-wh.png new file mode 100644 index 0000000000..014f929571 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico-wh.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/pico.png b/documentation/asciidoc/computers/raspberry-pi/images/pico.png new file mode 100644 index 0000000000..d36e87d798 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/pico.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/poe.jpg b/documentation/asciidoc/computers/raspberry-pi/images/poe.jpg new file mode 100644 index 0000000000..aabb5a7206 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/poe.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/rtc-battery.jpg b/documentation/asciidoc/computers/raspberry-pi/images/rtc-battery.jpg new file mode 100644 index 0000000000..a5d234f0f2 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/rtc-battery.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero-2-w.jpg b/documentation/asciidoc/computers/raspberry-pi/images/zero-2-w.jpg new file mode 100644 index 0000000000..b1998ce272 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero-2-w.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero-2-wh.png b/documentation/asciidoc/computers/raspberry-pi/images/zero-2-wh.png new file mode 100644 index 0000000000..f87157e223 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero-2-wh.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero-w.jpg b/documentation/asciidoc/computers/raspberry-pi/images/zero-w.jpg new file mode 100644 index 0000000000..87c1d93374 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero-w.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero-wh.jpg b/documentation/asciidoc/computers/raspberry-pi/images/zero-wh.jpg new file mode 100644 index 0000000000..d9b00c7b21 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero-wh.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero.jpg b/documentation/asciidoc/computers/raspberry-pi/images/zero.jpg new file mode 100644 index 0000000000..c698be8e13 Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero.jpg differ diff --git a/documentation/asciidoc/computers/raspberry-pi/images/zero2-pad-diagram.png b/documentation/asciidoc/computers/raspberry-pi/images/zero2-pad-diagram.png new file mode 100644 index 0000000000..83e5e701da Binary files /dev/null and b/documentation/asciidoc/computers/raspberry-pi/images/zero2-pad-diagram.png differ diff --git a/documentation/asciidoc/computers/raspberry-pi/introduction.adoc b/documentation/asciidoc/computers/raspberry-pi/introduction.adoc new file mode 100644 index 0000000000..168c673f7f --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/introduction.adoc @@ -0,0 +1,429 @@ +== Introduction + +Raspberry Pi makes computers in several different **series**: + +* The *Flagship* series, often referred to by the shorthand "Raspberry Pi", offers high-performance hardware, a full Linux operating system, and a variety of common ports in a form factor roughly the size of a credit card. +* The *Keyboard* series, offers high-performance Flagship hardware, a full Linux operating system, and a variety of common ports bundled inside a keyboard form factor. +* The *Zero* series offers a full Linux operating system and essential ports at an affordable price point in a minimal form factor with low power consumption. +* The *Compute Module* series, often referred to by the shorthand "CM", offers high-performance hardware and a full Linux operating system in a minimal form factor suitable for industrial and embedded applications. Compute Module models feature hardware equivalent to the corresponding flagship models, but with fewer ports and no on-board GPIO pins. Instead, users should connect Compute Modules to a separate baseboard that provides the ports and pins required for a given application. + +Additionally, Raspberry Pi makes the *Pico* series of tiny, versatile https://en.wikipedia.org/wiki/Microcontroller[microcontroller] boards. Pico models do not run Linux or allow for removable storage, but instead allow programming by flashing a binary onto on-board flash storage. + +=== Flagship series + +*Model B* indicates the presence of an Ethernet port. +*Model A* indicates a lower-cost model in a smaller form factor with no Ethernet port, reduced RAM, and fewer USB ports to limit board height. + +[cols="6a,2,2,3,5"] +|=== +| Model | SoC | Memory | GPIO | Connectivity + +^.^a| +.Raspberry Pi Model B +image::images/model-b.jpg[alt="Raspberry Pi Model B"] +| xref:processors.adoc#bcm2835[BCM2835] +a| +256MB + +512MB | 26-pin GPIO header +a| +* HDMI +* 2× USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm audio jack +* RCA composite video +* 100Mb/s Ethernet RJ45 +* SD card slot +* micro USB power +^.^a| +.Raspberry Pi Model A +image::images/model-a.jpg[alt="Raspberry Pi Model A",width="80%"] +| xref:processors.adoc#bcm2835[BCM2835] | 256MB | 26-pin GPIO header +a| +* HDMI +* USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm audio jack +* RCA composite video +* SD card slot +* micro USB power +^.^a| +.Raspberry Pi Model B+ +image::images/model-b-plus.jpg[alt="Raspberry Pi Model B+"] +| xref:processors.adoc#bcm2835[BCM2835] | 512MB | 40-pin GPIO header +a| +* HDMI +* 4× USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* 100Mb/s Ethernet RJ45 +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi Model A+ +image::images/model-a-plus.jpg[alt="Raspberry Pi Model A+"] +| xref:processors.adoc#bcm2835[BCM2835] +a| +256MB + +512MB | 40-pin GPIO header +a| +* HDMI +* USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi 2 Model B +image::images/2-model-b.jpg[alt="Raspberry Pi 2 Model B"] +| xref:processors.adoc#bcm2836[BCM2836] (in version 1.2, switched to xref:processors.adoc#bcm2837[BCM2837]) | 1 GB | 40-pin GPIO header +a| +* HDMI +* 4× USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* 100Mb/s Ethernet RJ45 +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi 3 Model B +image::images/3-model-b.jpg[alt="Raspberry Pi 3 Model B"] +| xref:processors.adoc#bcm2837[BCM2837] | 1 GB | 40-pin GPIO header +a| +* HDMI +* 4× USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* 100Mb/s Ethernet RJ45 +* 2.4GHz single-band 802.11n Wi-Fi (35Mb/s) +* Bluetooth 4.1, Bluetooth Low Energy (BLE) +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi 3 Model B+ +image::images/3-model-b-plus.jpg[alt="Raspberry Pi 3 Model B+"] +| xref:processors.adoc#bcm2837b0[BCM2837b0] | 1GB | 40-pin GPIO header +a| +* HDMI +* 4× USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* 300Mb/s Ethernet RJ45 with PoE support +* 2.4/5GHz dual-band 802.11ac Wi-Fi (100Mb/s) +* Bluetooth 4.2, Bluetooth Low Energy (BLE) +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi 3 Model A+ +image::images/3-model-a-plus.jpg[alt="Raspberry Pi 3 Model A+"] +| xref:processors.adoc#bcm2837b0[BCM2837b0] | 512 MB | 40-pin GPIO header +a| +* HDMI +* USB 2.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* 2.4/5GHz dual-band 802.11ac Wi-Fi (100Mb/s) +* Bluetooth 4.2, Bluetooth Low Energy (BLE) +* microSD card slot +* micro USB power +^.^a| +.Raspberry Pi 4 Model B +image::images/4-model-b.jpg[alt="Raspberry Pi 4 Model B"] +| xref:processors.adoc#bcm2711[BCM2711] +a| +1GB + +2GB + +4GB + +8GB | 40-pin GPIO header +a| +* 2× micro HDMI +* 2× USB 2.0 +* 2× USB 3.0 +* standard 15-pin, 1.0mm pitch, 16mm width, CSI (camera) port +* standard 15-pin, 1.0mm pitch, 16mm width, DSI (display) port +* 3.5mm AV jack +* Gigabit (1Gb/s) Ethernet RJ45 with PoE+ support +* 2.4/5GHz dual-band 802.11ac Wi-Fi (120Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) +* microSD card slot +* USB-C power (5V 3A (15W)) +^.^a| +.Raspberry Pi 5 +image::images/5.jpg[alt="Raspberry Pi 5"] +| xref:processors.adoc#bcm2712[BCM2712] +a| +2GB + +4GB + +8GB + +16GB | 40-pin GPIO header +a| +* 2× micro HDMI +* 2× USB 2.0 +* 2× USB 3.0 +* 2× mini 22-pin, 0.5mm (fine) pitch, 11.5mm width, combined CSI (camera)/DSI (display) ports +* single-lane https://datasheets.raspberrypi.com/pcie/pcie-connector-standard.pdf[PCIe FFC connector] +* https://datasheets.raspberrypi.com/debug/debug-connector-specification.pdf[UART connector] +* RTC battery connector +* xref:raspberry-pi.adoc#raspberry-pi-5-fan-connector-pinout[four-pin JST-SH PWM fan connector] +* Gigabit (1Gb/s) Ethernet RJ45 with PoE+ support +* 2.4/5GHz dual-band 802.11ac Wi-Fi 5 (300Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) +* microSD card slot +* USB-C power (5V 5A (25W), or 5V 3A (15W) with a 600mA peripheral limit) +|=== + +For more information about the ports on the Raspberry Pi flagship series, see the xref:raspberry-pi.adoc#schematics-and-mechanical-drawings[Schematics and mechanical drawings]. + +=== Keyboard series + +Keyboard series devices use model identifiers of the form ``, where `X` indicates the corresponding Flagship series device. For instance, "Raspberry Pi 500" is the keyboard version of the Raspberry Pi 5. + +[cols="6a,2,2,3,5"] +|=== +| Model | SoC | Memory | GPIO | Connectivity + +^.^a| +.Raspberry Pi 400 +image::images/400.jpg[alt="Raspberry Pi 400"] +| xref:processors.adoc#bcm2711[BCM2711] | 4GB | 40-pin GPIO header +a| +* 2× micro HDMI +* USB 2.0 +* 2× USB 3.0 +* Gigabit (1Gb/s) Ethernet RJ45 +* 2.4/5GHz dual-band 802.11ac Wi-Fi (120Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) +* microSD card slot +* USB-C power (5V 3A (15W)) +^.^a| +.Raspberry Pi 500 +image::images/500.png[alt="Raspberry Pi 500"] +| xref:processors.adoc#bcm2712[BCM2712] | 8GB | 40-pin GPIO header +a| +* 2× micro HDMI +* USB 2.0 +* 2× USB 3.0 +* Gigabit (1Gb/s) Ethernet RJ45 +* 2.4/5GHz dual-band 802.11ac Wi-Fi 5 (300Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) +* microSD card slot +* USB-C power (5V 5A (25W), or 5V 3A (15W) with a 600mA peripheral limit) +|=== + +=== Zero series + +Models with the *H* suffix have header pins pre-soldered to the GPIO header. Models that lack the *H* suffix do not come with header pins attached to the GPIO header; the user must solder pins manually or attach a third-party pin kit. + +All Zero models have the following connectivity: + +* a microSD card slot +* a mini HDMI port +* 2× micro USB ports (one for input power, one for external devices) + +Since version 1.3 of the original Zero, all Zero models also include: + +* a mini 22-pin, 0.5mm (fine) pitch, 11.5mm width, CSI (camera) port + +[cols="3a,1,1,1,2"] +|=== +| Model | SoC | Memory | GPIO | Wireless Connectivity + +^.^a| +.Raspberry Pi Zero +image::images/zero.jpg[alt="Raspberry Pi Zero"] +| xref:processors.adoc#bcm2835[BCM2835] | 512MB | 40-pin GPIO header (unpopulated) ^| none +^.^a| +.Raspberry Pi Zero W +image::images/zero-w.jpg[alt="Raspberry Pi Zero W"] +| xref:processors.adoc#bcm2835[BCM2835] | 512MB | 40-pin GPIO header (unpopulated) +a| +* 2.4GHz single-band 802.11n Wi-Fi (35Mb/s) +* Bluetooth 4.0, Bluetooth Low Energy (BLE) +^.^a| +.Raspberry Pi Zero WH +image::images/zero-wh.jpg[alt="Raspberry Pi Zero WH"] +| xref:processors.adoc#bcm2835[BCM2835] | 512MB | 40-pin GPIO header +a| +* 2.4GHz single-band 802.11n Wi-Fi (35Mb/s) +* Bluetooth 4.0, Bluetooth Low Energy (BLE) +^.^a| +.Raspberry Pi Zero 2 W +image::images/zero-2-w.jpg[alt="Raspberry Pi Zero 2 W"] +| xref:processors.adoc#rp3a0[RP3A0] | 512MB | 40-pin GPIO header (unpopulated) +a| +* 2.4GHz single-band 802.11n Wi-Fi (35Mb/s) +* Bluetooth 4.2, Bluetooth Low Energy (BLE) +^.^a| +.Raspberry Pi Zero 2 WH +image::images/zero-2-wh.png[alt="Raspberry Pi Zero 2 WH"] +| xref:processors.adoc#rp3a0[RP3A0] | 512MB | 40-pin GPIO header +a| +* 2.4GHz single-band 802.11n Wi-Fi (35Mb/s) +* Bluetooth 4.2, Bluetooth Low Energy (BLE) +|=== + +=== Compute Module series + +[cols="3a,1,1,1,1,2"] +|=== +| Model | SoC | Memory | Storage | Form factor | Wireless Connectivity + +^.^a| +.Raspberry Pi Compute Module 1 +image::images/compute-module-1.jpg[alt="Raspberry Pi Compute Module 1"] +| xref:processors.adoc#bcm2835[BCM2835] | 512MB +| 4GB | DDR2 SO-DIMM ^| none +^.^a| +.Raspberry Pi Compute Module 3 +image::images/compute-module-3.jpg[alt="Raspberry Pi Compute Module 3"] +| xref:processors.adoc#bcm2837[BCM2837] | 1GB +a| +0GB (Lite) + +4GB | DDR2 SO-DIMM ^| none +^.^a| +.Raspberry Pi Compute Module 3+ +image::images/compute-module-3-plus.jpg[alt="Raspberry Pi Compute Module 3+"] +| xref:processors.adoc#bcm2837b0[BCM2837b0] | 1GB +a| +0GB (Lite) + +8GB + +16GB + +32GB | DDR2 SO-DIMM ^| none +^.^a| +.Raspberry Pi Compute Module 4S +image::images/compute-module-4s.jpg[alt="Raspberry Pi Compute Module 4S"] +| xref:processors.adoc#bcm2711[BCM2711] +a| +1GB + +2GB + +4GB + +8GB +a| +0GB (Lite) + +8GB + +16GB + +32GB | DDR2 SO-DIMM ^| none +^.^a| +.Raspberry Pi Compute Module 4 +image::images/compute-module-4.jpg[alt="Raspberry Pi Compute Module 4"] +| xref:processors.adoc#bcm2711[BCM2711] +a| +1GB + +2GB + +4GB + +8GB +a| +0GB (Lite) + +8GB + +16GB + +32GB +| dual 100-pin high density connectors +a| optional: + +* 2.4/5GHz dual-band 802.11ac Wi-Fi 5 (300Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) + +^.^a| +.Raspberry Pi Compute Module 5 +image::images/compute-module-5.png[alt="Raspberry Pi Compute Module 5"] +| xref:processors.adoc#bcm2712[BCM2712] +a| +2GB + +4GB + +8GB +a| +0GB (Lite) + +16GB + +32GB + +64GB +| dual 100-pin high density connectors +a| optional: + +* 2.4/5GHz dual-band 802.11ac Wi-Fi 5 (300Mb/s) +* Bluetooth 5, Bluetooth Low Energy (BLE) +|=== + +NOTE: Compute Modules that use the physical DDR2 SO-DIMM form factor are *not* compatible with DDR2 SO-DIMM electrical specifications. + +For more information about Raspberry Pi Compute Modules, see xref:../computers/compute-module.adoc[the Compute Module documentation]. + +=== Pico microcontrollers + +Models with the *H* suffix have header pins pre-soldered to the GPIO header. Models that lack the *H* suffix do not come with header pins attached to the GPIO header; the user must solder pins manually or attach a third-party pin kit. + +[cols="3a,1,1,1,1,2"] +|=== +| Model | SoC | Memory | Storage | GPIO | Wireless Connectivity + +| +.Raspberry Pi Pico +image::images/pico.png[alt="Raspberry Pi Pico"] +| xref:../microcontrollers/silicon.adoc#rp2040[RP2040] | 264KB | 2MB | two 20-pin GPIO headers (unpopulated) ^| none +| +.Raspberry Pi Pico H +image::images/pico-h.png[alt="Raspberry Pi Pico H"] +| xref:../microcontrollers/silicon.adoc#rp2040[RP2040] | 264KB | 2MB | two 20-pin GPIO headers ^| none +| +.Raspberry Pi Pico W +image::images/pico-w.png[alt="Raspberry Pi Pico W"] +| xref:../microcontrollers/silicon.adoc#rp2040[RP2040] | 264KB | 2MB | two 20-pin GPIO headers (unpopulated) +a| +* 2.4GHz single-band 802.11n Wi-Fi (10Mb/s) +* Bluetooth 5.2, Bluetooth Low Energy (BLE) +| +.Raspberry Pi Pico WH +image::images/pico-wh.png[alt="Raspberry Pi Pico WH"] +| xref:../microcontrollers/silicon.adoc#rp2040[RP2040] | 264KB | 2MB | two 20-pin GPIO headers +a| +* 2.4GHz single-band 802.11n Wi-Fi (10Mb/s) +* Bluetooth 5.2, Bluetooth Low Energy (BLE) +| +.Raspberry Pi Pico 2 +image::images/pico-2.png[alt="Raspberry Pi Pico 2"] +| xref:../microcontrollers/silicon.adoc#rp2350[RP2350] | 520KB | 4MB | two 20-pin GPIO headers (unpopulated) ^| none +| +.Raspberry Pi Pico 2 W +image::images/pico-2-w.png[alt="Raspberry Pi Pico 2 W"] +| xref:../microcontrollers/silicon.adoc#rp2350[RP2350] | 520KB | 4MB | two 20-pin GPIO headers (unpopulated) a| +* 2.4GHz single-band 802.11n Wi-Fi (10Mb/s) +* Bluetooth 5.2, Bluetooth Low Energy (BLE) + +|=== + +For more information about Raspberry Pi Pico models, see xref:../microcontrollers/pico-series.adoc[the Pico documentation]. diff --git a/documentation/asciidoc/computers/raspberry-pi/otp-bits.adoc b/documentation/asciidoc/computers/raspberry-pi/otp-bits.adoc index a35431411d..c9efabb22b 100644 --- a/documentation/asciidoc/computers/raspberry-pi/otp-bits.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/otp-bits.adoc @@ -1,23 +1,33 @@ -== OTP Register and Bit Definitions +== OTP register and bit definitions -All SoCs used by the Raspberry Pi range have a inbuilt One-Time Programmable (OTP) memory block. +All SoCs used by the Raspberry Pi range have a inbuilt one-time programmable (OTP) memory block. A few locations have factory-programmed data. -It is 66 32-bit values long, although only a few locations have factory-programmed data. +OTP memory size: -The `vcgencmd` to display the contents of the OTP is: +* non-BCM2712 devices: 66 32-bit values +* BCM2712 devices: 192 32-bit values +To display the contents of the OTP, run the following command: + +[source,console] ---- -vcgencmd otp_dump +$ vcgencmd otp_dump ---- -=== OTP Registers +=== OTP registers on non-BCM2712 devices This list contains the publicly available information on the registers. If a register or bit is not defined here, then it is not public. -17 -- bootmode register +`16`:: OTP control register - BCM2711 ++ +* Bit 26: disables VC JTAG +* Bit 27: disables VC JTAG +`17`:: bootmode register ++ * Bit 1: sets the oscillator frequency to 19.2MHz * Bit 3: enables pull ups on the SDIO pins +* Bit 15: disables ROM RSA key 0 - (secure boot enabled if set) (BCM2711) * Bit 19: enables GPIO bootmode * Bit 20: sets the bank to check for GPIO bootmode * Bit 21: enables booting from SD card @@ -25,32 +35,35 @@ This list contains the publicly available information on the registers. If a reg * Bit 28: enables USB device booting * Bit 29: enables USB host booting (ethernet and mass storage) -NOTE: On BCM2711 the bootmode is defined by the xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[bootloader EEPROM configuration] instead of OTP. - -18 -- copy of bootmode register + -28 -- serial number + -29 -- ~(serial number) + -30 -- xref:raspberry-pi.adoc#raspberry-pi-revision-codes[revision code]^1^ + -33 - board revision extended - the meaning depends on the board model. + -This is available via device-tree in `/proc/device-tree/chosen/rpi-boardrev-ext` and for testing purposes this OTP value can be temporarily overriden by setting `board_rev_ext` in `config.txt`. +NOTE: On BCM2711 the bootmode is defined by the xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[bootloader EEPROM configuration] instead of OTP. +`18`:: copy of bootmode register +`28`:: serial number +`29`:: ~(serial number) +`30`:: xref:raspberry-pi.adoc#raspberry-pi-revision-codes[revision code] ^1^ +`33`:: board revision extended - the meaning depends on the board model. +This is available via device-tree in `/proc/device-tree/chosen/rpi-boardrev-ext` and for testing purposes this OTP value can be temporarily overridden by setting `board_rev_ext` in `config.txt`. ++ * Compute Module 4 - ** Bit 30: Whether the Compute Module has a WiFi module fitted - *** 0 - WiFi - *** 1 - No WiFi + ** Bit 30: Whether the Compute Module has a Wi-Fi module fitted + *** 0 - Wi-Fi + *** 1 - No Wi-Fi ** Bit 31: Whether the Compute Module has an EMMC module fitted *** 0 - EMMC *** 1 - No EMMC (Lite) -* Pi 400 +* Raspberry Pi 400 ** Bits 0-7: The default keyboard country code used by https://github.com/raspberrypi-ui/piwiz[piwiz] -36-43 - xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer OTP values] + -45 - MPG2 decode key + -46 - WVC1 decode key + -47-55 - Reserved for signed-boot on Compute Module 4 + -64/65 -- MAC address; if set, system will use this in preference to the automatically generated address based on the serial number + -66 -- advanced boot register (not BCM2711) - +`35` :: High 32 bits of 64-bit serial number +`36-43`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer OTP values] +`45`:: MPG2 decode key +`46`:: WVC1 decode key +`47-54`:: SHA256 of RSA public key for secure-boot +`55`:: secure-boot flags (reserved for use by the bootloader) +`56-63`:: 256-bit device-specific private key +`64-65`:: MAC address; if set, system will use this in preference to the automatically generated address based on the serial number +`66`:: advanced boot register (not BCM2711) ++ * Bits 0-6: GPIO for ETH_CLK output pin * Bit 7: enables ETH_CLK output * Bits 8-14: GPIO for LAN_RUN output pin @@ -61,3 +74,57 @@ This is available via device-tree in `/proc/device-tree/chosen/rpi-boardrev-ext` ** 1 - 24MHz ^1^Also contains bits to disable overvoltage, OTP programming, and OTP reading. + +=== OTP Registers on BCM2712 devices + +This list contains the publicly available information on the registers. If a register or bit is not defined here, then it is not public. + +`22`:: bootmode register ++ +* Bit 1: Boot from SD card +* Bits 2-4: Booting from SPI EEPROM (and which GPIOs) +* Bit 10: Disable booting from SD card +* Bit 11: Disable booting from SPI +* Bit 12: Disable booting from USB + +`23`:: copy of bootmode register +`29`:: advanced boot mode ++ +* Bits 0-7: GPIO for SD card detect +* Bits 8-15: GPIO to use for RPIBOOT + +`31`:: lower 32 bits of serial number +`32`:: xref:raspberry-pi.adoc#raspberry-pi-revision-codes[board revision] +`33`:: board attributes - the meaning depends on the board model. +This is available via device-tree in `/proc/device-tree/chosen/rpi-boardrev-ext` + +`35`:: upper 32 bits of serial number +The full 64 bit serial number is available in `/proc/device-tree/serial-number` + +`50-51`:: Ethernet MAC address +This is passed to the operating system in the Device Tree, e.g. `/proc/device-tree/axi/pcie@120000/rp1/ethernet@100000/local-mac-address` + +`52-53`:: Wi-Fi MAC address +This is passed to the operating system in the Device Tree, e.g. `/proc/device-tree/axi/mmc@1100000/wifi@1/local-mac-address` + +`54-55`:: Bluetooth MAC address +This is passed to the operating system in the Device Tree, e.g. `/proc/device-tree/soc/serial@7d50c000/bluetooth/local-bd-address` + +`77-84`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer OTP values] + +`86`:: board country - The default keyboard country code used by https://github.com/raspberrypi-ui/piwiz[piwiz] +If set, this is available via Device Tree in `/proc/device-tree/chosen/rpi-country-code` + +`87-88`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer Ethernet MAC address] +Overrides OTP rows 50-51 if set + +`89-90`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer Wi-Fi MAC address] +Overrides OTP rows 52-53 if set + +`89-90`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer Bluetooth MAC address] +Overrides OTP rows 54-55 if set + +`109-114`:: Factory device UUID +Currently a 16-digit numerical id which should match the bar code on the device. Padded with zero characters and c40 encoded. + +This is available via device-tree in `/proc/device-tree/chosen/rpi-duid`. diff --git a/documentation/asciidoc/computers/raspberry-pi/pcie.adoc b/documentation/asciidoc/computers/raspberry-pi/pcie.adoc new file mode 100644 index 0000000000..6e5d6d1f95 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/pcie.adoc @@ -0,0 +1,88 @@ +== Raspberry Pi connector for PCIe + +.Raspberry Pi connector for PCIe +image::images/pcie.jpg[alt="Raspberry Pi connector for PCIe",width="70%"] + +Raspberry Pi 5 has an FPC connector on the right-hand side of the board. This connector breaks out a PCIe Gen 2.0 ×1 interface for fast peripherals. + +To connect a PCIe https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf[HAT+ device], connect it to your Raspberry Pi. Your Raspberry Pi should automatically detect the device. To connect a non-HAT+ device, connect it to your Raspberry Pi, then <>. + +For more information about the PCIe FPC connector pinout and other details needed to create third-party devices, accessories, and HATs, see the https://datasheets.raspberrypi.com/pcie/pcie-connector-standard.pdf[Raspberry Pi Connector for PCIe] standards document. It should be read alongside the https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf[Raspberry Pi HAT+ Specification]. + +NOTE: Only certain devices https://github.com/raspberrypi/firmware/issues/1833[support] enumeration of PCIe devices behind a switch. + +=== Enable PCIe + +By default, the PCIe connector is not enabled unless connected to a HAT+ device. To enable the connector, add the following line to `/boot/firmware/config.txt`: + +[source,ini] +---- +dtparam=pciex1 +---- + +Reboot with `sudo reboot` for the configuration changes to take effect. + +NOTE: You can also use the alias `nvme`. + +=== Boot from PCIe + +By default, Raspberry Pi devices do not boot from PCIe storage. To enable boot from PCIe, change the `BOOT_ORDER` in the bootloader configuration. Edit the EEPROM configuration with the following command: + +[source,console] +---- +$ sudo rpi-eeprom-config --edit +---- + +Replace the `BOOT_ORDER` line with the following line: + +[source,ini] +---- +BOOT_ORDER=0xf416 +---- + +To boot from a non-HAT+ device, also add the following line: + +[source,ini] +---- +PCIE_PROBE=1 +---- + +After saving your changes, reboot your Raspberry Pi with `sudo reboot` to update the EEPROM. + +=== PCIe Gen 3.0 + +WARNING: The Raspberry Pi 5 is not certified for Gen 3.0 speeds. PCIe Gen 3.0 connections may be unstable. + +By default, Raspberry Pi 5 uses Gen 2.0 speeds (5 GT/s). Use one of the following approaches to force Gen 3.0 (8 GT/s) speeds: + +[tabs] +====== +`config.txt`:: ++ +To enable PCIe Gen 3.0 speeds, add the following line to `/boot/firmware/config.txt`: ++ +[source,ini] +---- +dtparam=pciex1_gen=3 +---- ++ +Reboot your Raspberry Pi with `sudo reboot` for these settings to take effect. + +`raspi-config`:: ++ +Run the following command to open the Raspberry Pi Configuration CLI: ++ +[source,console] +---- +$ sudo raspi-config +---- ++ +Complete the following steps to enable PCIe Gen 3.0 speeds: ++ +. Select `Advanced Options`. +. Select `PCIe Speed`. +. Choose `Yes` to enable PCIe Gen 3 mode. +. Select `Finish` to exit. +. Reboot your Raspberry Pi with `sudo reboot` for your changes to take effect. + +====== diff --git a/documentation/asciidoc/computers/raspberry-pi/peripheral_addresses.adoc b/documentation/asciidoc/computers/raspberry-pi/peripheral_addresses.adoc deleted file mode 100644 index 629ccf343f..0000000000 --- a/documentation/asciidoc/computers/raspberry-pi/peripheral_addresses.adoc +++ /dev/null @@ -1,92 +0,0 @@ -== Peripheral Addresses - -If there is no kernel driver available, and a program needs to access a peripheral address directly with mmap, it needs to know where in the virtual memory map the peripheral bus segment has been placed. This varies according to which model of Raspberry Pi is being used, so there are three helper functions in https://github.com/raspberrypi/userland/blob/3fd8527eefd8790b4e8393458efc5f94eb21a615/host_applications/linux/libs/bcm_host/bcm_host.c[bcm_host.c] to help provide platform independence. - -NOTE: You should use these functions rather than hardcoded values, as this will ensure future compatibility. - ----- -unsigned bcm_host_get_peripheral_address() ----- - -This returns the ARM-side physical address where peripherals are mapped. - ----- -unsigned bcm_host_get_peripheral_size() ----- - -This returns the size of the peripheral's space. - ----- -unsigned bcm_host_get_sdram_address() ----- - -This returns the bus address of the SDRAM. - -Here are the current values as of this writing, in table form: - -|=== -| SoC | Peripheral Address | Peripheral Size | SDRAM Address | Source - -| BCM2835 -| 0x20000000 -| 0x01000000 -| 0x40000000 -| https://github.com/raspberrypi/linux/blob/7f465f823c2ecbade5877b8bbcb2093a8060cb0e/arch/arm/boot/dts/bcm2835.dtsi#L21[bcm2835.dtsi] - -| BCM2836 -| 0x3f000000 -| 0x01000000 -| 0xC0000000 -| https://github.com/raspberrypi/linux/blob/7f465f823c2ecbade5877b8bbcb2093a8060cb0e/arch/arm/boot/dts/bcm2836.dtsi#L10[bcm2836.dtsi] - -| BCM2837 -| 0x3f000000 -| 0x01000000 -| 0xC0000000 -| https://github.com/raspberrypi/linux/blob/7f465f823c2ecbade5877b8bbcb2093a8060cb0e/arch/arm/boot/dts/bcm2837.dtsi#L9[bcm2837.dtsi] - -| BCM2711 -| 0xfe000000 -| 0x01800000 -| 0xc0000000 -| https://github.com/raspberrypi/linux/blob/7f465f823c2ecbade5877b8bbcb2093a8060cb0e/arch/arm/boot/dts/bcm2711.dtsi#L41[bcm2711.dtsi] -|=== - -[discrete] -=== Building a C program using these functions - -The include file and library are installed by default on a Raspberry Pi OS system. Just add the following line to your C program: - -[source,C] ----- -#include ----- - -Example: - -[source,C] ----- -#include -#include - -int main(void) { - printf("bcm_host_get_peripheral_address -> 0x%08x\n", bcm_host_get_peripheral_address()); - printf("bcm_host_get_peripheral_size -> 0x%08x\n", bcm_host_get_peripheral_size()); - printf("bcm_host_get_sdram_address -> 0x%08x\n", bcm_host_get_sdram_address()); - - return 0; -} ----- - -Link with: - ----- --lbcm_host ----- - -So a simple command line compile might be: - -[,shell] ----- -cc myfile.c -I/opt/vc/include -L/opt/vc/lib -lbcm_host -o myfile ----- diff --git a/documentation/asciidoc/computers/raspberry-pi/power-button.adoc b/documentation/asciidoc/computers/raspberry-pi/power-button.adoc new file mode 100644 index 0000000000..d8e1cf4a05 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/power-button.adoc @@ -0,0 +1,28 @@ +== Power button + +NOTE: This section only applies to Raspberry Pi models with a power button, such as the Raspberry Pi 5. + +When you plug your Raspberry Pi into power for the first time, it will automatically turn on and boot into the operating system without having to push the button. + +If you run Raspberry Pi Desktop, you can initiate a clean shutdown by briefly pressing the power button. A window will appear asking whether you want to shutdown, reboot, or logout. + +Select an option or press the power button again to initiate a clean shutdown. + +NOTE: If you run Raspberry Pi Desktop, you can press the power button twice in quick succession to shut down. If you run Raspberry Pi OS Lite without a desktop, press the power button a single time to initiate a shutdown. + +=== Restart + +If the Raspberry Pi board is turned off, but still connected to power, pressing the power button restarts the board. + +NOTE: Resetting the Power Management Integrated Circuit (PMIC) can also restart the board. Connecting a HAT can reset the PMIC. Always disconnect your device from the power supply before connecting a HAT. + +=== Hard shutdown + +To force a hard shutdown, press and hold the power button. + +=== Add your own power button + +.The J2 jumper +image::images/j2.jpg[alt="The J2 jumper on Raspberry Pi 5",width="70%"] + +The J2 jumper is located between the RTC battery connector and the board edge. This breakout allows you to add your own power button to Raspberry Pi 5 by adding a Normally Open (NO) momentary switch bridging the two pads. Briefly closing this switch will perform the same actions as the onboard power button. diff --git a/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc b/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc index f650ae58d3..af3bbd6e61 100644 --- a/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc @@ -1,28 +1,51 @@ -== Power Supply +== Power supply -The power supply requirements differ by Raspberry Pi model. All models require a 5.1V supply, but the current supplied generally increases according to model. All models up to the Raspberry Pi 3 require a microUSB power connector, whilst the Raspberry Pi 4 uses a USB-C connector. +The power supply requirements differ by Raspberry Pi model. All models require a 5.1V supply, but the current required generally increases according to model. All models up to the Raspberry Pi 3 require a micro USB power connector, while Raspberry Pi 4, Raspberry Pi 400, and Raspberry Pi 5 use a USB-C connector. -Exactly how much current (mA) the Raspberry Pi requires is dependent on what you connect to it. The following table gives various current requirements. +[[powering-raspberry-pi-5]] + +The current consumed by each Raspberry Pi depends on the peripherals connected. + +=== Recommended power supplies + +For Raspberry Pi 1, Raspberry Pi 2, and Raspberry Pi 3, we recommend the https://www.raspberrypi.com/products/micro-usb-power-supply/[2.5A micro USB supply]. For Raspberry Pi 4 and Raspberry Pi 400, we recommend the https://www.raspberrypi.com/products/type-c-power-supply/[3A USB-C Supply for Raspberry Pi 4]. For Raspberry Pi 5, we recommend the https://www.raspberrypi.com/products/27w-power-supply/[27W USB-C Power Supply]. + +NOTE: No Raspberry Pi models support USB-PPS. + +NOTE: If you use a third-party USB-PD multi-port power supply, plugging an additional device into the supply when your Raspberry Pi is connected causes a renegotiation between the supply and the Raspberry Pi. If the Raspberry Pi is powered, this happens seamlessly. If the Raspberry Pi is powered down, this renegotiation may cause the Raspberry Pi to boot. + +=== Power over Ethernet (PoE) connector + +.Raspberry Pi 5 PoE header +image::images/poe.jpg[alt="The PoE connector,width="70%"] + +The Ethernet jack on Raspberry Pi 5 is PoE+ capable, supporting the IEEE 802.3at-2009 PoE standard. + +The Ethernet jack on Raspberry Pi 4B and Pi 3B+ is PoE capable, supporting the IEEE 802.3af-2003 PoE standard. + +All Raspberry Pi models with a PoE-capable Ethernet jack require a HAT to draw power through the Ethernet port. For models that support PoE, we recommend the https://www.raspberrypi.com/products/poe-hat/[PoE HAT]. For models that support PoE+, we recommend the https://www.raspberrypi.com/products/poe-plus-hat/[PoE+ HAT]. + +=== Typical power requirements |=== | Product | Recommended PSU current capacity | Maximum total USB peripheral current draw | Typical bare-board active current consumption -| Raspberry Pi Model A +| Raspberry Pi 1 Model A | 700mA | 500mA | 200mA -| Raspberry Pi Model B +| Raspberry Pi 1 Model B | 1.2A | 500mA | 500mA -| Raspberry Pi Model A+ +| Raspberry Pi 1 Model A+ | 700mA | 500mA | 180mA -| Raspberry Pi Model B+ +| Raspberry Pi 1 Model B+ | 1.8A | 1.2A | 330mA @@ -52,33 +75,118 @@ Exactly how much current (mA) the Raspberry Pi requires is dependent on what you | 1.2A | 600mA -| Raspberry Pi Zero +| Raspberry Pi 5 +| 5.0A +| 1.6A (600mA if using a 3A power supply) +| 800mA + +| Pi 400 +| 3.0A +| 1.2A +| 800mA + +| Pi 500 +| 5.0A +| 1.6A (600mA if using a 3A power supply) +| 800mA + +| Zero | 1.2A | Limited by PSU, board, and connector ratings only | 100mA -| Raspberry Pi Zero W/WH +| Zero W | 1.2A | Limited by PSU, board, and connector ratings only. | 150mA + +| Zero 2 W +| 2A +| Limited by PSU, board, and connector ratings only. +| 350mA |=== -Raspberry Pi have developed their own power supplies for use with all models. These are reliable, use heavy gauge wires and are reasonably priced. +NOTE: The Raspberry Pi 5 provides 1.6A of power to downstream USB peripherals when connected to a power supply capable of 5A at +5V (25W). When connected to any other compatible power supply, the Raspberry Pi 5 restricts downstream USB devices to 600mA of power. + +Most Raspberry Pis provide enough current to USB peripherals to power most USB devices, including keyboards, mice, and adapters. However, some devices require additional current, including modems, external disks, and high-powered antenna. To connect a USB device with power requirements that exceed the values specified in the table above, connect it using an externally-powered USB hub. + +The power requirements of the Raspberry Pi increase as you make use of the various interfaces on the Raspberry Pi. Combined, the GPIO pins can draw 50mA safely; each pin can individually draw up to 16mA. The HDMI port uses 50mA. The Camera Module requires 250mA. USB keyboards and mice can take as little as 100mA or as much as 1000mA. Check the power rating of the devices you plan to connect to the Raspberry Pi and purchase a power supply accordingly. If you're not sure, use an externally-powered USB hub. + +Run the following command to check the status of power output to the USB ports: + +[source,console] +---- +$ vcgencmd get_config usb_max_current_enable +---- + +The following table describes the amount of power (in amps) drawn by different Raspberry Pi models during various workloads: + +|=== +| | | Raspberry Pi 1B+ | Raspberry Pi 2B | Raspberry Pi 3B | Raspberry Pi Zero | Raspberry Pi 4B +| Boot | Max | 0.26 | 0.40 | 0.75 | 0.20 | 0.85 +| | Avg | 0.22 | 0.22 | 0.35 | 0.15 | 0.7 +| Idle | Avg | 0.20 | 0.22 | 0.30 | 0.10 | 0.6 +| Video playback (H.264) | Max | 0.30 | 0.36 |0.55 |0.23 | 0.85 +| | Avg | 0.22 | 0.28 | 0.33 | 0.16 | 0.78 +| Stress | Max | 0.35 | 0.82 | 1.34 | 0.35 | 1.25 +| | Avg | 0.32 | 0.75 | 0.85 | 0.23 | 1.2 +| Halt current | | | | 0.10 | 0.055 | 0.023 +|=== + +NOTE: These measurements used a standard Raspberry Pi OS image (current as of 26 Feb 2016, or June 2019 for the Raspberry Pi 4), at room temperature, with the Raspberry Pi connected to a HDMI monitor, USB keyboard, and USB mouse. The Raspberry Pi 3 Model B was connected to a wireless LAN access point, the Raspberry Pi 4 was connected to Ethernet. All these power measurements are approximate and do not take into account power consumption from additional USB devices; power consumption can easily exceed these measurements if multiple additional USB devices or a HAT are connected to the Raspberry Pi. + +[.whitepaper, title="Extra PMIC features on Raspberry Pi 4 and Compute Module 4", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-004340-WP/Extra-PMIC-features-on-Raspberry-Pi-4-and-Compute-Module-4.pdf] +**** +A number of different PMIC devices have been used on both Raspberry Pi 4 and CM4. All the PMICs provide extra functionality alongside that of voltage supply. This document describes how to access these features in software. +**** + +==== Decrease Raspberry Pi 5 wattage when turned off + +By default, the Raspberry Pi 5 consumes around 1W to 1.4W of power when turned off. This can be decreased by manually editing the EEPROM configuration with `sudo rpi-eeprom-config -e`. Change the settings to the following: + +[source,ini] +---- +BOOT_UART=1 +POWER_OFF_ON_HALT=1 +BOOT_ORDER=0xf416 +---- + +This should drop the power consumption when powered down to around 0.01W. + +=== Power supply warnings + +On all models of Raspberry Pi since the Raspberry Pi B+ (2014) except the Zero range, there is low-voltage detection circuitry that will detect if the supply voltage drops below 4.63V (±5%). This will result in an entry being added to the kernel log. + +If you see warnings, switch to a higher quality power supply and cable. Low quality power supplies can corrupt storage or cause unpredictable behaviour within the Raspberry Pi. + +Voltages can drop for a variety of reasons. You may have plugged in too many high-demand USB devices. The power supply could be inadequate. Or the power supply cable could use wires that are too thin. + +[.whitepaper, title="Making a more resilient file system", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003610-WP/Making-a-more-resilient-file-system.pdf] +**** +Raspberry Pi devices are frequently used as data storage and monitoring devices, often in places where sudden power-downs may occur. As with any computing device, power dropouts can cause storage corruption. -For Raspberry Pi 0-3, we recommend our https://www.raspberrypi.org/products/raspberry-pi-universal-power-supply/[2.5A micro USB Supply]. For Raspberry Pi 4, we recommend our https://www.raspberrypi.org/products/type-c-power-supply/[3A USB-C Supply] +This white paper provides some options on how to prevent data corruption under these and other circumstances by selecting appropriate file systems and setups to ensure data integrity. +**** -The power requirements of the Raspberry Pi increase as you make use of the various interfaces on the Raspberry Pi. The GPIO pins can draw 50mA safely, distributed across all the pins; an individual GPIO pin can only safely draw 16mA. The HDMI port uses 50mA, the camera module requires 250mA, and keyboards and mice can take as little as 100mA or over 1000mA! Check the power rating of the devices you plan to connect to the Pi and purchase a power supply accordingly. +=== Power supplies and Raspberry Pi OS -If you need to connect a USB device that will take the power requirements above the values specified in the table above, then you must connect it to an externally-powered USB hub. +The bootloader passes information about the power supply via device-tree `/proc/device-tree/chosen/power`. Users will typically not read this directly. -=== Power Supply Warnings +max_current:: The max current in mA +uspd_power_data_objects:: A dump of the PDOs - debug for advanced users +usb_max_current_enable:: Whether the current limiter was set to high or low +usb_over_current_detected:: Whether any USB over current occurred during boot before transferring control to the OS +reset_event:: The PMIC reset reason e.g. watchdog, over- or under-voltage, over-temperature -On all models of Raspberry Pi since the Raspberry Pi B+ (2014) except the Zero range, there is low-voltage detection circuitry that will detect if the supply voltage drops below 4.63V (+/- 5%). This will result in a xref:configuration.adoc#firmware-warning-icons[warning icon] being displayed on all attached displays and an entry being added to the kernel log. +The PMIC has built-in ADCs that, among other things, can measure the supply voltage `EXT5V_V`. Use the following command to view ADC measurements: -If you are seeing warnings, you should improve the power supply and/or cable, as low power can cause problems with corruption of SD cards, or erratic behaviour of the Pi itself; for example, unexplained crashes. +[source,console] +---- +$ vcgencmd pmic_read_adc +---- -Voltages can drop for a variety of reasons, for example if the power supply itself is inadequate, the power supply cable is made of too thin wires, or you have plugged in high demand USB devices. +You can't see USB current or anything else connected directly to 5V, because this bypasses the PMIC. You should not expect this to add up to the wattage of the source power supply. However, it can be useful to monitor things like the core voltage. === Back-powering -Backpowering occurs when USB hubs do not provide a diode to stop the hub from powering against the host computer. Other hubs will provide as much power as you want out each port. Please also be aware that some hubs will backfeed the Raspberry Pi. This means that the hubs will power the Raspberry Pi through its USB cable input cable, without the need for a separate micro-USB power cable, and bypass the voltage protection. If you are using a hub that backfeeds to the Raspberry Pi and the hub experiences a power surge, your Raspberry Pi could potentially be damaged. +The USB specification requires that USB devices must not supply current to upstream devices. If a USB device does supply current to an upstream device, then this is called back-powering. Often this happens when a badly-made powered USB hub is connected, and will result in the powered USB hub supplying power to the host Raspberry Pi. This is not recommended since the power being supplied to the Raspberry Pi via the hub will bypass the protection circuitry built into the Raspberry Pi, leaving it vulnerable to damage in the event of a power surge. diff --git a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-compliance.adoc b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-compliance.adoc index 1caa967d8e..99aea72022 100644 --- a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-compliance.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-compliance.adoc @@ -1,23 +1,23 @@ == Product compliance and safety -All Raspberry Pi products have undergone extensive compliance testing, for more information see the https://pip.raspberrypi.org[Product Information Portal] +All Raspberry Pi products have undergone extensive compliance testing. For more information see the https://pip.raspberrypi.com[Product Information Portal]. -=== Flammability Rating +=== Flammability rating The PCBs used in Raspberry Pi devices adhere to UL94-V0. -NOTE: This applies to the PCBs *only*. +NOTE: This applies to the PCBs only. -=== The Raspberry Pi Compliance Support +=== Raspberry Pi Compliance Support The Compliance Support programme is designed to eliminate the burden of navigating compliance issues and make it easier for companies to bring new products to consumers. It provides access to the same test engineers who worked on our Raspberry Pis during their compliance testing, connecting the user to a dedicated team at https://www.ul-certification.com/[UL] who assess and test the user's product, facilitated by their in-depth knowledge of Raspberry Pi. -Find out more about the https://www.raspberrypi.org/for-industry/integrator-programme/[Raspberry Pi Compiance Support Programme]. +Find out more about the https://www.raspberrypi.com/for-industry/integrator-programme/[Raspberry Pi Compliance Support Programme]. === Powered by Raspberry Pi -The Powered by Raspberry Pi progamme provides a process for companies wanting to use a form of the Raspberry Pi logo, and covers products with Raspberry Pi computers or silicon inside, and services provided by a Raspberry Pi. If you wish to start the process to apply you can do so https://www.raspberrypi.org/trademark-rules/powered-raspberry-pi/[online]. +The Powered by Raspberry Pi program provides a process for companies wanting to use a form of the Raspberry Pi logo, and covers products with Raspberry Pi computers or silicon inside, and services provided by a Raspberry Pi. If you wish to start the process to apply you can do so https://www.raspberrypi.com/trademark-rules/powered-raspberry-pi/[online]. === Approved Design Partners -Our list of https://www.raspberrypi.org/for-industry/design-partners/[approved design partners] provide a set of consultancies that we work closely with and support so they can provide paid for design services across hardware, software, and mechanical. +Our list of https://www.raspberrypi.com/for-industry/design-partners/[Approved Design Partners] provides a set of consultancies which we work closely with and support so they can provide paid-for design services across hardware, software, and mechanical fields. diff --git a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-industrial.adoc b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-industrial.adoc index fbc929819b..faf0f06f0e 100644 --- a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-industrial.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-industrial.adoc @@ -1,42 +1,59 @@ == Industrial use of the Raspberry Pi -The Raspberry Pi is often used as part of another product. This documentation describes some extra facilities available to use other capabilities of the Pi. +Raspberry Pi is often used as part of another product. This documentation describes some extra facilities available to use other capabilities of your Raspberry Pi. -=== One-Time Programmable Settings +=== One-time programmable settings -There are a number of OTP values that can be used. To see a list of all the xref:raspberry-pi.adoc#otp-register-and-bit-definitions[OTP values], you can use: +[.whitepaper, title="Using the one-time programmable memory on Raspberry Pi single-board computers", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-003611-WP/Using-the-One-time-programmable-memory-on-Raspberry-Pi-single-board-computers.pdf] +**** +All Raspberry Pi single-board computers (SBCs) have an inbuilt area of one-time programmable (OTP) memory, which is actually part of the main system on a chip (SoC). As its name implies, OTP memory can be written to (i.e. a binary 0 can be changed to a 1) only once. Once a bit has been changed to 1, it can never be returned to 0. One way of looking at the OTP is to consider each bit as a fuse. Programming it involves deliberately blowing the fuse — an irreversible process, as you cannot get inside the chip to replace it! +This whitepaper assumes that the Raspberry Pi is running the Raspberry Pi operating system (OS), and is fully up-to-date with the latest firmware and kernels. +**** + +There are a number of OTP values that can be used. To see a list of all the xref:raspberry-pi.adoc#otp-register-and-bit-definitions[OTP values], run the following command: + +[source,console] ---- -pi@raspberrypi:~ $ vcgencmd otp_dump +$ vcgencmd otp_dump ---- Some interesting lines from this dump are: * 28 - Serial number * 29 - Ones complement of serial number -* 30 - Revision number +* 30 - Board revision number + +Also, from 36 to 43 (inclusive), there are eight rows of 32 bits available for the customer. + +NOTE: On BCM2712 devices these numbers are different. Row 31 is the serial number and row 32 is the board revision number. The customer rows are 77 to 84 inclusive. + +Some of these rows can be programmed with `vcmailbox`. This is a Linux driver interface to the firmware which will handle the programming of the rows. To do this, please refer to the https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface[documentation], and the vcmailbox https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/vcmailbox/vcmailbox.c[example application]. -Also, from 36 to 43 (inclusive), there are eight rows of 32 bits available for the customer +The vcmailbox application can be used directly from the command line on Raspberry Pi OS. An example usage would be: -To program these bits, you will need to use the vcmailbox. This is a Linux driver interface to the firmware which will handle the programming of the rows. To do this, please refer to the https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface[documentation], and the vcmailbox https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/vcmailbox/vcmailbox.c[example application]. +[source,console] +---- +$ vcmailbox 0x00010004 8 8 0 0 +---- -The vcmailbox application can be used directly from the command line on a Raspberry Pi Raspberry Pi OS build. An example usage would be: +...which will return something like: ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00010004 8 8 0 0 0x00000020 0x80000000 0x00010004 0x00000008 0x800000008 0xnnnnnnnn 0x00000000 0x00000000 ---- -The above uses the https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface[mailbox property interface] `GET_BOARD_SERIAL` with a request size of 8 bytes and response size of 8 bytes (sending two integers for the request 0, 0). The response to this will be two integers (0x00000020 and 0x80000000) followed by the tag code, the request length, the response length (with the 31st bit set to indicate that it is a response) then the 64 bit serial number (where the MS 32bits are always 0). +The above uses the https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface[mailbox property interface] `GET_BOARD_SERIAL` with a request size of 8 bytes and response size of 8 bytes (sending two integers for the request 0, 0). The response to this will be two integers (0x00000020 and 0x80000000) followed by the tag code, the request length, the response length (with the 31st bit set to indicate that it is a response) then the 64-bit serial number (where the MS 32 bits are always 0). -=== Write and Read Customer OTP Values +=== Write and read customer OTP values -WARNING: The OTP values are One-Time Programmable, once a bit has been changed from 0 to 1, it can't be changed back +WARNING: The OTP values are one-time programmable. Once a bit has been changed from 0 to 1, it can't be changed back. To set the customer OTP values you will need to use the `SET_CUSTOMER_OTP` (0x38021) tag as follows: +[source,console] ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00038021 [8 + number * 4] [8 + number * 4] [start_num] [number] [value] [value] [value] ... +$ vcmailbox 0x00038021 [8 + number * 4] [8 + number * 4] [start_num] [number] [value] [value] [value] ... ---- * `start_num` = the first row to program from 0-7 @@ -45,37 +62,173 @@ pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00038021 [8 + number * 4] [8 + number So, to program OTP customer rows 4, 5, and 6 to 0x11111111, 0x22222222, 0x33333333 respectively, you would use: +[source,console] ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00038021 20 20 4 3 0x11111111 0x22222222 0x33333333 +$ vcmailbox 0x00038021 20 20 4 3 0x11111111 0x22222222 0x33333333 ---- This will then program rows 40, 41, and 42. To read the values back, you can use: +[source,console] +---- +$ vcmailbox 0x00030021 20 20 4 3 0 0 0 +---- + +This should display: + ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00030021 20 20 4 3 0 0 0 0x0000002c 0x80000000 0x00030021 0x00000014 0x80000014 0x00000000 0x00000003 0x11111111 0x22222222 0x33333333 ---- If you'd like to integrate this functionality into your own code, you should be able to achieve this by using the vcmailbox.c code as an example. -=== Locking the OTP Changes +=== Locking OTP on non-BCM2712 devices + +It is possible to lock the OTP changes to avoid them being edited again. -It is possible to lock the OTP changes to avoid them being edited again. This can be done using a special argument with the OTP write mailbox: +This can be done using a special argument with the OTP write mailbox: +[source,console] ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00038021 8 8 0xffffffff 0xaffe0000 +$ vcmailbox 0x00038021 8 8 0xffffffff 0xaffe0000 ---- Once locked, the customer OTP values can no longer be altered. Note that this locking operation is irreversible. -=== Making Customer OTP bits Unreadable +=== Locking OTP on BCM2712 devices + +The customer region can be marked as read only with the following command. + +[source,console] +---- +$ vcmailbox 0x00030086 4 4 0 +---- + +OTP is only locked until the device is reset, so OTP locks need to be reapplied on every boot. + +=== Making customer OTP bits unreadable on non-BCM2712 devices It is possible to prevent the customer OTP bits from being read at all. This can be done using a special argument with the OTP write mailbox: +[source,console] ---- -pi@raspberrypi:~ $ /opt/vc/bin/vcmailbox 0x00038021 8 8 0xffffffff 0xaffebabe +$ vcmailbox 0x00038021 8 8 0xffffffff 0xaffebabe ---- This operation is unlikely to be useful for the vast majority of users, and is irreversible. + +=== Customer MAC addresses on BCM2712 devices + +On BCM2712 devices the Ethernet, Wi-Fi and Bluetooth MAC addresses are set in OTP memory. These values can change with customer values. + +Get customer mac address `vcmailbox 0x00030082/3/4 6 6 0 0`, where 2 is Ethernet, 3 is Wi-Fi and 4 is Bluetooth: + +[source,console] +---- +$ vcmailbox 0x00030083 6 6 0 0 +0x00000020 0x80000000 0x00030083 0x00000006 0x80000006 0xddccbbaa 0x0000ffee 0x00000000 +---- + +In order to set a customer MAC address, it has to be sent as two 32 words with the bytes in the right order. You can run a command to check it's formatted properly: + +[source,console] +---- +$ vcmailbox 0x00030085 6 6 0x44332211 0x6655 +---- + +Check the log to see if the MAC address matches your expectations: + +[source,console] +---- +$ sudo vclog -m +1057826.701: read mac address 11:22:33:44:55:66 +---- + +A multicast address is not considered valid. The least significant bit in the most significant octet of a MAC address is the multicast bit, so make sure this is not set. + +You can then set the customer MAC address with the command `vcmailbox 0x00038082/3/4 6 6 `: + +[source,console] +---- +$ vcmailbox 0x00038082 6 6 0x44332211 0x6655 +---- + +If a customer MAC address is set to `ff:ff:ff:ff:ff:ff`, then it's ignored. + +=== Device-specific private key + +Devices that use the Broadcom BCM2712 processor have 16 rows of OTP data (512 bits) to support filesystem encryption. +Devices that do not use BCM2712 have 8 rows of OTP (256 bits) available for use as a device-specific private key. + +These rows can be programmed and read using similar `vcmailbox` commands to those used for managing customer OTP rows. If +secure-boot / file-system encryption is not required, then the device private key rows can be used to store general-purpose information. + +* The device private key rows can only be read via the `vcmailbox` command which requires access to `/dev/vcio` which is restricted to the `video` group on Raspberry Pi OS. +* Raspberry Pi computers do not have a hardware protected key store. It is recommended that this feature is used in conjunction with https://github.com/raspberrypi/usbboot/blob/master/secure-boot-example/README.md[Secure Boot] in order to restrict access to this data. +* Raspberry Pi OS does not support an encrypted root-filesystem. + +See https://gitlab.com/cryptsetup/cryptsetup[Cryptsetup] for more information about open-source disk encryption. + +==== Program a key into OTP with `rpi-otp-private-key` + +NOTE: The `rpi-otp-private-key` script only works on devices that use the Broadcom xref:processors.adoc#bcm2711[BCM2711] or xref:processors.adoc#bcm2712[BCM2712] processors. + +The https://github.com/raspberrypi/rpi-eeprom/blob/master/tools/rpi-otp-private-key[`rpi-otp-private-key`] script wraps the device private key `vcmailbox` APIs to make it easier to read and write a key in the OpenSSL format. + +NOTE: The https://github.com/raspberrypi/usbboot[`usbboot`] repository contains all the tools you need, including https://github.com/raspberrypi/rpi-eeprom[`rpi-eeprom`] as a Git submodule. + +Read the 32-byte key as a 64-character hex number: + +[source,console] +---- +$ cd usbboot/tools +$ rpi-otp-private-key +---- + +Example output: + +---- +f8dbc7b0a4fcfb1d706e298ac9d0485c2226ce8df7f7596ac77337bd09fbe160 +---- + +Writes a 32-byte randomly generated number to the device private key. + +WARNING: This operation cannot be undone. + +[source,console] +---- +$ rpi-otp-private-key -w $(openssl rand -hex 32) +---- + +NOTE: To specify the number of OTP rows to use, pass `-l `. To specify a start location in the key store, pass `-o `. + +==== Mailbox API for reading/writing the key + +Read all of the rows. + +[source,console] +---- +$ vcmailbox 0x00030081 40 40 0 8 0 0 0 0 0 0 0 0 +---- + +Example output: + +---- +0x00000040 0x80000000 0x00030081 0x00000028 0x80000028 0x00000000 0x00000008 0xf8dbc7b0 0xa4fcfb1d 0x706e298a 0xc9d0485c 0x2226ce8d 0xf7f7596a 0xc77337bd 0x09fbe160 0x00000000 +---- + +Write all of the row (replace the trailing eight zeros with the key data): + +[source,console] +---- +$ vcmailbox 0x00038081 40 40 0 8 0 0 0 0 0 0 0 0 +---- + +Write the key shown in the previous example: + +[source,console] +---- +$ vcmailbox 0x38081 40 40 0 8 0xf8dbc7b0 0xa4fcfb1d 0x706e298a 0xc9d0485c 0x2226ce8d 0xf7f7596a 0xc77337bd 0x09fbe160 +---- diff --git a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-schematics.adoc b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-schematics.adoc index 1897d1c3cf..6af0d0dd3b 100644 --- a/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-schematics.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/raspberry-pi-schematics.adoc @@ -1,58 +1,104 @@ -== Schematics and Mechanical Drawings +== Schematics and mechanical drawings Schematics for the various Raspberry Pi board versions: +=== Raspberry Pi 5 + +* https://datasheets.raspberrypi.com/rpi5/raspberry-pi-5-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpi5/RaspberryPi5-step.zip[STEP file] for Raspberry Pi 5 + === Raspberry Pi 4 Model B -* https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-reduced-schematics.pdf[Schematics, Revision 4.0] -* https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-mechanical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-mechanical-drawing.dxf[Mechanical Drawings, DXF] +* https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-reduced-schematics.pdf[Schematics, revision 4.0] +* https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-mechanical-drawing.dxf[Mechanical drawings, DXF] === Raspberry Pi 3 Model B+ -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-plus-reduced-schematics.pdf[Schematics, Revision 1.0] -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.dxf[Mechanical Drawings, DXF] -* https://datasheets.raspberrypi.org/case/raspberry-pi-3-b-plus-case-mechanical-drawing.pdf[Case Drawings, PDF] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-reduced-schematics.pdf[Schematics, revision 1.0] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.dxf[Mechanical drawings, DXF] +* https://datasheets.raspberrypi.com/case/raspberry-pi-3-b-plus-case-mechanical-drawing.pdf[Case drawings, PDF] + +=== Raspberry Pi 3 Model A+ + +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-a-plus-reduced-schematics.pdf[Schematics, revision 1.0] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-a-plus-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/case/raspberry-pi-3-a-plus-case-mechanical-drawing.pdf[Case drawings, PDF] === Raspberry Pi 3 Model B -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-reduced-schematics.pdf[Schematics, Revision 1.2] -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-mechanical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-mechanical-drawing.dxf[Mechanical Drawings, DXF] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-reduced-schematics.pdf[Schematics, revision 1.2] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-mechanical-drawing.dxf[Mechanical drawings, DXF] === Raspberry Pi 2 Model B -* https://datasheets.raspberrypi.org/rpi2/raspberry-pi-2-b-reduced-schematics.pdf[Schematics, Revision 1.2] +* https://datasheets.raspberrypi.com/rpi2/raspberry-pi-2-b-reduced-schematics.pdf[Schematics, revision 1.2] -=== Raspberry Pi Model B+ +=== Raspberry Pi 1 Model B+ -* https://datasheets.raspberrypi.org/rpi/raspberry-pi-b-plus-reduced-schematics.pdf[Schematics, Revision 1.2] -* https://datasheets.raspberrypi.org/rpi/raspberry-pi-b-plus-mecahnical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/rpi/raspberry-pi-b-plus-mecahnical-drawing.dxf[Mechanical Drawings, DXF] +* https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-reduced-schematics.pdf[Schematics, revision 1.2] +* https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-mechanical-drawing.dxf[Mechanical drawings, DXF] -=== Raspberry Pi 3 Model A+ +=== Raspberry Pi 1 Model A+ -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-a-plus-reduced-schematics.pdf[Schematics, Revision 1.0] -* https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-a-plus-mechanical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/case/raspberry-pi-3-a-plus-case-mechanical-drawing.pdf[Case Drawings, PDF] +* https://datasheets.raspberrypi.com/rpi/raspberry-pi-a-plus-reduced-schematics.pdf[Schematics, revision 1.1] -NOTE: Mechanical drawings for the Raspberry Pi 3, Model A+ are also applicable to the Raspberry Pi, Model A+. +NOTE: Mechanical drawings for the Raspberry Pi 3 Model A+ are also applicable to the Raspberry Pi 1 Model A+. -=== Raspberry Pi Model A+ +=== Raspberry Pi Zero 2 W -* https://datasheets.raspberrypi.org/rpi/raspberry-pi-a-plus-reduced-schematics.pdf[Schematics, Revision 1.1] +* https://datasheets.raspberrypi.com/rpizero2/raspberry-pi-zero-2-w-reduced-schematics.pdf[Schematics] +* https://datasheets.raspberrypi.com/rpizero2/raspberry-pi-zero-2-w-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/rpizero2/raspberry-pi-zero-2-w-test-pads.pdf[Test pad positions] -=== Raspberry Pi Zero +==== Test pad locations + +The Raspberry Pi Zero 2 W has a number of test pad locations used during production of the board. + +image::images/zero2-pad-diagram.png[width="70%"] + +|=== +| Label | Function | X (mm from origin) | Y (mm from origin) + +| STATUS_LED | Power state of LED (LOW = ON) | 5.15 | 8.8 +| CORE | Processor power | 6.3 | 18.98 +| RUN | Connect to GND to reset | 8.37 | 22.69 +| 5V | 5V input | 8.75 | 11.05 +| 5V | 5V input | 11.21 | 6.3 +| GND | Ground pin | 10.9 | 3.69 +| GND | Ground pin | 17.29 | 2.41 +| USB_DP | USB port | 22.55 | 1.92 +| USB_DM | USB port | 24.68 | 1.92 +| OTG | On-the-go ID pin | 39.9 | 7.42 +| 1V8 | 1.8V analog supply | 42.03 | 8.42 +| TV | Composite TV out | 45.58 | 3.17 +| GND | Ground pin | 49.38 | 3.05 +| GND | Ground pin | 55.99 | 22.87 +| 3V3 | 3.3V I/O supply | 48.55 | 22.44 +| SD_CLK | SD Card clock pin | 60.95 | 18.45 +| SD_CMD | SD Card command pin | 58.2 | 16.42 +| SD_DAT0 | SD data pin | 58.13 | 20.42 +| SD_DAT1 | SD data pin | 60.65 | 21.1 +| SD_DAT2 | SD data pin | 57.78 | 13.57 +| SD_DAT3 | SD data pin | 60.8 | 15.22 +| BT_ON | Bluetooth power status | 25.13 | 19.55 +| WL_ON | Wireless LAN power status | 27.7 | 19.2 + +|=== -* https://datasheets.raspberrypi.org/rpizero/raspberry-pi-zero-reduced-schematics.pdf[Schematics, Revision 1.3] -* https://datasheets.raspberrypi.org/rpizero/raspberry-pi-zero-mechanical-drawing.pdf[Mechanical Drawings, PDF] -* https://datasheets.raspberrypi.org/case/raspberry-pi-zero-case-mechanical-drawing.pdf[Case Drawings, PDF - Blank Lid] -* https://datasheets.raspberrypi.org/case/raspberry-pi-zero-case-with-gpio-mechanical-drawing.pdf[Case Drawings, PDF - GPIO Lid] -* https://datasheets.raspberrypi.org/case/raspberry-pi-zero-case-with-camera-mechanical-drawing.pdf[Case Drawings, PDF - Camera Lid] === Raspberry Pi Zero W -* https://datasheets.raspberrypi.org/rpizero/raspberry-pi-zero-w-reduced-schematics.pdf[Schematics, Revision 1.1] -* https://datasheets.raspberrypi.org/rpizero/raspberry-pi-zero-w-mechanical-drawing.pdf[Mechanical Drawings, PDF] +* https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-w-reduced-schematics.pdf[Schematics, revision 1.1] +* https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-w-mechanical-drawing.pdf[Mechanical drawings, PDF] + +=== Raspberry Pi Zero +* https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-reduced-schematics.pdf[Schematics, revision 1.3] +* https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-mechanical-drawing.pdf[Mechanical drawings, PDF] +* https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-mechanical-drawing.pdf[Case drawings, PDF - blank lid] +* https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-with-gpio-mechanical-drawing.pdf[Case drawings, PDF - GPIO lid] +* https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-with-camera-mechanical-drawing.pdf[Case Drawings, PDF - camera lid] diff --git a/documentation/asciidoc/computers/raspberry-pi/revision-codes.adoc b/documentation/asciidoc/computers/raspberry-pi/revision-codes.adoc index 1360f9bc0f..79e929dbe4 100644 --- a/documentation/asciidoc/computers/raspberry-pi/revision-codes.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/revision-codes.adoc @@ -1,13 +1,13 @@ -== Raspberry Pi Revision Codes +== Raspberry Pi revision codes Each distinct Raspberry Pi model revision has a unique revision code. You can look up a Raspberry Pi's revision code by running: -[,bash] +[source,console] ---- -cat /proc/cpuinfo +$ cat /proc/cpuinfo ---- -The last three lines show the hardware type, the revision code, and the Pi's unique serial number. For example: +The last three lines show the hardware type, the revision code, and the Raspberry Pi's unique serial number. For example: ---- Hardware : BCM2835 @@ -15,9 +15,9 @@ Revision : a02082 Serial : 00000000765fc593 ---- -NOTE: As of the 4.9 kernel, all Pis report `BCM2835`, even those with BCM2836, BCM2837 and BCM2711 processors. You should not use this string to detect the processor. Decode the revision code using the information below, or `cat /sys/firmware/devicetree/base/model`. +NOTE: All Raspberry Pi computers report `BCM2835`, even those with BCM2836, BCM2837, BCM2711, and BCM2712 processors. You should not use this string to detect the processor. Decode the revision code using the information below, or `cat /sys/firmware/devicetree/base/model`. -=== Old-style Revision Codes +=== Old-style revision codes The first set of Raspberry Pi models were given sequential hex revision codes from `0002` to `0015`: @@ -127,7 +127,7 @@ The first set of Raspberry Pi models were given sequential hex revision codes fr | Embest |=== -=== New-style Revision Codes +=== New-style revision codes With the launch of the Raspberry Pi 2, new-style revision codes were introduced. Rather than being sequential, each bit of the hex code represents a piece of information about the revision: @@ -138,7 +138,7 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR |=== | Part | Represents | Options -| N +| N (bit 31) | Overvoltage | 0: Overvoltage allowed @@ -146,7 +146,7 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 1: Overvoltage disallowed -| O +| O (bit 30) | OTP Program^1^ | 0: OTP programming allowed @@ -154,7 +154,7 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 1: OTP programming disallowed -| Q +| Q (bit 29) | OTP Read^1^ | 0: OTP reading allowed @@ -162,11 +162,11 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 1: OTP reading disallowed -| uuu +| uuu (bits 26-28) | Unused | Unused -| W +| W (bit 25) | Warranty bit^2^ | 0: Warranty is intact @@ -174,11 +174,11 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 1: Warranty has been voided by xref:config_txt.adoc#overclocking-options[overclocking] -| u +| u (bit 24) | Unused | Unused -| F +| F (bit 23) | New flag | 1: new-style revision @@ -186,7 +186,7 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 0: old-style revision -| MMM +| MMM (bits 20-22) | Memory size | 0: 256MB @@ -210,7 +210,11 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 5: 8GB -| CCCC +| +| +| 6: 16GB + +| CCCC (bits 16-19) | Manufacturer | 0: Sony UK @@ -234,7 +238,7 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 5: Stadium -| PPPP +| PPPP (bits 12-15) | Processor | 0: BCM2835 @@ -250,90 +254,124 @@ NOQuuuWuFMMMCCCCPPPPTTTTTTTTRRRR | | 3: BCM2711 -| TTTTTTTT +| +| +| 4: BCM2712 + +| TTTTTTTT (bits 4-11) | Type -| 0: A +| 0x00: A + +| +| +| 0x01: B + +| +| +| 0x02: A+ + +| +| +| 0x03: B+ + +| +| +| 0x04: 2B + +| +| +| 0x05: Alpha (early prototype) + +| +| +| 0x06: CM1 | | -| 1: B +| 0x08: 3B | | -| 2: A+ +| 0x09: Zero | | -| 3: B+ +| 0x0a: CM3 | | -| 4: 2B +| 0x0c: Zero W | | -| 5: Alpha (early prototype) +| 0x0d: 3B+ | | -| 6: CM1 +| 0x0e: 3A+ | | -| 8: 3B +| 0x0f: Internal use only | | -| 9: Zero +| 0x10: CM3+ | | -| a: CM3 +| 0x11: 4B | | -| c: Zero W +| 0x12: Zero 2 W | | -| d: 3B+ +| 0x13: 400 | | -| e: 3A+ +| 0x14: CM4 | | -| f: Internal use only +| 0x15: CM4S | | -| 10: CM3+ +| 0x16: Internal use only | | -| 11: 4B +| 0x17: 5 | | -| 13: 400 +| 0x18: CM5 | | -| 14: CM4 +| 0x19: 500 -| RRRR +| +| +| 0x1a: CM5 Lite + +| RRRR (bits 0-3) | Revision | 0, 1, 2, etc. |=== ^1^ Information on xref:raspberry-pi.adoc#otp-register-and-bit-definitions[programming the OTP bits]. -^2^ Warranty bit is never set on Pi4. +^2^ The warranty bit is never set on Raspberry Pi 4. -=== New-style revision Codes In Use +=== New-style revision codes in use -This list is not exhaustive, there may be codes in use in the field that are not in this table. +NOTE: This list is not exhaustive - there may be codes in use that are not in this table. Please see the next section for best practices on using revision codes to identify boards. + +// This table is now sorted by Type (from table above), then Revision, then RAM, and finally Code. This is the most likley order-of-manufacture, which means we'll normally just add new revision-codes to the very bottom of the table, without having to worry about re-ordering entries. |=== | Code | Model | Revision | RAM | Manufacturer @@ -350,48 +388,6 @@ This list is not exhaustive, there may be codes in use in the field that are not | 512MB | Sony UK -| 900092 -| Zero -| 1.2 -| 512MB -| Sony UK - -| 900093 -| Zero -| 1.3 -| 512MB -| Sony UK - -| 9000c1 -| Zero W -| 1.1 -| 512MB -| Sony UK - -| 9020e0 -| 3A+ -| 1.0 -| 512MB -| Sony UK - -| 920092 -| Zero -| 1.2 -| 512MB -| Embest - -| 920093 -| Zero -| 1.3 -| 512MB -| Embest - -| 900061 -| CM -| 1.1 -| 512MB -| Sony UK - | a01040 | 2B | 1.0 @@ -404,23 +400,11 @@ This list is not exhaustive, there may be codes in use in the field that are not | 1GB | Sony UK -| a02082 -| 3B -| 1.2 -| 1GB -| Sony UK - -| a020a0 -| CM3 -| 1.0 -| 1GB -| Sony UK - -| a020d3 -| 3B+ -| 1.3 +| a21041 +| 2B +| 1.1 | 1GB -| Sony UK +| Embest | a02042 | 2B (with BCM2837) @@ -428,27 +412,27 @@ This list is not exhaustive, there may be codes in use in the field that are not | 1GB | Sony UK -| a21041 -| 2B -| 1.1 -| 1GB -| Embest - | a22042 | 2B (with BCM2837) | 1.2 | 1GB | Embest -| a22082 +| 900061 +| CM1 +| 1.1 +| 512MB +| Sony UK + +| a02082 | 3B | 1.2 | 1GB -| Embest +| Sony UK -| a220a0 -| CM3 -| 1.0 +| a22082 +| 3B +| 1.2 | 1GB | Embest @@ -470,6 +454,72 @@ This list is not exhaustive, there may be codes in use in the field that are not | 1GB | Embest +| 900092 +| Zero +| 1.2 +| 512MB +| Sony UK + +| 920092 +| Zero +| 1.2 +| 512MB +| Embest + +| 900093 +| Zero +| 1.3 +| 512MB +| Sony UK + +| 920093 +| Zero +| 1.3 +| 512MB +| Embest + +| a020a0 +| CM3 +| 1.0 +| 1GB +| Sony UK + +| a220a0 +| CM3 +| 1.0 +| 1GB +| Embest + +| 9000c1 +| Zero W +| 1.1 +| 512MB +| Sony UK + +| a020d3 +| 3B+ +| 1.3 +| 1GB +| Sony UK + +| a020d4 +| 3B+ +| 1.4 +| 1GB +| Sony UK + +| 9020e0 +| 3A+ +| 1.0 +| 512MB +| Sony UK + +| 9020e1 +| 3A+ +| 1.1 +| 512MB +| Sony UK + | a02100 | CM3+ | 1.0 @@ -488,44 +538,68 @@ This list is not exhaustive, there may be codes in use in the field that are not | 2GB | Sony UK +| c03111 +| 4B +| 1.1 +| 4GB +| Sony UK + | b03112 | 4B | 1.2 | 2GB | Sony UK +| c03112 +| 4B +| 1.2 +| 4GB +| Sony UK + | b03114 | 4B | 1.4 | 2GB | Sony UK -| c03111 +| c03114 | 4B -| 1.1 +| 1.4 | 4GB | Sony UK -| c03112 +| d03114 | 4B -| 1.2 -| 4GB +| 1.4 +| 8GB | Sony UK -| c03114 +| b03115 | 4B -| 1.4 +| 1.5 +| 2GB +| Sony UK + +| c03115 +| 4B +| 1.5 | 4GB | Sony UK -| d03114 +| d03115 | 4B -| 1.4 +| 1.5 | 8GB | Sony UK +| 902120 +| Zero 2 W +| 1.0 +| 512MB +| Sony UK + | c03130 -| Pi 400 +| 400 | 1.0 | 4GB | Sony UK @@ -553,4 +627,218 @@ This list is not exhaustive, there may be codes in use in the field that are not | 1.0 | 8GB | Sony UK + +| b04170 +| 5 +| 1.0 +| 2GB +| Sony UK + +| c04170 +| 5 +| 1.0 +| 4GB +| Sony UK + +| d04170 +| 5 +| 1.0 +| 8GB +| Sony UK + +| b04171 +| 5 +| 1.1 +| 2GB +| Sony UK + +| c04171 +| 5 +| 1.1 +| 4GB +| Sony UK + +| d04171 +| 5 +| 1.1 +| 8GB +| Sony UK + +| e04171 +| 5 +| 1.1 +| 16GB +| Sony UK + +| b04180 +| CM5 +| 1.0 +| 2GB +| Sony UK + +| c04180 +| CM5 +| 1.0 +| 4GB +| Sony UK + +| d04180 +| CM5 +| 1.0 +| 8GB +| Sony UK + +| d04190 +| 500 +| 1.0 +| 8GB +| Sony UK + +| b041a0 +| CM5 Lite +| 1.0 +| 2GB +| Sony UK + +| c041a0 +| CM5 Lite +| 1.0 +| 4GB +| Sony UK + +| d041a0 +| CM5 Lite +| 1.0 +| 8GB +| Sony UK + +|=== + +=== Using revision codes for board identification + +From the command line we can use the following to get the revision code of the board: + +[source,console] +---- +$ cat /proc/cpuinfo | grep Revision +Revision : c03111 +---- + +In this example above, we have a hexadecimal revision code of `c03111`. Converting this to binary, we get `0 0 0 000 0 0 1 100 0000 0011 00010001 0001`. Spaces have been inserted to show the borders between each section of the revision code, according to the above table. + +Starting from the lowest order bits, the bottom four (0-3) are the board revision number, so this board has a revision of 1. The next eight bits (4-11) are the board type, in this case binary `00010001`, hex `11`, so this is a Raspberry Pi 4B. Using the same process, we can determine that the processor is a BCM2711, the board was manufactured by Sony UK, and it has 4GB of RAM. + +==== Getting the revision code in your program + +Obviously there are so many programming languages out there it's not possible to give examples for all of them, but here are two quick examples for `C` and `Python`. Both these examples use a system call to run a bash command that gets the `cpuinfo` and pipes the result to `awk` to recover the required revision code. They then use bit operations to extract the `New`, `Model`, and `Memory` fields from the code. + + +[source,c] +---- +#include +#include + +int main( int argc, char *argv[] ) +{ + FILE *fp; + char revcode[32]; + + fp = popen("cat /proc/cpuinfo | awk '/Revision/ {print $3}'", "r"); + if (fp == NULL) + exit(1); + fgets(revcode, sizeof(revcode), fp); + pclose(fp); + + int code = strtol(revcode, NULL, 16); + int new = (code >> 23) & 0x1; + int model = (code >> 4) & 0xff; + int mem = (code >> 20) & 0x7; + + if (new && model == 0x11 && mem >= 3) // Note, 3 in the mem field is 2GB + printf("We are a 4B with at least 2GB of RAM!\n" ); + + return 0; +} +---- + +And the same in Python: + +[source,python] +---- +import subprocess + +cmd = "cat /proc/cpuinfo | awk '/Revision/ {print $3}'" +revcode = subprocess.check_output(cmd, shell=True) + +code = int(revcode, 16) +new = (code >> 23) & 0x1 +model = (code >> 4) & 0xff +mem = (code >> 20) & 0x7 + +if new and model == 0x11 and mem >= 3 : # Note, 3 in the mem field is 2GB + print("We are a 4B with at least 2GB RAM!") +---- + +=== Best practices for revision code usage + +To avoid problems when new board revisions are created, do not use the revision code (e.g. `c03111`). + +A naive implementation uses a list of supported revision codes, comparing the detected code with the list to decide if the device is supported. +This breaks when a new board revision comes out or if the production location changes: each creates a new revision code not in the supported revision code list. This would cause rejections of new revisions of the same board type, despite the fact that they are always backwards-compatible. Every time a new revision appears, you would have to release a new supported revision code list containing the new revision code - an onerous support burden. + +Instead, use one of the following approaches: + +* Filter by the board-type field (3A, 4B, etc.), which indicates the model, but not the revision. +* Filter by the amount-of-memory field, since RAM vaguely corresponds to the computing power of a board. + +For instance, you could limit support to Raspberry Pi 4B models with 2GB of RAM or more. +The examples in the previous section use this recommended approach. + +NOTE: Always check bit 23, the 'New' flag, to ensure that the revision code is the new version before checking any other fields. + +==== Check Raspberry Pi model and CPU across distributions + +Support and formatting for `/proc/cpuinfo` varies across Linux distributions. To check the model or CPU of a Raspberry Pi device on any Linux distribution (including Raspberry Pi OS), check the device tree: + +[source,console] +---- +$ cat /proc/device-tree/compatible | tr '\0' '\n' +raspberrypi,5-model-b +brcm,bcm2712 +---- + +This outputs two null-separated string values, each containing a comma-separated make and model. For instance, the Raspberry Pi 5 outputs the board and CPU strings above. These correspond to the following values: + +* `raspberrypi` (board make) +* `5-model-b` (board model) +* `brcm` (CPU make) +* `bcm2712` (CPU model) + +Raspberry Pi models have the following device tree values: + +|=== +| Device Name | Make | Model | CPU Make | CPU + +| Pi 500 | `raspberrypi` | `500` | `brcm` | `bcm2712` +| Compute Module 5 | `raspberrypi` | `5-compute-module` | `brcm` | `bcm2712` +| Raspberry Pi 5 | `raspberrypi` | `5-model-b` | `brcm` | `bcm2712` +| Pi 400 | `raspberrypi` | `400` | `brcm` | `bcm2711` +| Compute Module 4S | `raspberrypi` | `4s-compute-module` | `brcm` | `bcm2711` +| Compute Module 4 | `raspberrypi` | `4-compute-module` | `brcm` | `bcm2711` +| Raspberry Pi 4 Model B | `raspberrypi` | `4-model-b` | `brcm` | `bcm2711` +| Zero 2 W | `raspberrypi` | `model-zero-2-w` | `brcm` | `bcm2837` +| Compute Module 3+ | `raspberrypi` | `3-plus-compute-module` | `brcm` | `bcm2837` +| Compute Module 3 | `raspberrypi` | `3-compute-module` | `brcm` | `bcm2837` +| Raspberry Pi 3 Model A+ | `raspberrypi` | `3-model-a-plus` | `brcm` | `bcm2837` +| Raspberry Pi 3 Model B+ | `raspberrypi` | `3-model-b-plus` | `brcm` | `bcm2837` +| Raspberry Pi 3 Model B | `raspberrypi` | `3-model-b` | `brcm` | `bcm2837` +| Raspberry Pi 2 Model B | `raspberrypi` | `2-model-b` | `brcm` | `bcm2836` +| Zero W | `raspberrypi` | `model-zero-w` | `brcm` | `bcm2835` +| Zero | `raspberrypi` | `model-zero` | `brcm` | `bcm2835` +| Compute Module 1 | `raspberrypi` | `compute-module` | `brcm` | `bcm2835` +| Raspberry Pi Model A+ | `raspberrypi` | `model-a-plus` | `brcm` | `bcm2835` +| Raspberry Pi Model B+ | `raspberrypi` | `model-b-plus` | `brcm` | `bcm2835` +| Raspberry Pi Model B Rev 2 | `raspberrypi` | `model-b-rev2` | `brcm` | `bcm2835` +| Raspberry Pi Model A | `raspberrypi` | `model-a` | `brcm` | `bcm2835` +| Raspberry Pi Model B | `raspberrypi` | `model-b` | `brcm` | `bcm2835` |=== diff --git a/documentation/asciidoc/computers/raspberry-pi/rtc.adoc b/documentation/asciidoc/computers/raspberry-pi/rtc.adoc new file mode 100644 index 0000000000..3ae95bdbc4 --- /dev/null +++ b/documentation/asciidoc/computers/raspberry-pi/rtc.adoc @@ -0,0 +1,77 @@ +== Real Time Clock (RTC) + +The Raspberry Pi 5 includes an RTC module. This can be battery powered via the J5 (BAT) connector on the board located to the right of the USB-C power connector. + +.The J5 battery connector +image::images/j5.png[alt="The J5 battery connector",width="70%"] + +You can set a wake alarm which will switch the board to a very low-power state (approximately 3mA). When the alarm time is reached, the board will power back on. This can be useful for periodic jobs like time-lapse imagery. + +To support the low-power mode for wake alarms, edit the bootloader configuration: + +[source,console] +---- +$ sudo -E rpi-eeprom-config --edit +---- + +adding the following two lines. + +[source,ini] +---- +POWER_OFF_ON_HALT=1 +WAKE_ON_GPIO=0 +---- + +You can test the functionality with: + +[source,console] +---- +$ echo +600 | sudo tee /sys/class/rtc/rtc0/wakealarm +$ sudo halt +---- + +That will halt the board into a very low-power state, then wake and restart after 10 minutes. + +The RTC also provides the time on boot e.g. in `dmesg`, for use cases that lack access to NTP: + +---- +[ 1.295799] rpi-rtc soc:rpi_rtc: setting system clock to 2023-08-16T15:58:50 UTC (1692201530) +---- + +NOTE: The RTC is still usable even when there is no backup battery attached to the J5 connector. + +=== Add a backup battery + +.Lithium-manganese rechargeable RTC battery +image::images/rtc-battery.jpg[alt="Lithium-manganese rechargeable RTC battery",width="70%"] + +The official battery part is a rechargeable lithium manganese coin cell, with a pre-fitted two-pin JST-SH plug and an adhesive mounting pad. This is suitable for powering the RTC when the main power supply for the board is disconnected. Since the current draw when powered down measures in single-digit µA, the retention time measures in months. + +NOTE: We do not recommend using a primary (non-rechargeable) lithium cell for the RTC. The RTC backup current consumption is higher than most dedicated RTC modules and will result in a short service life. + +WARNING: Do not use a Lithium Ion cell for the RTC. + +=== Enable battery charging + +The RTC is equipped with a constant-current (3mA) constant-voltage charger. + +Charging of the battery is disabled by default. There are `sysfs` files that show the charging voltage and limits: + +---- +/sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage:0 +/sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage_max:4400000 +/sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage_min:1300000 +---- + +To charge the battery at a set voltage, add https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L279[`rtc_bbat_vchg`] to `/boot/firmware/config.txt`: + +[source,ini] +---- +dtparam=rtc_bbat_vchg=3000000 +---- + +Reboot with `sudo reboot` to use the new voltage setting. Check the `sysfs` files to ensure that the charging voltage was correctly set. + +=== Disable battery charging + +To stop charging, remove any lines that contain https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L279[`rtc_bbat_vchg`] from `config.txt`. diff --git a/documentation/asciidoc/computers/raspberry-pi/spi-bus-on-raspberry-pi.adoc b/documentation/asciidoc/computers/raspberry-pi/spi-bus-on-raspberry-pi.adoc index 87380d270d..6f5d85f16d 100644 --- a/documentation/asciidoc/computers/raspberry-pi/spi-bus-on-raspberry-pi.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/spi-bus-on-raspberry-pi.adoc @@ -1,130 +1,301 @@ [[spi-overview]] -== Serial Peripheral Interface (SPI) +== Serial peripheral interface (SPI) -The Raspberry Pi family of devices is equipped with a number of https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus[SPI] buses. SPI can be used to connect a wide variety of peripherals - displays, network controllers (Ethernet, CAN bus), UARTs, etc. These devices are best supported by kernel device drivers, but the `spidev` API allows userspace drivers to be written in a wide array of languages. +Raspberry Pi computers are equipped with a number of https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus[SPI] buses. SPI can be used to connect a wide variety of peripherals - displays, network controllers (Ethernet, CAN bus), UARTs, etc. These devices are best supported by kernel device drivers, but the `spidev` API allows userspace drivers to be written in a wide array of languages. [[spi-hardware]] -=== SPI Hardware +=== SPI hardware -The BCM2835 core common to all Raspberry Pi devices has 3 SPI Controllers: +Raspberry Pi Zero, 1, 2 and 3 have three SPI controllers: -* SPI0, with two hardware chip selects, is available on the header of all Pis (although there is an alternate mapping that is only usable on a Compute Module. -* SPI1, with three hardware chip selects, is available on 40-pin versions of Pis. -* SPI2, also with three hardware chip selects, is only usable on a Compute Module because the pins aren't brought out onto the 40-pin header. +* `SPI0`, with two hardware chip selects, is available on the header of all Raspberry Pis; there is also an alternate mapping that is only available on Compute Modules. +* `SPI1`, with three hardware chip selects, is available on all Raspberry Pi models except the original Raspberry Pi 1 Model A and Model B. +* `SPI2`, also with three hardware chip selects, is only available on Compute Module 1, 3 and 3+. -BCM2711 adds another 4 SPI buses - SPI3 to SPI6, each with 2 hardware chip selects. All are available on the 40-pin header (provided nothing else is trying to use the same pins). +On the Raspberry Pi 4, 400 and Compute Module 4 there are four additional SPI buses: SPI3 to SPI6, each with two hardware chip selects. These extra SPI buses are available via alternate function assignments on certain GPIO pins. For more information, see the https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf[BCM2711 Arm peripherals] datasheet. -Chapter 10 in the https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf[BCM2835 ARM Peripherals] datasheet describes the main controller. Chapter 2.3 describes the auxiliary controller. +Chapter 10 in the https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf[BCM2835 Arm peripherals] datasheet describes the main controller. Chapter 2.3 describes the auxiliary controller. ==== Pin/GPIO mappings -===== SPI0 (available on J8/P1 headers on all RPi versions) - -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 19 | GPIO10 | SPI0_MOSI | -| MISO | 21 | GPIO09 | SPI0_MISO | -| SCLK | 23 | GPIO11 | SPI0_SCLK | -| CE0 | 24 | GPIO08 | SPI0_CE0_N | -| CE1 | 26 | GPIO07 | SPI0_CE1_N | - -===== SPI0 alternate mapping (available only on Compute Modules) - -| SPI Function | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--| -| MOSI | GPIO38 | SPI0_MOSI | -| MISO | GPIO37 | SPI0_MISO | -| SCLK | GPIO39 | SPI0_SCLK | -| CE0 | GPIO36 | SPI0_CE0_N | -| CE1 | GPIO35 | SPI0_CE1_N | - -===== SPI1 (available only on 40-pin J8 header) - -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 38 | GPIO20 | SPI1_MOSI | -| MISO | 35 | GPIO19 | SPI1_MISO | -| SCLK | 40 | GPIO21 | SPI1_SCLK | -| CE0 | 12 | GPIO18 | SPI1_CE0_N | -| CE1 | 11 | GPIO17 | SPI1_CE1_N | -| CE2 | 36 | GPIO16 | SPI1_CE2_N | - -===== SPI2 (available only on Compute Modules) - -| SPI Function | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--| -| MOSI | GPIO41 | SPI2_MOSI | -| MISO | GPIO40 | SPI2_MISO | -| SCLK | GPIO42 | SPI2_SCLK | -| CE0 | GPIO43 | SPI2_CE0_N | -| CE1 | GPIO44 | SPI2_CE1_N | -| CE2 | GPIO45 | SPI2_CE2_N | +===== SPI0 + +[cols="1m,1,1m,1m"] +|=== +a| SPI function | Header pin a| Broadcom pin name a| Broadcom pin function + +| MOSI +| 19 +| GPIO10 +| SPI0_MOSI + +| MISO +| 21 +| GPIO09 +| SPI0_MISO + +| SCLK +| 23 +| GPIO11 +| SPI0_SCLK + +| CE0 +| 24 +| GPIO08 +| SPI0_CE0_N + +| CE1 +| 26 +| GPIO07 +| SPI0_CE1_N +|=== + +===== SPI0 alternate mapping (Compute Modules only, except CM4) + +[cols="1m,1m,1m"] +|=== +a| SPI function a| Broadcom pin name a| Broadcom pin function + +| MOSI +| GPIO38 +| SPI0_MOSI + +| MISO +| GPIO37 +| SPI0_MISO + +| SCLK +| GPIO39 +| SPI0_SCLK + +| CE0 +| GPIO36 +| SPI0_CE0_N + +| CE1 +| GPIO35 +| SPI0_CE1_N +|=== + +===== SPI1 + +[cols="1m,1,1m,1m"] +|=== +a| SPI function | Header pin | Broadcom pin name | Broadcom pin function + +| MOSI +| 38 +| GPIO20 +| SPI1_MOSI + +| MISO +| 35 +| GPIO19 +| SPI1_MISO + +| SCLK +| 40 +| GPIO21 +| SPI1_SCLK + +| CE0 +| 12 +| GPIO18 +| SPI1_CE0_N + +| CE1 +| 11 +| GPIO17 +| SPI1_CE1_N + +| CE2 +| 36 +| GPIO16 +| SPI1_CE2_N +|=== + +===== SPI2 (Compute Modules only, except CM4) + +[cols="1m,1m,1m"] +|=== +a| SPI function a| Broadcom pin name a| Broadcom pin function + +| MOSI +| GPIO41 +| SPI2_MOSI + +| MISO +| GPIO40 +| SPI2_MISO + +| SCLK +| GPIO42 +| SPI2_SCLK + +| CE0 +| GPIO43 +| SPI2_CE0_N + +| CE1 +| GPIO44 +| SPI2_CE1_N + +| CE2 +| GPIO45 +| SPI2_CE2_N +|=== ===== SPI3 (BCM2711 only) -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 03 | GPIO02 | SPI3_MOSI | -| MISO | 28 | GPIO01 | SPI3_MISO | -| SCLK | 05 | GPIO03 | SPI3_SCLK | -| CE0 | 27 | GPIO00 | SPI3_CE0_N | -| CE1 | 18 | GPIO24 | SPI3_CE1_N | +[cols="1m,1,1m,1m"] +|=== +a| SPI function | Header pin a| Broadcom pin name a| Broadcom pin function + +| MOSI +| 03 +| GPIO02 +| SPI3_MOSI + +| MISO +| 28 +| GPIO01 +| SPI3_MISO + +| SCLK +| 05 +| GPIO03 +| SPI3_SCLK + +| CE0 +| 27 +| GPIO00 +| SPI3_CE0_N + +| CE1 +| 18 +| GPIO24 +| SPI3_CE1_N +|=== ===== SPI4 (BCM2711 only) -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 31 | GPIO06 | SPI4_MOSI | -| MISO | 29 | GPIO05 | SPI4_MISO | -| SCLK | 26 | GPIO07 | SPI4_SCLK | -| CE0 | 07 | GPIO04 | SPI4_CE0_N | -| CE1 | 22 | GPIO25 | SPI4_CE1_N | +[cols="1m,1,1m,1m"] +|=== +a| SPI function | Header pin a| Broadcom pin name a| Broadcom pin function + +| MOSI +| 31 +| GPIO06 +| SPI4_MOSI + +| MISO +| 29 +| GPIO05 +| SPI4_MISO + +| SCLK +| 26 +| GPIO07 +| SPI4_SCLK + +| CE0 +| 07 +| GPIO04 +| SPI4_CE0_N + +| CE1 +| 22 +| GPIO25 +| SPI4_CE1_N +|=== ===== SPI5 (BCM2711 only) -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 08 | GPIO14 | SPI5_MOSI | -| MISO | 33 | GPIO13 | SPI5_MISO | -| SCLK | 10 | GPIO15 | SPI5_SCLK | -| CE0 | 32 | GPIO12 | SPI5_CE0_N | -| CE1 | 37 | GPIO26 | SPI5_CE1_N | +[cols="1m,1,1m,1m"] +|=== +a| SPI function | Header pin a| Broadcom pin name a| Broadcom pin function + +| MOSI +| 08 +| GPIO14 +| SPI5_MOSI + +| MISO +| 33 +| GPIO13 +| SPI5_MISO + +| SCLK +| 10 +| GPIO15 +| SPI5_SCLK + +| CE0 +| 32 +| GPIO12 +| SPI5_CE0_N + +| CE1 +| 37 +| GPIO26 +| SPI5_CE1_N +|=== ===== SPI6 (BCM2711 only) -| SPI Function | Header Pin | Broadcom Pin Name | Broadcom Pin Function | -|--|--|--|--| -| MOSI | 38 | GPIO20 | SPI6_MOSI | -| MISO | 35 | GPIO19 | SPI6_MISO | -| SCLK | 40 | GPIO21 | SPI6_SCLK | -| CE0 | 12 | GPIO18 | SPI6_CE0_N | -| CE1 | 13 | GPIO27 | SPI6_CE1_N | +[cols="1,1,1,1"] +|=== +| SPI function | Header pin | Broadcom pin name | Broadcom pin function + +| MOSI +| 38 +| GPIO20 +| SPI6_MOSI + +| MISO +| 35 +| GPIO19 +| SPI6_MISO + +| SCLK +| 40 +| GPIO21 +| SPI6_SCLK + +| CE0 +| 12 +| GPIO18 +| SPI6_CE0_N + +| CE1 +| 13 +| GPIO27 +| SPI6_CE1_N +|=== ==== Master modes -Signal name abbreviations +Signal name abbreviations: ----- -SCLK - Serial CLocK -CE - Chip Enable (often called Chip Select) -MOSI - Master Out Slave In -MISO - Master In Slave Out -MOMI - Master Out Master In ----- +SCLK:: serial clock +CE:: chip enable (often called chip select) +MOSI:: master out slave in +MISO:: master in slave out +MOMI:: master out master in ===== Standard mode -In Standard SPI mode the peripheral implements the standard 3 wire serial protocol (SCLK, MOSI and MISO). +In Standard SPI mode the peripheral implements the standard three-wire serial protocol (SCLK, MOSI and MISO). ===== Bidirectional mode In bidirectional SPI mode the same SPI standard is implemented, except that a single wire is used for data (MOMI) instead of the two used in standard mode (MISO and MOSI). In this mode, the MOSI pin serves as MOMI pin. -===== LoSSI mode (Low Speed Serial Interface) +===== Low speed serial interface (LoSSI) mode -The LoSSI standard allows issuing of commands to peripherals (LCD) and to transfer data to and from them. LoSSI commands and parameters are 8 bits long, but an extra bit is used to indicate whether the byte is a command or parameter/data. This extra bit is set high for a data and low for a command. The resulting 9-bit value is serialized to the output. LoSSI is commonly used with http://mipi.org/specifications/display-interface[MIPI DBI] type C compatible LCD controllers. +The LoSSI standard allows issuing of commands to peripherals (LCD) and to transfer data to and from them. LoSSI commands and parameters are 8 bits long, but an extra bit is used to indicate whether the byte is a command or parameter/data. This extra bit is set high for data and low for a command. The resulting 9-bit value is serialised to the output. LoSSI is commonly used with http://mipi.org/specifications/display-interface[MIPI DBI] type C compatible LCD controllers. -NOTE: Some commands trigger an automatic read by the SPI controller, so this mode can't be used as a multipurpose 9-bit SPI. +NOTE: Some commands trigger an automatic read by the SPI controller, so this mode cannot be used as a multipurpose 9-bit SPI. ==== Transfer modes @@ -134,65 +305,64 @@ NOTE: Some commands trigger an automatic read by the SPI controller, so this mod ==== Speed -The CDIV (Clock Divider) field of the CLK register sets the SPI clock speed: +The clock divider (CDIV) field of the CLK register sets the SPI clock speed: ----- -SCLK = Core Clock / CDIV -If CDIV is set to 0, the divisor is 65536. The divisor must be a multiple of 2, with odd numbers rounded down. Note that not all possible clock rates are usable because of analogue electrical issues (rise times, drive strengths, etc.) ----- +SCLK:: Core Clock / CDIV + +If CDIV is set to 0, the divisor is 65536. The divisor must be a multiple of 2, with odd numbers rounded down. Note that not all possible clock rates are usable because of analogue electrical issues (rise times, drive strengths, etc). See the <> section for more info. -==== Chip Selects +==== Chip selects -Setup and Hold times related to the automatic assertion and de-assertion of the CS lines when operating in *DMA* mode are as follows: +Setup and hold times related to the automatic assertion and de-assertion of the CS lines when operating in DMA mode are as follows: -* The CS line will be asserted at least 3 core clock cycles before the msb of the first byte of the transfer. -* The CS line will be de-asserted no earlier than 1 core clock cycle after the trailing edge of the final clock pulse. +* The CS line will be asserted at least three core clock cycles before the msb of the first byte of the transfer. +* The CS line will be de-asserted no earlier than one core clock cycle after the trailing edge of the final clock pulse. -[[software]] -=== SPI Software +=== SPI software [[driver]] ==== Linux driver -The default Linux driver is now the standard spi-bcm2835. +The default Linux driver is `spi-bcm2835`. -SPI0 is disabled by default. To enable it, use xref:configuration.adoc#raspi-config[raspi-config], or ensure the line `dtparam=spi=on` isn't commented out in `/boot/config.txt`. By default it uses 2 chip select lines, but this can be reduced to 1 using `dtoverlay=spi0-1cs`. `dtoverlay=spi0-2cs` also exists, and without any parameters it is equivalent to `dtparam=spi=on`. +SPI0 is disabled by default. To enable it, use xref:configuration.adoc#raspi-config[raspi-config], or ensure the line `dtparam=spi=on` is not commented out in xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]. By default it uses two chip select lines, but this can be reduced to one using `dtoverlay=spi0-1cs`. There is also `dtoverlay=spi0-2cs`; without any parameters it is equivalent to `dtparam=spi=on`. -To enable SPI1, you can use 1, 2 or 3 chip select lines, adding in each case: +To enable SPI1, you can use 1, 2 or 3 chip select lines. Add the appropriate lines to `/boot/firmware/config.txt`:" -.... - -dtoverlay=spi1-1cs #1 chip select -dtoverlay=spi1-2cs #2 chip select -dtoverlay=spi1-3cs #3 chip select -.... +[source,ini] +---- +#1 chip select +dtoverlay=spi1-1cs +#2 chip select +dtoverlay=spi1-2cs +#3 chip select +dtoverlay=spi1-3cs +---- -to /boot/config.txt file. Similar overlays exist for SPI2, SPI3, SPI4, SPI5 and SPI6. +Similar overlays exist for SPI2, SPI3, SPI4, SPI5 and SPI6. -The driver does not make use of the hardware chip select lines because of some limitations - instead it can use an arbitrary number of GPIOs as software/GPIO chip selects. This means you are free to choose any spare GPIO as a CS line, and all of these SPI overlays include that control - see `/boot/overlays/README` for details, or run (for example) `dtoverlay -h spi0-2cs` (`dtoverlay -a | grep spi` might be helpful to list them all). +The driver does not make use of the hardware chip select lines because of some limitations. Instead, it can use an arbitrary number of GPIOs as software/GPIO chip selects. This means you are free to choose any spare GPIO as a CS line, and all of these SPI overlays include that control - see `/boot/firmware/overlays/README` for details, or run (for example) `dtoverlay -h spi0-2cs` (`dtoverlay -a | grep spi` might be helpful to list them all). ===== Speed The driver supports all speeds which are even integer divisors of the core clock, although as said above not all of these speeds will support data transfer due to limits in the GPIOs and in the devices attached. As a rule of thumb, anything over 50MHz is unlikely to work, but your mileage may vary. -===== Supported Mode bits +===== Supported mode bits ----- -SPI_CPOL - Clock polarity -SPI_CPHA - Clock phase -SPI_CS_HIGH - Chip Select active high -SPI_NO_CS - 1 device per bus, no Chip Select -SPI_3WIRE - Bidirectional mode, data in and out pin shared ----- +SPI_CPOL:: clock polarity +SPI_CPHA:: clock phase +SPI_CS_HIGH:: chip select active high +SPI_NO_CS:: 1 device per bus, no Chip select +SPI_3WIRE:: bidirectional mode, data in and out pin shared -Bidirectional or "3-wire" mode is supported by the spi-bcm2835 kernel module. Please note that in this mode, either the tx or rx field of the spi_transfer struct must be a NULL pointer, since only half-duplex communication is possible. Otherwise, the transfer will fail. The spidev_test.c source code does not consider this correctly, and therefore does not work at all in 3-wire mode. +Bidirectional mode, also called 3-wire mode, is supported by the `spi-bcm2835` kernel module. Please note that in this mode, either the `tx` or `rx` field of the `spi_transfer` struct must be a NULL pointer, since only half-duplex communication is possible. Otherwise, the transfer will fail. The `spidev_test.c` source code does not consider this correctly, and therefore does not work at all in 3-wire mode. ===== Supported bits per word -* 8 - Normal -* 9 - This is supported using LoSSI mode. +* 8 - normal +* 9 - supported using LoSSI mode ===== Transfer modes @@ -200,31 +370,32 @@ Interrupt mode is supported on all SPI buses. SPI0, and SPI3-6 also support DMA ===== SPI driver latency -This https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489[thread] discusses latency problems. +This https://forums.raspberrypi.com/viewtopic.php?f=44&t=19489[thread] discusses latency problems. ==== spidev -spidev presents an ioctl-based userspace interface to individual SPI CS lines. Device Tree is used to indicate whether a CS line is going to be driven by a kernel driver module or managed by spidev on behalf of the user; it isn't possible to do both at the same time. Note that Raspberry Pi's own kernels are more relaxed about the use of Device Tree to enable spidev - the upstream kernels print warnings about such usage, and ultimately may prevent it altogether. +`spidev` presents an `ioctl`-based userspace interface to individual SPI CS lines. Device Tree is used to indicate whether a CS line is going to be driven by a kernel driver module or managed by `spidev` on behalf of the user; it is not possible to do both at the same time. Note that Raspberry Pi's own kernels are more relaxed about the use of Device Tree to enable `spidev` - the upstream kernels print warnings about such usage, and ultimately may prevent it altogether. + +===== Use `spidev` from C -===== Using spidev from C +There is a loopback test program in the Linux documentation that can be used as a starting point. See the <> section. -There's a loopback test program in the Linux documentation that can be used as a starting point. See the <> section. +===== Use `spidev` from Python -===== Using spidev from Python +There are several Python libraries that provide access to `spidev`, including `spidev` (`pip install spidev` - see https://pypi.org/project/spidev/) and `SPI-Py` (https://github.com/lthiery/SPI-Py). -There are several Python libraries that provide access to spidev, including the imaginatively named `spidev` (`pip install spidev` - see https://pypi.org/project/spidev/) and `SPI-Py` (https://github.com/lthiery/SPI-Py). +===== Use `spidev` from a shell such as bash -===== Using spidev from a shell such as bash +The following command writes binary 1, 2, and 3: -[,bash] +[source,console] ---- -# Write binary 1, 2 and 3 -echo -ne "\x01\x02\x03" > /dev/spidev0.0 +$ echo -ne "\x01\x02\x03" > /dev/spidev0.0 ---- ==== Other SPI libraries -There are other userspace libraries that provide SPI control by directly manipulating the hardware. This is not recommended. +There are other user space libraries that provide SPI control by directly manipulating the hardware: this is not recommended. [[troubleshooting-spi-hardware]] === Troubleshooting @@ -233,11 +404,11 @@ There are other userspace libraries that provide SPI control by directly manipul This can be used to test SPI send and receive. Put a wire between MOSI and MISO. It does not test CE0 and CE1. -[,bash] +[source,console] ---- -wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c -gcc -o spidev_test spidev_test.c -./spidev_test -D /dev/spidev0.0 +$ wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-6.1.y/tools/spi/spidev_test.c +$ gcc -o spidev_test spidev_test.c +$ ./spidev_test -D /dev/spidev0.0 spi mode: 0 bits per word: 8 max speed: 500000 Hz (500 KHz) @@ -251,4 +422,4 @@ DE AD BE EF BA AD F0 0D ---- -Some of the content above has been copied from https://elinux.org/RPi_SPI[the elinux SPI page], which also borrows from here. Both are covered by the CC-SA license. +Some of the content above has been copied from https://elinux.org/RPi_SPI[the elinux SPI page], which also borrows from here. Both are covered by the CC-SA licence. diff --git a/documentation/asciidoc/computers/raspberry-pi/usb-bus-on-raspberry-pi.adoc b/documentation/asciidoc/computers/raspberry-pi/usb-bus-on-raspberry-pi.adoc index 6ccad69fe4..8cf66c9a30 100644 --- a/documentation/asciidoc/computers/raspberry-pi/usb-bus-on-raspberry-pi.adoc +++ b/documentation/asciidoc/computers/raspberry-pi/usb-bus-on-raspberry-pi.adoc @@ -1,57 +1,70 @@ -== Universial Serial Bus (USB) +== Universal Serial Bus (USB) -In general, every device supported by Linux can be used with a Raspberry Pi, although there are some limitations for models prior to Pi 4. +In general, every device supported by Linux can be used with a Raspberry Pi, although there are some limitations for models prior to Raspberry Pi 4. -=== Maximum Power Output +=== Maximum power output -As with all computers, the USB ports on the Raspberry Pi supply a limited amount of power. Often problems with USB devices are caused by power issues. To rule out power as the cause of an problem, connect your USB devices to the Raspberry Pi using a powered hub. +As with all computers, the USB ports on the Raspberry Pi supply a limited amount of power. Often problems with USB devices are caused by power issues. To rule out insufficient power as the cause of the problem, connect your USB devices to the Raspberry Pi using a powered hub. |=== | Model | Max power output of USB ports -| Pi Zero, 1 +| Raspberry Pi Zero, 1 | 500mA per port^1^ -| Pi 2, 3, 4 +| Raspberry Pi 2, 3, 4 | 1200mA total across all ports + +| Raspberry Pi 5 +| 600mA if using a 3A supply, 1600mA if using a 5A supply |=== -. For the original Pi 1B the limit is 100mA per port. +. For the original Raspberry Pi 1 Model B the limit is 100mA per port. + +=== Raspberry Pi 5 + +The Raspberry Pi 5 requires a good quality USB-C power supply capable of delivering 3A at +5V (15W) in order to boot. However, using such a supply will restrict current draw to peripherals. If you are using a power supply that cannot provide 5A at +5V on first boot you will be warned by the operating system that the current draw to peripherals will be restricted to 600mA. + +For users who wish to drive high-power peripherals like hard drives and SSDs, while retaining margin for peak workloads, a USB-PD enabled power supply capable of supplying a 5A at +5V (25W) should be used. If the Raspberry Pi 5 firmware detects such a supply, it increases the USB current limit for peripherals to 1.6A, providing 5W of extra power for downstream USB devices, and 5W of extra onboard power budget. + +NOTE: The power budget is shared between the USB ports and the fan header. === Raspberry Pi 4 -The Pi 4 contains two USB 3.0 ports and two USB 2.0 ports which are connected to a VL805 USB controller. The USB 2.0 lines on all four ports are connected to a single USB 2.0 hub within the VL805: this limits the total available bandwidth for USB 1.1 and USB 2.0 devices to that of a single USB 2.0 port. +Raspberry Pi 4 offers two USB 3.0 ports and two USB 2.0 ports which are connected to a VL805 USB controller. The USB 2.0 lines on all four ports are connected to a single USB 2.0 hub within the VL805. This limits the total available bandwidth for USB 1.1 and USB 2.0 devices to that of a single USB 2.0 port. -On the Pi 4, the USB controller used on previous models is located on the USB type C port and is disabled by default. +On Raspberry Pi 4, the USB controller used on previous models is located on the USB type C port and is disabled by default. === Raspberry Pi Zero, 1, 2 and 3 -The USB controller on models prior to Pi 4 has only a basic level of support for certain devices, which presents a higher software processing overhead. It also supports only one root USB port: all traffic from connected devices is funnelled down this single bus, which operates at a maximum speed of 480mbps. +Raspberry Pi 1 Model B+, Raspberry Pi 2, and Raspberry Pi 3 boards offer four USB 2.0 ports. Raspberry Pi Zero boards have one micro USB on-the-go (OTG) port. + +The USB controller on models prior to Raspberry Pi 4 has only a basic level of support for certain devices, which presents a higher software processing overhead. It also supports only one root USB port: all traffic from connected devices is funnelled down this single bus, which operates at a maximum speed of 480Mbps. -The USB 2.0 specification defines three device speeds - low, full and high. Most mice and keyboards are low speed, most USB sound devices are full speed and most video devices (webcams or video capture) are high speed. +The USB 2.0 specification defines three device speeds - low, full and high. Most mice and keyboards are low speed, most USB sound devices are full speed, and most video devices (webcams or video capture) are high speed. -Generally, there are no issues with connecting multiple high speed USB devices to a Pi. +Generally, there are no issues with connecting multiple high speed USB devices to a Raspberry Pi. -The software overhead incurred when talking to low and full speed devices means that there are limitations on the number of simultaneously active low and full speed devices. Small numbers of these types of devices connected to a Pi will cause no issues. +The software overhead incurred when talking to low- and full-speed devices means that there are limitations on the number of simultaneously active low- and full-speed devices. Small numbers of these types of devices connected to a Raspberry Pi will cause no issues. -=== Known USB Issues +=== Known USB issues ==== Interoperability with USB 3.0 hubs -There is an issue with USB 3.0 hubs in conjunction with the use of full or low speed devices, including most mice and keyboards. A bug in most USB 3.0 hub hardware means that the models prior to Pi 4 cannot talk to full or low speed devices connected to a USB 3.0 hub. +There is an issue with USB 3.0 hubs in conjunction with the use of full- or low-speed devices, including most mice and keyboards. A bug in most USB 3.0 hub hardware means that the models prior to Raspberry Pi 4 cannot talk to full or low speed devices connected to a USB 3.0 hub. USB 2.0 high speed devices, including USB 2.0 hubs, operate correctly when connected via a USB 3.0 hub. -Avoid connecting low or full speed devices into a USB 3.0 hub. As a workaround, plug a USB 2.0 hub into the downstream port of the USB 3.0 hub and connect the low speed device, or use a USB 2.0 hub between the Pi and the USB 3.0 hub, then plug low speed devices into the USB 2.0 hub. +Avoid connecting low or full speed devices into a USB 3.0 hub. As a workaround, plug a USB 2.0 hub into the downstream port of the USB 3.0 hub and connect the low-speed device, or use a USB 2.0 hub between the Raspberry Pi and the USB 3.0 hub, then plug low-speed devices into the USB 2.0 hub. ==== USB 1.1 webcams -Old webcams may be full speed devices. Because these devices transfer a lot of data and incur additional software overhead, reliable operation is not guaranteed. As a workaround, try to use the camera at a lower resolution. +Old webcams may be full-speed devices. Because these devices transfer a lot of data and incur additional software overhead, reliable operation is not guaranteed. As a workaround, try to use the camera at a lower resolution. ==== Esoteric USB sound cards -Expensive audiophile sound cards typically use large amounts of USB bandwidth: reliable operation with 96kHz/192kHz DACs is not guaranteed. As a workaround, forcing the output stream to be CD quality (44.1kHz/48kHz 16-bit) will reduce the stream bandwidth to reliable levels. +Expensive audiophile sound cards typically use large amounts of USB bandwidth. Reliable operation with 96kHz/192kHz DACs is not guaranteed. As a workaround, forcing the output stream to be CD quality (44.1kHz/48kHz 16-bit) will reduce the stream bandwidth to reliable levels. ==== Single TT USB hubs -USB 2.0 and 3.0 hubs have a mechanism for talking to full or low speed devices connected to their downstream ports called a transaction translator (TT). This device buffers high speed requests from the host and transmits them at full or low speed to the downstream device. Two configurations of hub are allowed by the USB specification: Single TT (one TT for all ports) and Multi TT (one TT per port). Because of a hardware limitation, if too many full or low speed devices are plugged into a single TT hub, the devices may behave unreliably. It is recommended to use a Multi TT hub to interface with multiple full and low speed devices. As a workaround, spread full and low speed devices out between the Pi's own USB port and the single TT hub. +USB 2.0 and 3.0 hubs have a mechanism for talking to full- or low-speed devices connected to their downstream ports called a transaction translator (TT). This device buffers high speed requests from the host and transmits them at full or low speed to the downstream device. Two configurations of hub are allowed by the USB specification: Single TT (one TT for all ports) and Multi TT (one TT per port). Because of a hardware limitation, if too many full- or low-speed devices are plugged into a single TT hub, the devices may behave unreliably. It is recommended to use a Multi TT hub to interface with multiple full and low speed devices. As a workaround, spread full- and low-speed devices out between the Raspberry Pi's own USB port and the single TT hub. diff --git a/documentation/asciidoc/computers/remote-access.adoc b/documentation/asciidoc/computers/remote-access.adoc index 0af06ea0c6..def7f582fe 100644 --- a/documentation/asciidoc/computers/remote-access.adoc +++ b/documentation/asciidoc/computers/remote-access.adoc @@ -1,12 +1,12 @@ -include::remote-access/remote-access-introduction.adoc[] +include::remote-access/introduction.adoc[] -include::remote-access/secure-shell.adoc[] +include::remote-access/find-your-ip-address.adoc[] -include::remote-access/secure-shell-from-unix.adoc[] +include::remote-access/ssh.adoc[] -include::remote-access/secure-shell-from-windows10.adoc[] +include::remote-access/vnc.adoc[] -include::remote-access/secure-shell-passwordless.adoc[] +include::remote-access/raspberry-pi-connect.adoc[] include::remote-access/scp.adoc[] @@ -16,9 +16,8 @@ include::remote-access/nfs.adoc[] include::remote-access/samba.adoc[] -include::remote-access/vnc.adoc[] - include::remote-access/apache.adoc[] include::remote-access/network-boot-raspberry-pi.adoc[] +include::remote-access/network-boot-ipv6.adoc[] diff --git a/documentation/asciidoc/computers/remote-access/apache.adoc b/documentation/asciidoc/computers/remote-access/apache.adoc index 9c669811a2..1b9f59aa51 100644 --- a/documentation/asciidoc/computers/remote-access/apache.adoc +++ b/documentation/asciidoc/computers/remote-access/apache.adoc @@ -1,10 +1,10 @@ -== Setting up an Apache Web Server +== Set up an Apache web server Apache is a popular web server application you can install on the Raspberry Pi to allow it to serve web pages. On its own, Apache can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP. -=== Installing Apache +=== Install Apache First, update the available packages by typing the following command into the Terminal: @@ -20,17 +20,17 @@ Then, install the `apache2` package with this command: sudo apt install apache2 -y ---- -=== Test the Web Server +=== Test the web server -By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to `+http://localhost/+` on the Pi itself, or `+http://192.168.1.10+` (whatever the Pi's IP address is) from another computer on the network. To find the Pi's IP address, type `hostname -I` at the command line (or read more about finding your xref:remote-access.adoc#ip-address[IP address]). +By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to `+http://localhost/+` on the Raspberry Pi itself, or `+http://192.168.1.10+` (whatever the Raspberry Pi's IP address is) from another computer on the network. To find the Raspberry Pi's IP address, type `hostname -I` at the command line (or read more about finding your xref:remote-access.adoc#ip-address[IP address]). -Browse to the default web page either on the Pi or from another computer on the network and you should see the following: +Browse to the default web page either on the Raspberry Pi or from another computer on the network and you should see the following: image::images/apache-it-works.png[Apache success message] This means you have Apache working! -==== Changing the Default Web Page +==== Change the default web page This default web page is just an HTML file on the filesystem. It is located at `/var/www/html/index.html`. @@ -51,11 +51,16 @@ drwxr-xr-x 12 root root 4096 Jan 8 01:28 .. -rw-r--r-- 1 root root 177 Jan 8 01:29 index.html ---- -This shows that by default there is one file in `/var/www/html/` called ``index.html``and it is owned by the `root` user (as is the enclosing folder). In order to edit the file, you need to change its ownership to your own username. Change the owner of the file (the default `pi` user is assumed here) using `sudo chown pi: index.html`. +This shows that by default there is one file in `/var/www/html/` called `index.html` and it is owned by the `root` user (as is the enclosing folder). In order to edit the file, you need to change its ownership to your own username. Change the owner of the file using the following command, replacing the `` placeholder with the username of your primary user account: + +[source,console] +---- +$ sudo chown : index.html +---- You can now try editing this file and then refreshing the browser to see the web page change. If you know HTML you can put your own HTML files and other assets in this directory and serve them as a website on your local network. -=== Installing PHP for Apache +=== Install PHP for Apache To allow your Apache server to process PHP files, you'll need to install the latest version of PHP and the PHP module for Apache. Type the following command to install these: diff --git a/documentation/asciidoc/computers/remote-access/find-your-ip-address.adoc b/documentation/asciidoc/computers/remote-access/find-your-ip-address.adoc new file mode 100644 index 0000000000..326ee3d7e7 --- /dev/null +++ b/documentation/asciidoc/computers/remote-access/find-your-ip-address.adoc @@ -0,0 +1,175 @@ +[[ip-address]] +== Find the IP address of your Raspberry Pi + +Most methods of connecting to your Raspberry Pi from another machine require you to know the local IP address of your Raspberry Pi. + +Any device connected to a Local Area Network is assigned an IP address. In order to connect to your Raspberry Pi from another machine using xref:remote-access.adoc#ssh[SSH] or xref:remote-access.adoc#vnc[VNC], you need to know the Raspberry Pi's IP address. This is easy if you have a display connected, and there are a number of methods for finding it remotely from another machine on the network. + +To find the local IP address of your Raspberry Pi, use one of the following methods. + +=== Desktop + +Hover over the network icon in the system tray, and a tooltip will appear. This tooltip displays the name of the network you're currently connected to and your IP address. + +image::images/network-tooltip.png[the Network Manager tooltip displaying a Wi-Fi network name and IP address] + +=== Command line + +Run the following command to output your local IP address to the command line: + +[source,console] +---- +$ hostname -I +---- + +=== Boot output + +If you use a display with your Raspberry Pi and you boot to the command line instead of the desktop, the boot sequence includes your IP address as one of the last few output messages before your login prompt. + +=== Network Manager + +You can use the built-in Network Manager CLI (`nmcli`) to access details about your network. Run the following command: + +[source,console] +---- +$ nmcli device show +---- + +You should see output similar to the following: + +---- +GENERAL.DEVICE: wlan0 +GENERAL.TYPE: wifi +GENERAL.HWADDR: D0:3B:FF:41:AB:8A +GENERAL.MTU: 1500 +GENERAL.STATE: 100 (connected) +GENERAL.CONNECTION: exampleNetworkName +GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2 +IP4.ADDRESS[1]: 192.168.1.42/24 +IP4.GATEWAY: 192.168.1.1 +IP4.ROUTE[1]: dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 600 +IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 600 +IP4.DNS[1]: 192.168.1.3 +IP6.ADDRESS[1]: ab80::11ab:b1fc:bb7e:a8a5/64 +IP6.GATEWAY: -- +IP6.ROUTE[1]: dst = ab80::/64, nh = ::, mt = 1024 + +GENERAL.DEVICE: lo +GENERAL.TYPE: loopback +GENERAL.HWADDR: 00:00:00:00:00:00 +GENERAL.MTU: 65536 +GENERAL.STATE: 100 (connected (externally)) +GENERAL.CONNECTION: lo +GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1 +IP4.ADDRESS[1]: 127.0.0.1/8 +IP4.GATEWAY: -- +IP6.ADDRESS[1]: ::1/128 +IP6.GATEWAY: -- + +GENERAL.DEVICE: p2p-dev-wlan0 +GENERAL.TYPE: wifi-p2p +GENERAL.HWADDR: (unknown) +GENERAL.MTU: 0 +GENERAL.STATE: 30 (disconnected) +GENERAL.CONNECTION: -- +GENERAL.CON-PATH: -- + +GENERAL.DEVICE: eth0 +GENERAL.TYPE: ethernet +GENERAL.HWADDR: D0:3B:FF:41:AB:89 +GENERAL.MTU: 1500 +GENERAL.STATE: 20 (unavailable) +GENERAL.CONNECTION: -- +GENERAL.CON-PATH: -- +WIRED-PROPERTIES.CARRIER: off +IP4.GATEWAY: -- +IP6.GATEWAY: -- +---- + +This command outputs information about the various network interfaces accessible on your Raspberry Pi. Check the `GENERAL.TYPE` row to see which kind of network interface each block describes. For example, "ethernet" is the Ethernet port on your device, and "wifi" refers to the Wi-Fi chip built into some devices. You'll look at different blocks of output to find your IP address depending on the way your device accesses the internet: + +* if your device connects to the internet using Wi-Fi, check the "wifi" block +* if your device connects to the internet using the Ethernet port, check the "ethernet" block + +Once you've identified the correct network interface block, look for a field named `IP4.ADDRESS[1]` for an IPv4 address or `IP6.ADDRESS[1]` for an IPv6 address. You can ignore the trailing slash and number (e.g. `/24`) in those fields. + +In the example above, the Raspberry Pi uses Wi-Fi to access the internet. Check the block where the `GENERAL.TYPE` field reads "wifi" to find the IP address. In this case, you can access this device using the IPv4 address in the `IP4.ADDRESS[1]` field: `192.168.1.42`. + +=== Resolve `raspberrypi.local` with mDNS + +Raspberry Pi OS supports multicast DNS as part of the Avahi service. + +If your device supports mDNS, you can reach your Raspberry Pi by using its hostname and the `.local` suffix. +The default hostname on a fresh Raspberry Pi OS install is `raspberrypi`, so by default any Raspberry Pi running Raspberry Pi OS responds to: + +[source,console] +---- +$ ping raspberrypi.local +---- + +If the Raspberry Pi is reachable, `ping` will show its IP address: + +---- +PING raspberrypi.local (192.168.1.131): 56 data bytes +64 bytes from 192.168.1.131: icmp_seq=0 ttl=255 time=2.618 ms +---- + +TIP: If you change the system hostname of your Raspberry Pi using Raspberry Pi Configuration, `raspi-config`, or `/etc/hostname`, Avahi updates the `.local` mDNS address. If you don't remember the hostname of your Raspberry Pi, you can install Avahi on another device, then use https://linux.die.net/man/1/avahi-browse[`avahi-browse`] to browse all the hosts and services on your local network. + +=== Check your router's list of devices + +In a web browser, navigate to your router's IP address. Then, log in using your credentials. + +TIP: Your router's IP address is often `http://192.168.1.1`, but not always. You may be able to find your router's address and credentials printed on a label on your router. + +This will take you to a control panel. Browse to the list of connected devices or similar (all routers are different), and you should see some devices you recognise. Some devices are detected as PCs, tablets, phones, printers, etc. so you should recognise some and rule them out to figure out which is your Raspberry Pi. + +TIP: If you connect your Raspberry Pi to your network with a wire, try filtering for wired devices in the list. There should be fewer devices to choose from. + +=== Find devices with `nmap` + +The Network Mapper command (`nmap`) is a free and open source tool for network discovery. It is available for Linux, macOS, and Windows. + +* To install on *Linux*, install the `nmap` package e.g. `apt install nmap`. +* To install on *macOS* or *Windows*, see the http://nmap.org/download.html[nmap.org download page]. + +To use `nmap` to scan the devices on your network, you need to know the subnet you are connected to. First, find the local IP address of the computer you're using: + +* On *Linux*, type `hostname -I` into a terminal window +* On *macOS*, go to *System Settings* > *Network*, select your active network connection, then click the *Details...* button +* On *Windows*, go to the Control Panel, then under *Network and Sharing Center*, click *View network connections*, select your active network connection and click *View status of this connection* + +Next, scan the whole **subnet** for other devices. Most local networks use IPv4, which uses four numbers with values between 1 and 255 for each IP address. Devices on your subnet all use the same first three numbers. For example, if your IP address is `192.168.1.5`, other devices will use addresses like `192.168.1.2`, `192.168.1.6` and `192.168.1.200`. To scan this subnet with `nmap`, pass the string `192.168.1.0/24`, which covers the subnet range `192.168.1.0` to `192.168.1.255`. Use the `-sn` flag to run a **ping scan** on the entire subnet range: + +[source,console] +---- +$ sudo nmap -sn 192.168.1.0/24 +---- + +TIP: This may take up to a minute depending on your local network speed. + +A ping scan queries all IP addresses in the range for a response. For each device that responds to the ping, the output shows the hostname and IP address as follows: + +---- +Starting Nmap 6.40 ( http://nmap.org ) at 2014-03-10 12:46 GMT +Nmap scan report for hpprinter (192.168.1.2) +Host is up (0.00044s latency). +Nmap scan report for Gordons-MBP (192.168.1.4) +Host is up (0.0010s latency). +Nmap scan report for ubuntu (192.168.1.5) +Host is up (0.0010s latency). +Nmap scan report for raspberrypi (192.168.1.8) +Host is up (0.0030s latency). +Nmap done: 256 IP addresses (4 hosts up) scanned in 2.41 seconds +---- + +The output above shows a device with hostname `raspberrypi` has IP address `192.168.1.8`. + +=== Find devices with a smartphone app + +The Fing app is a free network scanner for smartphones. It is available for https://play.google.com/store/apps/details?id=com.overlook.android.fing[Android] and https://itunes.apple.com/gb/app/fing-network-scanner/id430921107?mt=8[iOS]. + +. Connect your phone to the same network as your Raspberry Pi. +. When you open the Fing app, touch the refresh button in the upper right-hand corner of the screen. +. After a few seconds, you should see a list with all the devices connected to your network. +. Scroll down to the entry with the manufacturer "Raspberry Pi". The IP address appears in the bottom left corner, and the MAC address in the bottom right corner of the entry. diff --git a/documentation/asciidoc/computers/remote-access/images/network-tooltip.png b/documentation/asciidoc/computers/remote-access/images/network-tooltip.png new file mode 100644 index 0000000000..86351ee3ba Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/network-tooltip.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/raspberry-pi-configuration.png b/documentation/asciidoc/computers/remote-access/images/raspberry-pi-configuration.png new file mode 100644 index 0000000000..2c99724c16 Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/raspberry-pi-configuration.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-enable.png b/documentation/asciidoc/computers/remote-access/images/vnc-enable.png new file mode 100644 index 0000000000..4c81b61ea3 Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-enable.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-signer-warning.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-signer-warning.png new file mode 100644 index 0000000000..6587b8b0ea Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-signer-warning.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-warning.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-warning.png new file mode 100644 index 0000000000..7160947acd Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-cert-warning.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-desktop.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-desktop.png new file mode 100644 index 0000000000..e8420b865a Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-desktop.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-enter-ip.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-enter-ip.png new file mode 100644 index 0000000000..da4acd465e Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-enter-ip.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-show-dot.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-show-dot.png new file mode 100644 index 0000000000..61042ffc45 Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-show-dot.png differ diff --git a/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-username-password.png b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-username-password.png new file mode 100644 index 0000000000..33524b2281 Binary files /dev/null and b/documentation/asciidoc/computers/remote-access/images/vnc-tigervnc-username-password.png differ diff --git a/documentation/asciidoc/computers/remote-access/introduction.adoc b/documentation/asciidoc/computers/remote-access/introduction.adoc new file mode 100644 index 0000000000..68c3109d7d --- /dev/null +++ b/documentation/asciidoc/computers/remote-access/introduction.adoc @@ -0,0 +1,24 @@ +== Introduction to remote access + +Sometimes you need to access a Raspberry Pi without connecting it to a monitor, keyboard, and mouse. Perhaps the Raspberry Pi is embedded in a robot or mounted in an inconvenient location. Or maybe you don't have a spare monitor. + +=== Remote control over the local network + +To remotely control your Raspberry Pi from another device on your local network, use one of the following services: + +* xref:remote-access.adoc#ssh[SSH] +* xref:remote-access.adoc#vnc[VNC] +* xref:remote-access.adoc#raspberry-pi-connect[Raspberry Pi Connect] + +SSH (**S**ecure **SH**ell) provides secure access to a terminal session on your Raspberry Pi. VNC (**V**irtual **N**etwork **C**omputing) provides secure access to a desktop screen share on your Raspberry Pi. All you need is another computer, a local network, and the local https://en.wikipedia.org/wiki/IP_address[IP address] of your Raspberry Pi. Raspberry Pi Connect shares your Raspberry Pi's screen securely with no need to determine your local IP address. + +=== Share files between devices over the local network + +Services like xref:remote-access.adoc#nfs[NFS] (Network File System), xref:remote-access.adoc#scp[SCP] (Secure Copy Protocol), xref:remote-access.adoc#samba[Samba], and xref:remote-access.adoc#rsync[`rsync`] enable you to share files between devices on the local network without directly controlling the remote device. These services can be useful when you need to access data stored on one device from another device. + +=== Remote control over the Internet + +To remotely control your Raspberry Pi from any device connected to the Internet, you can: + +* Expose xref:remote-access.adoc#ssh[SSH] or xref:remote-access.adoc#vnc[VNC] on your Raspberry Pi over the open internet, within a VPN, or using an external service like RealVNC's cloud https://www.realvnc.com/download/viewer/[VNC Viewer]. +* Use xref:remote-access.adoc#raspberry-pi-connect[Raspberry Pi Connect], a free screen sharing and remote shell service provided by Raspberry Pi. diff --git a/documentation/asciidoc/computers/remote-access/network-boot-ipv6.adoc b/documentation/asciidoc/computers/remote-access/network-boot-ipv6.adoc new file mode 100644 index 0000000000..e2db3adc16 --- /dev/null +++ b/documentation/asciidoc/computers/remote-access/network-boot-ipv6.adoc @@ -0,0 +1,341 @@ +== Network boot using IPv6 + +There are 4 stages to booting a Raspberry Pi computer over the network: + +1. The bootloader negotiates to get an IP address and the details of a TFTP server using DHCP. +2. The bootloader loads the firmware via TFTP and hands over the boot process to the firmware, passing it the details of the network. +3. The firmware loads the kernel and command line via TFTP. +4. The kernel boots the rest of the system, loading the root filesystem (rootfs) via NFS or some other mechanism. + +The bootloader and firmware (stages 1 to 3) have been enhanced to support booting over IPv6. + +IMPORTANT: IPv6 netboot is an *experimental alpha feature* and depending on feedback, we may need to change how it works in future. This only works on Raspberry Pi 4 and Compute Module 4. + +=== How it works + +To boot via IPv6 you need an updated version of the firmware (e.g. `start4.elf`) and the bootloader. Using the latest release of Raspberry Pi OS and the latest stable bootloader should be sufficient. + +NOTE: The commonly used `dnsmasq` DHCP server doesn't currently support the network boot parameters required for IPv6 network boot, so for the time being you will have to use a different DHCP server such as https://www.isc.org/dhcp/[ISC DHCP]. + +To mount `rootfs` over the network the xref:remote-access.adoc#network-boot-your-raspberry-pi[IPv4 netboot tutorial] suggests using `nfsroot`. This doesn't support IPv6, so another method is needed to mount `rootfs` over the network. + +If your ISP and router don't support IPv6 you will be limited in what you can do. + +==== Network addresses + +The first thing the bootloader does is send a router solicitation to get the details of the network. The router responds with an advertisement packet identifying its ethernet address, which the bootloader might need if the TFTP server is on a different network. + +The router advertisement includes a flag which tells it whether to use stateful (managed) or stateless (unmanaged) configuration for its IP address. Stateless configuration means that the device configures its own IP address. Currently the bootloader generates an address derived from its ethernet MAC address and a network prefix supplied by the router. + +If the router indicates that stateful configuration is enabled DHCP is used to obtain the IP address of the device. This involves the device sending a solicitation request to a DHCP server which responds with an advertisement. The client then requests the address before getting a reply acknowledgement from the server. + +DHCP Servers and clients identify themselves with variable length DUID (Device Unique ID). On the Raspberry Pi this is derived from the MAC address (DUID_LL). + +==== TFTP address + +Whether using stateless or stateful configuration, the DHCP server is used to obtain the TFTP server address. This is encoded in the `BOOTFILE-URL` parameter. We send the client architecture type value `0x29` to identify a device. + +See https://datatracker.ietf.org/doc/html/rfc5970[RFC 5970] and the https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml[IANA Dynamic Host Configuration Protocol for IPv6] documentation. + +==== Boot process + +The device should now have an IP address and TFTP details. It downloads the firmware binary `start4.elf` from the TFTP server and continues running with this. The firmware is passed the IP address and TFTP server details so it can download the kernel and boot the rest of the system. + +==== Kernel Boot + +With IPv4 netboot, `nfsroot` is used to mount `rootfs` over the network. This doesn't support IPv6 so another solution is required. It might involve a small RAM file system that can mount the appropriate network location before switching to the proper `rootfs` contents. + +NOTE: A mechanism to boot the Linux kernel with NFS via IPv6 is still to be demonstrated. + +=== Test setup + +If you want to try this out you will need another Raspberry Pi to act as the TFTP and DHCP server. + +The TFTP server can in theory be on any routable network but the DHCP server has to be on the same network as the devices it will serve. + +==== TFTP server + +If you have a working IPv4 network boot setup you can reuse the TFTP server in dnsmasq to supply the files (it can talk to both IPv4 and +IPv6). + +Alternatively you can use a standalone TFTP server like `tftpd-hpa`. + +[,bash] +---- +$ sudo apt install tftpd-hpa +$ sudo systemctl start tftpd-hpa +---- + +==== DHCP server + +DHCP in IPv6 has changed a lot. We need DHCP to at least tell us the address of the TFTP server, which in this case is the same machine. + +[,bash] +---- +$ sudo apt install isc-dhcp-server +---- + +Modify the configuration in `/etc/default/isc-dhcp-server` + +[,bash] +---- +DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf +INTERFACESv6="eth0" +---- + +In `/etc/dhcp/dhcpd6.conf` you need to specify the TFTP server address and setup a subnet. Here the DHCP server is configured to supply some made up unique local addresses (ULA). The `host test-rpi4` line tells DHCP to give a test device a fixed address. + +---- +not authoritative; + +# Check if the client looks like a Raspberry Pi +if option dhcp6.client-arch-type = 00:29 { + option dhcp6.bootfile-url "tftp://[fd49:869:6f93::1]/"; +} + +subnet6 fd49:869:6f93::/64 { + host test-rpi4 { + host-identifier option dhcp6.client-id 00:03:00:01:e4:5f:01:20:24:0b; + fixed-address6 fd49:869:6f93::1000; + } +} +---- + +Your server has to be assigned the IPv6 address in `/etc/dhcpcd.conf` + +---- +interface eth0 +static ip6_address=fd49:869:6f93::1/64 +---- + +Now start the DHCP server. + +[,bash] +---- +$ sudo systemctl restart isc-dhcp-server.service +---- + +==== Bootloader + +Modify the configuration to tell it to attempt network boot via IPv6 rather than IPv4. + +---- +BOOT_ORDER=0xf21 # 2=Network boot +USE_IPV6=1 # Enable IPv6 network boot +BOOT_UART=1 # Debug +---- + +To revert to IPv4 network boot just remove the `USE_IPV6` line from `boot.conf`. + +==== Router + +To use IPv6 you really need a router and ISP that supports IPv6. There are sites on the internet that can check this for you or alternatively run the following command. + +[,bash] +---- +sudo apt install ndisc6 +rdisc6 -1 eth0 +---- + +This sends a router solicitation to your router asking for your network details such as the network prefix, router ethernet address and whether to use DHCP for addressing. If there's no response to this command it's likely your network and ISP only supports IPv4. If IPv6 is supported it's most likely that it will be configured to use stateless configuration where clients generate their own addresses. + +---- +Soliciting ff02::2 (ff02::2) on eth0... +Hop limit : 64 ( 0x40) +Stateful address conf. : No +Stateful other conf. : Yes +Mobile home agent : No +Router preference : medium +Neighbor discovery proxy : No +Router lifetime : 180 (0x000000b4) seconds +Reachable time : unspecified (0x00000000) +Retransmit time : unspecified (0x00000000) +---- + +You might be able to configure your router for stateful configuration, which means it will use DHCP to obtain an IP address. + +---- +Hop limit : 64 ( 0x40) +Stateful address conf. : Yes +Stateful other conf. : Yes +Mobile home agent : No +Router preference : medium +Neighbor discovery proxy : No +Router lifetime : 180 (0x000000b4) seconds +Reachable time : unspecified (0x00000000) +Retransmit time : unspecified (0x00000000) +---- + +=== Debugging + +==== Logs and traces + +If the boot UART is enabled, you should see something like this from the serial port. The lines starting RX6 indicate that IPv6 is in use. + +Here `dc:a6:32:6f:73:f4` is the MAC address of the TFTP server and it has an IPv6 address of `fd49:869:6f93::1`. The device itself has a MAC address `e4:5f:01:20:24:0b` and an IPv6 address of `fd49:869:6f93::1000` + +---- +Boot mode: NETWORK (02) order f +GENET: RESET_PHY +PHY ID 600d 84a2 +NET_BOOT: e4:5f:01:20:24:0b wait for link TFTP6: (null) +LINK STATUS: speed: 100 full duplex +Link ready +GENET START: 64 16 32 +GENET: UMAC_START 0xe45f0120 0x240b0000 +RX6: 12 IP: 1 MAC: 1 ICMP: 1/1 UDP: 0/0 ICMP_CSUM_ERR: 0 UDP_CSUM_ERR: 0 +NET fd49:869:6f93::1000 tftp fd49:869:6f93::1 +RX6: 17 IP: 4 MAC: 4 ICMP: 2/2 UDP: 2/2 ICMP_CSUM_ERR: 0 UDP_CSUM_ERR: 0 +TFTP_GET: dc:a6:32:6f:73:f4 fd49:869:6f93::1 ab5a4158/start4.elf + +RX6: 17 IP: 4 MAC: 4 ICMP: 2/2 UDP: 2/2 ICMP_CSUM_ERR: 0 UDP_CSUM_ERR: 0 +RX6: 18 IP: 5 MAC: 5 ICMP: 2/2 UDP: 3/3 ICMP_CSUM_ERR: 0 UDP_CSUM_ERR: 0 +TFTP_GET: dc:a6:32:6f:73:f4 fd49:869:6f93::1 ab5a4158/config.txt +---- + +Finally the bootloader hands over to firmware which should load the kernel. + +==== Stateful configuration + +You can examine network activity with tcpdump. + +[source,console] +---- +$ sudo tcpdump -i eth0 -e ip6 -XX -l -v -vv +---- + +Below is an extract of a TCP dump where the router is configured to use stateful (DHCP) network configuration. + +Device sends a router solicitation. + +---- +12:23:35.387046 e4:5f:01:20:24:0b (oui Unknown) > 33:33:00:00:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 70: (hlim 255, next-header ICMPv6 (58) payload length: 16) fe80::e65f:1ff:fe20:240b > ip6-allrouters: [icmp6 sum ok] ICMP6, router solicitation, length 16 + source link-address option (1), length 8 (1): e4:5f:01:20:24:0b + 0x0000: e45f 0120 240b +---- + +Router sends a response telling the device to use stateful configuration. + +---- +12:23:35.498902 60:8d:26:a7:c1:88 (oui Unknown) > 33:33:00:00:00:01 (oui Unknown), ethertype IPv6 (0x86dd), length 110: (hlim 255, next-header ICMPv6 (58) payload length: 56) bthub.home > ip6-allnodes: [icmp6 sum ok] ICMP6, router advertisement, length 56 + hop limit 64, Flags [managed, other stateful], pref medium, router lifetime 180s, reachable time 0ms, retrans timer 0ms + rdnss option (25), length 24 (3): lifetime 60s, addr: bthub.home + 0x0000: 0000 0000 003c fe80 0000 0000 0000 628d + 0x0010: 26ff fea7 c188 + mtu option (5), length 8 (1): 1492 + 0x0000: 0000 0000 05d4 + source link-address option (1), length 8 (1): 60:8d:26:a7:c1:88 + 0x0000: 608d 26a7 c188 +---- + +Device sends a DHCP solicitation. + +---- +12:23:35.502517 e4:5f:01:20:24:0b (oui Unknown) > 33:33:00:01:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 114: (hlim 255, next-header UDP (17) payload length: 60) fe80::e65f:1ff:fe20:240b.dhcpv6-client > ff02::1:2.dhcpv6-server: [udp sum ok] dhcp6 solicit (xid=8cdd56 (client-ID hwaddr type 1 e45f0120240b) (IA_NA IAID:0 T1:0 T2:0) (option-request opt_59) (opt_61) (elapsed-time 0)) +---- + +The DHCP server replies with an advertisement. + +---- +12:23:35.510478 dc:a6:32:6f:73:f4 (oui Unknown) > e4:5f:01:20:24:0b (oui Unknown), ethertype IPv6 (0x86dd), length 172: (flowlabel 0xad54d, hlim 64, next-header UDP (17) payload length: 118) fe80::537a:52c:c647:b184.dhcpv6-server > fe80::e65f:1ff:fe20:240b.dhcpv6-client: [bad udp cksum 0xd886 -> 0x6d26!] dhcp6 advertise (xid=8cdd56 (IA_NA IAID:0 T1:3600 T2:7200 (IA_ADDR fd49:869:6f93::1000 pltime:604800 vltime:2592000)) (client-ID hwaddr type 1 e45f0120240b) (server-ID hwaddr/time type 1 time 671211709 dca6326f73f4) (opt_59)) +---- + +The device sends a request for an address and TFTP details to the DHCP server. + +---- +12:23:35.510763 e4:5f:01:20:24:0b (oui Unknown) > 33:33:00:01:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 132: (hlim 255, next-header UDP (17) payload length: 78) fe80::e65f:1ff:fe20:240b.dhcpv6-client > ff02::1:2.dhcpv6-server: [udp sum ok] dhcp6 request (xid=8cdd56 (client-ID hwaddr type 1 e45f0120240b) (server-ID hwaddr/time type 1 time 671211709 dca6326f73f4) (IA_NA IAID:0 T1:0 T2:0) (option-request opt_59) (opt_61) (elapsed-time 1)) +---- + +The DHCP server replies, `opt_59` is used to pass the address of the TFTP server. + +---- +12:23:35.512122 dc:a6:32:6f:73:f4 (oui Unknown) > e4:5f:01:20:24:0b (oui Unknown), ethertype IPv6 (0x86dd), length 172: (flowlabel 0xad54d, hlim 64, next-header UDP (17) payload length: 118) fe80::537a:52c:c647:b184.dhcpv6-server > fe80::e65f:1ff:fe20:240b.dhcpv6-client: [bad udp cksum 0xd886 -> 0x6826!] dhcp6 reply (xid=8cdd56 (IA_NA IAID:0 T1:3600 T2:7200 (IA_ADDR fd49:869:6f93::1000 pltime:604800 vltime:2592000)) (client-ID hwaddr type 1 e45f0120240b) (server-ID hwaddr/time type 1 time 671211709 dca6326f73f4) (opt_59)) +---- + +The device sends a neighbour solicitation to the FTP server because it needs its MAC address. + +---- +12:23:36.510768 e4:5f:01:20:24:0b (oui Unknown) > 33:33:ff:00:00:01 (oui Unknown), ethertype IPv6 (0x86dd), length 86: (hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::e65f:1ff:fe20:240b > ff02::1:ff00:1: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has fd49:869:6f93::1 + source link-address option (1), length 8 (1): e4:5f:01:20:24:0b + 0x0000: e45f 0120 240b +---- + +The FTP server replies with its MAC address. + +---- +12:23:36.510854 dc:a6:32:6f:73:f4 (oui Unknown) > e4:5f:01:20:24:0b (oui Unknown), ethertype IPv6 (0x86dd), length 86: (hlim 255, next-header ICMPv6 (58) payload length: 32) fd49:869:6f93::1 > fe80::e65f:1ff:fe20:240b: [icmp6 sum ok] ICMP6, neighbor advertisement, length 32, tgt is fd49:869:6f93::1, Flags [solicited, override] + destination link-address option (2), length 8 (1): dc:a6:32:6f:73:f4 + 0x0000: dca6 326f 73f4 +---- + +TFTP requests are made by the device which should now boot over the network. + +---- +12:23:36.530820 e4:5f:01:20:24:0b (oui Unknown) > dc:a6:32:6f:73:f4 (oui Unknown), ethertype IPv6 (0x86dd), length 111: (hlim 255, next-header UDP (17) payload length: 57) fd49:869:6f93::1000.61785 > fd49:869:6f93::1.tftp: [udp sum ok] 49 RRQ "ab5a4158/start4.elf" octet tsize 0 blksize 1024 +---- + +==== Stateless configuration + +Below is an extract of a tcp dump for a stateless (non-DHCP) network configuration. + +The device sends a router solicitation. + +---- +12:55:27.541909 e4:5f:01:20:24:0b (oui Unknown) > 33:33:00:00:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 70: (hlim 255, next-header ICMPv6 (58) payload length: 16) fe80::e65f:1ff:fe20:240b > ip6-allrouters: [icmp6 sum ok] ICMP6, router solicitation, length 16 + source link-address option (1), length 8 (1): e4:5f:01:20:24:0b + 0x0000: e45f 0120 240b +---- + +The router replies with the network details. + +---- +12:55:27.834684 60:8d:26:a7:c1:88 (oui Unknown) > 33:33:00:00:00:01 (oui Unknown), ethertype IPv6 (0x86dd), length 174: (hlim 255, next-header ICMPv6 (58) payload length: 120) bthub.home > ip6-allnodes: [icmp6 sum ok] ICMP6, router advertisement, length 120 + hop limit 64, Flags [other stateful], pref medium, router lifetime 180s, reachable time 0ms, retrans timer 0ms + prefix info option (3), length 32 (4): 2a00:23c5:ee00:5001::/64, Flags [onlink, auto, router], valid time 300s, pref. time 120s + 0x0000: 40e0 0000 012c 0000 0078 0000 0000 2a00 + 0x0010: 23c5 ee00 5001 0000 0000 0000 0000 + prefix info option (3), length 32 (4): fd4d:869:6f93::/64, Flags [onlink, auto, router], valid time 10080s, pref. time 2880s + 0x0000: 40e0 0000 2760 0000 0b40 0000 0000 fd4d + 0x0010: 0869 6f93 0000 0000 0000 0000 0000 + rdnss option (25), length 24 (3): lifetime 60s, addr: bthub.home + 0x0000: 0000 0000 003c fe80 0000 0000 0000 628d + 0x0010: 26ff fea7 c188 + mtu option (5), length 8 (1): 1492 + 0x0000: 0000 0000 05d4 + source link-address option (1), length 8 (1): 60:8d:26:a7:c1:88 + 0x0000: 608d 26a7 c188 +---- + +The device sends an information request to the DHCP multicast address asking for the TFTP details. + +---- +12:55:27.838300 e4:5f:01:20:24:0b (oui Unknown) > 33:33:00:01:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 98: (hlim 255, next-header UDP (17) payload length: 44) fe80::e65f:1ff:fe20:240b.dhcpv6-client > ff02::1:2.dhcpv6-server: [udp sum ok] dhcp6 inf-req (xid=e5e0a4 (client-ID hwaddr type 1 e45f0120240b) (option-request opt_59) (opt_61) (elapsed-time 0)) +---- + +The DHCP server replies with the TFTP server details (`opt_59`). + +---- +12:55:27.838898 dc:a6:32:6f:73:f4 (oui Unknown) > e4:5f:01:20:24:0b (oui Unknown), ethertype IPv6 (0x86dd), length 150: (flowlabel 0xd1248, hlim 64, next-header UDP (17) payload length: 96) fe80::537a:52c:c647:b184.dhcpv6-server > fe80::e65f:1ff:fe20:240b.dhcpv6-client: [bad udp cksum 0xd870 -> 0x78bb!] dhcp6 reply (xid=e5e0a4 (client-ID hwaddr type 1 e45f0120240b) (server-ID hwaddr/time type 1 time 671211709 dca6326f73f4) (opt_59)) +---- + +The device asks for the TFTP server MAC address since it can tell it's on the same network. + +---- +12:55:28.834796 e4:5f:01:20:24:0b (oui Unknown) > 33:33:ff:1d:fe:2a (oui Unknown), ethertype IPv6 (0x86dd), length 86: (hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::e65f:1ff:fe20:240b > ff02::1:ff1d:fe2a: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2a00:23c5:ee00:5001:57f1:7523:2f1d:fe2a + source link-address option (1), length 8 (1): e4:5f:01:20:24:0b + 0x0000: e45f 0120 240b +---- + +The FTP server replies with its MAC address. + +---- +12:55:28.834875 dc:a6:32:6f:73:f4 (oui Unknown) > e4:5f:01:20:24:0b (oui Unknown), ethertype IPv6 (0x86dd), length 86: (hlim 255, next-header ICMPv6 (58) payload length: 32) 2a00:23c5:ee00:5001:57f1:7523:2f1d:fe2a > fe80::e65f:1ff:fe20:240b: [icmp6 sum ok] ICMP6, neighbor advertisement, length 32, tgt is 2a00:23c5:ee00:5001:57f1:7523:2f1d:fe2a, Flags [solicited, override] + destination link-address option (2), length 8 (1): dc:a6:32:6f:73:f4 + 0x0000: dca6 326f 73f4 +---- + +The device starts making TFTP requests. + +---- +12:55:28.861097 e4:5f:01:20:24:0b (oui Unknown) > dc:a6:32:6f:73:f4 (oui Unknown), ethertype IPv6 (0x86dd), length 111: (hlim 255, next-header UDP (17) payload length: 57) 2a00:23c5:ee00:5001:e65f:1ff:fe20:240b.46930 > 2a00:23c5:ee00:5001:57f1:7523:2f1d:fe2a.tftp: [udp sum ok] 49 RRQ "ab5a4158/start4.elf" octet tsize 0 blksize 1024 +---- diff --git a/documentation/asciidoc/computers/remote-access/network-boot-raspberry-pi.adoc b/documentation/asciidoc/computers/remote-access/network-boot-raspberry-pi.adoc index b7c5a5fe62..75db65a00b 100644 --- a/documentation/asciidoc/computers/remote-access/network-boot-raspberry-pi.adoc +++ b/documentation/asciidoc/computers/remote-access/network-boot-raspberry-pi.adoc @@ -6,114 +6,120 @@ The instructions assume that you have an existing home network, and that you wan NOTE: Due to the huge range of networking devices and routers available, we can't guarantee that network booting will work with any device. We have had reports that, if you cannot get network booting to work, disabling STP frames on your network may help. -=== Client Configuration +=== Configure a network boot client -==== Raspberry Pi 3, Model B +==== Raspberry Pi 3 Model B -NOTE: This section only applies to the Raspberry Pi 3, Model B as network boot is enabled on the Raspberry Pi 3, Model B+ at the factory. +NOTE: This section only applies to the Raspberry Pi 3 Model B, as network boot is enabled on the Raspberry Pi 3 Model B+ at the factory. -Before the Raspberry Pi 3, Model B will network boot it needs to be booted from an SD Card with a config option to enable USB boot mode. This will set a bit in the OTP (One Time Programmable) memory in the Raspberry Pi SoC that enables network booting. Once this is done, the Pi 3B will attempt to boot from USB, and from the network, if it cannot boot from the SD card. +Before the Raspberry Pi 3 Model B will network boot it needs to be booted from an SD Card with a config option to enable USB boot mode. This will set a bit in the OTP (One Time Programmable) memory in the Raspberry Pi SoC that enables network booting. Once this is done, the Raspberry Pi 3B will attempt to boot from USB, and from the network, if it cannot boot from the SD card. -Install Raspberry Pi OS Lite, or Raspberry Pi OS with Raspberry Pi Desktop, on the SD card in the usual fashion. Next, enable USB boot mode with the following command: +Install Raspberry Pi OS Lite, or Raspberry Pi OS with desktop, on the SD card in the usual fashion. Next, enable USB boot mode with the following command: -[,bash] +[source,console] ---- -echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt +$ echo program_usb_boot_mode=1 | sudo tee -a /boot/firmware/config.txt ---- -This adds `program_usb_boot_mode=1` to the end of `/boot/config.txt`. Reboot the Raspberry Pi with `sudo reboot`. Once the client Raspberry Pi has rebooted, check that the OTP has been programmed with: +This adds `program_usb_boot_mode=1` to the end of xref:config_txt.adoc#what-is-config-txt[`/boot/firmware/config.txt`]. Reboot the Raspberry Pi with `sudo reboot`. Once the client Raspberry Pi has rebooted, check that the OTP has been programmed with: -[,bash] +[source,console] ---- -vcgencmd otp_dump | grep 17: +$ vcgencmd otp_dump | grep 17: 17:3020000a ---- Ensure the output `0x3020000a` is correct. -The client configuration is almost done. The final thing to do is to remove the `program_usb_boot_mode` line from `config.txt`. You can do this with `sudo nano /boot/config.txt`, for example. Finally, shut the client Raspberry Pi down with `sudo poweroff`. +The client configuration is almost done. As a final step, disable USB booting. Run the following command: -==== Raspberry Pi 4, Model B +[source,console] +---- +$ sudo nano /boot/firmware/config.txt +---- + +Remove the line that contains the text `program_usb_boot_mode=1`. Finally, shut the client Raspberry Pi down with `sudo poweroff`. -Network boot can be enabled on the Pi 4 using the `raspi-config` tool. First, run `raspi-config` as follows: +==== Raspberry Pi 4 Model B -[,bash] +Network boot can be enabled on the Raspberry Pi 4 using the `raspi-config` tool. First, run `raspi-config` as follows: + +[source,console] ---- -sudo raspi-config +$ sudo raspi-config ---- -Within `raspi-config`, choose `Advanced Options`, then `Boot Order`, then `Network Boot`. You must then reboot the device for the change to the boot order to be programmed into the bootloader EEPROM. Once the Pi has rebooted, check that the boot order is now `0xf21`: +Within `raspi-config`, choose `Advanced Options`, then `Boot Order`, then `Network Boot`. You must then reboot the device for the change to the boot order to be programmed into the bootloader EEPROM. Once the Raspberry Pi has rebooted, check that the boot order is now `0xf21`: -[,bash] +[source,console] ---- -vcgencmd bootloader_config +$ vcgencmd bootloader_config ---- -For further details of configuring the Pi 4 bootloader, see xref:raspberry-pi.adoc#raspberry-pi-4-bootloader-configuration[Pi 4 Bootloader Configuration]. +For further details of configuring the Raspberry Pi 4 bootloader, see xref:raspberry-pi.adoc#raspberry-pi-bootloader-configuration[Raspberry Pi Bootloader Configuration]. === Ethernet MAC address Before configuring network boot, make a note of the serial number and mac address so that the board can be identified by the TFTP/DHCP server. -On Raspberry Pi 4 the MAC address is programmed at manufacture and there is no link between the MAC address and serial number. Both the MAC address and serial numbers are displayed on the bootloader xref:raspberry-pi.adoc#boot-diagnostics-on-the-raspberry-pi-4[HDMI diagnostics] screen. +On Raspberry Pi 4 and later flagship models, the MAC address is programmed at manufacture and there is no link between the MAC address and serial number. Both the MAC address and serial numbers are displayed on the bootloader xref:raspberry-pi.adoc#boot-diagnostics[HDMI diagnostics] screen. -To find the Ethernet MAC address: +To find the Ethernet MAC address, run the following command: -[,bash] +[source,console] ---- -ethtool -P eth0 +$ ethtool -P eth0 ---- -To find the serial number: +To find the serial number, run the following command: -[,bash] +[source,console] ---- -grep Serial /proc/cpuinfo | cut -d ' ' -f 2 | cut -c 8-16 +$ grep Serial /proc/cpuinfo | cut -d ' ' -f 2 | cut -c 9-16 ---- -=== Server Configuration +=== Configure a network boot server Plug the SD card into the server Raspberry Pi, and then boot the server. The client Raspberry Pi will need a root file system to boot from: we will use a copy of the server's root filesystem and place it in `/nfs/client1`: -[,bash] +[source,console] ---- -sudo mkdir -p /nfs/client1 -sudo apt install rsync -sudo rsync -xa --progress --exclude /nfs / /nfs/client1 +$ sudo mkdir -p /nfs/client1 +$ sudo apt install rsync +$ sudo rsync -xa --progress --exclude /nfs / /nfs/client1 ---- Regenerate SSH host keys on the client filesystem by chrooting into it: -[,bash] +[source,console] ---- -cd /nfs/client1 -sudo mount --bind /dev dev -sudo mount --bind /sys sys -sudo mount --bind /proc proc -sudo chroot . -rm /etc/ssh/ssh_host_* -dpkg-reconfigure openssh-server -exit -sudo umount dev sys proc +$ cd /nfs/client1 +$ sudo mount --bind /dev dev +$ sudo mount --bind /sys sys +$ sudo mount --bind /proc proc +$ sudo chroot . +$ rm /etc/ssh/ssh_host_* +$ dpkg-reconfigure openssh-server +$ exit +$ sudo umount dev sys proc ---- Find the settings of your local network. You need to find the address of your router (or gateway), which can be done with: -[,bash] +[source,console] ---- -ip route | awk '/default/ {print $3}' +$ ip route | awk '/default/ {print $3}' ---- Then run: -[,bash] +[source,console] ---- -ip -4 addr show dev eth0 | grep inet +$ ip -4 addr show dev eth0 | grep inet ---- -which should give an output like: +You should see output similar to the following: -[,bash] ---- inet 10.42.0.211/24 brd 10.42.0.255 scope global eth0 ---- @@ -122,18 +128,18 @@ The first address is the IP address of your server Raspberry Pi on the network, Finally, note down the address of your DNS server, which is the same address as your gateway. You can find this with: -[,bash] +[source,console] ---- -cat /etc/resolv.conf +$ cat /etc/resolv.conf ---- Configure a static network address on your server Raspberry Pi via the `systemd` networking, which works as the network handler and DHCP server. -To do that, you'll need to to create a `10-eth0.netdev` and a `11-eth0.network` like so: +To do that, you'll need to create a `10-eth0.netdev` and a `11-eth0.network` like so: -[,bash] +[source,console] ---- -sudo nano /etc/systemd/network/10-eth0.netdev +$ sudo nano /etc/systemd/network/10-eth0.netdev ---- Add the following lines: @@ -148,9 +154,9 @@ DHCP=no Then create a network file: -[,bash] +[source,console] ---- -sudo nano /etc/systemd/network/11-eth0.network +$ sudo nano /etc/systemd/network/11-eth0.network ---- Add the following contents: @@ -169,14 +175,13 @@ Gateway=10.42.0.1 At this point, you will not have working DNS, so you will need to add the server you noted down before to `systemd/resolved.conf`. In this example, the gateway address is 10.42.0.1. -[,bash] +[source,console] ---- -sudo nano /etc/systemd/resolved.conf +$ sudo nano /etc/systemd/resolved.conf ---- Uncomment the DNS line and add the DNS IP address there. Additionally, if you have a fallback DNS server, add it there as well. -[,bash] ---- [Resolve] DNS=10.42.0.1 @@ -185,19 +190,19 @@ DNS=10.42.0.1 Enable `systemd-networkd` and then reboot for the changes to take effect: -[,bash] +[source,console] ---- -sudo systemctl enable systemd-networkd -sudo reboot +$ sudo systemctl enable systemd-networkd +$ sudo reboot ---- Now start `tcpdump` so you can search for DHCP packets from the client Raspberry Pi: -[,bash] +[source,console] ---- -sudo apt install tcpdump dnsmasq -sudo systemctl enable dnsmasq -sudo tcpdump -i eth0 port bootpc +$ sudo apt install tcpdump dnsmasq +$ sudo systemctl enable dnsmasq +$ sudo tcpdump -i eth0 port bootpc ---- Connect the client Raspberry Pi to your network and power it on. Check that the LEDs illuminate on the client after around 10 seconds, then you should get a packet from the client "DHCP/BOOTP, Request from ..." @@ -208,10 +213,10 @@ IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from b8:27:eb... Now you need to modify the `dnsmasq` configuration to enable DHCP to reply to the device. Press ++++++CTRL + C++++++ to exit the `tcpdump` program, then type the following: -[,bash] +[source,console] ---- -echo | sudo tee /etc/dnsmasq.conf -sudo nano /etc/dnsmasq.conf +$ echo | sudo tee /etc/dnsmasq.conf +$ sudo nano /etc/dnsmasq.conf ---- Then replace the contents of `dnsmasq.conf` with: @@ -230,19 +235,19 @@ Where the first address of the `dhcp-range` line is, use the broadcast address y Now create a `/tftpboot` directory: -[,bash] +[source,console] ---- -sudo mkdir /tftpboot -sudo chmod 777 /tftpboot -sudo systemctl enable dnsmasq.service -sudo systemctl restart dnsmasq.service +$ sudo mkdir /tftpboot +$ sudo chmod 777 /tftpboot +$ sudo systemctl enable dnsmasq.service +$ sudo systemctl restart dnsmasq.service ---- Now monitor the `dnsmasq` log: -[,bash] +[source,console] ---- -tail -F /var/log/daemon.log +$ journalctl -f ---- You should see something like this: @@ -253,18 +258,18 @@ raspberrypi dnsmasq-tftp[1903]: file /tftpboot/bootcode.bin not found Next, you will need to copy the contents of the boot folder into the `/tftpboot` directory. -First, press ++++++CTRL + C++++++ to exit the monitoring state. Then type the following: +First, press *CTRL + C* to exit the monitoring state. Then type the following: -[,bash] +[source,console] ---- -cp -r /boot/* /tftpboot +$ cp -r /boot/firmware/* /tftpboot ---- Since the tftp location has changed, restart `dnsmasq`: -[,bash] +[source,console] ---- -sudo systemctl restart dnsmasq +$ sudo systemctl restart dnsmasq ---- ==== Set up NFS root @@ -273,65 +278,36 @@ This should now allow your Raspberry Pi client to attempt to boot through until At this point, export the `/nfs/client1` file system created earlier, and the TFTP boot folder. -[,bash] +[source,console] ---- -sudo apt install nfs-kernel-server -echo "/nfs/client1 *(rw,sync,no_subtree_check,no_root_squash)" | sudo tee -a /etc/exports -echo "/tftpboot *(rw,sync,no_subtree_check,no_root_squash)" | sudo tee -a /etc/exports +$ sudo apt install nfs-kernel-server +$ echo "/nfs/client1 *(rw,sync,no_subtree_check,no_root_squash)" | sudo tee -a /etc/exports +$ echo "/tftpboot *(rw,sync,no_subtree_check,no_root_squash)" | sudo tee -a /etc/exports ---- Restart RPC-Bind and the NFS server in order to have them detect the new files. -[,bash] +[source,console] ---- -sudo systemctl enable rpcbind -sudo systemctl restart rpcbind -sudo systemctl enable nfs-kernel-server -sudo systemctl restart nfs-kernel-server +$ sudo systemctl enable rpcbind +$ sudo systemctl restart rpcbind +$ sudo systemctl enable nfs-kernel-server +$ sudo systemctl restart nfs-kernel-server ---- Edit `/tftpboot/cmdline.txt` and from `root=` onwards, and replace it with: ---- -root=/dev/nfs nfsroot=10.42.0.211:/nfs/client1,vers=4.1,proto=tcp rw ip=dhcp rootwait elevator=deadline +root=/dev/nfs nfsroot=10.42.0.211:/nfs/client1,vers=3 rw ip=dhcp rootwait ---- -You should substitute the IP address here with the IP address you have noted down. Also remove any part of the command line starting with init=. +You should substitute the IP address here with the IP address you have noted down. Also remove any part of the command line starting with `init=`. Finally, edit `/nfs/client1/etc/fstab` and remove the `/dev/mmcblk0p1` and `p2` lines (only `proc` should be left). Then, add the boot partition back in: -[,bash] ----- -echo "10.42.0.211:/tftpboot /boot nfs defaults,vers=4.1,proto=tcp 0 0" | sudo tee -a /nfs/client1/etc/fstab ----- - -Good luck! If it doesn't boot on the first attempt, keep trying. It can take a minute or so for the Raspberry Pi to boot, so be patient. - -=== Using `pxetools` - -We have created a Python script that is used internally to quickly set up Raspberry Pi's that will network boot. - -The script takes a serial number, which you can find in `cat /proc/cpuinfo`, an owner name and the name of the Raspberry Pi. It then creates a root filesystem for that Pi from a Raspberry Pi OS image. There is also a `--list` option which will print out the IP address of the Pi, and a `--remove` option. - -NOTE: The following instructions describe how to set up the environment required by the script starting from a fresh Raspberry Pi OS lite image. It might be a good idea to mount a hard disk or flash drive on `/nfs` so that your SD card isn't providing filesystems to multiple Pi's. This is left as an exercise for the reader. - ----- -sudo apt update -sudo apt full-upgrade -y -sudo reboot - -wget https://datasheets.raspberrypi.org/soft/prepare_pxetools.sh -bash prepare_pxetools ----- - -When prompted about saving `iptables` rules, say `no`. - -The `prepare_pxetools` script should prepare everything you need to use `pxetools`. - -We found that we needed to restart the `nfs` server after using `pxetools` for the first time. Do this with: - +[source,console] ---- -sudo systemctl restart nfs-kernel-server +$ echo "10.42.0.211:/tftpboot /boot/firmware/ nfs defaults,vers=3 0 0" | sudo tee -a /nfs/client1/etc/fstab ---- -Then plug in your Raspberry Pi and it should boot! \ No newline at end of file +If it doesn't boot on the first attempt, keep trying. It can take a minute or so for the Raspberry Pi to boot, so be patient. diff --git a/documentation/asciidoc/computers/remote-access/nfs.adoc b/documentation/asciidoc/computers/remote-access/nfs.adoc index 4692b576ad..5db9c843c6 100644 --- a/documentation/asciidoc/computers/remote-access/nfs.adoc +++ b/documentation/asciidoc/computers/remote-access/nfs.adoc @@ -1,39 +1,49 @@ +[[nfs]] == Network File System (NFS) Network File System (NFS) allows you to share a directory located on one networked computer with other computers or devices on the same network. The computer where the directory is located is called the *server*, and computers or devices connecting to that server are called clients. Clients usually `mount` the shared directory to make it a part of their own directory structure. The shared directory is an example of a shared resource or network share. -For smaller networks, an NFS is perfect for creating a simple NAS (Network-attached storage) in a Linux/Unix environment. +NFS is a popular way to create a simple NAS (Network-attached storage) in a Linux/Unix environment. -An NFS is perhaps best suited to more permanent network-mounted directories, such as `/home` directories or regularly-accessed shared resources. If you want a network share that guest users can easily connect to, Samba is better suited to the task. This is because tools to temporarily mount and detach from Samba shares are more readily available across old and proprietary operating systems. +An NFS is perhaps best suited to more permanent network-mounted directories, such as `/home` directories or regularly-accessed shared resources. If you want a network share that guest users can easily connect to, Samba is better suited to the task. Tools to temporarily mount and detach from Samba shares are more readily available across operating systems. Before deploying an NFS, you should be familiar with: * Linux file and directory permissions * mounting and unmounting filesystems -=== Setting up a Basic NFS Server +=== Set up a basic NFS server Install the packages required using the command below: -[,bash] +[source,console] ---- -sudo apt install nfs-kernel-server +$ sudo apt install nfs-kernel-server ---- For easier maintenance, we will isolate all NFS exports in single directory, into which the real directories will be mounted with the `--bind` option. Suppose we want to export our users' home directories, which are in `/home/users`. First we create the export filesystem: -[,bash] +[source,console] ---- -sudo mkdir -p /export/users +$ sudo mkdir -p /export/users ---- -Note that `/export` and `/export/users` will need 777 permissions, as we will be accessing the NFS share from the client without LDAP/NIS authentication. This will not apply if using authentication (see below). Now mount the real `users` directory with: +TIP: If you plan to configure LDAP/NIS authentication, skip the `chmod` step below. -[,bash] +Grant `/export` and `/export/users` read, write, and execute permissions (`777`) so you can access the NFS share from the client without LDAP/NIS authentication: + +[source,console] +---- +$ chmod -R 777 /export +---- + +Next, mount the real `users` directory with: + +[source,console] ---- -sudo mount --bind /home/users /export/users +$ sudo mount --bind /home/users /export/users ---- To save us from retyping this after every reboot, we add the following line to `/etc/fstab`: @@ -61,10 +71,10 @@ Nobody-Group = nogroup However, note that the client may have different requirements for the Nobody-User and Nobody-Group. For example, on RedHat variants, it is `nfsnobody` for both. If you're not sure, check via the following commands to see if `nobody` and `nogroup` are there: -[,bash] +[source,console] ---- -cat /etc/passwd -cat /etc/group +$ cat /etc/passwd +$ cat /etc/group ---- This way, server and client do not need the users to share same UID/GUID. For those who use LDAP-based authentication, add the following lines to the `idmapd.conf` of your clients: @@ -77,7 +87,7 @@ Method = nsswitch This will cause `idmapd` to know to look at `nsswitch.conf` to determine where it should look for credential information. If you have LDAP authentication already working, `nsswitch` shouldn't require further explanation. -To export our directories to a local network `192.168.1.0/24`, we add the following two lines to `/etc/exports`: +To export our directories to a local network `192.168.1.0/24`, add the following two lines to `/etc/exports`: ---- /export 192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async) @@ -108,25 +118,25 @@ Please ensure that the list of authorised IP addresses includes the `localhost` Finally, to make your changes take effect, restart the service: -[,bash] +[source,console] ---- -sudo systemctl restart nfs-kernel-server +$ sudo systemctl restart nfs-kernel-server ---- -=== Configuring an NFS Client +=== Configure an NFS client Now that your server is running, you need to set up any clients to be able to access it. To start, install the required packages: -[,bash] +[source,console] ---- -sudo apt install nfs-common +$ sudo apt install nfs-common ---- On the client, we can mount the complete export tree with one command: -[,bash] +[source,console] ---- -mount -t nfs -o proto=tcp,port=2049 :/ /mnt +$ mount -t nfs -o proto=tcp,port=2049 :/ /mnt ---- You can also specify the NFS server hostname instead of its IP address, but in this case you need to ensure that the hostname can be resolved to an IP on the client side. A robust way of ensuring that this will always resolve is to use the `/etc/hosts` file. @@ -135,9 +145,9 @@ Note that `:/export` is not necessary in NFSv4, as it was in NFSv We can also mount an exported subtree with: -[,bash] +[source,console] ---- -mount -t nfs -o proto=tcp,port=2049 :/users /home/users +$ mount -t nfs -o proto=tcp,port=2049 :/users /home/users ---- To ensure this is mounted on every reboot, add the following line to `/etc/fstab`: @@ -166,7 +176,7 @@ rpcbind : where `` is the IP address of the server. -=== A More Complex NFS Server +=== Configure a complex NFS server NFS user permissions are based on user ID (UID). UIDs of any users on the client must match those on the server in order for the users to have access. The typical ways of doing this are: @@ -199,9 +209,9 @@ where `myclients` is the netgroup name. Next run this command to rebuild the NIS database: -[,bash] +[source,console] ---- -sudo make -C /var/yp +$ sudo make -C /var/yp ---- The filename `yp` refers to Yellow Pages, the former name of NIS. @@ -228,9 +238,9 @@ where `` is a list of the IP addresses of the server and all client Install the necessary packages: -[,bash] +[source,console] ---- -sudo apt install rpcbind nfs-kernel-server +$ sudo apt install rpcbind nfs-kernel-server ---- Edit `/etc/exports` and add the shares: @@ -258,23 +268,21 @@ Here, `rw` makes the share read/write, and `sync` requires the server to only re After setting up `/etc/exports`, export the shares: -[,bash] +[source,console] ---- -sudo exportfs -ra +$ sudo exportfs -ra ---- You'll want to run this command whenever `/etc/exports` is modified. ==== Restart services -By default, `rpcbind` only binds to the loopback interface. To enable access to `rpcbind` from remote machines, you need to change `/etc/conf.d/rpcbind` to get rid of either `-l` or `-i 127.0.0.1`. - -If any changes are made, rpcbind and NFS will need to be restarted: +Restart `rpcbind` and NFS for the changes to take effect: -[,bash] +[source,console] ---- -sudo systemctl restart rpcbind -sudo systemctl restart nfs-kernel-server +$ sudo systemctl restart rpcbind +$ sudo systemctl restart nfs-kernel-server ---- ==== Security items to consider @@ -291,10 +299,10 @@ Mounting an NFS share inside an encrypted home directory will only work after yo . Create an alternative directory to mount the NFS shares in: -[,bash] +[source,console] ---- -sudo mkdir /nfs -sudo mkdir /nfs/music +$ sudo mkdir /nfs +$ sudo mkdir /nfs/music ---- . Edit `/etc/fstab` to mount the NFS share into that directory instead: @@ -305,8 +313,8 @@ nfsServer:music /nfs/music nfs auto 0 0 . Create a symbolic link inside your home, pointing to the actual mount location. For example, and in this case deleting the `Music` directory already existing there first: -[,bash] +[source,console] ---- -rmdir /home/user/Music -ln -s /nfs/music/ /home/user/Music +$ rmdir /home/user/Music +$ ln -s /nfs/music/ /home/user/Music ---- diff --git a/documentation/asciidoc/computers/remote-access/pxetools.adoc b/documentation/asciidoc/computers/remote-access/pxetools.adoc deleted file mode 100644 index 66553b5984..0000000000 --- a/documentation/asciidoc/computers/remote-access/pxetools.adoc +++ /dev/null @@ -1,24 +0,0 @@ -== Using `pxetools` - -We have created a Python script that is used internally to quickly set up Pi's that will network boot. It takes a serial number, which you can find in `cat /proc/cpuinfo`, an owner name and the name of the Pi. It then creates a root filesystem for that Pi from a Raspberry Pi OS image. There is also a --list option which will print out the IP address of the Pi, and a --remove option. The following instructions describe how to set up the environment required by the script starting from a fresh Raspberry Pi OS lite image. It might be a good idea to mount a hard disk or flash drive on /nfs so that your SD card isn't providing filesystems to multiple Pi's. This is left as an exercise for the reader. - ----- -sudo apt update -sudo apt full-upgrade -y -sudo reboot - -wget https://datasheets.raspberrypi.org/soft/prepare_pxetools.sh -bash prepare_pxetools ----- - -When prompted about saving iptables rules, say no. - -prepare_pxetools should prepare everything you need to use pxetools. - -We found that we needed to restart the nfs server after using pxetools for the first time. Do this with: - ----- -sudo systemctl restart nfs-kernel-server ----- - -Then plug in your Pi and it should boot! diff --git a/documentation/asciidoc/computers/remote-access/raspberry-pi-connect.adoc b/documentation/asciidoc/computers/remote-access/raspberry-pi-connect.adoc new file mode 100644 index 0000000000..cf720a74de --- /dev/null +++ b/documentation/asciidoc/computers/remote-access/raspberry-pi-connect.adoc @@ -0,0 +1,8 @@ +[[raspberry-pi-connect]] +== Remote access with Raspberry Pi Connect + +You can access a Raspberry Pi remotely from a browser on another device using Raspberry Pi Connect. Connect handles configuration automatically, so you don't have to find your Raspberry Pi's local IP address, your network's public IP address, or modify your local network firewall to enable external access. + +Connect includes the ability to screen share on Raspberry Pi models running the Wayland window server and remote shell (terminal) access on all Raspberry Pi models. + +For more information, see xref:../services/connect.adoc[the Connect documentation]. diff --git a/documentation/asciidoc/computers/remote-access/remote-access-introduction.adoc b/documentation/asciidoc/computers/remote-access/remote-access-introduction.adoc deleted file mode 100644 index 7bd376b79b..0000000000 --- a/documentation/asciidoc/computers/remote-access/remote-access-introduction.adoc +++ /dev/null @@ -1,149 +0,0 @@ -== Remote Access - -Sometimes you need to access a Raspberry Pi without connecting it to a monitor. Perhaps the Pi is embedded in something like a robot, or you may want to view some information from it from elsewhere. Ore perhaps you simply don't have a spare monitor! - -You can connect to your Raspberry Pi from another machine. But in order to do so you'll need to know it's IP Address. - -Any device connected to a Local Area Network is assigned an IP address. In order to connect to your Raspberry Pi from another machine using xref:remote-access.adoc#ssh[SSH] or xref:remote-access.adoc#vnc[VNC], you need to know the Pi's IP address. This is easy if you have a display connected, and there are a number of methods for finding it remotely from another machine on the network. - -[[ip-address]] -=== How to Find your IP Address - -It is possible to find the IP address of your Pi without connecting to a screen using one of the following methods: - -NOTE: If you are using a display with your Raspberry Pi and if you boot to the command line instead of the desktop, your IP address should be shown in the last few messages before the login prompt. Otherwise open a Terminal window and type `hostname -I` which will reveal your Raspberry Pi's IP address. - -==== Router devices list - -In a web browser navigate to your router's IP address e.g. `+http://192.168.1.1+`, which is usually printed on a label on your router; this will take you to a control panel. Then log in using your credentials, which is usually also printed on the router or sent to you in the accompanying paperwork. Browse to the list of connected devices or similar (all routers are different), and you should see some devices you recognise. Some devices are detected as PCs, tablets, phones, printers, etc. so you should recognise some and rule them out to figure out which is your Raspberry Pi. Also note the connection type; if your Pi is connected with a wire there should be fewer devices to choose from. - -==== Resolving `raspberrypi.local` with mDNS - -On Raspberry Pi OS, multicast DNS is supported out-of-the-box by the Avahi service. - -If your device supports mDNS, you can reach your Raspberry Pi by using its hostname and the `.local` suffix. -The default hostname on a fresh Raspberry Pi OS install is `raspberrypi`, so by default any Raspberry Pi running Raspberry Pi OS responds to: - -[,bash] ----- -ping raspberrypi.local ----- - -If the Raspberry Pi is reachable, `ping` will show its IP address: - ----- -PING raspberrypi.local (192.168.1.131): 56 data bytes -64 bytes from 192.168.1.131: icmp_seq=0 ttl=255 time=2.618 ms ----- - -If you change the system hostname of the Raspberry Pi (e.g., by editing `/etc/hostname`), Avahi will also change the `.local` mDNS address. - -If you don't remember the hostname of the Raspberry Pi, but have a system with Avahi installed, you can browse all the hosts and services on the LAN with the https://linux.die.net/man/1/avahi-browse[`avahi-browse`] command. - -==== nmap command - -The `nmap` command (Network Mapper) is a free and open-source tool for network discovery, available for Linux, macOS, and Windows. - -* To install on *Linux*, install the `nmap` package e.g. `apt install nmap`. -* To install on *macOS* or *Windows*, see the http://nmap.org/download.html[nmap.org download page]. - -To use `nmap` to scan the devices on your network, you need to know the subnet you are connected to. First find your own IP address, in other words the one of the computer you're using to find your Pi's IP address: - -* On *Linux*, type `hostname -I` into a terminal window -* On *macOS*, go to `System Preferences` then `Network` and select your active network connection to view the IP address -* On *Windows*, go to the Control Panel, then under `Network and Sharing Center`, click `View network connections`, select your active network connection and click `View status of this connection` to view the IP address - -Now you have the IP address of your computer, you will scan the whole subnet for other devices. For example, if your IP address is `192.168.1.5`, other devices will be at addresses like `192.168.1.2`, `192.168.1.3`, `192.168.1.4`, etc. The notation of this subnet range is `192.168.1.0/24` (this covers `192.168.1.0` to `192.168.1.255`). - -Now use the `nmap` command with the `-sn` flag (ping scan) on the whole subnet range. This may take a few seconds: - -[,bash] ----- -nmap -sn 192.168.1.0/24 ----- - -Ping scan just pings all the IP addresses to see if they respond. For each device that responds to the ping, the output shows the hostname and IP address like so: - ----- -Starting Nmap 6.40 ( http://nmap.org ) at 2014-03-10 12:46 GMT -Nmap scan report for hpprinter (192.168.1.2) -Host is up (0.00044s latency). -Nmap scan report for Gordons-MBP (192.168.1.4) -Host is up (0.0010s latency). -Nmap scan report for ubuntu (192.168.1.5) -Host is up (0.0010s latency). -Nmap scan report for raspberrypi (192.168.1.8) -Host is up (0.0030s latency). -Nmap done: 256 IP addresses (4 hosts up) scanned in 2.41 seconds ----- - -Here you can see a device with hostname `raspberrypi` has IP address `192.168.1.8`. Note, to see the hostnames, you must run nmap as root by prepending `sudo` to the command. - -==== Getting IPv6 addresses by pinging from a second device - -First find your own IP address(es), in other words the one of the computer you're using to find your Pi's IP address -by `hostname -I` - -`fd00::ba27:ebff:feb6:f293 2001:db8:494:9d01:ba27:ebff:feb6:f293` - -The example shows two IP addresses. The first one is a so called unique local unicast address(`fc00::/7`). The second one is the global unicast address(`2000::/3`). It is also possible to see only one them depending on your network (router) configuration. Both addresses are valid for reaching the Raspberry Pi within your LAN. The address out of `2000::/3` is accessible world wide, provided your router's firewall is opened. - -Now use one of IPs from the first step to ping all local nodes: - ----- -ping -c 2 -I 2001:db8:494:9d01:ba27:ebff:feb6:f293 ff02::1 -ping -c 2 -I 2001:db8:494:9d01:ba27:ebff:feb6:f293 ff02::1%eth0 ----- - -`-c 2` stands for sending two echo requests - -`-I` with the IP address, it sets the interface and the source address of the echo request, - it is necessary to choose the interface's IP address, - `eth0` isn't sufficient - the answer would be the local link address(`fe80::/10`), we need the global or local unicast address - -`ff02::1` is a well known multicast address for all nodes on the link, so it behaves like a local broadcast, usually it is defined in `/etc/hosts` so you can also use the name (`ip6-allnodes` or `ipv6-allnodes`) instead of the literal address - -Some newer systems expect the interface ID behind the multicast address. - ----- -ping -c 2 -I 2001:db8:494:9d01:ba27:ebff:feb6:f293 ip6-allnodes -PING ip6-allnodes(ip6-allnodes (ff02::1)) from 2001:db8:494:9d01:ba27:ebff:feb6:f293 : 56 data bytes -64 bytes from 2001:db8:494:9d01:ba27:ebff:feb6:f293: icmp_seq=1 ttl=64 time=0.597 ms -64 bytes from witz.fritz.box (2001:db8:494:9d01:728b:cdff:fe7d:a2e): icmp_seq=1 ttl=255 time=1.05 ms (DUP!) -64 bytes from raspberrypi4.fritz.box (2001:db8:494:9d01:dea6:32ff:fe23:6be1): icmp_seq=1 ttl=64 time=1.05 ms (DUP!) -64 bytes from 2001:db8:494:9d01:da37:beff:fefd:f09d (2001:db8:494:9d01:da37:beff:fefd:f09d): icmp_seq=1 ttl=255 time=1.05 ms (DUP!) -64 bytes from fusion.fritz.box (2001:db8:494:9d01:1e6f:65ff:fec9:8746): icmp_seq=1 ttl=255 time=2.12 ms (DUP!) -64 bytes from fritz.box (2001:db8:494:9d01:464e:6dff:fe72:8a08): icmp_seq=1 ttl=64 time=2.62 ms (DUP!) -64 bytes from raspberrypi.fritz.box (2001:db8:494:9d01:ba27:ebff:feb6:f293): icmp_seq=2 ttl=64 time=0.480 ms - ---- ip6-allnodes ping statistics --- -2 packets transmitted, 2 received, +5 duplicates, 0% packet loss, time 1001ms -rtt min/avg/max/mdev = 0.480/1.283/2.623/0.735 ms ----- - -This should result in replies from all the nodes on your (W)LAN link, with associated DNS names. - -Exclude your own IP( here `2001:db8:494:9d01:ba27:ebff:feb6:f293` ), -then check the others by trying to connect them via SSH. - ----- -ssh pi@2001:db8:494:9d01:dea6:32ff:fe23:6be1 -The authenticity of host '2001:db8:494:9d01:dea6:32ff:fe23:6be1 (2001:db8:494:9d01:dea6:32ff:fe23:6be1)' can't be established. -ECDSA key fingerprint is SHA256:DAW68oen42TdWDyrOycDZ1+y5ZV5D81kaVoi5FnpvoM. -Are you sure you want to continue connecting (yes/no)? yes -Warning: Permanently added '2001:db8:494:9d01:dea6:32ff:fe23:6be1' (ECDSA) to the list of known hosts. -pi@2001:db8:494:9d01:dea6:32ff:fe23:6be1's password: -Linux raspberrypi4 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l - -... - -pi@raspberrypi4:~ $ ----- - -==== Getting the IP address of a Pi using your smartphone - -The Fing app is a free network scanner for smartphones. It is available for https://play.google.com/store/apps/details?id=com.overlook.android.fing[Android] and https://itunes.apple.com/gb/app/fing-network-scanner/id430921107?mt=8[iOS]. - -Your phone and your Raspberry Pi have to be on the same network, so connect your phone to the correct wireless network. - -When you open the Fing app, touch the refresh button in the upper right-hand corner of the screen. After a few seconds you will get a list with all the devices connected to your network. Scroll down to the entry with the manufacturer "Raspberry Pi". You will see the IP address in the bottom left-hand corner, and the MAC address in the bottom right-hand corner of the entry. diff --git a/documentation/asciidoc/computers/remote-access/rsync.adoc b/documentation/asciidoc/computers/remote-access/rsync.adoc index f1fdcd23c9..d7330cecb2 100644 --- a/documentation/asciidoc/computers/remote-access/rsync.adoc +++ b/documentation/asciidoc/computers/remote-access/rsync.adoc @@ -1,23 +1,28 @@ -== Using `rsync` +[[rsync]] +== Synchronise folders between computers with `rsync` -You can use the tool `rsync` to synchronise folders between computers. You might want to transfer some files from your desktop computer or laptop to your Pi, for example, and for them to be kept up to date, or you might want the pictures taken by your Pi transferred to your computer automatically. +You can use `rsync` to synchronise folders between computers. For example, you could use `rsync` to transfer new pictures taken by your Raspberry Pi to your personal computer automatically. -Using `rsync` over SSH allows you to transfer files to your computer automatically. +Before you can configure `rsync`, determine values for the following: -Here is an example of how to set up the sync of a folder of pictures on your Pi to your computer: +* ``: your Raspberry Pi's local IP address: see xref:remote-access.adoc#ip-address[Find your Raspberry Pi's IP address] for more information +* ``: the username you use to log into your Raspberry Pi +* ``: the name of the folder you want to copy files from on your Raspberry Pi +* ``: the name of the folder you would like to synchronise on your personal computer -On your computer, create a folder called `camera`: +To configure `rsync` to synchronise files, complete the following steps on your personal computer, replacing placeholders in the commands with the values you determined above: +. Create the folder you would like to synchronise to: ++ +[source,console] ---- -mkdir camera +$ mkdir ---- - -Look up the Raspberry Pi's IP address by logging in to it and running `hostname -I`. In this example, the Pi is creating a timelapse by capturing a photo every minute, and saving the picture with a timestamp in the local folder `camera` on its SD card. - -Now run the following command (substituting your own Pi's IP address): - +. Synchronise files to the folder with `rsync`: ++ +[source,console] ---- -rsync -avz -e ssh pi@192.168.1.10:camera/ camera/ +$ rsync -avz -e ssh @:/ / ---- -This will copy all files from the Pi's `camera` folder to your computer's new `camera` folder. +This command copies all files from the selected folder on your Raspberry Pi to the selected folder on your personal computer. If you run the command multiple times, `rsync` keeps track of the files you have already downloaded and skips them. If you delete or modify an already synchronised file on the Raspberry Pi, `rsync` updates the files on your personal computer accordingly. diff --git a/documentation/asciidoc/computers/remote-access/samba.adoc b/documentation/asciidoc/computers/remote-access/samba.adoc index fb6d9cd33b..8735264cb5 100644 --- a/documentation/asciidoc/computers/remote-access/samba.adoc +++ b/documentation/asciidoc/computers/remote-access/samba.adoc @@ -1,88 +1,91 @@ +[[samba]] == Samba (SMB/CIFS) -Samba is a implementation of the SMB/CIFS networking protocol that is used by Microsoft Windows devices to provide shared access to files, printers, and serial ports. +Samba is a free software reimplementation of the https://en.wikipedia.org/wiki/Server_Message_Block[Server Message Block] (SMB) networking protocol. With Samba, you can share folders between Windows, macOS, and Linux machines. -You can use Samba to mount a folder shared from a Windows machine so it appears on your Raspberry Pi, or to share a folder from your Raspberry Pi so it can be accessed by your Windows machine. +=== Install Samba on your Raspberry Pi -=== Installing Samba Support +By default, Raspberry Pi OS does not include Samba. To install Samba on your Raspberry Pi, run the following command, which installs all the dependencies you need to run a Samba server or client: -By default, Raspberry Pi OS does not include CIFS/Samba support, but this can be added. The following commmands will install all the required components for using Samba as a server or a client. - -[,bash] +[source,console] ---- -sudo apt update -sudo apt install samba samba-common-bin smbclient cifs-utils +$ sudo apt update +$ sudo apt install samba samba-common-bin smbclient cifs-utils ---- -=== Mount a Folder Shared from Windows +=== Mount a folder shared from Windows -First, you need to share a folder on your Windows device. This is quite a convoluted process! +First, you need to share a folder on your Windows device. ==== Turn on sharing -. Open the Networking and Sharing Centre by right-clicking on the system tray and selecting it -. Click on *Change advanced sharing settings* -. Select *Turn on network discovery* -. Select *Turn on file and printer sharing* -. Save changes +. Right click the system tray and select *Networking and Sharing Centre* from the menu. +. Select *Change advanced sharing settings*. +. Select *Turn on network discovery*. +. Select *Turn on file and printer sharing*. +. Click the *Save* button to save your changes. ==== Share the folder -You can share any folder you want, but for this example, simply create a folder called `share`. +Follow these steps to share a folder from Windows: -. Create the folder `share` on your desktop. -. Right-click on the new folder, and select *Properties*. -. Click on the *Sharing* tab, and then the *Advanced Sharing* button -. Select *Share this folder*; by default, the share name is the name of the folder -. Click on the *Permissions* button -. For this example, select *Everyone* and *Full Control* (you can limit access to specific users if required); click *OK* when done, then *OK* again to leave the *Advanced Sharing* page -. Click on the *Security* tab, as we now need to configure the same permissions -. Select the same settings as the *Permissions* tab, adding the chosen user if necessary -. Click *OK* +. Right click the folder you want to share and select *Properties*. +. Select the *Sharing* tab. +. Click the *Advanced Sharing* button. +. Select *Share this folder*; by default, Windows uses the folder name as the share name. +. Click the *Permissions* button. +. Configure the *Everyone* and *Full Control* permissions. +. Click the *OK* button to leave the *Permissions* page. +. Click the *OK* button again to leave the *Advanced Sharing* page. +. Select the *Security* tab. +. Configure the *Everyone* and *Full Control* permissions. +. Click the *OK* button. -The folder should now be shared. +The folder should now be shared. You can modify shared folder permissions by changing permissions on both the *Permissions* and *Security* pages. ==== Windows 10 Sharing Wizard On Windows 10 there is a Sharing Wizard that helps with some of these steps. -. Run the Computer Management application from the Start Bar -. Select *Shared Folders*, then *Shares* -. Right-click and select *New Share*, which will start up the Sharing Wizard; click *Next* -. Select the folder you wish to share, and click *Next* -. Click *Next* to use all the sharing defaults -. Select *Custom* and set the required permissions, and click *OK*, then *Finish* +. Run the *Computer Management* application from the Start Bar. +. Select *Shared Folders* > *Shares*. +. Right click and select *New Share* to begin the Sharing Wizard. +. Click the *Next* button. +. Select the folder you wish to share, then click the *Next* button. +. Click *Next* to use the sharing defaults or select *Custom* and set the required permissions. +. Click the *OK* button. +. Click the *Finish* button to share the folder. ==== Mount the folder on the Raspberry Pi *Mounting* in Linux is the process of attaching a folder to a location, so firstly we need that location. -[,bash] +[source,console] ---- -mkdir windowshare +$ mkdir windowshare ---- -Now, we need to mount the remote folder to that location. The remote folder is the host name or IP address of the Windows PC, and the share name used when sharing it. We also need to provide the Windows username that will be used to access the remote machine. +Now, we need to mount the remote folder to that location. The remote folder is the host name or IP address of the Windows PC, and the share name used when sharing it. We also need to provide the Windows username that will be used to access the remote machine. Don't forget to replace the `` placeholder with your Raspberry Pi OS username. -[,bash] +[source,console] ---- -sudo mount.cifs ///share /home/pi/windowshare -o user= +$ sudo mount.cifs /// /home//windowshare -o user= ---- You should now be able to view the content of the Windows share on your Raspberry Pi. -[,bash] +[source,console] ---- -cd windowshare -ls +$ ls windowshare/ ---- ==== "Host is down" error -This error is caused by a combination of two things: A SMB protocol version mismatch, and the CIFS client on Linux returning a misleading error message. In order to fix this a version entry needs to be added to the mount command. By default Raspberry Pi OS will only use versions 2.1 and above, which are compatible with Windows 7 and later. Older devices, including some NAS, may require version 1.0: +This error occurs when SMB protocol version do not match and the Linux Samba client returns a misleading error message. By default Raspberry Pi OS uses versions 2.1 and above, compatible with Windows 7 and later. Older devices, including some NAS, may require version 1.0. To fix this error, append a version entry (e.g. `,vers=1.0`) to your mount command: +[source,console] ---- -sudo mount.cifs //IP/share /mnt/point -o user=,vers=1.0 +$ sudo mount.cifs //IP/share /mnt/point -o user=,vers=1.0 ---- You may need to try different versions to match up with the server version. Possible values are: @@ -114,20 +117,20 @@ You may need to try different versions to match up with the server version. Poss === Sharing a Folder from your Raspberry Pi -Firstly, create a folder to share. This example creates a folder called `shared` in the `home` folder of the current user, and assumes the current user is `pi`. +Firstly, create a folder to share. This example creates a folder called `shared` in the `home` folder of the current user: -[,bash] +[source,console] ---- -cd ~ -mkdir shared -chmod 0740 shared +$ cd ~ +$ mkdir shared +$ chmod 0740 shared ---- -Now we need to tell Samba that there is a `pi` user when accessing that folder. When asked, enter the password of the `pi` user - this can be the default password, but that is well known and should be changed for better security. +Now we need to tell Samba about your default user account when accessing that folder. When prompted, enter your password, replacing the `` placeholder with the username of your primary user account: -[,bash] +[source,console] ---- -sudo smbpasswd -a pi +$ sudo smbpasswd -a ---- Now we need to tell Samba to share this folder, using the Samba configuration file. @@ -137,11 +140,11 @@ Now we need to tell Samba to share this folder, using the Samba configuration fi sudo nano /etc/samba/smb.conf ---- -At the end of the file, add the following to share the folder, giving the remote user read/write permissions: +At the end of the file, add the following to share the folder, giving the remote user read/write permissions. Replace the `` placeholder with the username of the primary user account on your Raspberry Pi: ---- [share] - path = /home/pi/shared + path = /home//shared read only = no public = yes writable = yes @@ -154,4 +157,4 @@ In the same file, find the `workgroup` line, and if necessary, change it to the workgroup = ---- -That should be enough to share the folder. On your Windows device, when you browse the network, the folder should appear and you should be able to connect to it. +The shared folder should now appear to Windows or macOS devices on the network. Enter your Raspberry Pi username and password to mount the folder. diff --git a/documentation/asciidoc/computers/remote-access/scp.adoc b/documentation/asciidoc/computers/remote-access/scp.adoc index 2f6bb24956..159d6d7ed1 100644 --- a/documentation/asciidoc/computers/remote-access/scp.adoc +++ b/documentation/asciidoc/computers/remote-access/scp.adoc @@ -1,73 +1,81 @@ -== Using Secure Copy +[[scp]] +== Share files with SCP -Secure Copy (`scp`) is a command for sending files over SSH. This means you can copy files between computers, say from your Raspberry Pi to your desktop or laptop, or vice-versa. +Secure Copy Protocol (`scp`) sends files over SSH. You can use `scp` to copy files between your Raspberry Pi and another computer. -First of all, you'll need to know your Raspberry Pi's xref:remote-access.adoc#how-to-find-your-ip-address[IP address]. +To use `scp`, xref:remote-access.adoc#ip-address[find your Raspberry Pi's IP address]. -=== Copying Files to your Raspberry Pi +=== Copy files to your Raspberry Pi -Copy the file `myfile.txt` from your computer to the `pi` user's home folder of your Raspberry Pi at the IP address `192.168.1.3` with the following command: +To copy a file named `myfile.txt` from your personal computer to a user's home folder on your Raspberry Pi, run the following command from the directory containing `myfile.txt`, replacing the `` placeholder with the username you use to log in to your Raspberry Pi and the `` placeholder with your Raspberry Pi's IP address: -[,bash] +[source,console] ---- -scp myfile.txt pi@192.168.1.3: +$ scp myfile.txt @: ---- -Copy the file to the `/home/pi/project/` directory on your Raspberry Pi (the `project` folder must already exist): +To copy a file to a specific directory, append the directory path after the `:` in the `scp` command. Create the folder before you run `scp`, since `scp` won't create folders automatically. For instance, the following command copies a file named `myfile.txt` into the `project/` directory within a user's home folder: -[,bash] +[source,console] ---- -scp myfile.txt pi@192.168.1.3:project/ +$ scp myfile.txt @:project/ ---- -=== Copying Files from your Raspberry Pi +=== Copy files from your Raspberry Pi -Copy the file `myfile.txt` from your Raspberry Pi to the current directory on your other computer: +To copy a file named `myfile.txt` from a user's home directory on a Raspberry Pi to the current directory on another computer, run the following command: -[,bash] +[source,console] ---- -scp pi@192.168.1.3:myfile.txt . +$ scp @:myfile.txt . ---- -=== Copying Multiple Files +=== Copy multiple files with one command -Copy multiple files by separating them with spaces: +To copy multiple files, list the file names in a single command, separated by spaces: -[,bash] +[source,console] ---- -scp myfile.txt myfile2.txt pi@192.168.1.3: +$ scp myfile.txt myfile2.txt @: ---- -Alternatively, use a wildcard to copy all files matching a particular search with: +Alternatively, use a wildcard to copy all files matching a particular filter. The following command copies all files that end with `.txt`: -[,bash] +[source,console] ---- -scp *.txt pi@192.168.1.3: +$ scp *.txt @: ---- -(all files ending in `.txt`) +The following command copies all files that start with `m`: -[,bash] +[source,console] ---- -scp m* pi@192.168.1.3: +$ scp m* @: ---- -(all files starting with `m`) +The following command copies all files that start with `m` and end with `.txt`: -[,bash] +[source,console] ---- -scp m*.txt pi@192.168.1.3: +$ scp m*.txt @: ---- -(all files starting with `m` and ending in `.txt`) - [NOTE] -====== -Some of the examples above will not work for file names containing spaces. Names like this need to be enclosed in quotes: +==== +To copy files with names that contain spaces, enclose the file name in quotes: -[,bash] +[source,console] ---- -scp "my file.txt" pi@192.168.1.3: +$ scp "my file.txt" @: ---- -====== +==== + +=== Copy a folder + +To copy a folder and all of its contents, pass the folder name with the `-r` (recursive) flag: + +[source,console] +---- +$ scp -r project/ @: +---- diff --git a/documentation/asciidoc/computers/remote-access/secure-shell-from-unix.adoc b/documentation/asciidoc/computers/remote-access/secure-shell-from-unix.adoc deleted file mode 100644 index 8d6118233a..0000000000 --- a/documentation/asciidoc/computers/remote-access/secure-shell-from-unix.adoc +++ /dev/null @@ -1,49 +0,0 @@ -== Secure Shell from Linux or Mac OS - -You can use SSH to connect to your Raspberry Pi from a Linux desktop, another Raspberry Pi, or from an Apple Mac without installing additional software. - -Open a terminal window on your computer replacing `` with the IP address of the Raspberry Pi you're trying to connect to, - ----- -ssh pi@ ----- - -When the connection works you will see a security/authenticity warning. Type `yes` to continue. You will only see this warning the first time you connect. - -NOTE: If you receive a `connection timed out` error it is likely that you have entered the wrong IP address for the Raspberry Pi. - -WARNING: In the event your Pi has taken the IP address of a device to which your computer has connected before (even if this was on another network), you may be given a warning and asked to clear the record from your list of known devices. Following this instruction and trying the `ssh` command again should be successful. - -Next you will be prompted for the password for the `pi` login: the default password on Raspberry Pi OS is `raspberry`. - -For security reasons it is highly recommended to change the default password on the Raspberry Pi (also, you can not login through ssh if the password is blank). You should now be able to see the Raspberry Pi prompt, which will be identical to the one found on the Raspberry Pi itself. - -If you have set up another user on the Raspberry Pi, you can connect to it in the same way, replacing the username with your own, e.g. `eben@192.168.1.5` - ----- -pi@raspberrypi ~ $ ----- - -You are now connected to the Raspberry Pi remotely, and can execute commands. - -[discrete] -=== Forwarding X11 - -You can also forward your X session over SSH, to allow the use of graphical applications, by using the `-Y` flag: - -[,bash] ----- -ssh -Y pi@192.168.1.5 ----- - -NOTE: X11 is no longer installed by default https://support.apple.com/en-gb/HT201341[on macOS], so you will have to https://www.xquartz.org/[download] and install it. - -Now you are on the command line as before, but you have the ability to open up graphical windows. For example, typing: - -[,bash] ----- -geany & ----- - -will open up the Geany editor in a window on your local desktop. - diff --git a/documentation/asciidoc/computers/remote-access/secure-shell-from-windows10.adoc b/documentation/asciidoc/computers/remote-access/secure-shell-from-windows10.adoc deleted file mode 100644 index 412608dd2c..0000000000 --- a/documentation/asciidoc/computers/remote-access/secure-shell-from-windows10.adoc +++ /dev/null @@ -1,27 +0,0 @@ -== Secure Shell from Windows 10 - -You can use SSH to connect to your Raspberry Pi from a Windows 10 computer that is using _October 2018 Update_ or later without having to use third-party clients. - -Open a terminal window on your computer replacing `` with the IP address of the Raspberry Pi you're trying to connect to, - ----- -ssh pi@ ----- - -When the connection works you will see a security/authenticity warning. Type `yes` to continue. You will only see this warning the first time you connect. - -NOTE: If you receive a `connection timed out` error it is likely that you have entered the wrong IP address for the Raspberry Pi. - -WARNING: In the event your Pi has taken the IP address of a device to which your computer has connected before (even if this was on another network), you may be given a warning and asked to clear the record from your list of known devices. Following this instruction and trying the `ssh` command again should be successful. - -Next you will be prompted for the password for the `pi` login: the default password on Raspberry Pi OS is `raspberry`. - -For security reasons it is highly recommended to change the default password on the Raspberry Pi (also, you can not login through ssh if the password is blank). You should now be able to see the Raspberry Pi prompt, which will be identical to the one found on the Raspberry Pi itself. - -If you have set up another user on the Raspberry Pi, you can connect to it in the same way, replacing the username with your own, e.g. `eben@192.168.1.5` - ----- -pi@raspberrypi ~ $ ----- - -You are now connected to the Raspberry Pi remotely, and can execute commands. diff --git a/documentation/asciidoc/computers/remote-access/secure-shell-passwordless.adoc b/documentation/asciidoc/computers/remote-access/secure-shell-passwordless.adoc deleted file mode 100644 index 0a5a4af6c7..0000000000 --- a/documentation/asciidoc/computers/remote-access/secure-shell-passwordless.adoc +++ /dev/null @@ -1,124 +0,0 @@ -== Passwordless SSH Access - -It is possible to configure your Raspberry Pi to allow access from another computer without needing to provide a password each time you connect. To do this, you need to use an SSH key instead of a password. To generate an SSH key: - -=== Checking for Existing SSH Keys - -First, check whether there are already keys on the computer you are using to connect to the Raspberry Pi: - -[,bash] ----- -ls ~/.ssh ----- - -If you see files named `id_rsa.pub` or `id_dsa.pub` then you have keys set up already, so you can skip the 'Generate new SSH keys' step below. - -=== Generate new SSH Keys - -To generate new SSH keys enter the following command: - -[,bash] ----- -ssh-keygen ----- - -Upon entering this command, you will be asked where to save the key. We suggest saving it in the default location (`~/.ssh/id_rsa`) by pressing `Enter`. - -You will also be asked to enter a passphrase, which is optional. The passphrase is used to encrypt the private SSH key, so that if someone else copied the key, they could not impersonate you to gain access. If you choose to use a passphrase, type it here and press `Enter`, then type it again when prompted. Leave the field empty for no passphrase. - -Now look inside your `.ssh` directory: - -[,bash] ----- -ls ~/.ssh ----- - -and you should see the files `id_rsa` and `id_rsa.pub`: - ----- -authorized_keys id_rsa id_rsa.pub known_hosts ----- - -The `id_rsa` file is your private key. Keep this on your computer. - -The `id_rsa.pub` file is your public key. This is what you share with machines that you connect to: in this case your Raspberry Pi. When the machine you try to connect to matches up your public and private key, it will allow you to connect. - -Take a look at your public key to see what it looks like: - -[,bash] ----- -cat ~/.ssh/id_rsa.pub ----- - -It should be in the form: - -[,bash] ----- -ssh-rsa user@host ----- - -[[copy-your-public-key-to-your-raspberry-pi]] -=== Copy your Key to your Raspberry Pi - -Using the computer which you will be connecting from, append the public key to your `authorized_keys` file on the Raspberry Pi by sending it over SSH: - -[,bash] ----- -ssh-copy-id @ ----- - -NOTE: During this step you will need to authenticate with your password. - -Alternatively, if `ssh-copy-id` is not available on your system, you can copy the file manually over SSH: - -[,bash] ----- -cat ~/.ssh/id_rsa.pub | ssh @ 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' ----- - -If you see the message `ssh: connect to host port 22: Connection refused` and you know the `IP-ADDRESS` is correct, then you may not have enabled SSH on your Raspberry Pi. Run `sudo raspi-config` in the Pi's terminal window, enable SSH, then try to copy the files again. - -Now try `ssh @` and you should connect without a password prompt. - -If you see a message "Agent admitted failure to sign using the key" then add your RSA or DSA identities to the authentication agent `ssh-agent` then execute the following command: - -[,bash] ----- -ssh-add ----- - -NOTE: you can also send files over SSH using the xref:remote-access.adoc#using-secure-copy[`scp`] (secure copy) command. - -=== Adjust Directory Permissions - -If you can't establish a connection after following the steps above there might be a problem with your directory permissions. First, you want to check the logs for any errors: - -[,bash] ----- -tail -f /var/log/secure -# might return: -Nov 23 12:31:26 raspberrypi sshd[9146]: Authentication refused: bad ownership or modes for directory /home/pi ----- - -If the log says `Authentication refused: bad ownership or modes for directory /home/pi` there is a permission problem regarding your home directory. SSH needs your home and `~/.ssh` directory to not have group write access. You can adjust the permissions using `chmod`: - -[,bash] ----- -chmod g-w $HOME -chmod 700 $HOME/.ssh -chmod 600 $HOME/.ssh/authorized_keys ----- - -Now only the user itself has access to `.ssh` and `.ssh/authorized_keys` in which the public keys of your remote machines are stored. - -[discrete] -=== Storing the passphrase in the macOS keychain - -If you are using macOS, and after verifying that your new key allows you to connect, you have the option of storing the passphrase for your key in the macOS keychain. This allows you to connect to your Raspberry Pi without entering the passphrase. - -Run the following command to store it in your keychain: - -[,bash] ----- -ssh-add -K ~/.ssh/id_rsa ----- diff --git a/documentation/asciidoc/computers/remote-access/secure-shell.adoc b/documentation/asciidoc/computers/remote-access/secure-shell.adoc deleted file mode 100644 index c3ad18b2c6..0000000000 --- a/documentation/asciidoc/computers/remote-access/secure-shell.adoc +++ /dev/null @@ -1,34 +0,0 @@ -[[ssh]] -== Setting up a SSH Server - -You can access the command line of a Raspberry Pi remotely from another computer or device on the same network using Secure Shell (SSH). - -You will only have access to the command line, not the full desktop environment. For a full remote desktop, see xref:remote-access.adoc#virtual-network-computing-vnc[VNC]. - -=== Set up your Local Network - -Make sure your Raspberry Pi is properly set up and connected. If you are using wireless networking, this can be enabled via the desktop user interface, or using from the command line. If you are not using wireless connectivity, plug your Raspberry Pi directly into the router. - -NOTE: You will need to note down the IP address of your Raspberry Pi in order to connect to it later. Using the `ifconfig` command will display information about the current network status, including the IP address, or you can use `hostname -I` to display the IP addresses associated with the device. - -=== Enabling the Server - -Raspberry Pi OS has the SSH server disabled by default. It can be enabled manually from the desktop: - -. Launch `Raspberry Pi Configuration` from the `Preferences` menu -. Navigate to the `Interfaces` tab -. Select `Enabled` next to `SSH` -. Click `OK` - -Alternatively you can enable it from the terminal using the xref:configuration.adoc#the-raspi-config-tool[raspi-config] application, - -. Enter `sudo raspi-config` in a terminal window -. Select `Interfacing Options` -. Navigate to and select `SSH` -. Choose `Yes` -. Select `Ok` -. Choose `Finish` - -NOTE: For headless setup, SSH can be enabled by placing a file named `ssh`, without any extension, onto the boot partition of the SD Card. When the Raspberry Pi boots, it looks for the `ssh` file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all. - -WARNING: When enabling SSH on a Raspberry Pi that may be connected to the internet, you should xref:using_linux.adoc#changing-your-password[change the default password] to ensure that it remains secure. diff --git a/documentation/asciidoc/computers/remote-access/ssh.adoc b/documentation/asciidoc/computers/remote-access/ssh.adoc new file mode 100644 index 0000000000..aaa58862aa --- /dev/null +++ b/documentation/asciidoc/computers/remote-access/ssh.adoc @@ -0,0 +1,222 @@ +[[ssh]] +== Access a remote terminal with SSH + +You can access the terminal of a Raspberry Pi remotely from another computer on the same network using the **S**ecure **SH**ell (SSH) protocol. + +=== Enable the SSH server + +By default, Raspberry Pi OS disables the SSH server. Enable SSH in one of the following ways: + +[tabs] +====== +On the desktop:: ++ +. From the *Preferences* menu, launch *Raspberry Pi Configuration*. +. Navigate to the *Interfaces* tab. +. Select *Enabled* next to *SSH*. +. Click *OK*. + +While flashing a fresh OS image:: ++ +To configure SSH on a completely new installation of Raspberry Pi OS: ++ +. Follow the instructions in the xref:../computers/getting-started.adoc#raspberry-pi-imager[Install with Imager] guide. +. During the **OS Customisation** step, navigate to the **Services** tab. +. Tick the checkbox to **Enable SSH**. +. Select **password authentication** to log in using the same username and password you use while physically using your Raspberry Pi. Select **Allow public-key authentication only** to xref:remote-access.adoc#configure-ssh-without-a-password[configure an SSH key] for passwordless login. + +From the terminal:: ++ +. Enter `sudo raspi-config` in a terminal window. +. Select `Interfacing Options`. +. Navigate to and select `SSH`. +. Choose `Yes`. +. Select `Ok`. +. Choose `Finish`. + +Manually:: ++ +. Create an empty file named `ssh` in the boot partition: ++ +[source,console] +---- +$ sudo touch /boot/firmware/ssh +---- +. Reboot the machine: ++ +[source,console] +---- +$ sudo reboot +---- +====== + +=== Connect to an SSH server + +Open a terminal window on your computer and enter the following command, replacing the `` placeholder with the xref:remote-access.adoc#ip-address[IP address of the Raspberry Pi you're trying to connect to] and `` with your username: + +[source,console] +---- +$ ssh @ +---- + +When the connection works, you will see a security warning. Type `yes` to continue. You will only see this warning the first time you connect. + +Enter your account password when prompted. + +You should now see the Raspberry Pi command prompt: + +[source,console?prompt=@ ~ $] +---- +@ ~ $ +---- + +You are now connected to the Raspberry Pi remotely, and can execute commands. + +NOTE: If you receive a `connection timed out` error, you may have entered the wrong IP address for the Raspberry Pi. Check the xref:remote-access.adoc#ip-address[IP address of the Raspberry Pi]. + +==== Forward X11 over SSH + +NOTE: On Raspberry Pi 4 and 5, Raspberry Pi OS Bookworm uses the Wayland window server by default. You can only forward X11 if you use the X window server. To enable window forwarding over X11, switch your desktop to the X window server in Raspberry Pi Configuration. + +NOTE: X11 is no longer installed by default on many desktop environments. Install a third-party X server such as https://www.xquartz.org/[XQuartz] to use X11 forwarding. + +X11 enables graphical applications over SSH. Pass the `-Y` flag to forward an X session over SSH: + +[source,console] +---- +$ ssh -Y @ +---- + +Once authenticated, you will see the command line as usual. However, you can also open graphical windows that an X server can render for you. For example, type the following command to launch a https://www.geany.org/[Geany] window: + +[source,console] +---- +$ geany & +---- + +=== Configure SSH without a password + +To remotely access your Raspberry Pi without providing a password each time you connect, use an SSH keypair. + +==== Preconfigure an OS image with Raspberry Pi Imager + +When configuring a boot image with Raspberry Pi Imager, you can preconfigure SSH keys. You can generate a new SSH keypair or an existing SSH key. + +. Follow the xref:getting-started.adoc#raspberry-pi-imager[install using Imager] guide to configure your boot image. +. During the *OS Customisation* step, navigate to the *Services* tab and tick the *Enable SSH* checkbox. +. Select the *Allow public-key authentication only* radio button. If you already have an SSH public key stored in `~/.ssh/id_rsa.pub`, Imager automatically uses that public key to prefill the text box. If Imager doesn't find an SSH public key, you can click the *RUN SSH-KEYGEN* button to generate a new keypair. + +==== Manually configure an SSH key + +If you already have an installation of Raspberry Pi OS, you can update your existing configuration to use SSH key authentication. + +==== Check for existing SSH public keys + +To check for an existing SSH public key on the computer you use to remotely connect to the Raspberry Pi, run the following command: + +[source,console] +---- +$ ls ~/.ssh +---- + +If you see files named `id_ed25519.pub`, `id_rsa.pub`, or `id_dsa.pub`, you already have an SSH key. Skip SSH keypair generation and proceed to xref:remote-access.adoc#add-ssh-key-identity[add the SSH key to your list of SSH identities]. + +==== Generate new SSH keypair + +TIP: This guide provides instructions to generate a new RSA key. For additional security, you can instead generate a http://ed25519.cr.yp.to/[Ed25519] key. Pass `-t ed25519` to `ssh-keygen` and replace `rsa` with `ed25519` when referencing your public and private key file names to use an Ed25519 key. + +To generate a new SSH keypair, enter the following command: + +[source,console] +---- +$ ssh-keygen +---- + +When asked where to save the key, press *Enter* to use the default location, `~/.ssh/id_rsa`. + +When asked for an optional keyphrase, press *Enter* to use no keyphrase. + +Run the following command to check the contents of the `.ssh` directory: + +[source,console] +---- +$ ls ~/.ssh +---- + +You should see the files `id_rsa` and `id_rsa.pub`: + +---- +authorized_keys id_rsa id_rsa.pub known_hosts +---- + +The `id_rsa` file contains your private key. Keep this secure on the computer you use to remotely connect to the Raspberry Pi. + +The `id_rsa.pub` file contains your public key. You will share this key with your Raspberry Pi. When you connect with the Raspberry Pi remotely, it will use this key to verify your identity. + +[[add-ssh-key-identity]] +==== Add the SSH key to your list of SSH identities + +Start the SSH agent: + +[source,console] +---- +$ eval "$(ssh-agent -s)" +---- + +Next, add your key identities to `ssh-agent` with the following command: + +[source,console] +---- +$ ssh-add ~/.ssh/id_rsa +---- + +[[copy-your-public-key-to-your-raspberry-pi]] +==== Copy a public key to your Raspberry Pi + +On the computer you use to remotely connect to the Raspberry Pi, use the following command to securely copy your public key to the Raspberry Pi: + +[source,console] +---- +$ ssh-copy-id @ +---- + +When prompted, enter the password for your user account on the Raspberry Pi. +You can now connect to your Raspberry Pi without entering a password. + +==== Manually copy a public key to your Raspberry Pi + +If your operating system does not support `ssh-copy-id`, you can instead copy your public key with xref:remote-access.adoc#scp[`scp`]. + +First, _on your Raspberry Pi_, create the directory where Linux expects to find keys: + +[source,console] +---- +$ mkdir .ssh +---- + +Then, configure the proper permissions for the `.ssh` directory: + +[source,console] +---- +$ chmod 700 .ssh +---- + +_On your usual computer_, use `scp` to copy your public key to a file named `.ssh/authorized_keys` on your Raspberry Pi: + +[source,console] +---- +$ scp .ssh/id_rsa.pub @:.ssh/authorized_keys +---- + +TIP: The command above assumes you have never before authorized any keys to access your Raspberry Pi. If you have previously added at least one key, you should instead add a new line containing the public key to the end of the `authorized_keys` file to preserve your existing keys. + +When prompted, enter the password for your user account on the Raspberry Pi. + +Then, _on your Raspberry Pi_, configure permissions for the `authorized_keys` file: + +[source,console] +---- +$ chmod 644 .ssh/authorized_keys +---- + +You can now connect to your Raspberry Pi without entering a password. diff --git a/documentation/asciidoc/computers/remote-access/vnc.adoc b/documentation/asciidoc/computers/remote-access/vnc.adoc index b827f933d7..e7ee1c300b 100644 --- a/documentation/asciidoc/computers/remote-access/vnc.adoc +++ b/documentation/asciidoc/computers/remote-access/vnc.adoc @@ -1,123 +1,95 @@ [[vnc]] -== Virtual Network Computing (VNC) -:experimental: +== Screen share with VNC -Sometimes it is not convenient to work directly on the Raspberry Pi. Maybe you would like to work on it from another device by remote control. +Sometimes it is not convenient to physically work with a device. Virtual Network Computing (VNC) allows you to control the desktop of one device from another. -VNC is a graphical desktop sharing system that allows you to remotely control the desktop interface of one computer (running VNC Server) from another computer or mobile device (running VNC Viewer). VNC Viewer transmits the keyboard and either mouse or touch events to VNC Server, and receives updates to the screen in return. +VNC relies upon a client and a server. The client runs on a device you can physically interact with, such as a personal laptop, desktop, tablet, or phone. The server runs on your Raspberry Pi. +When you use VNC, the client transmits keyboard and mouse events to the server. The server executes those events on your Raspberry Pi, and returns screen updates to the client. -You will see the desktop of the Raspberry Pi inside a window on your computer or mobile device. You'll be able to control it as though you were working on the Raspberry Pi itself. +The VNC client displays the desktop of your Raspberry Pi in a window. You can interact with the desktop as though you were working on the Raspberry Pi itself. -VNC Connect from RealVNC is included with Raspberry Pi OS. It consists of both VNC Server, which allows you to control your Raspberry Pi remotely, and VNC Viewer, which allows you to control desktop computers remotely from your Raspberry Pi should you want to. +Raspberry Pi OS includes https://github.com/any1/wayvnc[wayvnc]. This provides a VNC server that you can enable in your device preferences. -You must enable VNC Server before you can use it. By default, VNC Server gives you remote access to the graphical desktop that is running on your Raspberry Pi, as though you were sitting in front of it. +Before you can use VNC on your Raspberry Pi, you must enable the VNC server. -However, you can also use VNC Server to gain graphical remote access to your Raspberry Pi if it is headless or not running a graphical desktop. For more information on this, see *Creating a virtual desktop*, further below. +=== Enable the VNC server -=== Installing VNC on Raspberry Pi +Raspberry Pi OS supports enabling the VNC server both graphically and at the command line. -VNC is already installed on the full Raspberry Pi OS image, and can be installed via `Recommended Software` from the `Preferences` menu on other versions. +TIP: Once enabled, you can access your WayVNC configuration at `/etc/wayvnc/`. -If you are not using a desktop you can install it from the command line as follows: +==== Enable VNC Server Graphically -[,bash] ----- -sudo apt update -sudo apt install realvnc-vnc-server realvnc-vnc-viewer ----- - -=== Enabling the VNC Server - -You can do this graphically or at the command line. - -==== Enabling VNC Server graphically - -* On your Raspberry Pi, boot into the graphical desktop. -* Select menu:Menu[Preferences > Raspberry Pi Configuration > Interfaces]. -* Ensure *VNC* is *Enabled*. +. Boot into the graphical desktop on your Raspberry Pi. +. Click the Raspberry Pi icon in the system tray of your desktop. +. Select *Preferences* > *Raspberry Pi Configuration* from the menu. ++ +-- +image::images/raspberry-pi-configuration.png[alt="Select Raspberry Pi Configuration from the Preferences menu in the system tray",width="80%"] +-- +. Navigate to the *Interfaces* tab. +. Click the radio button next to *VNC* into the active position. ++ +-- +image::images/vnc-enable.png[alt="In the Interfaces tab, click the VNC toggle into the active position to enable VNC.",width="80%"] +-- +. Click the *OK* button to save your configuration changes. -==== Enabling VNC Server at the command line +==== Enable the VNC server on the command line -You can enable VNC Server at the command line using xref:configuration.adoc#the-raspi-config-tool[raspi-config]: +Use xref:configuration.adoc#raspi-config[raspi-config] to enable the VNC server on the command line. -[,bash] +. Open `raspi-config` with the following line: ++ +[source,console] ---- -sudo raspi-config +$ sudo raspi-config ---- +. Navigate to *Interface Options*. Press `Enter` to select. +. Select *VNC*. Press `Enter` to select. +. Under *Would you like the VNC Server to be enabled?*, highlight `` and press `Enter`. +. Press `Enter` to return to the menu. Press `Esc` to exit `raspi-config`. -Now, enable VNC Server by doing the following: - -* Navigate to *Interfacing Options*. -* Scroll down and select menu:VNC[Yes]. - -=== Connecting to your Raspberry Pi - -There are two ways to connect to your Raspberry Pi. You can use either or both, depending on what works best for you. - -==== Establishing a direct connection - -Direct connections are quick and simple providing you're joined to the same private local network as your Raspberry Pi. For example, this might be a wired or wireless network at home, at school, or in the office. - -* On your Raspberry Pi (using a terminal window or via SSH) use xref:remote-access.adoc#ip-address[these instructions] or run `ifconfig` to discover your private IP address. -* On the device you'll use to take control, download VNC Viewer. For best results, use the https://www.realvnc.com/download/viewer/[compatible app] from RealVNC. -* Enter your Raspberry Pi's private IP address into VNC Viewer: - -==== Establishing a cloud connection - -You are entitled to use RealVNC's cloud service for free, provided that remote access is for educational or non-commercial purposes only. - -Cloud connections are convenient and encrypted end-to-end. They are highly recommended for connecting to your Raspberry Pi over the internet. There's no firewall or router reconfiguration, and you don't need to know the IP address of your Raspberry Pi, or provide a static one. - -* Sign up for a https://www.realvnc.com/raspberrypi/#sign-up[RealVNC account] here: it's free and it only takes a few seconds. -* On your Raspberry Pi, sign in to VNC Server using your new RealVNC account credentials: -* On the device you'll use to take control, download VNC Viewer. You *must* use the https://www.realvnc.com/download/viewer/[compatible app] from RealVNC. -* Sign in to VNC Viewer using the same RealVNC account credentials, and then either tap or click to connect to your Raspberry Pi: - -==== Authenticating to VNC Server +=== Connect to a VNC server -To complete either a direct or cloud connection, you must authenticate to VNC Server. +To connect to your Raspberry Pi, you'll need the following: -If you're connecting from the https://www.realvnc.com/download/viewer/[compatible VNC Viewer app] from RealVNC, enter the user name and password you normally use to log in to your user account on the Raspberry Pi. By default, these credentials are `pi` and `raspberry`. +* your Raspberry Pi and the device running the VNC client, connected to the same network (e.g. a home wireless network or VPN) +* the hostname or IP address of your Raspberry Pi +* a valid username and password combination for an account on your Raspberry Pi -If you're connecting from a non-RealVNC Viewer app, you'll first need to downgrade VNC Server's authentication scheme, specify a password unique to VNC Server, and then enter that instead. +If you don't know the IP address of your device, see xref:remote-access.adoc#ip-address[our instructions on finding your IP address]. -* If you are in front of your Raspberry Pi and can see its screen, open the VNC Server dialog on your Raspberry Pi, select menu:Menu[Options > Security], and choose *VNC password* from the *Authentication* dropdown. -* *Or* if you're configuring your Raspberry Pi remotely from the command line, then to make the changes for Service Mode (the default configuration for the Raspberry Pi): - ** Open the `/root/.vnc/config.d/vncserver-x11` config file. - ** Replace `Authentication=SystemAuth` with `Authentication=VncAuth` and save the file. - ** In the command line, run `sudo vncpasswd -service`. This will prompt you to set a password, and will insert it for you in the right config file for VNC Server running in Service Mode. - ** Restart VNC Server. - -=== Using Directly Rendered Applications - -You can remotely access apps which use a directly rendered overlay such as; the text console, the Raspberry Pi Camera Module, and others. - -To turn this feature on: - -* On your Raspberry Pi, open the VNC Server dialog. -* Navigate to menu:Menu[Options > Troubleshooting] and select *Enable experimental direct capture mode*. -* On the device you'll use to take control, run VNC Viewer and connect. +. Download https://tigervnc.org/[TigerVNC]. You can install the latest version from the https://github.com/TigerVNC/tigervnc/releases[Releases page of their GitHub repository]. Click on the link in the latest release, and find the binary for your platform. Windows users should download an `exe`; macOS users should download the `dmg`; Linux users should install the `jar`. +. On your client device, launch TigerVNC. On macOS and Windows, you can double-click the binary. On Linux, install java with `sudo apt install default-jre`, then run `java -jar VncViewer-.jar`, replacing the `` placeholder with the version you downloaded. +. In the "VNC server" field, enter the IP address of your Raspberry Pi. + -NOTE: Existing connections must be restarted in order for these changes to take effect. - -Please note that direct screen capture is an experimental feature. If you're connecting from a desktop computer and mouse movements seem erratic, try pressing *F8* to open the VNC Viewer shortcut menu and selecting *Relative Pointer Motion*. - -=== Creating a Virtual Desktop - -If your Raspberry Pi is headless (i.e. not plugged into a monitor) or controlling a robot, it is unlikely to be running a graphical desktop. - -VNC Server can create a *virtual desktop* for you, giving you graphical remote access on demand. This virtual desktop exists only in your Raspberry Pi's memory: - -To create and connect to a virtual desktop: - -* On your Raspberry Pi (using Terminal or via SSH), run `vncserver`. Make note of the IP address/display number that VNC Server will print to your Terminal (e.g. `192.167.5.149:1`). -* On the device you'll use to take control, enter this information into https://www.realvnc.com/download/viewer/[VNC Viewer]. - -To destroy a virtual desktop, run the following command: - -[,bash] ----- -vncserver -kill : ----- - -This will also stop any existing connections to this virtual desktop. +-- +image::images/vnc-tigervnc-enter-ip.png[alt="Entering the Raspberry Pi's local IP address into TigerVNC",width="60%"] +-- +. Click the "Options" button. Navigate to the "Input" tab. Check the box next to "Show dot when no cursor" to ensure that you can always see a cursor in TigerVNC. ++ +-- +image::images/vnc-tigervnc-show-dot.png[alt="TigerVNC option to render the cursor at all times as a dot",width="60%"] +-- +. Click the "Connect" button to initiate a connection with the server. + * If TigerVNC warns you that the "Hostname does not match the server certificate", click the "Yes" button to continue. ++ +-- +image::images/vnc-tigervnc-cert-warning.png[alt=TigerVNC warning about mismatched certificates",width="60%"] +-- +* If TigerVNC warns you that the "certificate has been signed by an unknown authority", click the "Yes" button to grant an exception for your Raspberry Pi. ++ +-- +image::images/vnc-tigervnc-cert-signer-warning.png[alt="TigerVNC warning about certificates signed by an unknown authority",width="60%"] +-- +. When prompted for a username and password, enter your credentials. ++ +-- +image::images/vnc-tigervnc-username-password.png[alt="Entering a username and password to authenticate via TigerVNC",width="60%"] +-- +. Click the "OK" button to authenticate with the VNC server. If your credentials are correct, TigerVNC should open a window containing the desktop corresponding to your account on the Raspberry Pi. You should be able to move your mouse and keyboard to input text and interact with the desktop. ++ +-- +image::images/vnc-tigervnc-desktop.png[alt="The desktop of a Raspberry Pi after successfully authenticating with TigerVNC",width="60%"] +-- diff --git a/documentation/asciidoc/computers/software-sources.adoc b/documentation/asciidoc/computers/software-sources.adoc new file mode 100644 index 0000000000..9079a426c4 --- /dev/null +++ b/documentation/asciidoc/computers/software-sources.adoc @@ -0,0 +1,166 @@ +At Raspberry Pi we're trying to open source as much of our code as possible to make it easy to use and adapt for your own uses. Raspberry Pi develops and supports software specifically for our products and focuses its energy on software which provides the most optimal user experience. For example, drivers which optimize multimedia acceleration such as the 3D, HEVC decode, the camera imaging pipeline, AI acceleration, dual HDMI and audio. + +== Finding software sources in Raspberry Pi OS + +When looking for software which is distributed with Raspberry Pi OS, there are often upstream software sources that we patch to create our downstream packages (those tagged with `pass:[+rpt]`). To view the source for those packages it is usually easier to fetch through apt. To do this, you first need to edit your apt lists to include the source packages. The following files should be edited to remove the leading `pass:[#]` from each line: + +* `+/etc/apt/sources.list+` +* `+/etc/apt/sources.list.d/raspi.list+` + +Next you must update the package lists: + +[source,console] +---- +$ sudo apt update +---- + +Now you can fetch the package source, for example: + +[source,console] +---- +$ apt source labwc +---- + +Finally you can build the package using the standard Debian building process. + +[source,console] +---- +$ sudo apt build-dep labwc +$ debuild -uc -us +---- + +== Our GitHub organizations + +The other place you can find our software in a more standard form is in our GitHub repositories, we have three GitHub organisations we use to store our sources: + +* https://github.com/raspberrypi +* https://github.com/raspberrypi-ui +* https://github.com/RPi-Distro + +== List of categorized sources + +The following is a curated list of repositories which most people are interested in: + +=== Main sources + +https://github.com/raspberrypi/linux:: +This repository contains the source code for the downstream Linux kernel supported and working on all versions of Raspberry Pi from Pi 1 to Pi 5. + +=== Libraries and applications + +https://github.com/raspberrypi/utils:: +A collection of useful utilities such as pinctrl, piolib and raspinfo, also gpiolib a Raspberry Pi supported method of directly accessing GPIO pins. + +https://github.com/raspberrypi/libcamera:: +A libcamera library implementation for controlling the Raspberry Pi's ISP and cameras. + +https://github.com/raspberrypi/rpicam-apps:: +A C++ library and application suite for image/video processing and encoding with Raspberry Pi cameras using libcamera. + +https://github.com/raspberrypi/picamera2:: +A Python library for using and controlling the Raspberry Pi cameras. + +https://github.com/raspberrypi/drmu:: +A library for directly controlling and accessing multimedia interfaces. + +=== Desktop + +https://github.com/raspberrypi-ui/wf-panel-pi:: +The taskbar displayed at the top of the screen when running the Wayland-based desktop. + +https://github.com/raspberrypi-ui/lxpanel-pi:: +The taskbar displayed at the top of the screen when running the legacy X-based desktop. + +https://github.com/raspberrypi-ui/pplug-batt:: +https://github.com/raspberrypi-ui/pplug-bluetooth:: +https://github.com/raspberrypi-ui/pplug-clock:: +https://github.com/raspberrypi-ui/pplug-cpu:: +https://github.com/raspberrypi-ui/pplug-cputemp:: +https://github.com/raspberrypi-ui/pplug-ejecter:: +https://github.com/raspberrypi-ui/pplug-gpu:: +https://github.com/raspberrypi-ui/pplug-menu:: +https://github.com/raspberrypi-ui/pplug-netman:: +https://github.com/raspberrypi-ui/pplug-power:: +https://github.com/raspberrypi-ui/pplug-updater:: +https://github.com/raspberrypi-ui/pplug-volumepulse:: +The plugins displayed on the taskbars. + +https://github.com/raspberrypi-ui/pcmanfm:: +https://github.com/raspberrypi-ui/libfm:: +The file manager used by the desktop, which also displays the desktop background. + +https://github.com/raspberrypi-ui/appset:: +The Appearance settings panel. + +https://github.com/raspberrypi-ui/rc_gui:: +The Raspberry Pi Configuration settings panel. + +https://github.com/raspberrypi-ui/rasputin:: +The Mouse and Keyboard settings panel. + +https://github.com/raspberrypi-ui/raindrop:: +The Screen Configuration settings panel. + +https://github.com/raspberrypi-ui/rpinters:: +The Printers settings panel. + +=== Applications + +https://github.com/raspberrypi-ui/agnostics:: +The Diagnostics application used to check SD cards. + +https://github.com/raspberrypi-ui/bookshelf:: +The code for the Bookshelf application which allows you to download and read e-books and past issues of the Raspberry Pi Official Magazine. + +https://github.com/raspberrypi-ui/piclone:: +The SD Card Copier application which allows cards and drives to be cloned. + +https://github.com/raspberrypi-ui/rp-prefapps:: +The Recommended Software application which allows selected programs to be installed or removed. + +=== Debug + +https://github.com/raspberrypi/rpi-analyse-boot:: +A boot analysis service that gathers boot-time metrics from various different sources. + +=== Tools + +https://github.com/raspberrypi/rpi-imager:: +The code for the Raspberry Pi Imager application which flashes an operating system to an SD card. + +https://github.com/raspberrypi/rpi-image-gen:: +A build system for developing an operating system for an embedded Raspberry Pi system. + +https://github.com/raspberrypi/rpi-sb-provisioner:: +A tool to provision Raspberry Pi devices at manufacture, including secure boot and encrypted filesystems. + +https://github.com/raspberrypi/usbboot:: +A tool to boot a Raspberry Pi over USB for provisioning Compute Module and Raspberry Pi devices. + +=== Feedback + +http://github.com/raspberrypi/bookworm-feedback:: +A repo specifically reserved for bug-reporting for the current Raspberry Pi OS release. + +=== Raspberry Pi Pico + +https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico:: +This is where you can go to download and install the Microsoft Visual Studio Code extension for the Raspberry Pi Pico SDK. + +https://github.com/raspberrypi/pico-setup:: +Quick-start installation tool for the Raspberry Pi Pico SDK for command line use. + +https://github.com/raspberrypi/pico-sdk:: +The Raspberry Pi Pico SDK sources. + +https://github.com/raspberrypi/debugprobe:: +Sources for the Raspberry Pi Debug Probe, providing both SWD and UART easily. + +https://github.com/raspberrypi/openocd:: +The Raspberry Pi downstream OpenOCD sources. + +https://github.com/raspberrypi/pico-examples:: +Examples for Raspberry Pi Pico. + +https://github.com/raspberrypi/picotool:: +Tool for interacting with RP-series device(s) in BOOTSEL mode. diff --git a/documentation/asciidoc/computers/using_linux.adoc b/documentation/asciidoc/computers/using_linux.adoc deleted file mode 100644 index 60fcca31e6..0000000000 --- a/documentation/asciidoc/computers/using_linux.adoc +++ /dev/null @@ -1,20 +0,0 @@ -include::using_linux/using-the-terminal.adoc[] - -include::using_linux/filesystem-home.adoc[] - -include::using_linux/linux-using-commands.adoc[] - -include::using_linux/linux-using-text-editors.adoc[] - -include::using_linux/linux-multiple-users.adoc[] - -include::using_linux/linux-root-user.adoc[] - -include::using_linux/linux-bash.adoc[] - -include::using_linux/linux-scripting.adoc[] - -include::using_linux/linux-crontab.adoc[] - -include::using_linux/linux-systemd.adoc[] - diff --git a/documentation/asciidoc/computers/using_linux/filesystem-home.adoc b/documentation/asciidoc/computers/using_linux/filesystem-home.adoc deleted file mode 100644 index 6f59b2886c..0000000000 --- a/documentation/asciidoc/computers/using_linux/filesystem-home.adoc +++ /dev/null @@ -1,16 +0,0 @@ -== The Linux File System - -It is important to have a basic understanding of the fundamentals of the Linux file system: where your files are kept, where software is installed, where the danger zones are, and so on. For more information, please refer to the Linux https://wiki.debian.org/FilesystemHierarchyStandard[Filesystem Hierarchy Standard]. - -=== Home - -When you log into a Pi and open a terminal window, or you boot to the command line instead of the graphical user interface, you start in your home folder; this is located at `/home/pi`, assuming your username is `pi`. - -This is where the user's own files are kept. The contents of the user's desktop is in a directory here called `Desktop`, along with other files and folders. - -To navigate to your home folder on the command line, simply type `cd` and press `Enter`. This is the equivalent of typing `cd /home/pi`, where `pi` is your username. You can also use the tilde key (`~`), for example `cd ~`, which can be used to relatively link back to your home folder. For instance, `cd ~/Desktop/` is the same as `cd /home/pi/Desktop`. - -Navigate to `/home/` and run `ls`, and you'll see the home folders of each of the users on the system. - -Note that if logged in as the root user, typing `cd` or `cd ~` will take you to the xref:using_linux.adoc#root-and-sudo[root] user's home directory; unlike normal users, this is located at `/root/` not `/home/root/`. - diff --git a/documentation/asciidoc/computers/using_linux/images/lsresult.png b/documentation/asciidoc/computers/using_linux/images/lsresult.png deleted file mode 100644 index 10f34a161a..0000000000 Binary files a/documentation/asciidoc/computers/using_linux/images/lsresult.png and /dev/null differ diff --git a/documentation/asciidoc/computers/using_linux/images/terminal.png b/documentation/asciidoc/computers/using_linux/images/terminal.png deleted file mode 100644 index 83c8c44cf4..0000000000 Binary files a/documentation/asciidoc/computers/using_linux/images/terminal.png and /dev/null differ diff --git a/documentation/asciidoc/computers/using_linux/linux-bash.adoc b/documentation/asciidoc/computers/using_linux/linux-bash.adoc deleted file mode 100644 index db0d766a7d..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-bash.adoc +++ /dev/null @@ -1,52 +0,0 @@ -== The `.bashrc ` File - -In your home folder you will find a hidden file called `.bashrc` which contains some user configuration options. You can edit this file to suit your needs. Changes made in this file will be actioned the next time a terminal is opened, since that is when the `.bashrc` file is read. - -If you want your changes to take place in your current terminal, you can use either `source ~/.bashrc` or `exec bash`. These actually do slightly different things: the former simply re-executes the `.bashrc` file, which may result in undesirable changes to things like the path, the latter replaces the current shell with a new bash shell, which resets the shell back to the state at login, throwing away any shell variables you may have set. Choose whichever is most appropriate. - -Some useful adaptions are provided for you; some of these are commented out with a `#` by default. To enable them, remove the `#` and they will be active next time you boot your Pi or start a new terminal. - -For example, some `ls` aliases: - ----- -alias ls='ls --color=auto' -#alias dir='dir --color=auto' -#alias vdir='vdir --color=auto' - -alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' ----- - -Aliases like these are provided to help users of other systems like Microsoft Windows (`dir` is the `ls` of DOS/Windows). Others are to add colour to the output of commands like `ls` and `grep` by default. - -More variations of `ls` are also provided: - ----- -# some more ls aliases -#alias ll='ls -l' -#alias la='ls -A' -#alias l='ls -CF' ----- - -Ubuntu users may be familiar with these as they are provided by default on that distribution. Uncomment these lines to have access to these aliases in future. - -=== The `.bash_aliases` File - -`.bashrc` also contains a reference to a `.bash_aliases` file, which does not exist by default. You can add it to provide a handy way of keeping all your aliases in a separate file. - ----- -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi ----- - -The `if` statement here checks the file exists before including it. - -Then you just create the file `.bash_aliases` and add more aliases like so: - ----- -alias gs='git status' ----- - -You can add other things directly to this file, or to another and include that file like the `.bash_aliases` example above. diff --git a/documentation/asciidoc/computers/using_linux/linux-crontab.adoc b/documentation/asciidoc/computers/using_linux/linux-crontab.adoc deleted file mode 100644 index a0b79eb3ab..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-crontab.adoc +++ /dev/null @@ -1,67 +0,0 @@ -== Scheduling Tasks with Cron - -Cron is a tool for configuring scheduled tasks on Unix systems. It is used to schedule commands or scripts to run periodically and at fixed intervals. Tasks range from backing up the user's home folders every day at midnight, to logging CPU information every hour. - -The command `crontab` (cron table) is used to edit the list of scheduled tasks in operation, and is done on a per-user basis; each user (including `root`) has their own `crontab`. - -=== Editing the `crontab` File - -Run `crontab` with the `-e` flag to edit the cron table: - -[,bash] ----- -crontab -e ----- - -NOTE: The first time you run `crontab` you'll be prompted to select an editor; if you are not sure which one to use, choose `nano` by pressing `Enter`. - -=== Adding a Scheduled Task - -The layout for a cron entry is made up of six components: minute, hour, day of month, month of year, day of week, and the command to be executed. - ----- -# m h dom mon dow command ----- - ----- -# * * * * * command to execute -# ┬ ┬ ┬ ┬ ┬ -# │ │ │ │ │ -# │ │ │ │ │ -# │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) -# │ │ │ └────────── month (1 - 12) -# │ │ └─────────────── day of month (1 - 31) -# │ └──────────────────── hour (0 - 23) -# └───────────────────────── min (0 - 59) ----- - -For example: - ----- -0 0 * * * /home/pi/backup.sh ----- - -This cron entry would run the `backup.sh` script every day at midnight. - -=== Viewing Scheduled Tasks - -View your currently saved scheduled tasks with: - -[,bash] ----- -crontab -l ----- - -=== Running a Task on Reboot - -To run a command every time the Raspberry Pi starts up, write `@reboot` instead of the time and date. For example: - ----- -@reboot python /home/pi/myscript.py ----- - -This will run your Python script every time the Raspberry Pi reboots. If you want your command to be run in the background while the Raspberry Pi continues starting up, add a space and `&` at the end of the line, like this: - ----- -@reboot python /home/pi/myscript.py & ----- diff --git a/documentation/asciidoc/computers/using_linux/linux-multiple-users.adoc b/documentation/asciidoc/computers/using_linux/linux-multiple-users.adoc deleted file mode 100644 index 6d2f304307..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-multiple-users.adoc +++ /dev/null @@ -1,40 +0,0 @@ -== Linux Users - -User management in Raspberry Pi OS is done on the command line. The default user is `pi`, and the password is `raspberry`. You can add users and change each user's password. - -=== Changing your Password - -Once you're logged in as the `pi` user, it is highly advisable to use the `passwd` command to change the default password to improve your Pi's security. - -Enter `passwd` on the command line and press `Enter`. You'll be prompted to enter your current password to authenticate, and then asked for a new password. Press `Enter` on completion and you'll be asked to confirm it. Note that no characters will be displayed while entering your password. Once you've correctly confirmed your password, you'll be shown a success message (`passwd: password updated successfully`), and the new password will apply immediately. - -If your user has `sudo` permissions, you can change another user's password with `passwd` followed by the user's username. For example, `sudo passwd bob` will allow you to set the user ``bob``'s password, and then some additional optional values for the user such as their name. Just press `Enter` to skip each of these options. - -==== Remove a User's Password - -You can remove the password for the user `bob` with `sudo passwd bob -d`. Without a password the user will not be able to login to a Terminal. - -NOTE: This is useful for users that need to exist for system reasons, but you don't want it to be possible to login to the account for security reasons. - -=== Creating a New User - -You can create additional users on your Raspberry Pi OS installation with the `adduser` command. - -Enter `sudo adduser bob` and you'll be prompted for a password for the new user `bob`. Leave this blank if you don't want a password. - -==== Your Home Folder - -When you create a new user, they will have a home folder in `/home/`. The `pi` user's home folder is at `/home/pi/`. - -===== The `skel` Command - -Upon creating a new user, the contents of `/etc/skel/` will be copied to the new user's home folder. You can add or modify dot-files such as the `.bashrc` in `/etc/skel/` to your requirements, and this version will be applied to new users. - -=== Deleting a User - -You can delete a user on your system with the command `userdel`. Apply the `-r` flag to remove their home folder too: - -[,bash] ----- -sudo userdel -r bob ----- diff --git a/documentation/asciidoc/computers/using_linux/linux-root-user.adoc b/documentation/asciidoc/computers/using_linux/linux-root-user.adoc deleted file mode 100644 index dd6ef72263..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-root-user.adoc +++ /dev/null @@ -1,38 +0,0 @@ -== Root and Sudo - -The Linux operating system is a multi-user operating system which allows multiple users to log in and use the computer. To protect the computer (and the privacy of other users), the users' abilities are restricted. - -Most users are allowed to run most programs, and to save and edit files stored in their own home folder. Normal users are not normally allowed to edit files in other users' folders or any of the system files. There's a special user in Linux known as the *superuser*, which is usually given the username `root`. The superuser has unrestricted access to the computer and can do almost anything. - -=== The `sudo` Command - -You won't normally log into the computer as `root`, but you can use the `sudo` command to provide access as the superuser. If you log into your Raspberry Pi as the `pi` user, then you're logging in as a normal user. You can run commands as the `root` user by using the `sudo` command before the program you want to run. - -For example, if you want to install additional software on Raspberry Pi OS then you normally use the `apt` tool. To update the list of available software, you need to prefix the `apt` command with sudo: - -`sudo apt update` - -You can also run a superuser shell by using `sudo su`. When running commands as a superuser there's nothing to protect against mistakes that could damage the system. It's recommended that you only run commands as the superuser when required, and to exit a superuser shell when it's no longer needed. - -=== The Sudo'ers List - -The default `pi` user on Raspberry Pi OS is a member of the `sudo` group. This gives the ability to run commands as root when preceded by `sudo`, and to switch to the root user with `sudo su`. - -To add a new user to the `sudo` group, use the `adduser` command: - -[,bash] ----- -sudo adduser bob sudo ----- - -Note that the user `bob` will be prompted to enter their password when they run `sudo`. This differs from the behaviour of the `pi` user, since `pi` is not prompted for their password. If you wish to remove the password prompt from the new user, create a custom sudoers file and place it in the `/etc/sudoers.d` directory. - -. Create the file using `sudo visudo /etc/sudoers.d/010_bob-nopasswd`. -. Insert the following contents on a single line: `bob ALL=(ALL) NOPASSWD: ALL` -. Save the file and exit. - -Once you have exited the editor, the file will be checked for any syntax errors. If no errors were detected, the file will be saved and you will be returned to the shell prompt. If errors were detected, you will be asked 'what now?' Press the 'enter' key on your keyboard: this will bring up a list of options. You will probably want to use 'e' for '(e)dit sudoers file again,' so you can edit the file and fix the problem. - -NOTE: Choosing option 'Q' will save the file with any syntax errors still in place, which makes it impossible for _any_ user to use the sudo command. - -NOTE: It is standard practice on Linux to have the user prompted for their password when they run `sudo`, since it makes the system slightly more secure. \ No newline at end of file diff --git a/documentation/asciidoc/computers/using_linux/linux-scripting.adoc b/documentation/asciidoc/computers/using_linux/linux-scripting.adoc deleted file mode 100644 index d3de0c608b..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-scripting.adoc +++ /dev/null @@ -1,21 +0,0 @@ -== Shell Scripts - -Commands can be combined together in a file which can then be executed. As an example, copy the following into your favourite text editor: - -[,bash] ----- -#!/usr/bin/bash - -while : -do -echo Raspberry Pi! -done ----- - -Save this with the name `fun-script`. - -Before you can run it you must first make it executable; this can be done by using the change mode command `chmod`. Each file and directory has its own set of permissions that dictate what a user can and can't do to it. In this case, by running the command `chmod +x fun-script`, the file `fun-script` will now be executable. - -You can then run it by typing `./fun-script` (assuming that it's in your current directory). - -This script infinitely loops and prints `Raspberry Pi!`; to stop it, press `Ctrl + C`. This kills any command that's currently being run in the terminal. diff --git a/documentation/asciidoc/computers/using_linux/linux-systemd.adoc b/documentation/asciidoc/computers/using_linux/linux-systemd.adoc deleted file mode 100644 index 2cee90da22..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-systemd.adoc +++ /dev/null @@ -1,60 +0,0 @@ -== The `systemd` Daemon - -In order to have a command or program run when the Pi boots, you can add it as a service. Once this is done, you can start/stop enable/disable from the linux prompt. - -=== Creating a Service - -On your Pi, create a `.service` file for your service, for example: `myscript.service` - ----- -[Unit] -Description=My service -After=network.target - -[Service] -ExecStart=/usr/bin/python3 -u main.py -WorkingDirectory=/home/pi/myscript -StandardOutput=inherit -StandardError=inherit -Restart=always -User=pi - -[Install] -WantedBy=multi-user.target ----- - -So in this instance, the service would run Python 3 from our working directory `/home/pi/myscript` which contains our python program to run `main.py`. But you are not limited to Python programs: simply change the `ExecStart` line to be the command to start any program or script that you want running from booting. - -Copy this file into `/etc/systemd/system` as root, for example: - ----- -sudo cp myscript.service /etc/systemd/system/myscript.service ----- - -Once this has been copied, you have to inform `systemd` that a new service has been added. This is done with the following command: - ----- -sudo systemctl daemon-reload ----- - -Now you can attempt to start the service using the following command: - ----- -sudo systemctl start myscript.service ----- - -Stop it using following command: - ----- -sudo systemctl stop myscript.service ----- - -When you are happy that this starts and stops your app, you can have it start automatically on reboot by using this command: - ----- -sudo systemctl enable myscript.service ----- - -The `systemctl` command can also be used to restart the service or disable it from boot up. - -NOTE: The order in which things are started is based on their dependencies -- this particular script should start fairly late in the boot process, after a network is available (see the After section). You can configure different dependencies and orders based on your requirements. diff --git a/documentation/asciidoc/computers/using_linux/linux-using-commands.adoc b/documentation/asciidoc/computers/using_linux/linux-using-commands.adoc deleted file mode 100644 index 6dedab9e7f..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-using-commands.adoc +++ /dev/null @@ -1,157 +0,0 @@ -== Linux Commands - -Here are some fundamental and common Linux commands with example usage: - -=== Filesystem - -==== ls - -The `ls` command lists the content of the current directory (or one that is specified). It can be used with the `-l` flag to display additional information (permissions, owner, group, size, date and timestamp of last edit) about each file and directory in a list format. The `-a` flag allows you to view files beginning with `.` (i.e. dotfiles). - -==== cd - -Using `cd` changes the current directory to the one specified. You can use relative (i.e. `cd directoryA`) or absolute (i.e. `cd /home/pi/directoryA`) paths. - -==== pwd - -The `pwd` command displays the name of the present working directory: on a Raspberry Pi, entering `pwd` will output something like `/home/pi`. - -==== mkdir - -You can use `mkdir` to create a new directory, e.g. `mkdir newDir` would create the directory `newDir` in the present working directory. - -==== rmdir - -To remove empty directories, use `rmdir`. So, for example, `rmdir oldDir` will remove the directory `oldDir` only if it is empty. - -==== rm - -The command ``rm``removes the specified file (or recursively from a directory when used with `-r`). Be careful with this command: files deleted in this way are mostly gone for good! - -==== cp - -Using `cp` makes a copy of a file and places it at the specified location (this is similar to copying and pasting). For example, `cp ~/fileA /home/otherUser/` would copy the file `fileA` from your home directory to that of the user `otherUser` (assuming you have permission to copy it there). This command can either take `FILE FILE` (`cp fileA fileB`), `FILE DIR` (`cp fileA /directoryB/`) or `-r DIR DIR` (which recursively copies the contents of directories) as arguments. - -==== mv - -The `mv` command moves a file and places it at the specified location (so where `cp` performs a 'copy-paste', `mv` performs a 'cut-paste'). The usage is similar to `cp`. So `mv ~/fileA /home/otherUser/` would move the file `fileA` from your home directory to that of the user otherUser. This command can either take `FILE FILE` (`mv fileA fileB`), `FILE DIR` (`mv fileA /directoryB/`) or `DIR DIR` (`mv /directoryB /directoryC`) as arguments. This command is also useful as a method to rename files and directories after they've been created. - -==== touch - -The command `touch` sets the last modified time-stamp of the specified file(s) or creates it if it does not already exist. - -==== cat - -You can use `cat` to list the contents of file(s), e.g. `cat thisFile` will display the contents of `thisFile`. Can be used to list the contents of multiple files, i.e. `cat *.txt` will list the contents of all `.txt` files in the current directory. - -==== head - -The `head` command displays the beginning of a file. Can be used with `-n` to specify the number of lines to show (by default ten), or with `-c` to specify the number of bytes. - -==== tail - -The opposite of `head`, `tail` displays the end of a file. The starting point in the file can be specified either through `-b` for 512 byte blocks, `-c` for bytes, or `-n` for number of lines. - -==== chmod - -You would normally use `chmod` to change the permissions for a file. The `chmod` command can use symbols `u` (user that owns the file), `g` (the files group) , and `o` (other users) and the permissions `r` (read), `w` (write), and `x` (execute). Using `chmod u+x *filename*` will add execute permission for the owner of the file. - -==== chown - -The `chown` command changes the user and/or group that owns a file. It normally needs to be run as root using sudo e.g. `sudo chown pi:root *filename*` will change the owner to pi and the group to root. - -==== ssh - -`ssh` denotes the secure shell. Connect to another computer using an encrypted network connection. -For more details see xref:remote-access.adoc#ssh[SSH (secure shell)] - -==== scp - -The `scp` command copies a file from one computer to another using `ssh`. -For more details see xref:remote-access.adoc#using-secure-copy[SCP (secure copy)] - -==== sudo - -The `sudo` command enables you to run a command as a superuser, or another user. Use `sudo -s` for a superuser shell. -For more details see xref:using_linux.adoc#root-and-sudo[Root user / sudo] - -==== dd - -The `dd` command copies a file converting the file as specified. It is often used to copy an entire disk to a single file or back again. So, for example, `dd if=/dev/sdd of=backup.img` will create a backup image from an SD card or USB disk drive at /dev/sdd. Make sure to use the correct drive when copying an image to the SD card as it can overwrite the entire disk. - -==== df - -Use `df` to display the disk space available and used on the mounted filesystems. Use `df -h` to see the output in a human-readable format using M for MBs rather than showing number of bytes. - -==== unzip - -The `unzip` command extracts the files from a compressed zip file. - -==== tar - -Use `tar` to store or extract files from a tape archive file. It can also reduce the space required by compressing the file similar to a zip file. - -To create a compressed file, use `tar -cvzf *filename.tar.gz* *directory/*` -To extract the contents of a file, use `tar -xvzf *filename.tar.gz*` - -==== pipes - -A pipe allows the output from one command to be used as the input for another command. The pipe symbol is a vertical line `|`. For example, to only show the first ten entries of the `ls` command it can be piped through the head command `ls | head` - -==== tree - -Use the `tree` command to show a directory and all subdirectories and files indented as a tree structure. - -==== & - -Run a command in the background with `&`, freeing up the shell for future commands. - -==== wget - -Download a file from the web directly to the computer with `wget`. So `+wget https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-datasheet.pdf+` will download the Raspberry Pi 4 datasheet and save it as `raspberry-pi-4-datasheet.pdf`. - -==== curl - -Use `curl` to download or upload a file to/from a server. By default, it will output the file contents of the file to the screen. - -==== man - -Show the manual page for a file with `man`. To find out more, run `man man` to view the manual page of the man command. - -=== Search - -==== grep - -Use `grep` to search inside files for certain search patterns. For example, `grep "search" *.txt` will look in all the files in the current directory ending with .txt for the string search. - -The `grep` command supports regular expressions which allows special letter combinations to be included in the search. - -==== awk - -`awk` is a programming language useful for searching and manipulating text files. - -==== find - -The `find` command searches a directory and subdirectories for files matching certain patterns. - -==== whereis - -Use `whereis` to find the location of a command. It looks through standard program locations until it finds the requested command. - -=== Networking - -==== ping - -The `ping` utility is usually used to check if communication can be made with another host. It can be used with default settings by just specifying a hostname (e.g. `ping raspberrypi.org`) or an IP address (e.g. `ping 8.8.8.8`). It can specify the number of packets to send with the `-c` flag. - -==== nmap - -`nmap` is a network exploration and scanning tool. It can return port and OS information about a host or a range of hosts. Running just `nmap` will display the options available as well as example usage. - -==== hostname - -The `hostname` command displays the current hostname of the system. A privileged (super) user can set the hostname to a new one by supplying it as an argument (e.g. `hostname new-host`). - -==== ifconfig - -Use `ifconfig` to display the network configuration details for the interfaces on the current system when run without any arguments (i.e. `ifconfig`). By supplying the command with the name of an interface (e.g. `eth0` or `lo`) you can then alter the configuration: check the manual page for more details. diff --git a/documentation/asciidoc/computers/using_linux/linux-using-text-editors.adoc b/documentation/asciidoc/computers/using_linux/linux-using-text-editors.adoc deleted file mode 100644 index 7b62ff0389..0000000000 --- a/documentation/asciidoc/computers/using_linux/linux-using-text-editors.adoc +++ /dev/null @@ -1,58 +0,0 @@ -== Text Editors -:pp: {plus}{plus} - -On Linux, you have a choice of text editors. Some are easy-to-use but have limited functionality; others require training to use and take a long time to master, but offer incredible functionality. - -=== Text Editors on Desktop - -==== Text Editor - -When using Raspberry Pi OS Desktop, in the accessories menu there is an option to run a Text Editor. This is a simple editor which opens in a window like a normal application. It allows use of the mouse and keyboard, and has tabs and syntax highlighting. - -You can use keyboard shortcuts, such as `Ctrl + S` to save a file and `Ctrl + X` to exit. - -==== Thonny - -https://thonny.org/[Thonny] is a Python REPL and IDE, so you can write and edit Python code in a window and run it directly from the editor. Thonny has independent windows, and syntax highlighting, and uses Python 3. - -==== Geany - -A fast and lightweight IDE, supporting many different file types, including C/C{pp} and Python. It is installed by default on Raspberry Pi OS. - -=== Text Editors in the Terminal - -==== Nano - -GNU Nano is at the easy-to-use end of command-line editors. It's installed by default, so use `nano somefile.txt` to edit a file, and keyboard shortcuts like `Ctrl + O` to save and `Ctrl + X` to exit. - -==== Vi - -Vi is a very old (c. 1976) command-line editor, which is available on most UNIX systems and is pre-installed on Raspberry Pi OS. It's succeeded by Vim (Vi Improved), which requires installation. - -Unlike most editors, Vi and Vim have a number of different modes. When you open Vi with `vi somefile.txt`, you start in command mode which doesn't directly permit text entry. Press `i` to switch to insert mode in order to edit the file, and type away. To save the file you must return to command mode, so press the `Escape` key and enter `:w` (followed by `Enter`), which is the command to write the file to disk. - -To search for the word 'raspberry' in a file, make sure you're in command mode (press `Escape`), then type `/raspberry` followed by `n` and `N` to flick forwards/backwards through the results. - -To save and exit, enter the command `:wq`. To exit without saving, enter the command `:q!`. - -Depending on your keyboard configuration, you may find your cursor keys don't work. In this case, you can use the H-J-K-L keys (which move left, down, up, and right respectively) to navigate the file in command mode. - -==== Vim - -Vim is an extension of Vi and works in much the same way, with a number of improvements. Only Vi is installed by default so to get the full features of Vim, install it with APT: - ----- -sudo apt install vim ----- - -You can edit a file in Vim with `vim somefile.txt`. - -==== Emacs - -Emacs is a GNU command-line text editor; it's powerful, extensible, and customisable. You can install it with APT: - ----- -sudo apt install emacs ----- - -You can use keyboard combination commands, such as `Ctrl + X Ctrl + S` to save and `Ctrl + X Ctrl + C` to close. diff --git a/documentation/asciidoc/computers/using_linux/using-the-terminal.adoc b/documentation/asciidoc/computers/using_linux/using-the-terminal.adoc deleted file mode 100644 index 4adfaff2bd..0000000000 --- a/documentation/asciidoc/computers/using_linux/using-the-terminal.adoc +++ /dev/null @@ -1,64 +0,0 @@ -== Terminal - -The terminal (or 'command-line') on a computer allows a user a great deal of control over their system. Users of Windows may already have come across `Command Prompt` or `Powershell`, while mac OS users may be familiar with `Terminal`. All of these tools allow a user to directly manipulate their system through the use of commands. These commands can be chained together and/or combined together into complex xref:using_linux.adoc#shell-scripts[scripts] that can potentially complete tasks more efficiently than much larger traditional software packages. - -=== Opening a Terminal window - -On the Raspberry Pi OS, the default terminal application is called `LXTerminal`. This is known as a 'terminal emulator', this means that it emulates the old style video terminals — from before Windowing systems were developed — inside a graphical environment. The application can be found on the Raspberry Pi desktop, and when started will look something like this: - -image::images/terminal.png[Terminal screenshot] - -In the terminal window you should be able to see the following prompt: - -[source,bash] ----- -pi@raspberrypi ~ $ ----- - -This shows your username and the hostname of the Pi. Here the username is `pi` and the hostname is `raspberrypi`. - -=== Navigating and browsing your Pi - -One of the key aspects of using a terminal is being able to navigate your file system. Go ahead and type `ls -la` into the Terminal window, and then hit the RETURN key. You should see something similar to: - -image::images/lsresult.png[ls result] - -The `ls` command lists the contents of the directory that you are currently in (your present working directory). The `-la` component of the command is what's known as a 'flag'. Flags modify the command that's being run. In this case the `l` displays the contents of the directory in a list, showing data such as their sizes and when they were last edited, and the `a` displays all files, including those beginning with a `.`, known as 'dotfiles'. Dotfiles usually act as configuration files for software and as they are written in text, they can be modified by simply editing them. - -In order to navigate to other directories the change directory command, `cd`, can be used. You can specify the directory that you want to go to by either the 'absolute' or the 'relative' path. So if you wanted to navigate to the `python_games` directory, you could either do `cd /home/pi/python_games` or just `cd python_games` (if you are currently in `/home/pi`). There are some special cases that may be useful: `~` acts as an alias for your home directory, so `~/python_games` is the same as `/home/pi/python_games`; `.` and `..` are aliases for the current directory and the parent directory respectively, e.g. if you were in `/home/pi/python_games`, `cd ..` would take you to `/home/pi`. - -=== History and auto-complete - -Rather than type every command, the terminal allows you to scroll through previous commands that you've run by pressing the `up` or `down` keys on your keyboard. If you are writing the name of a file or directory as part of a command then pressing `tab` will attempt to auto-complete the name of what you are typing. For example, if you have a file in a directory called `aLongFileName` then pressing tab after typing `a` will allow you to choose from all file and directory names beginning with `a` in the current directory, allowing you to choose `aLongFileName`. - -=== The `sudo` command - -Some commands that make permanent changes to the state of your system require you to have root privileges to run. The command `sudo` temporarily gives your account (if you're not already logged in as root) the ability to run these commands, provided your user name is in a list of users ('sudoers'). When you append `sudo` to the start of a command and press `enter`, the command following `sudo` will be run using root privileges. Be very careful: commands requiring root privileges can irreparably damage your system! Note that on some systems you will be prompted to enter your password when you run a command with `sudo`. - -Further information on `sudo` and the root user can be found on the xref:using_linux.adoc#root-and-sudo[linux root page]. - -=== Installing software using `apt` - -You can use the xref:os.adoc#using-apt[`apt`] command to install software in Raspberry Pi OS. This is the 'package manager' that is included with any Debian-based Linux distributions, including Raspberry Pi OS. It allows you to install and manage new software packages on your Raspberry Pi. - -In order to install a new package, you would type `sudo apt install `, where `` is the package that you want to install. - -Running `sudo apt update` will update a list of software packages that are available on your system. If a new version of a package is available, then `sudo apt full-upgrade` will update any old packages to the new version. - -Finally, `sudo apt remove ` removes or uninstalls a package from your system. - -=== Other useful commands - -There are a few other commands that you may find useful, these are listed below: - -* `cp` makes a copy of a file and places it at the specified location (essentially doing a 'copy-paste'), for example - `cp file_a /home/other_user/` would copy the file `file_a` from your home directory to that of the user `other_user` (assuming you have permission to copy it there). Note that if the target is a folder, the filename will remain the same, but if the target is a filename, it will give the file the new name. -* `mv` moves a file and places it at the specified location (so where `cp` performs a 'copy-paste', `mv` performs a 'cut-paste'). The usage is similar to `cp`, so `mv file_a /home/other_user/` would move the file `file_a` from your home directory to that of the specified user. `mv` is also used to rename a file, i.e. move it to a new location, e.g. `mv hello.txt story.txt`. -* `rm` removes the specified file (or directory when used with `-r`). *Warning:* Files deleted in this way are generally not restorable. -* `mkdir`: This makes a new directory, e.g. `mkdir new_dir` would create the directory `new_dir` in the present working directory. -* `cat` lists the contents of files, e.g. `cat some_file` will display the contents of `some_file`. - -Other commands you may find useful can be found in the xref:using_linux.adoc#linux-commands[commands page]. - -=== Finding out about a command - -To find out more information about a particular command then you can run the `man` followed by the command you want to know more about (e.g. `man ls`). The man-page (or manual page) for that command will be displayed, including information about the flags for that program and what effect they have. Some man-pages will give example usage. diff --git a/documentation/asciidoc/microcontrollers/c_sdk.adoc b/documentation/asciidoc/microcontrollers/c_sdk.adoc new file mode 100644 index 0000000000..2211b8b010 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/c_sdk.adoc @@ -0,0 +1,7 @@ +include::c_sdk/sdk_setup.adoc[] + +include::c_sdk/official_sdk.adoc[] + +include::c_sdk/your_first_binary.adoc[] + +include::c_sdk/quick_start.adoc[] \ No newline at end of file diff --git a/documentation/asciidoc/microcontrollers/c_sdk/images/Blink-an-LED.webm b/documentation/asciidoc/microcontrollers/c_sdk/images/Blink-an-LED.webm new file mode 100644 index 0000000000..5d1c3df81b Binary files /dev/null and b/documentation/asciidoc/microcontrollers/c_sdk/images/Blink-an-LED.webm differ diff --git a/documentation/asciidoc/microcontrollers/c_sdk/images/Hello-World.webm b/documentation/asciidoc/microcontrollers/c_sdk/images/Hello-World.webm new file mode 100644 index 0000000000..e6d5e34abd Binary files /dev/null and b/documentation/asciidoc/microcontrollers/c_sdk/images/Hello-World.webm differ diff --git a/documentation/asciidoc/microcontrollers/c_sdk/official_sdk.adoc b/documentation/asciidoc/microcontrollers/c_sdk/official_sdk.adoc new file mode 100644 index 0000000000..691c6511a4 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/c_sdk/official_sdk.adoc @@ -0,0 +1,27 @@ +== Raspberry Pi Pico C/C++ SDK + +Our official C SDK can be used from the command line, or from popular integrated development environments like Visual Studio Code, Eclipse, and CLion. To get started, download our C/{cpp} SDK and Examples, and take a look at our 'https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[getting started]' documentation. Or for a quick setup see the next section. + +You can find documentation around the C/{cpp} SDK at: + +https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico-series]:: C/{cpp} development with Raspberry Pi Pico, Pico 2, and other Raspberry Pi microcontroller-based boards + +https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf[Connecting to the Internet with Raspberry Pi Pico W]:: Getting Raspberry Pi Pico W online with C/{cpp} or MicroPython + +https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf[Raspberry Pi Pico-series C/{cpp} SDK]:: Libraries and tools for C/{cpp} development on Raspberry Pi microcontrollers + +xref:../pico-sdk/index_doxygen.adoc[API level documentation]:: Documentation for the Raspberry Pi Pico C/{cpp} SDK + +https://github.com/raspberrypi/pico-examples[The pico-examples repository]:: Example projects + +SDK source code is open source, available via the https://github.com/raspberrypi/pico-sdk[pico-sdk Github repository]. + +[NOTE] +==== +To build applications with the C/{cpp} SDK for a board _other than the Raspberry Pi Pico_, pass `-DPICO_BOARD=boardname` to CMake, where `boardname` is the name of your board. For example: + +* to build an application for the Adafruit Feather RP2040, pass `-DPICO_BOARD=adafruit_feather_rp2040` +* to build an application for Pico W, pass `-DPICO_BOARD=pico_w` (in addition to -DWIFI_SSID="Your Network" -DWIFI_PASSWORD="Your Password", should you wish to connect to a wireless network) + +For more information, see the https://github.com/raspberrypi/pico-sdk/tree/master/src/boards[`boards/` directory] in the Raspberry Pi Pico SDK and the https://forums.raspberrypi.com/viewtopic.php?f=147&t=304393[forums]. +==== diff --git a/documentation/asciidoc/microcontrollers/c_sdk/quick_start.adoc b/documentation/asciidoc/microcontrollers/c_sdk/quick_start.adoc new file mode 100644 index 0000000000..b36220c807 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/c_sdk/quick_start.adoc @@ -0,0 +1,94 @@ +== Quick-start your own project + +NOTE: The following instructions are terse, and Linux-based only. For detailed steps, instructions for other platforms, and just in general, we recommend you see the https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico] and https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf[Raspberry Pi Pico C/{cpp} SDK] books. + +Install CMake (at least version 3.13), and GCC cross compiler + +[source,console] +---- +$ sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib +---- + +Set up your project to point to use the Raspberry Pi Pico SDK by cloning the SDK locally: + +[source,console] +---- +$ git clone https://github.com/raspberrypi/pico-sdk.git +---- + +Copy `external/pico_sdk_import.cmake` from the SDK into your project directory + +Set `PICO_SDK_PATH` to the SDK location in your environment, or pass it (`-DPICO_SDK_PATH=`) to `cmake` later. + +Setup a `CMakeLists.txt` like: + +---- +cmake_minimum_required(VERSION 3.13) + +# initialize the SDK based on PICO_SDK_PATH +# note: this must happen before project() +include(pico_sdk_import.cmake) + +project(my_project) + +# initialize the Raspberry Pi Pico SDK +pico_sdk_init() + +# rest of your project +---- + +Go ahead and write your code, see https://github.com/raspberrypi/pico-examples[pico-examples] or the https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf[Raspberry Pi Pico C/{cpp} SDK] book for more information on how to go about that. + +About the simplest you can do is a single source file (e.g. `hello_world.c`) + +[source,c] +---- +#include +#include "pico/stdlib.h" + +int main() { + setup_default_uart(); + printf("Hello, world!\n"); + return 0; +} +---- + +and add the following to your CMakeLists.txt: + +---- +add_executable(hello_world + hello_world.c +) + +# Add pico_stdlib library which aggregates commonly used features +target_link_libraries(hello_world pico_stdlib) + +# create map/bin/hex/uf2 file in addition to ELF. +pico_add_extra_outputs(hello_world) +---- + +NOTE: This example uses the default UART for stdout; if you want to use the default USB see the hello-usb example. + +Setup a CMake build directory. For example, if not using an IDE: + +[source,console] +---- +$ mkdir build +$ cd build +$ cmake .. +---- + +When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the cmake command above, e.g. cmake `-DPICO_BOARD=pico_w ..` to configure the SDK and build options accordingly for that particular board. + +Doing so sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain cases also enables the use of additional libraries (e.g. wireless support when building for `PICO_BOARD=pico_w`) which cannot be built without a board which provides the requisite functionality. + +For a list of boards defined in the SDK itself, look in https://github.com/raspberrypi/pico-sdk/blob/master/src/boards/include/boards[this directory] which has a header for each named board. + +Make your target from the build directory you created. + +[source,console] +---- +$ make hello_world +---- + +You now have `hello_world.elf` to load via a debugger, or `hello_world.uf2` that can be installed and run on your Raspberry Pi Pico via drag and drop. diff --git a/documentation/asciidoc/microcontrollers/c_sdk/sdk_setup.adoc b/documentation/asciidoc/microcontrollers/c_sdk/sdk_setup.adoc new file mode 100644 index 0000000000..e59fbc857e --- /dev/null +++ b/documentation/asciidoc/microcontrollers/c_sdk/sdk_setup.adoc @@ -0,0 +1,6 @@ +== SDK Setup + +For a full walk-through of how to get going with the C/{cpp} SDK, you should read our 'https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[getting started]' documentation. However, if you are intending to develop for Pico on a xref:../computers/os.adoc[Raspberry Pi], then you can set up the C/{cpp} toolchain quickly by running our https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh[setup script] from the command line. + +NOTE: You should make sure the OS on your Raspberry Pi is xref:../computers/os.adoc#update-software[up to date] before running the setup script. + diff --git a/documentation/asciidoc/microcontrollers/c_sdk/your_first_binary.adoc b/documentation/asciidoc/microcontrollers/c_sdk/your_first_binary.adoc new file mode 100644 index 0000000000..9beb1fc8e7 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/c_sdk/your_first_binary.adoc @@ -0,0 +1,40 @@ +== Your First Binaries + +=== Blink an LED + +The first program anyone writes when using a new microcontroller is to blink an LED on and off. The Raspberry Pi Pico comes with a single LED on-board. The LED is connected to `GP25` on the board's Raspberry Pi RP2040 for Pico, and `WL_GPIO0` on the Infineon 43439 wireless chip for Pico W. + +video::images/Blink-an-LED.webm[width="80%"] + +You can blink this on and off by, + +. Download the Blink UF2 https://datasheets.raspberrypi.com/soft/blink.uf2[for Raspberry Pi Pico], or https://datasheets.raspberrypi.com/soft/blink_picow.uf2[for Pico W]. +. Push and hold the BOOTSEL button and plug your Pico into the USB port of your Raspberry Pi or other computer. +. It will mount as a Mass Storage Device called RPI-RP2. +. Drag and drop the Blink UF2 binary onto the RPI-RP2 volume. Pico will reboot. + +You should see the on-board LED blinking. + +You can see the code on Github for the https://github.com/raspberrypi/pico-examples/blob/master/blink/blink.c[Raspberry Pi Pico] and https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/blink/picow_blink.c[Pico W] versions. + +=== Say "Hello World" + +The next program anyone writes is to say 'Hello World' over a USB serial connection. + +video::images/Hello-World.webm[width="80%"] + +. Download the https://datasheets.raspberrypi.com/soft/hello_world.uf2['Hello World' UF2]. +. Push and hold the BOOTSEL button and plug your Pico into the USB port of your Raspberry Pi or other computer. +. It will mount as a Mass Storage Device called RPI-RP2. +. Drag and drop the 'Hello World' UF2 binary onto the RPI-RP2 volume. Pico will reboot. +. Open a Terminal window and type: ++ +[source,console] +------ +$ sudo apt install minicom +$ minicom -b 115200 -o -D /dev/ttyACM0 +------ + +You should see 'Hello, world!' printed to the Terminal. + +You can see the code https://github.com/raspberrypi/pico-examples/blob/master/hello_world/usb/hello_usb.c[on Github] diff --git a/documentation/asciidoc/microcontrollers/debug-probe.adoc b/documentation/asciidoc/microcontrollers/debug-probe.adoc new file mode 100644 index 0000000000..230b7a8c52 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe.adoc @@ -0,0 +1,13 @@ +include::debug-probe/introduction.adoc[] + +include::debug-probe/getting-started.adoc[] + +include::debug-probe/installing-tools.adoc[] + +include::debug-probe/swd-connection.adoc[] + +include::debug-probe/uart-connection.adoc[] + +include::debug-probe/updating-firmware.adoc[] + +include::debug-probe/schematics.adoc[] \ No newline at end of file diff --git a/documentation/asciidoc/microcontrollers/debug-probe/getting-started.adoc b/documentation/asciidoc/microcontrollers/debug-probe/getting-started.adoc new file mode 100644 index 0000000000..54fcb5d347 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/getting-started.adoc @@ -0,0 +1,20 @@ +== Getting started + +image:images/labelled-wiring.jpg[width="100%"] + +Depending on your setup, there are several ways to wire the Debug Probe to a xref:pico-series.adoc[Pico-series device]. Below, we connect the Debug Probe to a Raspberry Pi Pico H which has the newer three-pin JST-SH connector for SWD. + +video::4RCZBZsfsek[youtube,width=80%,height=400px] + +Connect the following: + +* The Debug Probe "D" port to Pico H SWD JST-SH connector +* The Debug Probe "U" port, with the three-pin JST-SH connector to 0.1-inch header (male): +** Debug Probe `RX` connected to Pico H `TX` pin +** Debug Probe `TX` connected to Pico H `RX` pin +** Debug Probe `GND` connected to Pico H `GND` pin + +NOTE: If you have a non-H Pico or Pico W (without a JST-SH connector) you can still connect it to a Debug Probe. Solder a male connector to the `SWCLK`, `GND`, and `SWDIO` header pins on the board. Using the alternate 3-pin JST-SH connector to 0.1-inch header (female) cable included with the Debug Probe, connect to the Debug Probe "D" port. Connect `SWCLK`, `GND`, and `SWDIO` on the Pico or Pico W to the `SC`, `GND`, and `SD` pins on the Debug Probe, respectively. + +image:images/wiring.png[width="70%"] + diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/debug-leds.png b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-leds.png new file mode 100644 index 0000000000..063bc43bc0 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-leds.png differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe-tps.jpg b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe-tps.jpg new file mode 100644 index 0000000000..5e641c82ac Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe-tps.jpg differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe.jpg b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe.jpg new file mode 100644 index 0000000000..efd98c6c91 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/debug-probe.jpg differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/description.jpg b/documentation/asciidoc/microcontrollers/debug-probe/images/description.jpg new file mode 100644 index 0000000000..4f3d8df211 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/description.jpg differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/labelled-wiring.jpg b/documentation/asciidoc/microcontrollers/debug-probe/images/labelled-wiring.jpg new file mode 100644 index 0000000000..81a0c3b1a2 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/labelled-wiring.jpg differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/the-probe.png b/documentation/asciidoc/microcontrollers/debug-probe/images/the-probe.png new file mode 100644 index 0000000000..32f1d6f89f Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/the-probe.png differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/wiring-real.jpg b/documentation/asciidoc/microcontrollers/debug-probe/images/wiring-real.jpg new file mode 100644 index 0000000000..80f89a6305 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/wiring-real.jpg differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/images/wiring.png b/documentation/asciidoc/microcontrollers/debug-probe/images/wiring.png new file mode 100644 index 0000000000..28302214f0 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/debug-probe/images/wiring.png differ diff --git a/documentation/asciidoc/microcontrollers/debug-probe/installing-tools.adoc b/documentation/asciidoc/microcontrollers/debug-probe/installing-tools.adoc new file mode 100644 index 0000000000..4ade8e9ca6 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/installing-tools.adoc @@ -0,0 +1,12 @@ +== Install tools + +To use the Debug Probe, OpenOCD and the GNU Project Debugger (GDB) are required. An Integrated Development Environment (IDE) may also be useful. + +On Raspberry Pi OS, most Linux variants, macOS, and Microsoft Windows, it is recommended to install our VS Code extension. This extension bundles OpenOCD, ARM toolchains, GDB, and register definitions for Pico-series microcontrollers. + +See Chapter 3 of our https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting Started with Raspberry Pi Pico] guide. + +Alternatively, tools can be manually installed by following Appendix C in the guide. + +NOTE: Manual installation of the tools on Windows is not recommended. + diff --git a/documentation/asciidoc/microcontrollers/debug-probe/introduction.adoc b/documentation/asciidoc/microcontrollers/debug-probe/introduction.adoc new file mode 100644 index 0000000000..80e0f9fbaf --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/introduction.adoc @@ -0,0 +1,41 @@ +== About the Debug Probe + +image::images/debug-probe.jpg[width="100%"] + +The Raspberry Pi Debug Probe is a USB device that provides both a UART serial port and a standard Arm Serial Wire Debug (SWD) interface. The probe is designed for easy, solderless, plug-and-play debugging. It has the following features: + +* USB to ARM https://developer.arm.com/documentation/ihi0031/a/The-Serial-Wire-Debug-Port\--SW-DP-/Introduction-to-the-ARM-Serial-Wire-Debug\--SWD\--protocol[Serial Wire Debug] (SWD) port +* USB to UART bridge +* Compatible with the https://developer.arm.com/documentation/101451/0100/About-CMSIS-DAP[CMSIS-DAP] standard +* Works with https://openocd.org/[OpenOCD] and other tools supporting CMSIS-DAP +* Open source, easily upgradeable firmware + +NOTE: For more information on the Raspberry Pi three-pin debug connector see the https://rptl.io/debug-spec[specification]. + +This makes it easy to use a Raspberry Pi Pico on platforms such as Windows, macOS, and Linux that lack a GPIO header to connect directly to the Pico's serial UART or SWD port. + +=== The Debug Probe + +The probe operates at 3.3V nominal I/O voltage. + +image:images/the-probe.png[width="70%"] + +Included with the Debug Probe is a USB power cable and three debug cables: + +* three-pin JST-SH connector to 3-pin JST-SH connector cable +* three-pin JST-SH connector to 0.1-inch header (female) +* three-pin JST-SH connector to 0.1-inch header (male) + +The two 0.1-inch header cables — intended for breadboard (male) or direct connection to a board with header pins (female) — are coloured as below: + +Orange:: TX/SC (Output from Probe) +Black:: GND +Yellow:: RX/SD (Input to Probe or I/O) + +While the cable with three-pin JST-SH connectors is intended to be used with the https://rptl.io/debug-spec[standard three-pin connector] which newer Raspberry Pi boards use for the SWD debug port and UART connectors. + +The Debug Probe has five LEDs, a red LED to indicate power, and four more activity indicator LEDs + +image::images/debug-leds.png[width="70%"] + +NOTE: OpenOCD switches both DAP LEDs on when the target is connected, and turns them off when it calls `DAP_DISCONNECT`. diff --git a/documentation/asciidoc/microcontrollers/debug-probe/schematics.adoc b/documentation/asciidoc/microcontrollers/debug-probe/schematics.adoc new file mode 100644 index 0000000000..61bd752d2d --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/schematics.adoc @@ -0,0 +1,10 @@ +== Schematics + +Schematics and mechanical drawing of the Debug Probe are available: + +* https://datasheets.raspberrypi.com/debug/raspberry-pi-debug-probe-schematics.pdf[Schematics] (PDF) +* https://datasheets.raspberrypi.com/debug/raspberry-pi-debug-probe-mechanical-drawing.pdf[Mechanical Diagram] (PDF) + +The test point (TP) shown on the schematics are located as shown in the diagram below. + +image::images/debug-probe-tps.jpg[width="70%"] \ No newline at end of file diff --git a/documentation/asciidoc/microcontrollers/debug-probe/swd-connection.adoc b/documentation/asciidoc/microcontrollers/debug-probe/swd-connection.adoc new file mode 100644 index 0000000000..33a5f0a2f3 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/swd-connection.adoc @@ -0,0 +1,61 @@ +== Starting a Debug Session + +The Debug Probe will let you load binaries via the SWD port and OpenOCD: you will not need to unplug, and then push-and-hold, the BOOTSEL button every time you push a new binary to your Pico. Using the Debug Probe to upload new binaries is an entirely hands-off affair. + +GDB is then used to debug the binary running on the Pico. + +We recommend the use of the Raspberry Pi Pico VSCode extension, which integrates the use of OpenOCD and GDB, to upload and debug programs. See Chapter 4 of https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico] for more information. + +=== Standalone program upload + +Once you have built a binary: + +[source,console] +---- +$ sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit" +---- + +NOTE: When you use the Debug Probe to upload a binary the ELF version of the file is used, not the UF2 file that you would use when you drag-and-drop. + +=== Standalone debug session + +This will use `openocd` in server mode, and connect GDB, which gives you breakpoints and single-step over a console interface. + +[IMPORTANT] +====== +To allow debugging, you must build your binaries as `Debug` rather than `Release` build type, e.g. + +---- +$ cd ~/pico/pico-examples/ +$ rm -rf build +$ mkdir build +$ cd build +$ export PICO_SDK_PATH=../../pico-sdk +$ cmake -DCMAKE_BUILD_TYPE=Debug .. +$ cd blink +$ make -j4 +---- + +In a debug build you will get more information when you run it under the debugger, as the compiler builds your program with the information to tell GDB what your program is doing. +====== + +NOTE: For computers that are _not_ Raspberry Pis, a variant of GDB that can debug ARM processors is required. Use one of the following alternatives depending on your operating system and device: +* On Linux devices, use `gdb-multiarch`. +* On macOS and Windows devices, use `arm-none-eabi-gdb` from the toolchain on https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads[Arm's website] + +To start an OpenOCD server, run the following command: + +[source,console] +---- +$ sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" +---- + +Then open a second terminal window, switch to the directory containing your built binary, and start a debugger to attach it to the OpenOCD server: + +[source,console] +---- +$ gdb blink.elf +> target remote localhost:3333 +> monitor reset init +> continue +---- diff --git a/documentation/asciidoc/microcontrollers/debug-probe/uart-connection.adoc b/documentation/asciidoc/microcontrollers/debug-probe/uart-connection.adoc new file mode 100644 index 0000000000..ebc84205d4 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/uart-connection.adoc @@ -0,0 +1,59 @@ +== Serial connections + +Ensure that the Debug Probe is connected to the UART pins of your Raspberry Pi Pico. + +image:images/wiring.png[width="80%"] + +The default pins for Raspberry Pi Pico UART0 are as follows: + +[cols="1,1,1"] +|=== +| Default UART0 | Physical Pin | GPIO Pin + +| GND | 3 | N/A +| UART0_TX | 1 | GP0 +| UART0_RX | 2 | GP1 +|=== + +Once connected, traffic over the Raspberry Pi Pico's UART will be relayed to your computer by the Debug Probe and exposed as a CDC UART. On a Raspberry Pi this will show up as `/dev/ttyACM0`; on other platforms this serial port will show up differently (e.g. on macOS it will appear as `/dev/cu.usbmodemXXXX`). + +If you have not already done so you should install minicom: + +[source,console] +---- +$ sudo apt install minicom +---- + +and open the serial port: + +[source,console] +---- +$ minicom -b 115200 -o -D /dev/ttyACM0 +---- + +TIP: To exit `minicom`, use CTRL-A followed by X. + +To test serial communication you can build and upload the "Hello World" example application. + +Change directory into the `hello_world` directory inside the `pico-examples` tree, and run `make`. Afterwards, you can upload it to your Raspberry Pi Pico using `openocd`. For a full walkthrough of building the `hello_serial` example program, see Chapter 4 of https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico]. + +[source,console] +---- +$ cd pico-examples +$ mkdir build +$ cd build +$ export PICO_SDK_PATH=../../pico-sdk +$ cmake .. +$ cd hello_world/serial +$ make -j4 +$ sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "program hello_serial.elf verify reset exit" +$ minicom -b 115200 -o -D /dev/ttyACM0 +---- + +On opening `minicom` you should see "Hello, world!" printed to the console. + +For terminal programs that support it, a description of the USB serial UART is advertised in the USB device description. + +image::images/description.jpg[width="60%"] + +The unique serial number in this description means that on Windows your COM port numbering is "sticky" per device, and will allow you to write `udev` rules to associate a named device node with a particular Debug Probe. diff --git a/documentation/asciidoc/microcontrollers/debug-probe/updating-firmware.adoc b/documentation/asciidoc/microcontrollers/debug-probe/updating-firmware.adoc new file mode 100644 index 0000000000..f0c3af0b92 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/debug-probe/updating-firmware.adoc @@ -0,0 +1,15 @@ +== Updating the firmware on the Debug Probe + +Firmware for the Debug Probe is available as a UF2 file distributed by Raspberry Pi. + +The latest version of the Debug Probe firmware is version 2.2. If you're running an older version, or if you have accidentally overwritten the firmware on your Debug Probe, you can find the latest release of the firmware in https://github.com/raspberrypi/debugprobe/releases/latest[the debugprobe GitHub repository]. + +Download `debugprobe.uf2` from the latest release. + +Pinch to remove the top of the Debug Probe enclosure. + +Push and hold the BOOTSEL button as you plug the Debug Probe into your computer to mount a volume called "RPI-RP2". + +Copy `debugprobe.uf2` onto the "RPI-RP2" volume. The volume will dismount automatically after the file finishes copying onto the device. + +Your Debug Probe will reboot and now runs an updated version of the Debug Probe firmware. It is now ready for debugging. diff --git a/documentation/asciidoc/microcontrollers/microcontroller_docs.adoc b/documentation/asciidoc/microcontrollers/microcontroller_docs.adoc new file mode 100644 index 0000000000..8b242e97ef --- /dev/null +++ b/documentation/asciidoc/microcontrollers/microcontroller_docs.adoc @@ -0,0 +1,50 @@ +// Included from both silicon.adoc and pico-series.adoc + +== Documentation + +Documentation for Pico-series and other Raspberry Pi microcontroller-based boards. + +=== RP2350 + +https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf[RP2350 Datasheet]:: A microcontroller by Raspberry Pi + +https://datasheets.raspberrypi.com/rp2350/hardware-design-with-rp2350.pdf[Hardware design with RP2350]:: Using RP2350 microcontrollers to build boards and products + +=== RP2040 + +https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf[RP2040 Datasheet]:: A microcontroller by Raspberry Pi + +https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf[Hardware design with RP2040]:: Using RP2040 microcontrollers to build boards and products + +=== Raspberry Pi Pico 2 + +https://datasheets.raspberrypi.com/pico/pico-2-datasheet.pdf[Raspberry Pi Pico 2 Datasheet]:: An RP2350-based microcontroller board + +https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico-series Microcontrollers]:: C/{cpp} development with Raspberry Pi Pico-series devices and other Raspberry Pi microcontroller-based boards + +=== Raspberry Pi Pico + +https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf[Raspberry Pi Pico Datasheet]:: An RP2040-based microcontroller board + +https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting started with Raspberry Pi Pico-series Microcontrollers]:: C/{cpp} development with Raspberry Pi Pico-series devices and other Raspberry Pi microcontroller-based boards + +=== Raspberry Pi Pico 2 W + +https://datasheets.raspberrypi.com/picow/pico-2-w-datasheet.pdf[Raspberry Pi Pico 2 W Datasheet]:: An RP2350-based microcontroller board with wireless + +https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf[Connecting to the Internet with Raspberry Pi Pico W-series]:: Getting Raspberry Pi Pico W-series devices online with C/{cpp} or MicroPython + +=== Raspberry Pi Pico W + +https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf[Raspberry Pi Pico W Datasheet]:: An RP2040-based microcontroller board with wireless + +https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf[Connecting to the Internet with Raspberry Pi Pico W-series]:: Getting Raspberry Pi Pico W-series devices online with C/{cpp} or MicroPython + +=== Software Development + +https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf[Raspberry Pi Pico C/{cpp} SDK]:: Libraries and tools for C/{cpp} development on RP2040 microcontrollers + +https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf[Raspberry Pi Pico Python SDK]:: A MicroPython environment for RP2040 microcontrollers + +The API level Doxygen documentation for the Raspberry Pi Pico C/{cpp} SDK is also available https://rptl.io/pico-doxygen[as a micro-site]. + diff --git a/documentation/asciidoc/microcontrollers/micropython.adoc b/documentation/asciidoc/microcontrollers/micropython.adoc new file mode 100644 index 0000000000..8a8669132e --- /dev/null +++ b/documentation/asciidoc/microcontrollers/micropython.adoc @@ -0,0 +1,7 @@ +include::micropython/what-is-micropython.adoc[] + +include::micropython/drag-and-drop.adoc[] + +include::micropython/micropython-documentation.adoc[] + +include::micropython/what-board.adoc[] diff --git a/documentation/asciidoc/microcontrollers/micropython/drag-and-drop.adoc b/documentation/asciidoc/microcontrollers/micropython/drag-and-drop.adoc new file mode 100644 index 0000000000..70931fea6e --- /dev/null +++ b/documentation/asciidoc/microcontrollers/micropython/drag-and-drop.adoc @@ -0,0 +1,31 @@ +== Drag-and-Drop MicroPython + +You can program your Pico by connecting it to a computer via USB, then dragging and dropping a file onto it so we've put together a downloadable UF2 file to let you install MicroPython more easily. + +video::images/MicroPython.webm[width="80%"] + +Download the correct MicroPython UF2 file for your board: + +* https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2[Pico] + +* https://micropython.org/download/rp2-pico-w/rp2-pico-w-latest.uf2[Pico W] + +* https://micropython.org/download/RPI_PICO2/RPI_PICO2-latest.uf2[Pico 2] + +* https://downloads.raspberrypi.com/micropython/mp_firmware_unofficial_latest.uf2[Pico 2 W] + +For more information about using Wi-Fi and Bluetooth on Raspberry Pi Pico W-series devices with C/{cpp} or MicroPython, see https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf[Connecting to the Internet with Raspberry Pi Pico W-series]. + +For more information about https://github.com/bluekitchen/btstack#supported-protocols-and-profiles[supported Bluetooth protocols and profiles], see the Blue Kitchen https://github.com/bluekitchen/btstack[BTStack] Github repository. + +NOTE: MicroPython distributions for other RP2040- and RP2350-based boards are available on the https://micropython.org/download/[MicroPython download page]. + +To program your device, follow these steps: + +. Push and hold the BOOTSEL button while connecting your Pico with a USB cable to a computer. Release the BOOTSEL button once your Pico appears as a Mass Storage Device called RPI-RP2. + +. Drag and drop the MicroPython UF2 file onto the RPI-RP2 volume. Your Pico will reboot. You are now running MicroPython. + +. Access the REPL via USB Serial. + +The https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf[Raspberry Pi Pico-series Python SDK] book contains step-by-step instructions for connecting to your Pico and programming it in MicroPython using both the command line and the https://thonny.org/[Thonny] IDE. diff --git a/documentation/asciidoc/microcontrollers/micropython/images/MicroPython.webm b/documentation/asciidoc/microcontrollers/micropython/images/MicroPython.webm new file mode 100644 index 0000000000..9ef956aa82 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/micropython/images/MicroPython.webm differ diff --git a/documentation/asciidoc/microcontrollers/micropython/images/micropython_book.png b/documentation/asciidoc/microcontrollers/micropython/images/micropython_book.png new file mode 100644 index 0000000000..86f9ec0a0c Binary files /dev/null and b/documentation/asciidoc/microcontrollers/micropython/images/micropython_book.png differ diff --git a/documentation/asciidoc/microcontrollers/micropython/micropython-documentation.adoc b/documentation/asciidoc/microcontrollers/micropython/micropython-documentation.adoc new file mode 100644 index 0000000000..d40b32c250 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/micropython/micropython-documentation.adoc @@ -0,0 +1,9 @@ +== Where can I find documentation? + +You can find information on the MicroPython port to RP2040 at; + +https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf[Raspberry Pi Pico Python SDK]:: A MicroPython environment for RP2040 microcontrollers +https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf[Connecting to the Internet with Raspberry Pi Pico W]:: Getting Raspberry Pi Pico W online with C/{cpp} or MicroPython +https://docs.micropython.org/en/latest/rp2/quickref.html[RP2 Quick Reference]:: The official documentation around the RP2040 port of MicroPython +https://docs.micropython.org/en/latest/library/rp2.html[RP2 Library]:: The official documentation about the `rp2` module in MicroPython + diff --git a/documentation/asciidoc/microcontrollers/micropython/what-board.adoc b/documentation/asciidoc/microcontrollers/micropython/what-board.adoc new file mode 100644 index 0000000000..fa3c8ab560 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/micropython/what-board.adoc @@ -0,0 +1,21 @@ +== Which hardware am I running on? + +There is no direct method for software written in MicroPython to discover whether it is running on a Raspberry Pi Pico or a Pico W by looking at the hardware. However, you can tell indirectly by looking to see if network functionality is included in your particular MicroPython firmware: + +[source,python] +---- +import network +if hasattr(network, "WLAN"): + # the board has WLAN capabilities +---- + +Alternatively, you can inspect the MicroPython firmware version to check whether it was compiled for Raspberry Pi Pico or for Pico W using the `sys` module. + +[source] +---- +>>> import sys +>>> sys.implementation +(name='micropython', version=(1, 19, 1), _machine='Raspberry Pi Pico W with RP2040', _mpy=4102) +---- + +If the 'Pico W' string is present and in `sys.implementation._machine`, your firmware was compiled for Pico W. diff --git a/documentation/asciidoc/microcontrollers/micropython/what-is-micropython.adoc b/documentation/asciidoc/microcontrollers/micropython/what-is-micropython.adoc new file mode 100644 index 0000000000..7f57633e2f --- /dev/null +++ b/documentation/asciidoc/microcontrollers/micropython/what-is-micropython.adoc @@ -0,0 +1,6 @@ +== What is MicroPython? + +MicroPython is a full implementation of the Python 3 programming language that runs directly on embedded hardware like Raspberry Pi Pico. You get an interactive prompt (the REPL) to execute commands immediately via USB Serial, and a built-in filesystem. The Pico port of MicroPython includes modules for accessing low-level chip-specific hardware. + +* The https://github.com/micropython/micropython/wiki[MicroPython Wiki] +* The https://forum.micropython.org/[MicroPython Forums] diff --git a/documentation/asciidoc/microcontrollers/pico-series.adoc b/documentation/asciidoc/microcontrollers/pico-series.adoc new file mode 100644 index 0000000000..e063028a1d --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series.adoc @@ -0,0 +1,5 @@ +include::pico-series/about_pico.adoc[] + +include::microcontroller_docs.adoc[] + +include::pico-series/utilities.adoc[] diff --git a/documentation/asciidoc/microcontrollers/pico-series/about_pico.adoc b/documentation/asciidoc/microcontrollers/pico-series/about_pico.adoc new file mode 100644 index 0000000000..aed8798cbc --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/about_pico.adoc @@ -0,0 +1,164 @@ +Pico-series devices are organised into **families** based on product generation. + +The original Raspberry Pi Pico family, referred to as Pico or Pico 1, comes in the following variants: + +* Pico +* Pico H +* Pico W +* Pico WH + +The second-generation Raspberry Pi Pico family is referred to as Pico 2. Pico 2 comes in the following variants: + +* Pico 2 +* Pico 2 W + +== Pico 2 family + +image::images/pico-2.png[width="75%"] + +[[pico-2-technical-specification]] +=== Raspberry Pi Pico 2 + +Raspberry Pi Pico 2 is a low-cost, high-performance microcontroller board with flexible digital interfaces. Key features include: + +* xref:silicon.adoc#rp2350[RP2350] microcontroller chip designed by Raspberry Pi in the United Kingdom +* Dual Cortex-M33 or Hazard3 processors at up to 150MHz +* 520KB of SRAM, and 4MB of on-board flash memory +* USB 1.1 with device and host support +* Low-power sleep and dormant modes +* Drag-and-drop programming using mass storage over USB +* 26× multi-function GPIO pins including 3 that can be used for ADC +* 2× SPI, 2× I2C, 2× UART, 3× 12-bit 500ksps Analogue to Digital Converter (ADC), 24× controllable PWM channels +* 2× Timer with 4 alarms, 1× AON Timer +* Temperature sensor +* 3 × Programmable IO (PIO) blocks, 12 state machines total for custom peripheral support +** Flexible, user-programmable high-speed IO +** Can emulate interfaces such as SD Card and VGA + +The Raspberry Pi Pico 2 comes as a castellated module which allows soldering direct to carrier boards, while the Pico 2 _with headers_ comes with pre-soldered headers. + +NOTE: Both boards have a three pin Serial Wire Debug (SWD) header. However, the Pico 2 with headers breaks this out into a small, keyed, https://datasheets.raspberrypi.com/debug/debug-connector-specification.pdf[3-pin connector] while the Pico has three castellated through-hole pins adjacent to the edge of the board. + +==== Pinout and design files + +image::images/pico-2-r4-pinout.svg[] + +* Download the https://datasheets.raspberrypi.com/pico/Pico-2-Pinout.pdf[Pinout Diagram] (PDF) +* Download https://datasheets.raspberrypi.com/pico/Pico-2-step-20240708.zip[STEP File] +* Download https://datasheets.raspberrypi.com/pico/Pico-2-Fritzing-20240708.fzpz[Fritzing Part] for Raspberry Pi Pico + +NOTE: More information on Fritzing is available on the https://fritzing.org/[fritzing.org] website. + +[[pico2w-technical-specification]] +=== Raspberry Pi Pico 2 W + +Raspberry Pi Pico 2 W adds on-board single-band 2.4GHz wireless interfaces (802.11n) using the Infineon CYW43439 to the Pico 2 hardware. The on-board 2.4GHz wireless interface has the following features: + +* Wireless (802.11n), single-band (2.4 GHz) +* WPA3 +* Soft access point supporting up to four clients +* Bluetooth 5.2 +** Support for Bluetooth LE Central and Peripheral roles +** Support for Bluetooth Classic + +The onboard antenna is licensed from ABRACON (formerly ProAnt). The wireless interface is connected via +SPI to the xref:silicon.adoc#rp2350[RP2350] microcontroller. + +Due to pin limitations, some of the wireless interface pins are shared. The CLK is shared with VSYS monitor, so only +when there isn't an SPI transaction in progress can VSYS be read via the ADC. The Infineon CYW43439 DIN/DOUT and +IRQ all share one pin on the RP2350. Only when an SPI transaction isn't in progress is it suitable to check for IRQs. The interface typically runs at 33MHz. + +For best wireless performance, position the antenna in free space. For instance, metal underneath or nearby the +antenna can reduce performance both in terms of gain and bandwidth. Adding grounded metal to the sides of the +antenna can improve the antenna's bandwidth. + +`libcyw43` is licensed for non-commercial use. However, Pico 2 W users, and anyone else who builds their product around RP2350 and CYW43439, benefit from a free https://github.com/georgerobotics/cyw43-driver/blob/195dfcc10bb6f379e3dea45147590db2203d3c7b/LICENSE.RP[commercial-use license]. + +In addition to the https://github.com/bluekitchen/btstack/blob/master/LICENSE[standard BTstack licensing] terms, a https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_btstack/LICENSE.RP[supplemental licence] covers commercial use of BTstack with Raspberry Pi Pico 2 W. + +==== Pinout and design files + +image::images/pico2w-pinout.svg[] + +* https://datasheets.raspberrypi.com/picow/pico-2-w-pinout.pdf[Pinout Diagram] (PDF) +* https://datasheets.raspberrypi.com/picow/pico-2-w-schematic.pdf[Schematic] +// TODO: add these when available +// * Download https://datasheets.raspberrypi.com/pico2w/RPi-PicoW-PUBLIC-20220607.zip[Design Files] (Cadence Allegro) +// * Download https://datasheets.raspberrypi.com/pico2w/PicoW-step.zip[STEP File] + +== Pico 1 family + +image::images/pico-1s.png[width="75%"] + +The Raspberry Pi Pico 1 family consists of four boards; Raspberry Pi Pico (far left), Pico H (middle left), Pico W (middle right), and Pico WH (far right). + +[[pico-1-technical-specification]] +=== Raspberry Pi Pico and Pico H + +Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces. Key features include: + +* xref:silicon.adoc#rp2040[RP2040] microcontroller chip designed by Raspberry Pi in the United Kingdom +* Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz +* 264KB of SRAM, and 2MB of on-board flash memory +* USB 1.1 with device and host support +* Low-power sleep and dormant modes +* Drag-and-drop programming using mass storage over USB +* 26 × multi-function GPIO pins +* 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels +* Accurate clock and timer on-chip +* Temperature sensor +* Accelerated floating-point libraries on-chip +* 8 × Programmable I/O (PIO) state machines for custom peripheral support + +The Raspberry Pi Pico comes as a castellated module which allows soldering direct to carrier boards, while the Pico H comes with pre-soldered headers. + +NOTE: Both boards have a three pin Serial Wire Debug (SWD) header. However, the Pico H has this broken out into a small, keyed, https://datasheets.raspberrypi.com/debug/debug-connector-specification.pdf[3-pin connector] while the Pico has three castellated through-hole pins adjacent to the edge of the board. + +==== Pinout and design files + +image::images/pico-pinout.svg[] + +* Download the https://datasheets.raspberrypi.com/pico/Pico-R3-A4-Pinout.pdf[Pinout Diagram] (PDF) +* Download https://datasheets.raspberrypi.com/pico/RPi-Pico-R3-PUBLIC-20200119.zip[Design Files] (Cadence Allegro) +* Download https://datasheets.raspberrypi.com/pico/Pico-R3-step.zip[STEP File] +* Download https://datasheets.raspberrypi.com/pico/Pico-R3-Fritzing.fzpz[Fritzing Part] for Raspberry Pi Pico +* Download https://datasheets.raspberrypi.com/pico/PicoH-Fritzing.fzpz[Fritzing Part] for Raspberry Pi Pico H + +NOTE: More information on Fritzing is available on the https://fritzing.org/[fritzing.org] website. + +[[picow-technical-specification]] +=== Raspberry Pi Pico W and Pico WH + +Raspberry Pi Pico W adds on-board single-band 2.4GHz wireless interfaces (802.11n) using the Infineon CYW43439 while retaining the Pico form factor. The on-board 2.4GHz wireless interface has the following features: + +* Wireless (802.11n), single-band (2.4 GHz) +* WPA3 +* Soft access point supporting up to four clients +* Bluetooth 5.2 +** Support for Bluetooth LE Central and Peripheral roles +** Support for Bluetooth Classic + +The antenna is an onboard antenna licensed from ABRACON (formerly ProAnt). The CYW43439 wireless chip is connected via +SPI to the xref:silicon.adoc#rp2040[RP2040] microcontroller. + +Due to pin limitations, some of the wireless interface pins are shared. The CLK is shared with VSYS monitor, so only +when there isn't an SPI transaction in progress can VSYS be read via the ADC. The Infineon CYW43439 DIN/DOUT and +IRQ all share one pin on the RP2040. Only when an SPI transaction isn't in progress is it suitable to check for IRQs. The +interface typically runs at 33MHz. + +For best wireless performance, the antenna should be in free space. For instance, putting metal under or close by the +antenna can reduce its performance both in terms of gain and bandwidth. Adding grounded metal to the sides of the +antenna can improve the antenna's bandwidth. + +`libcyw43` is licensed for non-commercial use. However, Pico W users, and anyone else who builds their product around RP2040 and CYW43439, benefit from a free https://github.com/georgerobotics/cyw43-driver/blob/195dfcc10bb6f379e3dea45147590db2203d3c7b/LICENSE.RP[commercial-use license]. + +In addition to the https://github.com/bluekitchen/btstack/blob/master/LICENSE[standard BTstack licensing] terms, a https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_btstack/LICENSE.RP[supplemental licence] covers commercial use of BTstack with Raspberry Pi Pico W or Raspberry Pi Pico WH. + +==== Pinout and design files + +image::images/picow-pinout.svg[] + +* Download the https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf[Pinout Diagram] (PDF) +* Download https://datasheets.raspberrypi.com/picow/RPi-PicoW-PUBLIC-20220607.zip[Design Files] (Cadence Allegro) +* Download https://datasheets.raspberrypi.com/picow/PicoW-step.zip[STEP File] +* Download https://datasheets.raspberrypi.com/picow/PicoW-Fritzing.fzpz[Fritzing Part] for Raspberry Pi Pico W diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/Pico-R3-SDK11-Pinout.svg b/documentation/asciidoc/microcontrollers/pico-series/images/Pico-R3-SDK11-Pinout.svg new file mode 100644 index 0000000000..b26047a9de --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/images/Pico-R3-SDK11-Pinout.svg @@ -0,0 +1,4510 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico-1s.png b/documentation/asciidoc/microcontrollers/pico-series/images/pico-1s.png new file mode 100644 index 0000000000..434a35c44a Binary files /dev/null and b/documentation/asciidoc/microcontrollers/pico-series/images/pico-1s.png differ diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico-2-r4-pinout.svg b/documentation/asciidoc/microcontrollers/pico-series/images/pico-2-r4-pinout.svg new file mode 100644 index 0000000000..be839bab9f --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/images/pico-2-r4-pinout.svg @@ -0,0 +1,1816 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + 39 + + + DEBUG + + + 1 + + + LED + + + USB + + + BOOTSEL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico-2.png b/documentation/asciidoc/microcontrollers/pico-series/images/pico-2.png new file mode 100644 index 0000000000..6b0c282463 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/pico-series/images/pico-2.png differ diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico-pinout.svg b/documentation/asciidoc/microcontrollers/pico-series/images/pico-pinout.svg new file mode 100644 index 0000000000..959593f4f9 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/images/pico-pinout.svg @@ -0,0 +1,10747 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.png b/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.png new file mode 100644 index 0000000000..d130346b5a Binary files /dev/null and b/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.png differ diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.svg b/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.svg new file mode 100644 index 0000000000..50faeacd5a --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/images/pico2w-pinout.svg @@ -0,0 +1,9360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/asciidoc/microcontrollers/pico-series/images/picow-pinout.svg b/documentation/asciidoc/microcontrollers/pico-series/images/picow-pinout.svg new file mode 100644 index 0000000000..9e22e72c79 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/images/picow-pinout.svg @@ -0,0 +1,9061 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/asciidoc/microcontrollers/pico-series/utilities.adoc b/documentation/asciidoc/microcontrollers/pico-series/utilities.adoc new file mode 100644 index 0000000000..532f8f6b3b --- /dev/null +++ b/documentation/asciidoc/microcontrollers/pico-series/utilities.adoc @@ -0,0 +1,30 @@ +== Software Utilities + +=== What is on your Pico-series device? + +If you are unsure what is programmed into your Raspberry Pi Pico-series device, and the program was built using the Pico C/{cpp} SDK, it will usually have a name and other useful information embedded into the binary. You can use the https://github.com/raspberrypi/picotool[Picotool] command line utility to find out these details. Full instructions on how to use Picotool to do this are available in our 'https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[getting started]' documentation. + +* Go to the https://github.com/raspberrypi/picotool[Picotool Github repository]. + +=== Debugging using another Pico-series device + +You can use one Pico-series device to debug another Pico-series device. This is possible via `debugprobe`, an application that allows a Pico to act as a USB → SWD and UART converter. + +You can find the latest release of the firmware in https://github.com/raspberrypi/debugprobe/releases/latest[the debugprobe GitHub repository]. + +Download `debugprobe_on_pico.uf2` (for Pico) or `debugprobe_on_pico2.uf2` (for Pico 2) from the latest release. + +Push and hold the BOOTSEL button as you plug the debugger device into your computer to mount a volume called "RPI-RP2". + +Copy the UF2 file onto the volume. The volume will dismount automatically after the file finishes copying onto the device. + +Your device will reboot and now runs an updated version of the `debugprobe` firmware. It is now ready for debugging. + +TIP: For instructions on how to use the debugger, see https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting Started with Pico-series Microcontrollers]. + +=== Resetting Flash memory + +For Pico-series devices, BOOTSEL mode lives in read-only memory inside the RP2040 or RP2350 chip, and can't be overwritten accidentally. No matter what, if you hold down the BOOTSEL button when you plug in your Pico, it will appear as a drive onto which you can drag a new UF2 file. There is no way to brick the board through software. However, there are some circumstances where you might want to make sure your flash memory is empty. You can do this by dragging and dropping a special UF2 binary onto your Pico when it is in mass storage mode. + +* Download the https://datasheets.raspberrypi.com/soft/flash_nuke.uf2[UF2 file] +* See the https://github.com/raspberrypi/pico-examples/blob/master/flash/nuke/nuke.c[code on Github] diff --git a/documentation/asciidoc/microcontrollers/silicon.adoc b/documentation/asciidoc/microcontrollers/silicon.adoc new file mode 100644 index 0000000000..ae42368343 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon.adoc @@ -0,0 +1,8 @@ +include::silicon/rp2350.adoc[] + +include::silicon/rp2040.adoc[] + +include::silicon/rp1.adoc[] + +include::microcontroller_docs.adoc[] + diff --git a/documentation/asciidoc/microcontrollers/silicon/images/pico.jpg b/documentation/asciidoc/microcontrollers/silicon/images/pico.jpg new file mode 100644 index 0000000000..ccb70c0dce Binary files /dev/null and b/documentation/asciidoc/microcontrollers/silicon/images/pico.jpg differ diff --git a/documentation/asciidoc/microcontrollers/silicon/images/rp1.jpg b/documentation/asciidoc/microcontrollers/silicon/images/rp1.jpg new file mode 100644 index 0000000000..bf7b21eeae Binary files /dev/null and b/documentation/asciidoc/microcontrollers/silicon/images/rp1.jpg differ diff --git a/documentation/asciidoc/microcontrollers/silicon/images/rp2040.jpg b/documentation/asciidoc/microcontrollers/silicon/images/rp2040.jpg new file mode 100644 index 0000000000..3ec60937b5 Binary files /dev/null and b/documentation/asciidoc/microcontrollers/silicon/images/rp2040.jpg differ diff --git a/documentation/asciidoc/microcontrollers/silicon/images/rp2040_explanation.svg b/documentation/asciidoc/microcontrollers/silicon/images/rp2040_explanation.svg new file mode 100755 index 0000000000..48fbd534d1 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon/images/rp2040_explanation.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + RP2040 + + + + + + + + + + + + + + + + + + + Raspberry Pi + + + + + + + + + + + + + + + Number of cores + + + + + + + + + + Type of core (e.g. M0+) + + + + + + + + + + floor(log2(ram / 16k)) + + floor(log2(nonvolatile / 16k)) + + diff --git a/documentation/asciidoc/microcontrollers/silicon/images/rp2350.png b/documentation/asciidoc/microcontrollers/silicon/images/rp2350.png new file mode 100644 index 0000000000..a824c6647c Binary files /dev/null and b/documentation/asciidoc/microcontrollers/silicon/images/rp2350.png differ diff --git a/documentation/asciidoc/microcontrollers/silicon/images/rp2350_explanation.svg b/documentation/asciidoc/microcontrollers/silicon/images/rp2350_explanation.svg new file mode 100644 index 0000000000..5eae2b2518 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon/images/rp2350_explanation.svg @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + RP 2350 + + + + + + + + + + + + + + + + + + Raspberry Pi + + + + + + + + + + + + + + + Number of cores + + + + + + + + + + Type of core (e.g. Cortex-M33) + + + + + + + + + + floor(log2(RAM / 16 kB)) + + floor(log2(nonvolatile / 128 kB)) + + diff --git a/documentation/asciidoc/microcontrollers/silicon/rp1.adoc b/documentation/asciidoc/microcontrollers/silicon/rp1.adoc new file mode 100644 index 0000000000..c6e66772b4 --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon/rp1.adoc @@ -0,0 +1,27 @@ + +== RP1 + +[[about-rp1]] + +.Architecture +image::images/rp1.jpg[alt="Architecture diagram of the RP1",width="70%"] + +RP1 is a 12×12mm, 0.65mm-pitch BGA southbridge, which provides the majority of the I/O capabilities for Raspberry Pi 5. + +video::aioB40BGQYU[youtube,width=80%,height=400px] + +It provides: + +* 4-lane PCIe 2.0 endpoint +* Gigabit Ethernet MAC +* 2× USB 3 host controllers +** Each has 1× USB 3 and 1× USB 2 port +** More than twice the usable USB bandwidth vs. Raspberry Pi 4 +* 2× SDIO ports/eMMC (not used on Raspberry Pi 5) +* 2× MIPI transceivers (4-lane, supporting DSI and CSI-2) +* Video DAC (3-channel, supporting PAL/NTSC and VGA) +** Only one channel (composite) used on Raspberry Pi 5 +* Low-speed peripherals (SPI, UART, I2C, PWM, GPIO, I2S) +* Delta-sigma PWM audio out + +More information on RP1 can be found in the https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf[RP1 Peripherals] document. diff --git a/documentation/asciidoc/microcontrollers/silicon/rp2040.adoc b/documentation/asciidoc/microcontrollers/silicon/rp2040.adoc new file mode 100644 index 0000000000..f55dc79f2d --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon/rp2040.adoc @@ -0,0 +1,106 @@ +== RP2040 + +RP2040 is a microcontroller designed by Raspberry Pi. + +image::images/rp2040.jpg[] + +Whether you have a xref:pico-series.adoc#pico-1-technical-specification[Raspberry Pi Pico 1] or another RP2040-based microcontroller board, everything you need to get started is here. You'll find support for getting started with xref:c_sdk.adoc#sdk-setup[C/{cpp}] or xref:micropython.adoc#what-is-micropython[MicroPython] on Raspberry Pi Pico, and links to resources for other boards that use RP2040. There are also links to the technical documentation for both the Raspberry Pi Pico microcontroller board and our RP2040 microcontroller chip. + +=== Why is the chip called RP2040? + +The post-fix numeral on RP2040 comes from the following, + +image::images/rp2040_explanation.svg[width=640] + +. Number of processor cores (2) +. Loosely which type of processor (M0+) +. floor(log2(RAM / 16k)) +. floor(log2(nonvolatile / 16k)) or 0 if no onboard nonvolatile storage + +=== Technical Specification + +RP2040 is the debut microcontroller from Raspberry Pi. It brings our signature values of high performance, low cost, +and ease of use to the microcontroller space. + +With a large on-chip memory, symmetric dual-core processor complex, deterministic bus fabric, and rich peripheral set +augmented with our unique Programmable I/O (PIO) subsystem, it provides professional users with unrivalled power +and flexibility. With detailed documentation, a polished MicroPython port, and a UF2 bootloader in ROM, it has the +lowest possible barrier to entry for beginner and hobbyist users. + +RP2040 is a stateless device, with support for cached execute-in-place from external QSPI memory. This design +decision allows you to choose the appropriate density of non-volatile storage for your application, and to benefit from +the low pricing of commodity flash parts. + +RP2040 is manufactured on a modern 40nm process node, delivering high performance, low dynamic power +consumption, and low leakage, with a variety of low-power modes to support extended-duration operation on battery +power + +Key features: + +* Dual ARM Cortex-M0+ @ 133MHz +* 264kB on-chip SRAM in six independent banks +* Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus +* DMA controller +* Fully-connected AHB crossbar +* Interpolator and integer divider peripherals +* On-chip programmable LDO to generate core voltage +* 2 on-chip PLLs to generate USB and core clocks +* 30 GPIO pins, 4 of which can be used as analogue inputs +* Peripherals +** 2 UARTs +** 2 SPI controllers +** 2 I2C controllers +** 16 PWM channels +** USB 1.1 controller and PHY, with host and device support +** 8 PIO state machines + +[.whitepaper, title="Power switching RP2040 for low standby current applications", subtitle="", link=https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-004339-WP/Power-switching-RP2040-for-low-standby-current-applications.pdf] +**** +Even in deep sleep RP2040 draws a typical current of ~180μA, and sleep current is very dependent on PVT: process (current varies from chip to chip), voltage (current varies linearly with voltage), and temperature (current varies nonlinearly with temperature). + +For many use cases where minimal current draw is required, the best option is to power off the system (or the RP2040 part of the system) completely if possible. This application note gives a couple of options for how this can be done, and these circuits are simple enough that a designer can adjust them for their own use case. +**** + +==== Design Files + +* Download https://datasheets.raspberrypi.com/rp2040/Minimal-KiCAD.zip[Minimal Viable Board] Design Files (KiCad) +* Download https://datasheets.raspberrypi.com/rp2040/VGA-KiCAD.zip[VGA Carrier Board] Design Files (KiCad) + +=== RP2040-based Boards + +Designed by Raspberry Pi as both a development board, and as a reference design, the xref:pico-series.adoc#pico-1-family[Raspberry Pi Pico 1] is a family of RP2040-based boards. + +The design files for Raspberry Pi Pico and Pico W are available openly, with no limitations. + +* Download https://datasheets.raspberrypi.com/pico/RPi-Pico-R3-PUBLIC-20200119.zip[Design Files] for Raspberry Pi Pico (Cadence Allegro) +* Download https://datasheets.raspberrypi.com/picow/RPi-PicoW-PUBLIC-20220607.zip[Design Files] for Raspberry Pi Pico W (Cadence Allegro) + +Permission to use, copy, modify, and/or distribute this design for any purpose with or without fee is hereby granted. + +THE DESIGN IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS DESIGN INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS DESIGN. + +==== Other Boards + +You can find discussions around third-party RP2040-based boards on the https://forums.raspberrypi.com/viewforum.php?f=147[Raspberry Pi forums]. + +==== USB PIDs + +Many RP2040-based devices use Raspberry Pi's USB Vendor ID and Product ID combination. If you build a third-party board based on RP2040, you may require a unique USB Product ID (PID). + +You might need a unique USB PID if you need to provide a custom driver for Windows users. + +USB-IF have given Raspberry Pi permission to license USB product ID values for its Vendor ID (`0x2E8A`) for common silicon components used with RP2040. + +To reserve a USB PID associated with Raspberry Pi's vendor ID, follow the instructions in the https://github.com/raspberrypi/usb-pid[Raspberry Pi USB PID git repository]. + +NOTE: If you use the standard RP2040 PID, you can use the `iManufacturer`, `iProduct`, and `iSerial` strings to uniquely identify your device. + +=== Internal Temperature Sensor + +The internal temperature sensor in the RP2040 package is a low-resolution sensor that needs to be user-calibrated to be useful to any degree of accuracy. + +A crucial part of accurately determining the temperature measured is knowing the ADC VREF voltage. The conversion formula means that small errors in the ADC VREF voltage can give quite large discrepancies in temperature calculated. The RP2040 doesn't have an internal Fixed Voltage Reference which can be used to determine VREF voltage so VREF voltage needs to be measured manually - with the caveat it could change - or an external Fixed Voltage Reference needs to be provided. + +NOTE: The RP2040 sensor voltage falls as temperature rises. + +See Chapter 4, section 4.9.5 of the https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf[RP2040 Datasheet] for further details of the internal temperature sensor. diff --git a/documentation/asciidoc/microcontrollers/silicon/rp2350.adoc b/documentation/asciidoc/microcontrollers/silicon/rp2350.adoc new file mode 100644 index 0000000000..23508f7c1f --- /dev/null +++ b/documentation/asciidoc/microcontrollers/silicon/rp2350.adoc @@ -0,0 +1,85 @@ +== RP2350 + +RP2350 is a microcontroller designed by Raspberry Pi. + +image::images/rp2350.png[] + +Whether you have a xref:pico-series.adoc#pico-2-technical-specification[Raspberry Pi Pico 2] or another RP2350-based microcontroller board, everything you need to get started is here. You'll find support for getting started with xref:c_sdk.adoc#sdk-setup[C/{cpp}] or xref:micropython.adoc#what-is-micropython[MicroPython] on Raspberry Pi Pico 2, and links to resources for other boards that use RP2350. There are also links to the technical documentation for both the Raspberry Pi Pico 2 microcontroller board and our RP2350 microcontroller chip. + +=== Why is the chip called RP2350? + +The post-fix numeral on RP2350 comes from the following, + +image::images/rp2350_explanation.svg[width=640] + +. Number of processor cores (2) +. Loosely which type of processor (M33) +. floor(log2(RAM / 16KB)) +. floor(log2(nonvolatile / 128KB)) or 0 if no onboard nonvolatile storage + +=== Technical Specification + +RP2350 is a high-performance, secure, low-cost, easy-to-use microcontroller from Raspberry Pi. + +With a large on-chip memory, symmetric dual-core processor complex, deterministic bus fabric, and rich peripheral set augmented with our unique Programmable I/O (PIO) subsystem, it provides professional users with unrivalled power and flexibility. With detailed documentation, a polished MicroPython port, and a UF2 bootloader in ROM, it has the lowest possible barrier to entry for beginner and hobbyist users. + +RP2350 is a stateless device, with support for cached execute-in-place from external QSPI memory. This design decision allows you to choose the appropriate density of non-volatile storage for your application, and to benefit from the low pricing of commodity flash parts. + +RP2350 is manufactured on a modern 40nm process node, delivering high performance, low dynamic power consumption, and low leakage, with a variety of low-power modes to support extended-duration operation on battery power. + +Key features include: + +* Dual Cortex-M33 or Hazard3 processors at up to 150MHz +* 520KB multi-bank high performance SRAM +* Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus +* DMA controller +* Fully-connected AHB crossbar +* On-chip programmable LDO to generate core voltage +* 2 on-chip PLLs to generate USB and core clocks +* 30 GPIO pins, 4 of which can be used as analogue inputs +* Peripherals +** 2 UARTs +** 2 SPI controllers +** 2 I2C controllers +** 24 PWM channels +** USB 1.1 controller and PHY, with host and device support +** 3 Programmable IO (PIO) blocks, 12 state machines total + +==== Security + +RP2350 has a comprehensive security architecture, built around Arm TrustZone for Cortex-M, including the following features: + +* Signed boot support +* 8KB of on-chip antifuse one-time-programmable (OTP) memory +* SHA-256 acceleration +* A hardware true random number generator (TRNG) + +==== Architecture Switching + +RP2350 includes a pair of open-hardware Hazard3 RISC-V cores which can be substituted at boot time for the Cortex-M33 cores. Our boot ROM can even auto-detect the architecture for which a second-stage binary has been built and reboot the chip into the appropriate mode. All features of the chip, apart from a handful of security features, and the double-precision floating-point accelerator, are available in RISC-V mode. + +=== RP2350-based Boards + +Designed by Raspberry Pi as both a development board, and as a reference design, the xref:pico-series.adoc#pico-2-technical-specification[Raspberry Pi Pico 2] is based on the RP2350. + +Permission to use, copy, modify, and/or distribute this design for any purpose with or without fee is hereby granted. + +THE DESIGN IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS DESIGN INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS DESIGN. + +==== Other Boards + +You can find discussions around third-party RP2350-based boards on the https://forums.raspberrypi.com/viewforum.php?f=147[Raspberry Pi forums]. + +==== USB PIDs + +Many RP2350-based devices use Raspberry Pi's USB Vendor ID and Product ID combination. If you build a third-party board based on RP2350, you may require a unique USB Product ID (PID). + +You might need a unique USB PID if you need to provide a custom driver for Windows users. + +USB-IF have given Raspberry Pi permission to license USB product ID values for its Vendor ID (`0x2E8A`) for common silicon components used with RP2350. + +To reserve a USB PID associated with Raspberry Pi's vendor ID, follow the instructions in the https://github.com/raspberrypi/usb-pid[Raspberry Pi USB PID git repository]. + +NOTE: If you use the standard RP2350 PID, you can use the `iManufacturer`, `iProduct`, and `iSerial` strings to uniquely identify your device. + + diff --git a/documentation/asciidoc/services/connect.adoc b/documentation/asciidoc/services/connect.adoc new file mode 100644 index 0000000000..e67bd3b165 --- /dev/null +++ b/documentation/asciidoc/services/connect.adoc @@ -0,0 +1,8 @@ +include::connect/introduction.adoc[] + +include::connect/install.adoc[] + +include::connect/use.adoc[] + +include::connect/troubleshooting.adoc[] + diff --git a/documentation/asciidoc/services/connect/images/browser-sign-in.png b/documentation/asciidoc/services/connect/images/browser-sign-in.png new file mode 100644 index 0000000000..03c6ad37a4 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/browser-sign-in.png differ diff --git a/documentation/asciidoc/services/connect/images/device.png b/documentation/asciidoc/services/connect/images/device.png new file mode 100644 index 0000000000..a3bef029d7 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/device.png differ diff --git a/documentation/asciidoc/services/connect/images/devices.png b/documentation/asciidoc/services/connect/images/devices.png new file mode 100644 index 0000000000..c6f9d48f1b Binary files /dev/null and b/documentation/asciidoc/services/connect/images/devices.png differ diff --git a/documentation/asciidoc/services/connect/images/disallow-remote-shell.png b/documentation/asciidoc/services/connect/images/disallow-remote-shell.png new file mode 100644 index 0000000000..35fb887253 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/disallow-remote-shell.png differ diff --git a/documentation/asciidoc/services/connect/images/disallow-screen-sharing.png b/documentation/asciidoc/services/connect/images/disallow-screen-sharing.png new file mode 100644 index 0000000000..52d4d17aae Binary files /dev/null and b/documentation/asciidoc/services/connect/images/disallow-screen-sharing.png differ diff --git a/documentation/asciidoc/services/connect/images/hero.png b/documentation/asciidoc/services/connect/images/hero.png new file mode 100644 index 0000000000..0e7be5130a Binary files /dev/null and b/documentation/asciidoc/services/connect/images/hero.png differ diff --git a/documentation/asciidoc/services/connect/images/new-device.png b/documentation/asciidoc/services/connect/images/new-device.png new file mode 100644 index 0000000000..08b794e711 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/new-device.png differ diff --git a/documentation/asciidoc/services/connect/images/remote-shell-disabled.png b/documentation/asciidoc/services/connect/images/remote-shell-disabled.png new file mode 100644 index 0000000000..1196bf4fad Binary files /dev/null and b/documentation/asciidoc/services/connect/images/remote-shell-disabled.png differ diff --git a/documentation/asciidoc/services/connect/images/remote-shell-ended.png b/documentation/asciidoc/services/connect/images/remote-shell-ended.png new file mode 100644 index 0000000000..0f4ce1f433 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/remote-shell-ended.png differ diff --git a/documentation/asciidoc/services/connect/images/remote-shell-in-progress.png b/documentation/asciidoc/services/connect/images/remote-shell-in-progress.png new file mode 100644 index 0000000000..fc75efc7fb Binary files /dev/null and b/documentation/asciidoc/services/connect/images/remote-shell-in-progress.png differ diff --git a/documentation/asciidoc/services/connect/images/remote-shell-notification.png b/documentation/asciidoc/services/connect/images/remote-shell-notification.png new file mode 100644 index 0000000000..2bb47d88fa Binary files /dev/null and b/documentation/asciidoc/services/connect/images/remote-shell-notification.png differ diff --git a/documentation/asciidoc/services/connect/images/remote-shell.png b/documentation/asciidoc/services/connect/images/remote-shell.png new file mode 100644 index 0000000000..398165e17f Binary files /dev/null and b/documentation/asciidoc/services/connect/images/remote-shell.png differ diff --git a/documentation/asciidoc/services/connect/images/screen-sharing-disabled.png b/documentation/asciidoc/services/connect/images/screen-sharing-disabled.png new file mode 100644 index 0000000000..75c2950f29 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/screen-sharing-disabled.png differ diff --git a/documentation/asciidoc/services/connect/images/screen-sharing-ended.png b/documentation/asciidoc/services/connect/images/screen-sharing-ended.png new file mode 100644 index 0000000000..58c4190a51 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/screen-sharing-ended.png differ diff --git a/documentation/asciidoc/services/connect/images/screen-sharing-in-progress.png b/documentation/asciidoc/services/connect/images/screen-sharing-in-progress.png new file mode 100644 index 0000000000..ff840eb8e3 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/screen-sharing-in-progress.png differ diff --git a/documentation/asciidoc/services/connect/images/screen-sharing-notification.png b/documentation/asciidoc/services/connect/images/screen-sharing-notification.png new file mode 100644 index 0000000000..439d437483 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/screen-sharing-notification.png differ diff --git a/documentation/asciidoc/services/connect/images/screen-sharing.png b/documentation/asciidoc/services/connect/images/screen-sharing.png new file mode 100644 index 0000000000..94fc1e871e Binary files /dev/null and b/documentation/asciidoc/services/connect/images/screen-sharing.png differ diff --git a/documentation/asciidoc/services/connect/images/sign-in-email.png b/documentation/asciidoc/services/connect/images/sign-in-email.png new file mode 100644 index 0000000000..57875a2198 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/sign-in-email.png differ diff --git a/documentation/asciidoc/services/connect/images/sign-in.png b/documentation/asciidoc/services/connect/images/sign-in.png new file mode 100644 index 0000000000..7b66320e9a Binary files /dev/null and b/documentation/asciidoc/services/connect/images/sign-in.png differ diff --git a/documentation/asciidoc/services/connect/images/turn-on-connect.png b/documentation/asciidoc/services/connect/images/turn-on-connect.png new file mode 100644 index 0000000000..96c749c795 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/turn-on-connect.png differ diff --git a/documentation/asciidoc/services/connect/images/waiting-for-remote-shell.png b/documentation/asciidoc/services/connect/images/waiting-for-remote-shell.png new file mode 100644 index 0000000000..0197088f11 Binary files /dev/null and b/documentation/asciidoc/services/connect/images/waiting-for-remote-shell.png differ diff --git a/documentation/asciidoc/services/connect/images/waiting-for-screen-sharing.png b/documentation/asciidoc/services/connect/images/waiting-for-screen-sharing.png new file mode 100644 index 0000000000..87ba5fcecc Binary files /dev/null and b/documentation/asciidoc/services/connect/images/waiting-for-screen-sharing.png differ diff --git a/documentation/asciidoc/services/connect/install.adoc b/documentation/asciidoc/services/connect/install.adoc new file mode 100644 index 0000000000..7c8224c220 --- /dev/null +++ b/documentation/asciidoc/services/connect/install.adoc @@ -0,0 +1,68 @@ +[[install-connect]] +== Install + +If Connect isn't already installed in your version of Raspberry Pi OS, open a Terminal window. Run the following command to update your system and packages: + +[source,console] +---- +$ sudo apt update +$ sudo apt full-upgrade +---- + +Run the following command on your Raspberry Pi to install Connect: + +[source,console] +---- +$ sudo apt install rpi-connect +---- + +You can also install Connect from the Recommended Software application. + +After installation, use the `rpi-connect` command line interface to start Connect for your current user: + +[source,console] +---- +$ rpi-connect on +---- + +Alternatively, click the Connect icon in the menu bar to open a dropdown menu and select *Turn On Raspberry Pi Connect*: + +image::images/turn-on-connect.png[width="80%"] + +=== Connect Lite + +We distribute an alternate *Lite* variant of Connect that only supports remote shell access, with no ability to screen share. + +Run the following command on your Raspberry Pi to install Connect Lite: + +[source,console] +---- +$ sudo apt install rpi-connect-lite +---- + +After installation, use the `rpi-connect` command line interface to start Connect for your current user: + +[source,console] +---- +$ rpi-connect on +---- + +xref:connect.adoc#enable-remote-shell-at-all-times[Enable user-lingering] to make your device accessible even when your user account isn't logged in. + +TIP: Lite commands use the same `rpi-connect` name as the full version of Connect. `rpi-connect-lite` is just a package name. + +=== Manually start and stop Connect + +To start Connect from the command line, run the following command: + +[source,console] +---- +$ rpi-connect on +---- + +To stop Connect, run the following command: + +[source,console] +---- +$ rpi-connect off +---- diff --git a/documentation/asciidoc/services/connect/introduction.adoc b/documentation/asciidoc/services/connect/introduction.adoc new file mode 100644 index 0000000000..19ef62fc35 --- /dev/null +++ b/documentation/asciidoc/services/connect/introduction.adoc @@ -0,0 +1,11 @@ +== Introduction + +Raspberry Pi Connect provides secure access to your Raspberry Pi from anywhere in the world. + +image::images/hero.png[width="100%"] + +To use Connect, xref:connect.adoc#install-connect[install the Connect software] and xref:connect.adoc#link-connect[link your device with an account] on your Raspberry Pi. Then visit https://connect.raspberrypi.com[connect.raspberrypi.com] to access the desktop or a shell running on your Raspberry Pi in a browser window. + +Connect uses a secure, encrypted connection. By default, Connect communicates directly between your Raspberry Pi and your browser. However, when Connect can't establish a direct connection between your Raspberry Pi and your browser, we use a relay server. In such cases, Raspberry Pi only retains the metadata required to operate Connect. + +NOTE: To use Connect, your Raspberry Pi must run https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/[Raspberry Pi OS Bookworm] or later. diff --git a/documentation/asciidoc/services/connect/troubleshooting.adoc b/documentation/asciidoc/services/connect/troubleshooting.adoc new file mode 100644 index 0000000000..4616fbdd69 --- /dev/null +++ b/documentation/asciidoc/services/connect/troubleshooting.adoc @@ -0,0 +1,227 @@ +== Troubleshooting + +=== Known issues + +* Screen sharing only supports sharing a single, primary display of your Raspberry Pi. When a Raspberry Pi is connected to multiple HDMI screens, Connect sometimes shares the contents of the secondary screen. You can work around this by right-clicking the desktop and changing the location of the taskbar in **Desktop Preferences...**. + +* Connect does not support on-screen keyboards. For full functionality, use a physical keyboard. + +* Connect requires a browser that implements https://caniuse.com/?search=es2020[ECMAScript 2020] (ES11) as it makes use of https://caniuse.com/?feats=mdn-javascript_operators_optional_chaining,mdn-javascript_operators_nullish_coalescing,mdn-javascript_builtins_globalthis,es6-module-dynamic-import,bigint,mdn-javascript_builtins_promise_allsettled,mdn-javascript_builtins_string_matchall,mdn-javascript_statements_export_namespace,mdn-javascript_operators_import_meta[features] unavailable in older browsers. + +* Browsers intercept certain keys and key combinations. As a result, you can't type these keys into your Connect window. Screen sharing includes a toolbar to simulate some of the most popular intercepted keys. + +* Upgrading `rpi-connect` and `rpi-connect-lite` using Connect's remote shell is not supported. The upgrade process will terminate all remote shell sessions and drop all connections. To upgrade Connect in a remote shell session, use a tool like `screen` or `tmux` to ensure the process continues uninterrupted after your connection is closed. + +* To upgrade from version 1 to version 2, you must first upgrade the package you currently have installed before switching between `rpi-connect` and `rpi-connect-lite`. This ensures that Connect's services properly migrate to the version 2 format. If you currently have `rpi-connect` installed, run the following command: ++ +[source,console] +---- +$ sudo apt install --only-upgrade rpi-connect +---- ++ +Alternatively, if you currently have `rpi-connect-lite` installed, run the following command: ++ +[source,console] +---- +$ sudo apt install --only-upgrade rpi-connect-lite +---- ++ +You should see output similar to the following during the upgrade, indicating that Connect's services have migrated to the version 2 format: ++ +[source,console] +---- +Replacing globally-enabled rpi-connect services with user-enabled ones... +---- + +=== Common issues + +==== Screen sharing not available + +If Connect states that screen sharing is unavailable, one or more requirements for screen sharing support are not met. To help debug the problem, `rpi-connect` and `rpi-connect-lite` include the `doctor` command. Use `rpi-connect doctor` to identify issues with screen sharing. + +Run the following command: + +[source,console] +---- +$ rpi-connect doctor +---- + +If all is well, you should see output similar to the following: + +---- +Screen sharing is supported by this version of rpi-connect +✓ Wayland compositor available +✓ Screen sharing services enabled and active +✓ Communication with Raspberry Pi Connect WebSocket server +✓ Communication with Raspberry Pi Connect API +✓ Authentication with Raspberry Pi Connect API +✓ Peer-to-peer connection candidate via STUN +✓ Peer-to-peer connection candidate via TURN +---- + +If there is an issue, you will see something like so: + +---- +Screen sharing is supported by this version of rpi-connect +✓ Wayland compositor available +✗ Screen sharing services enabled and active - Please run rpi-connect on to enable and start all required services +✓ Communication with Raspberry Pi Connect WebSocket server +✓ Communication with Raspberry Pi Connect API +✓ Authentication with Raspberry Pi Connect API +✓ Peer-to-peer connection candidate via STUN +✓ Peer-to-peer connection candidate via TURN + +✗ Some checks failed +---- + +If you have repeated issues trying to run Connect's required services, run the following commands to check their status in more detail: + +[source,console] +---- +$ systemctl --user status rpi-connect-wayvnc.service rpi-connect-wayvnc-watcher.path +$ journalctl --user --follow --unit rpi-connect-wayvnc.service --unit rpi-connect-wayvnc-watcher.path +---- + +If the service fails to start or doesn't exist, ensure that your environment meets the following criteria: + +. You use `rpi-connect` version 1.1.0 or later. +. You do not use `rpi-connect-lite`, which lacks screen sharing support. +. You use a Wayland compositor such as wayfire or labwc, not X. You can control this setting via ``raspi-config``'s Advanced Options. +. You use a desktop environment supported by WayVNC, e.g. Raspberry Pi Desktop. For instance, using KDE switches your Wayland compositor to kwin, which is unsupported. +. You have an active graphical desktop session running as the same user as the one you signed into. For most, this means enabling "Desktop Autologin" via ``raspi-config``'s System Options. + +==== Can't connect after restarting or ending SSH session + +Connect runs as a user-level service and is therefore only available if there is an active session for the user signed into the service. If you want remote shell access without also running another login session, xref:connect.adoc#enable-remote-shell-at-all-times[enable user-lingering] for your user, which will keep Connect running at all times. + +For screen sharing, Connect can only share an existing graphical desktop session: it does not create entirely new sessions. There must already be a desktop session in progress. To start such a session automatically on boot, enable Desktop Autologin via ``raspi-config``'s System Options. + +==== Networking and firewall issues + +Connect usually communicates between devices without requiring changes to your network or firewall. However, especially restrictive networks can sometimes block Connect communication. To help debug problems with such networks, `rpi-connect` and `rpi-connect-lite` include the `rpi-connect doctor` command. `rpi-connect doctor` runs a series of tests to check that Connect communication functions properly on your network. + +To run these tests on your device, run the following command: + +[source,console] +---- +$ rpi-connect doctor +---- + +If Connect can communicate properly on your network, you should see output similar to the following: + +---- +Screen sharing is supported by this version of rpi-connect +✓ Wayland compositor available +✓ Screen sharing services enabled and active +✓ Communication with Raspberry Pi Connect WebSocket server +✓ Communication with Raspberry Pi Connect API +✓ Authentication with Raspberry Pi Connect API +✓ Peer-to-peer connection candidate via STUN +✓ Peer-to-peer connection candidate via TURN +---- + +If Connect can't communicate properly on your network, you'll see an "x" instead of a check next to the failing test case. Ask your network administrator to enable the following connections on your network: + +* HTTPS requests to the Raspberry Pi Connect API and WebSocket server on port 443 of `api.connect.raspberrypi.com` and `ws.connect.raspberrypi.com` +* requests to Raspberry Pi Connect STUN or TURN servers on UDP port 3478 of all of the following: +** `stun.raspberrypi.com` +** `turn1.raspberrypi.com` +** `turn2.raspberrypi.com` +** `turn3.raspberrypi.com` +* requests to Raspberry Pi Connect TURN servers on TCP ports 3478 or 443 of all of the following: +** `turn1.raspberrypi.com` +** `turn2.raspberrypi.com` +** `turn3.raspberrypi.com` +* requests to Raspberry Pi Connect TURN servers on UDP ports 3478, 443, or 49152 -> 65535 of all of the following: +** `turn1.raspberrypi.com` +** `turn2.raspberrypi.com` +** `turn3.raspberrypi.com` + +=== View Connect status + +To view the current status of the Connect service, run the following command: + +[source,console] +---- +$ rpi-connect status +---- + +You should see output similar to the following: + +---- +Signed in: yes +Subscribed to events: yes +Screen sharing: allowed (0 sessions active) +Remote shell: allowed (0 sessions active) +---- + +The output of this command indicates whether or not you are currently signed in to Connect, as well as the remote services enabled on your Raspberry Pi. + +If you see output including "Raspberry Pi Connect is not running, run rpi-connect on", run `rpi-connect on` to start Connect. + +=== Enable enhanced logging + +You can enable debug logging for both `rpi-connect` and its dedicated WayVNC server for a detailed account of local operations on your Raspberry Pi. + +==== Enable enhanced logging in `rpi-connect` + +Override the `rpi-connect` service definition with the following command: + +[source,console] +---- +$ systemctl --user edit rpi-connect +---- + +Enter the following lines of configuration between the comments: + +[source,bash] +---- +[Service] +ExecStart= +ExecStart=/usr/bin/rpi-connectd -socket %t/rpi-connect-wayvnc.sock -v +---- + +NOTE: You need **both** lines that begin with `ExecStart=`. + +Finally, restart Connect with the following command: + +[source,console] +---- +$ rpi-connect restart +---- + +==== Enable enhanced logging in the dedicated `wayvnc` server + +Override the `rpi-connect-wayvnc` service definition with the following command: + +[source,console] +---- +$ systemctl --user edit rpi-connect-wayvnc +---- + +Enter the following lines of configuration between the comments (including the `-Ldebug` flag): + +[source,bash] +---- +[Service] +ExecStart= +ExecStart=/usr/bin/rpi-connect-env /usr/bin/wayvnc --config /etc/rpi-connect/wayvnc.config --render-cursor --unix-socket --socket=%t/rpi-connect-wayvnc-ctl.sock -Ldebug %t/rpi-connect-wayvnc.sock +---- + +NOTE: You need **both** lines that begin with `ExecStart=`. + +Finally, restart Connect with the following command: + +[source,console] +---- +$ rpi-connect restart +---- + +=== View Connect logs + +To view logs for the Connect service and its dedicated WayVNC server, run the following command: + +[source,console] +---- +$ journalctl --user --follow --unit rpi-connect --unit rpi-connect-wayvnc +---- diff --git a/documentation/asciidoc/services/connect/use.adoc b/documentation/asciidoc/services/connect/use.adoc new file mode 100644 index 0000000000..9e331d585a --- /dev/null +++ b/documentation/asciidoc/services/connect/use.adoc @@ -0,0 +1,248 @@ +[[link-connect]] +== Link a Raspberry Pi device with a Connect account + +Now that you've installed and started Connect on your Raspberry Pi device, you must associate your device with your Connect account. + +[tabs] +====== +Desktop:: ++ +If you're using the Connect plugin for the menu bar, click **Turn On Raspberry Pi Connect** for the first time to open your browser, prompting you to sign in with your Raspberry Pi ID: ++ +image::images/browser-sign-in.png[width="80%"] ++ +Alternatively, choose **Sign In...** from the dropdown menu: ++ +image::images/sign-in.png[width="80%"] ++ +If you don't already have a Raspberry Pi ID, click *create one for free* to xref:id.adoc#create-a-raspberry-pi-id[create one]. + +CLI:: ++ +Use the following command to generate a link that will connect your device with your Connect account: ++ +[source,console] +---- +$ rpi-connect signin +---- ++ +This command should output something like the following: ++ +---- +Complete sign in by visiting https://connect.raspberrypi.com/verify/XXXX-XXXX +---- ++ +Visit the verification URL on any device and sign in with your Raspberry Pi ID to link your device with your Connect account. + +====== + +=== Finish linking your Raspberry Pi + +After authenticating, assign a name to your device. Choose a name that uniquely identifies the device. Click the **Create device and sign in** button to continue. + +image::images/new-device.png[width="80%"] + +You can now remotely connect to your device. The Connect icon in your menu bar will turn blue to indicate that your device is now signed in to the Connect service. You should receive an email notification indicating that a new device is linked to your Connect account. + +image::images/sign-in-email.png[width="70%"] + +WARNING: If you receive an email that says a device that you do not recognise has signed into Connect, change your Raspberry Pi ID password immediately. xref:connect.adoc#manage-devices[Remove the device from Connect] to permanently disassociate it from your account. Consider xref:id.adoc#enable-two-factor-authentication[enabling two-factor authentication] to keep your account secure. + +Click the Connect icon in your menu bar to open the Connect menu. This menu allows you to turn Connect on and off, sign in and out, and allow or disallow remote access methods. + +TIP: Connect signs communication with your device serial number. Moving your SD card between devices will sign you out of Connect. + +== Access your Raspberry Pi device + +Now that your device appears on your Connect dashboard, you can access your device from anywhere using only a browser. Connect provides multiple ways to interact with your device remotely. + +=== Screen sharing + +Connect includes the ability to share your device's screen in a browser. Use the following instructions to share your device's screen. + +NOTE: Screen sharing requires the **Wayland** window server. Raspberry Pi OS _Bookworm_ and later use Wayland by default. Screen sharing is **not** compatible with Raspberry Pi OS Lite or systems that use the X window server. + +Visit https://connect.raspberrypi.com[connect.raspberrypi.com] on any computer. + +Connect redirects you to the Raspberry Pi ID service to sign in. After signing in, Connect displays a list of linked devices. Devices available for screen sharing show a grey **Screen sharing** badge below the name of the device. + +image::images/devices.png[width="80%"] + +Click the **Connect via** button to the right of the device you would like to access. Select the **Screen sharing** option from the menu. This opens a browser window that displays your device's desktop. + +image::images/waiting-for-screen-sharing.png[width="80%"] + +You can now use your device as you would locally. For more information about the connection, hover your mouse over the padlock icon immediately to the right of the **Disconnect** button. + +image::images/screen-sharing.png[width="80%"] + +TIP: Use the **Copy from remote** and **Paste to remote** buttons above your desktop to transfer text between your local and remote clipboards. + +Once connected, a green dot appears next to the **Screen sharing** badge in the Connect dashboard. This indicates an active screen sharing session. Hover to see the current number of screen sharing sessions. + +image::images/screen-sharing-in-progress.png[width="80%"] + +The Connect icon in the system tray turns purple and displays a closed circle when a screen sharing session is in progress. A desktop notification will appear whenever a screen sharing session starts. + +image::images/screen-sharing-notification.png[width="80%"] + +==== Stop screen sharing + +To close a screen sharing session, click the **Disconnect** button above your desktop. + +image::images/screen-sharing-ended.png[width="80%"] + +==== Disallow screen sharing + +To turn off screen sharing, click the Connect icon in the menu bar and unselect **Allow Screen Sharing**. Your device remains signed into Connect, but you won't be able to create a screen sharing session from the Connect dashboard. + +image::images/disallow-screen-sharing.png[width="80%"] + +Alternatively, you can disallow screen sharing with the following command: + +[source,console] +---- +$ rpi-connect vnc off +---- + +In the Connect dashboard, the **Screen sharing** badge and the **Screen sharing** option in the **Connect via** menu will appear crossed-out. + +image::images/screen-sharing-disabled.png[width="80%"] + +To re-enable screen sharing, do one of the following: + +* click the Connect icon in the menu bar and select **Allow Screen Sharing** +* run the following command: ++ +[source,console] +---- +$ rpi-connect vnc on +---- + +=== Remote shell + +Connect includes the ability to start a shell running on your device from a browser. Use the following instructions to access the remote shell. + +Visit https://connect.raspberrypi.com[connect.raspberrypi.com] on any computer. + +Connect redirects you to the Raspberry Pi ID service to sign in. After signing in, Connect displays a list of linked devices. Devices available for remote shell access show a grey **Remote shell** badge below the name of the device. + +image::images/devices.png[width="80%"] + +Click the **Connect via** button to the right of the device you would like to access. Select the **Remote shell** option from the menu. This opens a shell session on your device. + +image::images/waiting-for-remote-shell.png[width="80%"] + +You can now use your device as you would locally. + +image::images/remote-shell.png[width="80%"] + +TIP: On some operating systems, the browser intercepts key combinations like **Ctrl+Shift+C** and **Ctrl+C**. Instead, you can use the right click menu or **Ctrl+Insert** to copy and **Shift+Insert** to paste. + +Once connected, a green dot appears next to the **Remote shell** badge in the Connect dashboard. This indicates an active remote shell session. Hover to see the current number of remote shell sessions. + +image::images/remote-shell-in-progress.png[width="80%"] + +TIP: Every remote shell connection creates a brand new connection, just like SSH. To persist background commands and configuration across multiple sessions, use `screen` or `tmux`. + +The Connect icon in the menu bar turns purple and displays a closed circle when a remote shell session is in progress. A desktop notification will appear whenever a remote shell session starts. + +image::images/remote-shell-notification.png[width="80%"] + +TIP: The `CONNECT_TTY` environment variable indicates that a session uses a remote shell provided by Connect. + +==== End your remote shell session + +To close a remote shell session, run the `exit` command or close the window. + +image::images/remote-shell-ended.png[width="80%"] + +==== Disallow remote shell access + +To turn off remote shell access, click the Connect icon in the menu bar and unselect **Allow Remote Shell Access**. Your device remains signed into Connect, but you won't be able to create a remote shell session from the Connect dashboard. + +image::images/disallow-remote-shell.png[width="80%"] + +Alternatively, you can disallow remote shell access with the following command: + +[source,console] +---- +$ rpi-connect shell off +---- + +In the Connect dashboard, the **Remote shell** badge and the **Remote shell** option in the **Connect via** menu will appear crossed-out. + +image::images/remote-shell-disabled.png[width="80%"] + +To re-enable remote shell access, do one of the following: + +* click the Connect system tray icon and select **Allow Remote Shell Access** +* run the following command: ++ +[source,console] +---- +$ rpi-connect shell on +---- + +== Enable remote shell at all times + +Connect runs as a user-level service, not as root. As a result, Connect only works when your user account is currently logged in on your device. This can make your device unreachable if you reboot with automatic login disabled. To continue running Connect even when you aren't logged into your device, enable **user-lingering**. Run the following command from your user account to enable user-lingering: + +[source,console] +---- +$ loginctl enable-linger +---- + +TIP: We recommend enabling user-lingering on all headless Raspberry Pi OS Lite setups to prevent your device from becoming unreachable after a remote reboot. + +== Manage devices + +The Connect dashboard lists all of the devices linked with your Connect account and shows you the various ways you can access them. + +image::images/devices.png[width="80%"] + +Click on a device name to open the device details page. This screen provides low-level information about your device. You can also edit the device name or remove the device from Connect. + +image::images/device.png[width="80%"] + +Deleting a device from Connect automatically signs you out of Connect on the device. The Connect icon in the menu bar turns grey and the menu only provides a **Sign In...** option. + +== Update + +To update to the latest version of Connect, run the following command: + +[source, console] +---- +$ sudo apt update +$ sudo apt install --only-upgrade rpi-connect +---- + +TIP: If you installed Connect Lite, replace `rpi-connect` with `rpi-connect-lite` in the above command. + +== Disconnect a device from Connect + +Run the following command on your device to sign out of your Raspberry Pi ID, which will disable your device on the Connect screen: + +[source,console] +---- +$ rpi-connect signout +---- + +Alternatively, click the Connect icon in the menu bar and click "Sign Out". + +TIP: To fully remove a device from your Connect account, xref:connect.adoc#manage-devices[remove it from the Connect dashboard]. + +== Uninstall + +Run the following command to stop and remove Connect from a device: + +[source,console] +---- +$ sudo apt remove --purge rpi-connect +---- + +TIP: If you installed Connect Lite, replace `rpi-connect` with `rpi-connect-lite` in the above command. + +After uninstalling, the serial number of the device remains linked with your Connect account. The device still appears in the Connect dashboard, but can't be used for remote access. If you install Connect again, even with a different SD card, on the same device, it will reuse the existing device name in the Connect dashboard. + +To sever the link between a device and a Connect account, remove the device from the list of devices in the Connect dashboard. diff --git a/documentation/asciidoc/services/id.adoc b/documentation/asciidoc/services/id.adoc new file mode 100644 index 0000000000..efe416cc88 --- /dev/null +++ b/documentation/asciidoc/services/id.adoc @@ -0,0 +1,3 @@ +include::id/signing_up.adoc[] + +include::id/2fa.adoc[] \ No newline at end of file diff --git a/documentation/asciidoc/services/id/2fa.adoc b/documentation/asciidoc/services/id/2fa.adoc new file mode 100644 index 0000000000..d15b3b64af --- /dev/null +++ b/documentation/asciidoc/services/id/2fa.adoc @@ -0,0 +1,37 @@ +== Enable Two-factor authentication + +Like most modern web services, Raspberry Pi ID supports two-factor authentication (2FA) using a https://en.wikipedia.org/wiki/Time-based_one-time_password[time-based one-time password] (TOTP). + +Two-factor authentication adds an extra layer of protection. In addition to a password, 2FA requires another piece of information to log in. You should base this second factor on either _something you have_ (like a smart phone) or _something you are_ (like biometric information). + +This guide uses your smart phone as a second factor for authentication. + +TIP: Raspberry Pi ID supports macOS and iOS iCloud Keychain integration. Right click the QR code to get the "Set up verification code" option on your Mac or iPhone. + +=== Install a 2FA application + +First, download an app to your phone that generates TOTP. Install any 2FA app like https://authy.com/[Authy] or Google Authenticator. + +=== Enable 2FA + +To enable 2FA, click the **Two-factor authentication** option when signed in to your https://id.raspberrypi.com[Raspberry Pi ID]. + +image::images/enable_2fa.png[width="80%"] + +Open the 2FA app on your phone. Scan the QR code provided by your Raspberry Pi ID with your 2FA app to begin generating tokens. + +NOTE: See the documentation for your 2FA app to find out how to scan a QR code to generate a token. + +image::images/authenticate.png[width="80%"] + +Enter the six-digit TOTP generated by your 2FA app to register the 2FA app with your Raspberry Pi ID. + +A confirmation screen will appear, containing a recovery code. Store the recovery code in a safe place. **This is the only way to bypass 2FA** if you lose your phone and the 2FA app. + +image::images/totp_enabled.png[width="80%"] + +You have now configured your Raspberry Pi ID to require 2FA. From now on, sign in requires a TOTP generated by the 2FA app on your phone. + +NOTE: You can disable two-factor authentication at any point in the future at https://id.raspberrypi.com[id.raspberrypi.com]. + + diff --git a/documentation/asciidoc/services/id/images/authenticate.png b/documentation/asciidoc/services/id/images/authenticate.png new file mode 100644 index 0000000000..2aa1d143fe Binary files /dev/null and b/documentation/asciidoc/services/id/images/authenticate.png differ diff --git a/documentation/asciidoc/services/id/images/create_account_identity.png b/documentation/asciidoc/services/id/images/create_account_identity.png new file mode 100644 index 0000000000..d62c13d7c3 Binary files /dev/null and b/documentation/asciidoc/services/id/images/create_account_identity.png differ diff --git a/documentation/asciidoc/services/id/images/enable_2fa.png b/documentation/asciidoc/services/id/images/enable_2fa.png new file mode 100644 index 0000000000..ae87274069 Binary files /dev/null and b/documentation/asciidoc/services/id/images/enable_2fa.png differ diff --git a/documentation/asciidoc/services/id/images/signed_in_identity.png b/documentation/asciidoc/services/id/images/signed_in_identity.png new file mode 100644 index 0000000000..cffbc421bc Binary files /dev/null and b/documentation/asciidoc/services/id/images/signed_in_identity.png differ diff --git a/documentation/asciidoc/services/id/images/totp_enabled.png b/documentation/asciidoc/services/id/images/totp_enabled.png new file mode 100644 index 0000000000..a56492e156 Binary files /dev/null and b/documentation/asciidoc/services/id/images/totp_enabled.png differ diff --git a/documentation/asciidoc/services/id/images/verify_identity.png b/documentation/asciidoc/services/id/images/verify_identity.png new file mode 100644 index 0000000000..d44be1cc20 Binary files /dev/null and b/documentation/asciidoc/services/id/images/verify_identity.png differ diff --git a/documentation/asciidoc/services/id/signing_up.adoc b/documentation/asciidoc/services/id/signing_up.adoc new file mode 100644 index 0000000000..ef9366cc16 --- /dev/null +++ b/documentation/asciidoc/services/id/signing_up.adoc @@ -0,0 +1,20 @@ +[[create-a-raspberry-pi-id]] +== Create a Raspberry Pi ID + +To use Raspberry Pi services, you must first create a https://id.raspberrypi.com[Raspberry Pi ID]. + +In a browser, navigate to https://id.raspberrypi.com[id.raspberrypi.com]. + +Enter an email and password. Click the **Sign up** button to create your account. + +image::images/create_account_identity.png[width="80%"] + +Once you have created an account, you will receive a verification email. + +image::images/verify_identity.png[width="80%"] + +Click the **Verify email** button in the email to verify your email address and complete account creation. + +image::images/signed_in_identity.png[width="80%"] + +After creating a Raspberry Pi ID, you can log in to Raspberry Pi services using the **Sign in with Raspberry Pi ID** button. diff --git a/documentation/htaccess_extra.txt b/documentation/htaccess_extra.txt new file mode 100644 index 0000000000..db4cf04917 --- /dev/null +++ b/documentation/htaccess_extra.txt @@ -0,0 +1,33 @@ + +Redirect 302 "/documentation/hardware/raspberrypi/conformity.md" "https://pip.raspberrypi.com" +RedirectMatch 302 "^/documentation/faqs" "/documentation/" +RedirectMatch 302 "^/documentation/rp2040" "/documentation/microcontrollers/" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/compliance/" "https://pip.raspberrypi.com" +RedirectMatch 302 "^/documentation/hardware/camera/" "/documentation/accessories/camera.html" +RedirectMatch 302 "^/documentation/hardware/computemodule/" "/documentation/computers/compute-module.html" +RedirectMatch 302 "^/documentation/hardware/display/" "/documentation/accessories/display.html" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/bcm2711/" "/documentation/computers/processors.html" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/bcm2835/" "/documentation/computers/processors.html" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/bcm2836/" "/documentation/computers/processors.html" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/bcm2837/" "/documentation/computers/processors.html" +RedirectMatch 302 "^/documentation/hardware/raspberrypi/bcm2837b0/" "/documentation/computers/processors.html" +RedirectMatch 302 "^/documentation/hardware/sense-hat/" "/documentation/accessories/sense-hat.html" +RedirectMatch 302 "^/documentation/hardware/tv-hat/" "/documentation/accessories/tv-hat.html" +RedirectMatch 302 "^/documentation/hardware/" "/documentation/computers/raspberry-pi.html" +RedirectMatch 302 "^/documentation/installation/" "/documentation/computers/getting-started.html" +RedirectMatch 302 "^/documentation/linux/kernel/" "/documentation/computers/linux_kernel.html" +RedirectMatch 302 "^/documentation/linux/software/libcamera/" "/documentation/accessories/camera.html" +RedirectMatch 302 "^/documentation/linux/software/" "/documentation/computers/os.html" +RedirectMatch 302 "^/documentation/raspbian/" "/documentation/computers/os.html" +RedirectMatch 302 "^/documentation/remote-access/" "/documentation/computers/remote-access.html" +RedirectMatch 302 "^/documentation/setup/" "/documentation/computers/getting-started.html" +RedirectMatch 302 "^/documentation/usage/camera/" "/documentation/accessories/camera.html" +RedirectMatch 302 "^/documentation/usage/" "/documentation/computers/os.html" +RedirectMatch 302 "^/documentation/configuration/" "/documentation/computers/configuration.html" +RedirectMatch 302 "^/documentation/computers/raspberry-pi-5.html" "/documentation/computers/raspberry-pi.html" +RedirectMatch 302 "^/documentation/microcontrollers/rp1.html" "/documentation/microcontrollers/silicon.html" +RedirectMatch 302 "^/documentation/microcontrollers/rp2040.html" "/documentation/microcontrollers/silicon.html" +RedirectMatch 302 "^/documentation/microcontrollers/raspberry-pi-pico.html" "/documentation/microcontrollers/pico-series.html" +RedirectMatch 302 "^/documentation/microcontrollers/pico.html" "/documentation/microcontrollers/pico-series.html" + + diff --git a/documentation/images/C-and-CPP-SMALL.png b/documentation/images/C-and-CPP-SMALL.png new file mode 100644 index 0000000000..60df9bc843 Binary files /dev/null and b/documentation/images/C-and-CPP-SMALL.png differ diff --git a/documentation/images/MP-SMALL.png b/documentation/images/MP-SMALL.png new file mode 100644 index 0000000000..e2950c6b10 Binary files /dev/null and b/documentation/images/MP-SMALL.png differ diff --git a/documentation/images/Pico-SMALL.png b/documentation/images/Pico-SMALL.png deleted file mode 100644 index 21d169209c..0000000000 Binary files a/documentation/images/Pico-SMALL.png and /dev/null differ diff --git a/documentation/images/Touch-Display-2-SMALL.png b/documentation/images/Touch-Display-2-SMALL.png new file mode 100644 index 0000000000..1a5f615507 Binary files /dev/null and b/documentation/images/Touch-Display-2-SMALL.png differ diff --git a/documentation/images/ai-cam-SMALL.png b/documentation/images/ai-cam-SMALL.png new file mode 100644 index 0000000000..f4a2e75c2d Binary files /dev/null and b/documentation/images/ai-cam-SMALL.png differ diff --git a/documentation/images/ai-hat-plus-SMALL.png b/documentation/images/ai-hat-plus-SMALL.png new file mode 100644 index 0000000000..48233f4bb4 Binary files /dev/null and b/documentation/images/ai-hat-plus-SMALL.png differ diff --git a/documentation/images/ai-kit-SMALL.png b/documentation/images/ai-kit-SMALL.png new file mode 100644 index 0000000000..28ab2b3432 Binary files /dev/null and b/documentation/images/ai-kit-SMALL.png differ diff --git a/documentation/images/ai.png b/documentation/images/ai.png new file mode 100644 index 0000000000..f4a2e75c2d Binary files /dev/null and b/documentation/images/ai.png differ diff --git a/documentation/images/bumper-SMALL.png b/documentation/images/bumper-SMALL.png new file mode 100644 index 0000000000..346b6510a2 Binary files /dev/null and b/documentation/images/bumper-SMALL.png differ diff --git a/documentation/images/full-sized/Audio-HATs.png b/documentation/images/full-sized/Audio-HATs.png new file mode 100644 index 0000000000..801d985155 Binary files /dev/null and b/documentation/images/full-sized/Audio-HATs.png differ diff --git a/documentation/images/full-sized/Build-HAT.png b/documentation/images/full-sized/Build-HAT.png new file mode 100644 index 0000000000..8a81a1d2bd Binary files /dev/null and b/documentation/images/full-sized/Build-HAT.png differ diff --git a/documentation/images/full-sized/C-and-CPP.png b/documentation/images/full-sized/C-and-CPP.png new file mode 100644 index 0000000000..442c96fcf8 Binary files /dev/null and b/documentation/images/full-sized/C-and-CPP.png differ diff --git a/documentation/images/full-sized/Configuration.png b/documentation/images/full-sized/Configuration.png index f1a7192ef0..aca7034fdf 100644 Binary files a/documentation/images/full-sized/Configuration.png and b/documentation/images/full-sized/Configuration.png differ diff --git a/documentation/images/full-sized/Connect-BIG.png b/documentation/images/full-sized/Connect-BIG.png new file mode 100644 index 0000000000..8e9eff4f68 Binary files /dev/null and b/documentation/images/full-sized/Connect-BIG.png differ diff --git a/documentation/images/full-sized/Debug-Probe.png b/documentation/images/full-sized/Debug-Probe.png new file mode 100644 index 0000000000..e7165c26dc Binary files /dev/null and b/documentation/images/full-sized/Debug-Probe.png differ diff --git a/documentation/images/full-sized/Forums.png b/documentation/images/full-sized/Forums.png new file mode 100644 index 0000000000..e20b268f66 Binary files /dev/null and b/documentation/images/full-sized/Forums.png differ diff --git a/documentation/images/full-sized/Getting-Started.png b/documentation/images/full-sized/Getting-Started.png index 282ec3250e..14dd7823c4 100644 Binary files a/documentation/images/full-sized/Getting-Started.png and b/documentation/images/full-sized/Getting-Started.png differ diff --git a/documentation/images/full-sized/Legacy-config-txt.png b/documentation/images/full-sized/Legacy-config-txt.png new file mode 100644 index 0000000000..c09c4d42c5 Binary files /dev/null and b/documentation/images/full-sized/Legacy-config-txt.png differ diff --git a/documentation/images/full-sized/Linux-Kernel.png b/documentation/images/full-sized/Linux-Kernel.png new file mode 100644 index 0000000000..78ac498dcd Binary files /dev/null and b/documentation/images/full-sized/Linux-Kernel.png differ diff --git a/documentation/images/full-sized/MP.png b/documentation/images/full-sized/MP.png new file mode 100644 index 0000000000..78a00b40a5 Binary files /dev/null and b/documentation/images/full-sized/MP.png differ diff --git a/documentation/images/full-sized/Pi-5.png b/documentation/images/full-sized/Pi-5.png new file mode 100644 index 0000000000..442a6e3ad6 Binary files /dev/null and b/documentation/images/full-sized/Pi-5.png differ diff --git a/documentation/images/full-sized/RP2040.png b/documentation/images/full-sized/RP2040.png deleted file mode 100644 index 90c94467a9..0000000000 Binary files a/documentation/images/full-sized/RP2040.png and /dev/null differ diff --git a/documentation/images/full-sized/Raspberry-Pi-Hardware.png b/documentation/images/full-sized/Raspberry-Pi-Hardware.png index 221748176b..118c5e3259 100644 Binary files a/documentation/images/full-sized/Raspberry-Pi-Hardware.png and b/documentation/images/full-sized/Raspberry-Pi-Hardware.png differ diff --git a/documentation/images/full-sized/Raspberry-Pi-ID.png b/documentation/images/full-sized/Raspberry-Pi-ID.png new file mode 100644 index 0000000000..42658ee930 Binary files /dev/null and b/documentation/images/full-sized/Raspberry-Pi-ID.png differ diff --git a/documentation/images/full-sized/SDK-Intro.png b/documentation/images/full-sized/SDK-Intro.png new file mode 100644 index 0000000000..2181ea2473 Binary files /dev/null and b/documentation/images/full-sized/SDK-Intro.png differ diff --git a/documentation/images/full-sized/The-config-txt-file.png b/documentation/images/full-sized/The-config-txt-file.png index 71f329aac5..3a721b291d 100644 Binary files a/documentation/images/full-sized/The-config-txt-file.png and b/documentation/images/full-sized/The-config-txt-file.png differ diff --git a/documentation/images/full-sized/Touch-Display-2.png b/documentation/images/full-sized/Touch-Display-2.png new file mode 100644 index 0000000000..e9b7d96cc4 Binary files /dev/null and b/documentation/images/full-sized/Touch-Display-2.png differ diff --git a/documentation/images/full-sized/Tutorials.png b/documentation/images/full-sized/Tutorials.png new file mode 100644 index 0000000000..7a740f2b8f Binary files /dev/null and b/documentation/images/full-sized/Tutorials.png differ diff --git a/documentation/images/full-sized/ai-cam.png b/documentation/images/full-sized/ai-cam.png new file mode 100644 index 0000000000..13e2da0a3b Binary files /dev/null and b/documentation/images/full-sized/ai-cam.png differ diff --git a/documentation/images/full-sized/ai-hat-plus.png b/documentation/images/full-sized/ai-hat-plus.png new file mode 100644 index 0000000000..f2e81af828 Binary files /dev/null and b/documentation/images/full-sized/ai-hat-plus.png differ diff --git a/documentation/images/full-sized/ai-kit.png b/documentation/images/full-sized/ai-kit.png new file mode 100644 index 0000000000..7d8ddfdaa7 Binary files /dev/null and b/documentation/images/full-sized/ai-kit.png differ diff --git a/documentation/images/full-sized/ai.png b/documentation/images/full-sized/ai.png new file mode 100644 index 0000000000..13e2da0a3b Binary files /dev/null and b/documentation/images/full-sized/ai.png differ diff --git a/documentation/images/full-sized/bumper.png b/documentation/images/full-sized/bumper.png new file mode 100644 index 0000000000..7dfd8e1c71 Binary files /dev/null and b/documentation/images/full-sized/bumper.png differ diff --git a/documentation/images/full-sized/m2-hat-plus.png b/documentation/images/full-sized/m2-hat-plus.png new file mode 100644 index 0000000000..b8423f39c8 Binary files /dev/null and b/documentation/images/full-sized/m2-hat-plus.png differ diff --git a/documentation/images/full-sized/monitor.png b/documentation/images/full-sized/monitor.png new file mode 100644 index 0000000000..612a5d801c Binary files /dev/null and b/documentation/images/full-sized/monitor.png differ diff --git a/documentation/images/full-sized/pico-sdk_0.png b/documentation/images/full-sized/pico-sdk_0.png new file mode 100644 index 0000000000..8784ad8129 Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_0.png differ diff --git a/documentation/images/full-sized/pico-sdk_1.png b/documentation/images/full-sized/pico-sdk_1.png new file mode 100644 index 0000000000..d52bd9ea3a Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_1.png differ diff --git a/documentation/images/full-sized/pico-sdk_2.png b/documentation/images/full-sized/pico-sdk_2.png new file mode 100644 index 0000000000..0965651c41 Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_2.png differ diff --git a/documentation/images/full-sized/pico-sdk_3.png b/documentation/images/full-sized/pico-sdk_3.png new file mode 100644 index 0000000000..7a634a2c3c Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_3.png differ diff --git a/documentation/images/full-sized/pico-sdk_4.png b/documentation/images/full-sized/pico-sdk_4.png new file mode 100644 index 0000000000..87a1256565 Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_4.png differ diff --git a/documentation/images/full-sized/pico-sdk_5.png b/documentation/images/full-sized/pico-sdk_5.png new file mode 100644 index 0000000000..80d1ac67e4 Binary files /dev/null and b/documentation/images/full-sized/pico-sdk_5.png differ diff --git a/documentation/images/full-sized/pico-series.png b/documentation/images/full-sized/pico-series.png new file mode 100644 index 0000000000..d2da8d0964 Binary files /dev/null and b/documentation/images/full-sized/pico-series.png differ diff --git a/documentation/images/full-sized/sd-card.png b/documentation/images/full-sized/sd-card.png new file mode 100644 index 0000000000..fe6fc104e2 Binary files /dev/null and b/documentation/images/full-sized/sd-card.png differ diff --git a/documentation/images/full-sized/silicon.png b/documentation/images/full-sized/silicon.png new file mode 100644 index 0000000000..a9e2c5157a Binary files /dev/null and b/documentation/images/full-sized/silicon.png differ diff --git a/documentation/images/full-sized/software-sources.png b/documentation/images/full-sized/software-sources.png new file mode 100644 index 0000000000..64cf707be0 Binary files /dev/null and b/documentation/images/full-sized/software-sources.png differ diff --git a/documentation/images/full-sized/ssd-kit.png b/documentation/images/full-sized/ssd-kit.png new file mode 100644 index 0000000000..f208c1d8f6 Binary files /dev/null and b/documentation/images/full-sized/ssd-kit.png differ diff --git a/documentation/images/full-sized/ssds.png b/documentation/images/full-sized/ssds.png new file mode 100644 index 0000000000..4c47488ffa Binary files /dev/null and b/documentation/images/full-sized/ssds.png differ diff --git a/documentation/images/full-sized/usb-3-hub.png b/documentation/images/full-sized/usb-3-hub.png new file mode 100644 index 0000000000..31c75a1a2f Binary files /dev/null and b/documentation/images/full-sized/usb-3-hub.png differ diff --git a/documentation/images/m2-hat-plus-SMALL.png b/documentation/images/m2-hat-plus-SMALL.png new file mode 100644 index 0000000000..267da74b89 Binary files /dev/null and b/documentation/images/m2-hat-plus-SMALL.png differ diff --git a/documentation/images/monitor-SMALL.png b/documentation/images/monitor-SMALL.png new file mode 100644 index 0000000000..e4c3547b3f Binary files /dev/null and b/documentation/images/monitor-SMALL.png differ diff --git a/documentation/images/pico-series-SMALL.png b/documentation/images/pico-series-SMALL.png new file mode 100644 index 0000000000..d1cd300aaf Binary files /dev/null and b/documentation/images/pico-series-SMALL.png differ diff --git a/documentation/images/sd-card-SMALL.png b/documentation/images/sd-card-SMALL.png new file mode 100644 index 0000000000..ee96081dd6 Binary files /dev/null and b/documentation/images/sd-card-SMALL.png differ diff --git a/documentation/images/ssd-kit-SMALL.png b/documentation/images/ssd-kit-SMALL.png new file mode 100644 index 0000000000..464260cc39 Binary files /dev/null and b/documentation/images/ssd-kit-SMALL.png differ diff --git a/documentation/images/ssds-SMALL.png b/documentation/images/ssds-SMALL.png new file mode 100644 index 0000000000..74667b5afc Binary files /dev/null and b/documentation/images/ssds-SMALL.png differ diff --git a/documentation/images/usb-3-hub-SMALL.png b/documentation/images/usb-3-hub-SMALL.png new file mode 100644 index 0000000000..41e1d6bc49 Binary files /dev/null and b/documentation/images/usb-3-hub-SMALL.png differ diff --git a/documentation/index.json b/documentation/index.json index 8e84695f6a..f857503642 100644 --- a/documentation/index.json +++ b/documentation/index.json @@ -6,76 +6,82 @@ "default_tab": "yes", "subitems": [ { - "title": "Getting Started", - "description": "This is the stuff about how to get started.", - "image": "Getting-Started-SMALL.png", + "title": "Getting started", + "description": "How to get started with your Raspberry Pi", + "image": "full-sized/Getting-Started.png", "subpath": "getting-started.adoc" }, { "title": "Raspberry Pi OS", - "description": "The official OS of Raspberry Pi", - "image": "Raspberry-Pi-OS-SMALL.png", + "description": "The official Raspberry Pi operating system", + "image": "full-sized/Raspberry-Pi-OS.png", "subpath": "os.adoc" }, { "title": "Configuration", - "description": "Configuring the Raspberry Pi's settings to suit your needs", - "image": "Configuration-SMALL.png", + "description": "Configuring your Raspberry Pi's settings", + "image": "full-sized/Configuration.png", "subpath": "configuration.adoc" }, { - "title": "The config.txt file", - "description": "Low-level control of your Raspberry Pi's settings", - "image": "The-config-txt-file-SMALL.png", + "title": "`config.txt`", + "description": "Low-level settings control", + "image": "full-sized/The-config-txt-file.png", "subpath": "config_txt.adoc" }, + { + "title": "Legacy `config.txt` options", + "description": "Options which may be useful for OSes other than Raspberry Pi OS", + "image": "full-sized/Legacy-config-txt.png", + "subpath": "legacy_config_txt.adoc" + }, { "title": "The Linux kernel", "description": "How to configure and build a custom kernel for your Raspberry Pi", - "image": "Linux-Kernel-SMALL.png", + "image": "full-sized/Linux-Kernel.png", "subpath": "linux_kernel.adoc" }, { - "title": "Using Linux", - "description": "How to use the Linux command line from Raspberry Pi OS", - "image": "Using-Linux-SMALL.png", - "subpath": "using_linux.adoc" - }, - { - "title": "Remote Access", + "title": "Remote access", "description": "Accessing your Raspberry Pi remotely", - "image": "Remote-Access-SMALL.png", + "image": "full-sized/Remote-Access.png", "subpath": "remote-access.adoc" }, { - "title": "Raspberry Pi Hardware", + "title": "Camera software", + "description": "Software and libraries for Raspberry Pi camera hardware", + "image": "full-sized/Camera.png", + "subpath": "camera_software.adoc" + }, + { + "title": "AI Kit and AI HAT+ software", + "description": "Software and libraries for artificial intelligence on a Raspberry Pi hardware", + "image": "full-sized/ai.png", + "subpath": "ai.adoc" + }, + { + "title": "Raspberry Pi hardware", "description": "Technical information about Raspberry Pi hardware", - "image": "Raspberry-Pi-Hardware-SMALL.png", + "image": "full-sized/Raspberry-Pi-Hardware.png", "subpath": "raspberry-pi.adoc" }, { - "title": "Compute Module Hardware", + "title": "Compute Module hardware", "description": "Technical information about Raspberry Pi Compute Module hardware", - "image": "Compute-Module-Hardware-SMALL.png", + "image": "full-sized/Compute-Module-Hardware.png", "subpath": "compute-module.adoc" }, { "title": "Processors", "description": "Technical information about the CPUs used by Raspberry Pi", - "image": "Processors-SMALL.png", + "image": "full-sized/Processors.png", "subpath": "processors.adoc" }, { - "title": "PIP", - "description": "The Product Information Portal (PIP) for Raspberry Pi compliance documents.", - "image": "PIP-SMALL.png", - "url": "https://pip.raspberrypi.org/" - }, - { - "title": "Datasheets", - "description": "The Datasheets site for PDF-based documentation.", - "image": "Datasheets-SMALL.png", - "url": "https://datasheets.raspberrypi.org" + "title": "Software sources", + "description": "Open source software by Raspberry Pi", + "image": "full-sized/software-sources.png", + "subpath": "software-sources.adoc" } ] }, @@ -84,53 +90,119 @@ "path": "accessories", "default_tab": "no", "subitems": [ + { + "title": "SD Cards", + "description": "Raspberry Pi's official SD cards", + "image": "full-sized/sd-card.png", + "subpath": "sd-cards.adoc" + }, + { + "title": "SSDs", + "description": "Raspberry Pi's official Solid State Drives", + "image": "full-sized/ssds.png", + "subpath": "ssds.adoc" + }, + { + "title": "SSD Kit", + "description": "Storage for your Raspberry Pi", + "image": "full-sized/ssd-kit.png", + "subpath": "ssd-kit.adoc" + }, + { + "title": "M.2 HAT+", + "description": "Connect storage to your Raspberry Pi via PCIe", + "image": "full-sized/m2-hat-plus.png", + "subpath": "m2-hat-plus.adoc" + }, + { + "title": "Touch Display 2", + "description": "The Raspberry Pi Touch Display 2", + "image": "full-sized/Touch-Display-2.png", + "subpath": "touch-display-2.adoc" + }, + { + "title": "Monitor", + "description": "The Raspberry Pi Monitor", + "image": "full-sized/monitor.png", + "subpath": "monitor.adoc" + }, { "title": "Camera", - "description": "We have several Raspberry Pi Cameras", - "image": "Camera-SMALL.png", + "description": "Raspberry Pi camera boards", + "image": "full-sized/Camera.png", "subpath": "camera.adoc" }, { - "title": "Display", - "description": "The Raspberry Pi Touch display", - "image": "Display-SMALL.png", - "subpath": "display.adoc" + "title": "AI Camera", + "description": "An AI Camera for your Raspberry Pi", + "image": "full-sized/ai-cam.png", + "subpath": "ai-camera.adoc" + }, + { + "title": "Keyboard and mouse", + "description": "Official Raspberry Pi keyboard and mouse", + "image": "full-sized/Keyboard-and-Mouse.png", + "subpath": "keyboard-and-mouse.adoc" }, { - "title": "Keyboard & Mouse", - "description": "We have our own Keyboard and Mouse", - "image": "Keyboard-and-Mouse-SMALL.png", - "url": "https://datasheets.raspberrypi.org/keyboard-mouse/getting-started-with-keyboard-and-mouse.pdf" + "title": "USB Hub", + "description": "Official Raspberry Pi USB hub", + "image": "full-sized/usb-3-hub.png", + "subpath": "usb-3-hub.adoc" + }, + { + "title": "Build HAT", + "description": "How to use the Build HAT", + "image": "full-sized/Build-HAT.png", + "subpath": "build-hat.adoc" }, { "title": "Sense HAT", - "description": "How to use the Sense HAT", - "image": "Sense-HAT-SMALL.png", + "description": "Monitor and visualise sensor data", + "image": "full-sized/Sense-HAT.png", "subpath": "sense-hat.adoc" }, { - "title": "TV HAT", - "description": "How to watch TV on your Raspberry Pi", - "image": "TV-HAT-SMALL.png", - "subpath": "tv-hat.adoc" + "title": "AI Kit", + "description": "An NPU that connects to your Raspberry Pi via M.2", + "image": "full-sized/ai-kit.png", + "subpath": "ai-kit.adoc" + }, + { + "title": "AI HAT+", + "description": "An NPU HAT+ for your Raspberry Pi", + "image": "full-sized/ai-hat-plus.png", + "subpath": "ai-hat-plus.adoc" + }, + { + "title": "Raspberry Pi Audio", + "description": "High-definition audio with Raspberry Pi", + "image": "full-sized/Audio-HATs.png", + "subpath": "audio.adoc" }, { "title": "Designing a HAT", "description": "Information on the HAT specification", - "image": "Designing-a-HAT-SMALL.png", - "url": "https://github.com/raspberrypi/hats" + "image": "full-sized/Designing-a-HAT.png", + "url": "https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf" + }, + { + "title": "Touch Display", + "description": "The Raspberry Pi Touch Display", + "image": "full-sized/Display.png", + "subpath": "display.adoc" }, { - "title": "PIP", - "description": "The Product Information Portal (PIP) for Raspberry Pi compliance documents.", - "image": "PIP-SMALL.png", - "url": "https://pip.raspberrypi.org/" + "title": "TV HAT", + "description": "Watch TV on your Raspberry Pi", + "image": "full-sized/TV-HAT.png", + "subpath": "tv-hat.adoc" }, { - "title": "Datasheets", - "description": "The Datasheets site for PDF-based documentation.", - "image": "Datasheets-SMALL.png", - "url": "https://datasheets.raspberrypi.org" + "title": "Bumper", + "description": "A protective case for your Raspberry Pi 5", + "image": "full-sized/bumper.png", + "subpath": "bumper.adoc" } ] }, @@ -139,30 +211,59 @@ "path": "microcontrollers", "subitems": [ { - "title": "RP2040", - "description": "Our first microcontroller device", - "image": "RP2040-SMALL.png", - "url": "https://www.raspberrypi.org/documentation/rp2040/getting-started/#rp2040-boards" + "title": "Silicon", + "description": "Raspberry Pi in-house Silicon", + "image": "full-sized/silicon.png", + "subpath": "silicon.adoc" + }, + { + "title": "Pico-series Microcontrollers", + "description": "Support for Raspberry Pi Pico-series devices", + "image": "full-sized/pico-series.png", + "subpath": "pico-series.adoc" }, { - "title": "Raspberry Pi Pico", - "description": "A board built around our RP2040", - "image": "Pico-SMALL.png", - "url": "https://www.raspberrypi.org/documentation/rp2040/getting-started/#board-specifications" + "title": "Raspberry Pi Debug Probe", + "description": "Supports Arm Serial Wire Debug (SWD), and acts as a UART bridge", + "image": "full-sized/Debug-Probe.png", + "subpath": "debug-probe.adoc" + }, + { + "title": "MicroPython", + "description": "Getting started with MicroPython", + "image": "full-sized/MP.png", + "subpath": "micropython.adoc" }, { - "title": "PIP", - "description": "The Product Information Portal (PIP) for Raspberry Pi compliance documents.", - "image": "PIP-SMALL.png", - "url": "https://pip.raspberrypi.org/" + "title": "The C/C++ SDK", + "description": "Getting started with the C/C++ SDK", + "image": "full-sized/C-and-CPP.png", + "subpath": "c_sdk.adoc" + } + ] + }, + { + "title": "Services", + "path": "services", + "subitems": [ + { + "title": "Raspberry Pi ID", + "description": "Our identity service", + "image": "full-sized/Raspberry-Pi-ID.png", + "subpath": "id.adoc" }, { - "title": "Datasheets", - "description": "The Datasheets site for PDF-based documentation.", - "image": "Datasheets-SMALL.png", - "url": "https://datasheets.raspberrypi.org" + "title": "Raspberry Pi Connect", + "description": "Connect to your Raspberry Pi from your browser", + "image": "full-sized/Connect-BIG.png", + "subpath": "connect.adoc" } ] + }, + { + "title": "Pico C SDK", + "from_json": "picosdk_index.json", + "directory": "pico-sdk" } ] } diff --git a/documentation/redirects/datasheets.csv b/documentation/redirects/datasheets.csv index c1de552f95..241df2db5a 100644 --- a/documentation/redirects/datasheets.csv +++ b/documentation/redirects/datasheets.csv @@ -1,40 +1,83 @@ -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_DE_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/DE-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_DK_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/DK-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_ES_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/ES-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_FR_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/FR-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_IT_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/IT-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_NO_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/NO-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_PT_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/PT-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_SE_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/SE-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_UK_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/UK-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_US_layout.png,https://datasheets.raspberrypi.org/keyboard-mouse/US-layout.png -/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_mouse.pdf,https://datasheets.raspberrypi.org/keyboard-mouse/keyboard-mouse-mechanical-drawing.pdf -/documentation/hardware/display/mechanical/7InchDisplayDrawing-14092015.pdf,https://datasheets.raspberrypi.org/display/7-inch-display-mechanical-drawing.pdf -/documentation/hardware/camera/mechanical/rpi_MECH_Camera2_2p1.pdf,https://datasheets.raspberrypi.org/camera/camera-v2-mechanical-drawing.pdf -/documentation/hardware/camera/mechanical/rpi_MECH_HQcamera_1p0.pdf,https://datasheets.raspberrypi.org/hq-camera/hq-camera-mechanical-drawing.pdf -/documentation/hardware/camera/mechanical/rpi_MECH_HQcamera_lensmount_1p0.pdf,https://datasheets.raspberrypi.org/hq-camera/hq-camera-lensmount-drawing.pdf -/documentation/hardware/camera/schematics/rpi_SCH_Camera2_2p1.pdf,https://datasheets.raspberrypi.org/camera/camera-v2-schematics.pdf -/documentation/hardware/camera/schematics/rpi_SCH_HQcamera_1p0.pdf,https://datasheets.raspberrypi.org/hq-camera/hq-camera-schematics.pdf -/documentation/hardware/sense-hat/schematics/Sense-HAT-V1_0.pdf,https://datasheets.raspberrypi.org/sense-hat/sense-hat-schematics.pdf -/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0.pdf,https://datasheets.raspberrypi.org/bcm2711/bcm2711-peripherals.pdf -/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0_preliminary.pdf,https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-datasheet.pdf -/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf,https://datasheets.raspberrypi.org/bcm2836/bcm2836-peripherals.pdf -/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf,https://datasheets.raspberrypi.org/bcm2835/bcm2835-peripherals.pdf -/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_3p0.pdf,https://datasheets.raspberrypi.org/cm/cm1-and-cm3-datasheet.pdf -/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_2p0.pdf,https://datasheets.raspberrypi.org/cm/cm1-and-cm3-datasheet.pdf -/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_1p0.pdf,https://datasheets.raspberrypi.org/cm/cm1-and-cm3-datasheet.pdf -/documentation/hardware/computemodule/datasheets/rpi_DATA_CM3plus_1p0.pdf,https://datasheets.raspberrypi.org/cm/cm3-plus-datasheet.pdf -/documentation/hardware/computemodule/dt-blob-cam1.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-cam1.bin -/documentation/hardware/computemodule/dt-blob-cam1.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-cam1.dts -/documentation/hardware/computemodule/dt-blob-disp0-only.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-disp0-only.bin -/documentation/hardware/computemodule/dt-blob-disp0-only.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-disp0-only.dts -/documentation/hardware/computemodule/dt-blob-disp1-cam1.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam1.bin -/documentation/hardware/computemodule/dt-blob-disp1-cam1.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam1.dts -/documentation/hardware/computemodule/dt-blob-disp1-cam2.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam2.bin -/documentation/hardware/computemodule/dt-blob-disp1-cam2.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-cam2.dts -/documentation/hardware/computemodule/dt-blob-disp1-only.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-only.bin -/documentation/hardware/computemodule/dt-blob-disp1-only.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-disp1-only.dts -/documentation/hardware/computemodule/dt-blob-dualcam.bin,https://datasheets.raspberrypi.org/cmio/dt-blob-dualcam.bin -/documentation/hardware/computemodule/dt-blob-dualcam.dts,https://datasheets.raspberrypi.org/cmio/dt-blob-dualcam.dts -/documentation/hardware/computemodule/example1-overlay.dts,https://datasheets.raspberrypi.org/cm/example1-overlay.dts -/documentation/hardware/computemodule/minimal-cm-dt-blob.dts,https://datasheets.raspberrypi.org/cm/minimal-cm-dt-blob.dts +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_DE_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/DE-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_DK_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/DK-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_ES_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/ES-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_FR_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/FR-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_IT_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/IT-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_NO_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/NO-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_PT_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/PT-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_SE_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/SE-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_UK_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/UK-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_US_layout.png,https://datasheets.raspberrypi.com/keyboard-mouse/US-layout.png +/documentation/hardware/keyboard_mouse/mechanical/rpi_MECH_keyboard_mouse.pdf,https://datasheets.raspberrypi.com/keyboard-mouse/keyboard-mouse-mechanical-drawing.pdf +/documentation/hardware/display/7InchDisplayDrawing-14092015.pdf,https://datasheets.raspberrypi.com/display/7-inch-display-mechanical-drawing.pdf +/documentation/hardware/display/mechanical/7InchDisplayDrawing-14092015.pdf,https://datasheets.raspberrypi.com/display/7-inch-display-mechanical-drawing.pdf +/documentation/hardware/camera/mechanical/rpi_MECH_Camera2_2p1.pdf,https://datasheets.raspberrypi.com/camera/camera-module-2-mechanical-drawing.pdf +/documentation/hardware/camera/mechanical/rpi_MECH_HQcamera_1p0.pdf,https://datasheets.raspberrypi.com/hq-camera/hq-camera-cs-mechanical-drawing.pdf +/documentation/hardware/camera/mechanical/rpi_MECH_HQcamera_lensmount_1p0.pdf,https://datasheets.raspberrypi.com/hq-camera/hq-camera-cs-lensmount-drawing.pdf +/documentation/hardware/camera/schematics/rpi_SCH_Camera2_2p1.pdf,https://datasheets.raspberrypi.com/camera/camera-module-2-schematics.pdf +/documentation/hardware/camera/schematics/rpi_SCH_HQcamera_1p0.pdf,https://datasheets.raspberrypi.com/hq-camera/hq-camera-schematics.pdf +/documentation/hardware/sense-hat/images/Sense-HAT-V1_0.pdf,https://datasheets.raspberrypi.com/sense-hat/sense-hat-schematics.pdf +/documentation/hardware/sense-hat/schematics/Sense-HAT-V1_0.pdf,https://datasheets.raspberrypi.com/sense-hat/sense-hat-schematics.pdf +/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0.pdf,https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf +/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0_preliminary.pdf,https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-datasheet.pdf +/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf,https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf +/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf,https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf +/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_3p0.pdf,https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf +/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_2p0.pdf,https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf +/documentation/hardware/computemodule/datasheets/rpi_DATA_CM_1p0.pdf,https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf +/documentation/hardware/computemodule/datasheets/rpi_DATA_CM3plus_1p0.pdf,https://datasheets.raspberrypi.com/cm/cm3-plus-datasheet.pdf +/documentation/hardware/computemodule/dt-blob-cam1.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-cam1.bin +/documentation/hardware/computemodule/dt-blob-cam1.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-cam1.dts +/documentation/hardware/computemodule/dt-blob-disp0-only.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-disp0-only.bin +/documentation/hardware/computemodule/dt-blob-disp0-only.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-disp0-only.dts +/documentation/hardware/computemodule/dt-blob-disp1-cam1.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-cam1.bin +/documentation/hardware/computemodule/dt-blob-disp1-cam1.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-cam1.dts +/documentation/hardware/computemodule/dt-blob-disp1-cam2.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-cam2.bin +/documentation/hardware/computemodule/dt-blob-disp1-cam2.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-cam2.dts +/documentation/hardware/computemodule/dt-blob-disp1-only.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-only.bin +/documentation/hardware/computemodule/dt-blob-disp1-only.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-disp1-only.dts +/documentation/hardware/computemodule/dt-blob-dualcam.bin,https://datasheets.raspberrypi.com/cmio/dt-blob-dualcam.bin +/documentation/hardware/computemodule/dt-blob-dualcam.dts,https://datasheets.raspberrypi.com/cmio/dt-blob-dualcam.dts +/documentation/hardware/computemodule/example1-overlay.dts,https://datasheets.raspberrypi.com/cm/example1-overlay.dts +/documentation/hardware/computemodule/minimal-cm-dt-blob.dts,https://datasheets.raspberrypi.com/cm/minimal-cm-dt-blob.dts +/documentation/linux/software/libcamera/rpi_SOFT_libcamera_1p0.pdf,https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf +/documentation/linux/software/libcamera/rpi_SOFT_libcamera_1p1.pdf,https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf +/documentation/linux/software/libcamera/rpi_SOFT_libcamera_1p2.pdf,https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_4b_4p0-with_mounting.dxf,https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-mechanical-drawing.dxf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_4b_4p0.dxf,https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-mechanical-drawing.dxf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_4b_4p0.pdf,https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-mechanical-drawing.pdf +/documentation/hardware/computemodule/schematics/rpi_SCH_CM3_1p0.pdf,https://datasheets.raspberrypi.com/cm/cm3-schematics.pdf +/documentation/hardware/computemodule/schematics/rpi_SCH_CMCDA_1p1.pdf,https://datasheets.raspberrypi.com/cmcda/cmcda-schematics.pdf +/documentation/hardware/computemodule/schematics/rpi_SCH_CMIO_1p2.pdf,https://datasheets.raspberrypi.com/cmio/cmio-schematics.pdf +/documentation/hardware/computemodule/schematics/rpi_SCH_CMIO_3p0.pdf,https://datasheets.raspberrypi.com/cmio/cmio-schematics.pdf +/documentation/hardware/computemodule/schematics/rpi_SCH_CM_1p1.pdf,https://datasheets.raspberrypi.com/cm/cm1-schematics.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3aplus.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-a-plus-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3aplus_case.pdf,https://datasheets.raspberrypi.com/case/raspberry-pi-3-a-plus-case-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3b_1p2.dxf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-mechanical-drawing.dxf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3b_1p2.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3bplus.dxf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.dxf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3bplus.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3bplus_case.pdf,https://datasheets.raspberrypi.com/case/raspberry-pi-3-b-plus-case-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_PoEHAT.pdf,https://datasheets.raspberrypi.com/poe/poe-hat-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_Zero_1p2.pdf,https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_Zero_1p3.pdf,https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_Zero_case_blank.pdf,https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_Zero_case_camera.pdf,https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-with-camera-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_Zero_case_gpio.pdf,https://datasheets.raspberrypi.com/case/raspberry-pi-zero-case-with-gpio-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_bplus_1p2.dxf,https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-mechanical-drawing.dxf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_bplus_1p2.pdf,https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/mechanical/rpi_MECH_TVHAT_1p0.PNG,https://datasheets.raspberrypi.com/tv-hat/tv-hat-mechanical-drawing.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_1aplus_1p1_reduced.pdf,https://datasheets.raspberrypi.com/rpi/raspberry-pi-a-plus-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_1bplus_1p2_reduced.pdf,https://datasheets.raspberrypi.com/rpi/raspberry-pi-b-plus-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_2b_1p2_reduced.pdf,https://datasheets.raspberrypi.com/rpi2/raspberry-pi-2-b-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_3aplus_1p0_reduced.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-a-plus-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_3b_1p2_reduced.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_3bplus_1p0_reduced.pdf,https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_4b_4p0_reduced.pdf,https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_ZeroW_1p1_reduced.pdf,https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-w-reduced-schematics.pdf +/documentation/hardware/raspberrypi/schematics/rpi_SCH_Zero_1p3_reduced.pdf,https://datasheets.raspberrypi.com/rpizero/raspberry-pi-zero-reduced-schematics.pdf +/documentation/hardware/computemodule/designdata/rpi_DSGN_CMCDA_1p1.zip,https://datasheets.raspberrypi.com/cmcda/RPi-CMCDA-1P1.zip +/documentation/hardware/computemodule/designdata/rpi_DSGN_CMIO_1p2.zip,https://datasheets.raspberrypi.com/cmio/RPi-CMIO-R1P2.zip +/documentation/hardware/computemodule/designdata/rpi_DSGN_CMIO_3p0.zip,https://datasheets.raspberrypi.com/cmio/RPi-CMIO-R3P0.zip +/documentation/hardware/raspberrypi/bootmodes/pxetools/prepare_pxetools,https://datasheets.raspberrypi.com/soft/prepare_pxetools.sh +/documentation/hardware/raspberrypi/bootmodes/pxetools/pxetools,https://datasheets.raspberrypi.com/soft/pxetools.py diff --git a/jekyll-assets/_includes/contribute.html b/jekyll-assets/_includes/contribute.html deleted file mode 100644 index d4dbcadbf9..0000000000 --- a/jekyll-assets/_includes/contribute.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/jekyll-assets/_includes/copyright.html b/jekyll-assets/_includes/copyright.html deleted file mode 100644 index da5ad8d343..0000000000 --- a/jekyll-assets/_includes/copyright.html +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/jekyll-assets/_includes/footer.html b/jekyll-assets/_includes/footer.html index 540dcc9151..1296bcc74f 100644 --- a/jekyll-assets/_includes/footer.html +++ b/jekyll-assets/_includes/footer.html @@ -1,114 +1,233 @@ -