什么是config.txt?
与常规PC上的BIOS不同,树莓派设备使用的配置文件名为config.txt. The GPU reads config.txt before the Arm CPU and Linux initialise. Raspberry Pi OS looks for this file in the 启动分区,位于/boot/firmware/.
您可以编辑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.
对config.txt only take effect after a reboot. You can view the current active settings using the following commands:
vcgencmd get_config <config>-
所做的更改,例如,
vcgencmd get_config arm_freq vcgencmd get_config int-
会显示特定的配置值,例如,
vcgencmd get_config str-
列出所有非零整型配置选项(非零)
并非所有配置设置均可通过上述方法获取vcgencmd.
|
一些旧版config.txt options are no longer officially supported. These are listed in 旧版config.txt选项及其未包含在本文中。
文件格式
该config.txt file is read by the early-stage boot firmware, so it uses a very simple file format: 单个property=value statement on each line, where value is either an integer or a string句点。您可以通过在行首添加该符号来添加注释或屏蔽现有配置值。# character.
条目存在98个字符的行长限制。Raspberry Pi OS会忽略超出此限制的字符。
以下是一个示例文件:
# 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
高级功能
include
指定文件的内容将被插入到当前文件中。
例如,添加该行include extraconfig.txt to config.txt will include the content of extraconfig.txt file in the config.txt file.
|
该 由bootloader处理的设置仅在指定的情况下才会生效。
|
条件过滤
条件过滤器在conditionals 部分.
autoboot.txt
autoboot.txt is an optional configuration file placed in the initial boot partition that can be used to specify the boot_partition number.
此文件可与tryboot feature to implement A/B booting for fail-safe operating system upgrades. It is a native bootloader and firmware capability that operates independently of third-party multi-boot managers.
[8] MiRo-Eautoboot.txt file only controls which boot partition the bootloader selects. Building a resilient, production-ready A/B update system requires dedicated partition layouts (such as redundant boot and root filesystems) and update tooling. For an automated solution, see A/B启动更新树莓派5rpi-image-gen工具。 |
该autoboot.txt file supports the [all], [none], and [tryboot] 条件过滤器.
另请参阅TRYBOOT启动流程。
boot_partition
指定用于启动的分区编号,除非该分区编号已作为参数传递给reboot command (for example, sudo reboot 2).
分区编号从
开始1. Specifying partition 0 instructs the bootloader to pick the default partition, which resolves to the first bootable FAT partition (normally partition 1).
可启动分区必须格式化为 FAT12、FAT16 或 FAT32,并且包含一个start.elf file (or a config.txt file on Raspberry Pi 5) in order for the bootloader to classify them as bootable.
到
的连接cmdline.txt and root filesystem selection
引导加载程序仅读取autoboot.txt to locate the target boot partition. It doesn’t parse or act on cmdline.txt beyond passing its arguments to the operating system kernel.
根分区选择(root=…) is handled by the kernel through cmdline.txt. In a dual-slot A/B system, each boot partition typically contains its own independent cmdline.txt file pointing to its corresponding root partition. Alternatively, if identical files are used on each boot partition, you can use the [boot_partition=N] conditional filter in config.txt to select an alternate cmdline.txt:
[boot_partition=2]
cmdline=cmdline_rootfs_a.txt
[boot_partition=3]
cmdline=cmdline_rootfs_b.txt
tryboot_a_b
将此属性设置为1 to load the normal config.txt and boot.img files instead of tryboot.txt and tryboot.img when the tryboot flag is set.
这将启用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.
A/B 启动的示例更新流程
考虑如下所示的 A/B 分区布局:
-
分区 1(FAT):包含初始引导加载程序的分区
autoboot.txt. -
分区 2(FAT):Slot A 启动分区(
boot_partition=2), containing firmware, kernel, and acmdline.txtpointing to Root A. -
分区 3(FAT):Slot B 启动分区(
boot_partition=3), containing firmware, kernel, and acmdline.txtpointing to Root B. -
分区 4:Slot A 根文件系统分区(Root A)。
-
分区 5:Slot B 根文件系统分区(Root B)。
-
分区 6:一个可选的持久数据存储分区。
初始autoboot.txt:
[all]
tryboot_a_b=1
boot_partition=2
[tryboot]
boot_partition=3
安装更新
系统默认启动到分区 2。假设的更新服务随后将:
-
将下一个操作系统版本安装到分区 3(及其对应的根分区)。
-
通过执行 tryboot 重启来测试更新:
$ sudo reboot "0 tryboot"
提交或取消更新
系统从分区 3 启动,因为[tryboot] filter in autoboot.txt evaluates to true.
替换为您的实际地址:tryboot is active (/proc/device-tree/chosen/bootloader/tryboot equals 1) and we’ve booted from the tryboot partition (/proc/device-tree/chosen/bootloader/partition matches the boot_partition set in the [tryboot] section of autoboot.txt):
* The hypothetical update service would then validate system health.
* 如果成功:更新autoboot.txt to swap the default and tryboot partitions, committing the update.
* 如果失败:执行正常重启而不更改autoboot.txt. The tryboot flag is automatically cleared, causing the system to revert to booting from partition 2.
已更新autoboot.txt after committing:
[all]
tryboot_a_b=1
boot_partition=3
[tryboot]
boot_partition=2
|
位于 下的属性
|
常用选项
常见显示选项
hdmi_enable_4kp60
| 此选项仅适用于 Raspberry Pi 4B、Compute Module 4、Compute Module 4S 和 Raspberry Pi 400。 |
默认情况下,当连接到 4K 显示器时,某些型号会选择 30 Hz 刷新率。使用此选项以允许选择 60 Hz 刷新率。受此设置影响的型号仅在 HDMI0 上支持 4Kp60 输出。启用此设置会增加功耗和温度。
常见硬件配置选项
camera_auto_detect
默认情况下,Raspberry Pi OS 包含一行在/boot/firmware/config.txt that enables this setting.
启用后,固件将自动加载已识别的CSI摄像头的overlays。
若要禁用,请设置camera_auto_detect=0 (or remove camera_auto_detect=1).
display_auto_detect
默认情况下,Raspberry Pi OS 包含一行在/boot/firmware/config.txt that enables this setting.
启用后,固件将自动加载已识别的DSI显示器的overlays。
若要禁用,请设置display_auto_detect=0 (or remove display_auto_detect=1).
dtoverlay
该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.
作为特殊情况,若调用时不带值 –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.
有关更多详细信息,请参阅DTBs、overlays和config.txt.
dtparam
Raspberry Pi设备的Device Tree配置文件支持用于启用I2C和SPI接口等各种功能的参数。许多DT overlays均可通过参数进行配置。这两种类型的参数均可使用以下方式提供: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.
有关更多详细信息,请参阅DTBs、overlays和config.txt.
arm_boost
| 此选项仅适用于包含两相供电的后续Raspberry Pi 4B修订版,以及所有版本的Raspberry Pi 400。 |
默认情况下,Raspberry Pi OS 包含一行在/boot/firmware/config.txt that enables this setting on supported devices.
部分Raspberry Pi设备为SoC电压轨配备了第二路开关模式电源。启用后,会将默认的turbo模式时钟从1.5 GHz提升至1.8 GHz。
若要禁用,请设置arm_boost=0.
power_force_3v3_pwm
| 此选项仅适用于Raspberry Pi 5、500、500+及Compute Module 5。 |
强制在GPIO排针或CSI连接器的3.3V输出上启用PWM。
若要禁用,请设置power_force_3v3_pwm=0.
板载模拟音频(3.5 mm 插孔)
板载音频输出使用 config 选项来更改模拟音频的驱动方式,以及是否启用某些 firmware 功能。
audio_pwm_mode
audio_pwm_mode=1 selects legacy low-quality analogue audio from the 3.5 mm AV jack.
audio_pwm_mode=2 (the default) selects high quality analogue audio using an advanced modulation scheme.
| 此选项会使用更多 GPU 计算资源,并可能干扰某些型号上的某些使用场景。 |
disable_audio_dither
默认情况下,如果音频流被路由到模拟音频输出,则会对其应用 1.0LSB dither。在某些情况下,这可能会产生可听见的背景嘶声,例如当 ALSA 音量设置为较低水平时。设置disable_audio_dither to 1 to disable dither application.
enable_audio_dither
音频 dither(参见上文的 disable_audio_dither)通常在音频样本大于 16 bits 时被禁用。将此选项设置为1 to force the use of dithering for all bit depths.
pwm_sample_bits
该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 音频
默认情况下,所有带 HDMI 输出的 Raspberry Pi 型号都启用了 HDMI 音频输出。
要禁用 HDMI 音频输出,请追加,noaudio to the end of the dtoverlay=vc4-kms-v3d line in /boot/firmware/config.txt:
dtoverlay=vc4-kms-v3d,noaudio
启动选项
start_file, fixup_file
这些选项指定在启动前传输到 VideoCore GPU 的 firmware 文件。
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.
该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.
精简固件(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.
|
Raspberry Pi 5、500、500+ 和 Compute Module 5 的 firmware 存储在 bootloader EEPROM 镜像中,而不是 boot 分区中。这些设备会忽略start*.elf and fixup*.dat files in the boot partition, and ignore the start_file and fixup_file options in config.txt. To update the firmware on these devices, update the bootloader EEPROM. For more information, see 更新 bootloader 配置.
|
cmdline
cmdline is the alternative filename on the boot partition from which to read the kernel command line string; the default value is cmdline.txt.
kernel
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.
Raspberry Pi 5、500、500+ 和 Compute Module 5 的 firmware 默认加载kernel_2712.img because this image contains optimisations specific to those models (for example, 16K page-size). If this file is not present, then the common 64-bit kernel (kernel8.img) will be loaded instead.
arm_64bit
如果设为 1,kernel 将以 64 位模式启动。设为 0 则选择 32 位模式。
在 64 位模式下,firmware 将选择合适的 kernel(例如,kernel8.img), unless there is an explicit kernel option defined, in which case that is used instead.
在 Raspberry Pi 4、400 以及 Compute Module 4 和 4S 平台上默认为 1。在所有其他平台上默认为 0。但是,如果在显式的kernel option matches one of the known kernels then arm_64bit is set accordingly.
64 位 kernel 有以下形式:
-
未压缩的镜像文件
-
镜像的 gzip 归档
两种形式都可以使用img file extension; the bootloader recognises archives using signature bytes at the start of the file.
以下 Raspberry Pi 型号支持此 flag:
-
2B 版本 1.2
-
3B
-
3A+
-
打印属于自己的那份怀旧记忆
-
4B
-
400
-
零2 W
-
计算模块3
-
计算模块 3+
-
计算模块 4
-
计算模块4S
自 Raspberry Pi 5 起的旗舰型号、自 CM5 起的 Compute Module,以及自 Raspberry Pi 500 起的 Keyboard 型号仅支持 64 位 kernel。仅支持 64 位 kernel 的型号会忽略此 flag。
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.
stub 是一小段 Arm 代码,在 kernel 之前运行。它的任务是在将控制权传递给 kernel 之前,设置中断控制器等低级硬件。
ramfsfile
ramfsfile is the optional filename on the boot partition of a ramfs to load.
较新的 firmware 支持加载多个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 论坛.
|
ramfsaddr
ramfsaddr is the memory address to which the ramfsfile should be loaded.
initramfs
构建和更新initramfs is considered an advanced technique that’s undertaken only by experienced users. It isn’t officially supported by Raspberry Pi and we therefore don’t provide instructions for it.
|
该initramfs command specifies both the ramfs filename 和要加载到的内存地址。它执行以下两者的操作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.
此选项使用与其他所有选项不同的语法,并且你不应使用= character here.
|
auto_initramfs
替换为您的实际地址: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. For example, 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 initramfsstatement 是必需的。
disable_poe_fan
默认情况下,即使未连接 PoE HAT,启动时也会在 I2C 总线上进行 probe。将此项设置为 1 会禁用通过 I2C(在 ID_SD 和 ID_SC 引脚上)控制 PoE HAT 风扇。如果你不打算使用 PoE HAT,这是缩短启动时间的有用方法。
disable_splash
替换为您的实际地址:disable_splash is set to 1, the rainbow splash screen will not be shown on boot. The default value is 0.
enable_uart
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
将此选项设置为0 to prevent the firmware from trying to read an I2C HAT EEPROM (connected to pins ID_SD & ID_SC) at power up. See also disable_poe_fan.
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 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.
为了降低系统无法启动的可能性,firmware 会先测试提供的 prefix 值是否可行——除非能在新位置/名称找到预期的 kernel 和 .dtb,否则会忽略该 prefix(设置为 "")。此可行性测试的一个特殊情况适用于 overlays,它们只会从${os_prefix}${overlay_prefix} (where the default value of overlay_prefix是 "overlays/")如果${os_prefix}${overlay_prefix}README exists, otherwise it ignores os_prefix and treats overlays as shared.
(firmware 在检查 prefixes 时检查关键文件是否存在而不是目录,原因有两方面:prefix 不能是目录,并且并非所有启动方法都支持测试目录是否存在。)
任何用户指定的 OS 文件都可以通过使用绝对路径(相对于 boot 分区)绕过所有 prefixes——只需让文件路径以/, for example, kernel=/my_common_kernel.img.
|
otg_mode (Raspberry Pi 4 only)
USB On-The-Go(通常缩写为 OTG)是一项功能,允许受支持的 USB 设备使用合适的 OTG 线缆将自身配置为 USB 主机。在较旧的 Raspberry Pi 设备上,单个 USB 2.0 控制器同时用于 USB 主机和设备模式。
一个通过 PCIe 连接的高性能 USB 3.0 控制器驱动 Raspberry Pi 4B 及更高版本、以及 Raspberry Pi 400 及更高版本上的主 USB 端口。传统 USB 2.0 控制器仍可在 USB-C 电源连接器上用于作为设备(otg_mode=0, the default). Raspberry Pi Compute Module 4 and earlier do not include the USB 3.0 controller.
otg_mode=1 requests that a more capable XHCI USB 2.0 controller is used as an alternative host controller on that USB-C connector.
默认情况下,Raspberry Pi OS 在/boot/firmware/config.txt that enables this setting on Compute Module 4.
|
overlay_prefix
指定从中加载 overlays 的子目录/prefix,默认值为overlays/ (note the trailing /). If used in conjunction with os_prefix,该os_prefix comes before the overlay_prefix; for example, dtoverlay=disable-bt attempts to load ${os_prefix}${overlay_prefix}disable-bt.dtbo.
除非${os_prefix}${overlay_prefix}README exists, overlays are shared with the main OS (that is, os_prefix is ignored).
|
配置属性
Raspberry Pi 5 需要一个config.txt file to be present to indicate that the partition is bootable.
boot_ramdisk
如果此属性设置为1 then the bootloader will attempt load a ramdisk file called boot.img containing the boot 文件系统。后续文件(例如,start4.elf) are read from the ramdisk instead of the original boot file system.
的主要目的是boot_ramdisk is to support secure-boot, however, unsigned boot.img files can also be useful to Network Boot or RPIBOOT configurations.
-
ramdisk 文件的最大大小为:Raspberry Pi 4 及更高版本为 180 MB,较早设备为 128 MB。但是,在内存有限的设备上(例如 256 MB),我们建议使用较小的 ramdisk 文件(例如 32 MB)。
-
boot.imgfiles are raw disk.imgfiles. The recommended format is a plain FAT32 partition with no MBR. -
ramdisk 文件系统的内存会在操作系统启动之前释放。
-
替换为您的实际地址:TRYBOOT被选中,则 bootloader 将搜索
tryboot.imginstead ofboot.img. -
另请参阅autoboot.txt.
有关以下内容的更多信息:secure-boot and creating boot.img files, see USBBOOT.
默认值:0
boot_load_flags
用于自定义固件(裸机)的实验性属性。
位 0 (0x1) 表示 .elf 文件是自定义固件。这会禁用任何兼容性检查(例如,是否支持 USB MSD 启动),并在启动可执行文件之前重置 PCIe。
在 Raspberry Pi 5 上不相关,因为没有start.elf file.
默认值:0x0
enable_rp1_uart
仅适用于 Raspberry Pi 5。
当设置为1, firmware initialises RP1 UART0 to 115200 bps 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.
默认值:0x0
pciex4_reset
仅适用于 Raspberry Pi 5。
默认情况下,由 使用的 PCIe x4 控制器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.
默认值:1
sha256
如果设置为非零值,则启用对已加载文件(内核、initramfs、Device Tree .dtb 文件和 overlays)的 SHA256 哈希日志记录,这些哈希由 生成sha256sum utility. The logging output goes to the UART if enabled, and is also accessible through sudo vclog --msg. This option can be useful when debugging boot problems, but at the cost of potentially adding 多少秒添加到启动时间。在所有平台上默认为 0。
uart_2ndstage
替换为您的实际地址: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 启动选项页面。
该BOOT_UART property also enables bootloader UART logging but does not enable UART logging in start.elf unless uart_2ndstage=1 is also set.
默认值:0
erase_eeprom
替换为您的实际地址: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.
默认值:0
set_reboot_arg1
仅适用于 Raspberry Pi 5。
设置 的值boot_arg1 to be passed through a reset-safe register to the bootloader after a reboot.
See boot_arg1以获取更多详情。
要在运行时设置 reboot 参数而无需编辑config.txt, you can use vcmailbox. For example, to set boot_arg1 to 42 on the next reboot:
$ sudo vcmailbox 0x0003808c 8 8 1 42
默认:``
set_reboot_order
仅适用于 Raspberry Pi 5。
设置 的值启动顺序以在重启后通过 reset-safe 寄存器传递给 bootloader。与tryboot, this is a one-time setting and is automatically cleared after use.
此属性可用于调试不同的启动顺序设置。或者,它可用于对电源和 具有控制权的预配系统中nRPIBOOT GPIO to override the boot mode without specifying 条件过滤器EEPROM 配置中的语句。
要在运行时设置重启顺序而无需编辑config.txt, you can use vcmailbox. For example, to test network boot on the next reboot:
$ sudo vcmailbox 0x0003808b 4 4 0xf4612
$ sudo reboot
默认:``
kernel_watchdog_timeout
如果设置为非零值(以秒为单位),此属性会启用一个硬件看门狗定时器,并在启动时将其移交给操作系统 (OS)。如果 OS 不定期“kick”或重置看门狗,系统将在指定超时后重置。
此属性设置systemd watchdog.open_timeout parameter, which controls how long the OS has to initialise and start servicing the watchdog. The value is passed to the OS through the kernel command line. For ongoing operation, the OS must also regularly reset the watchdog, typically controlled by the RuntimeWatchdogSec parameter in systemd. For more information, see systemd watchdog 文档.
|
在 Raspberry Pi OS 上书虫,该 如果两者都 建议使用 |
这对于确保系统在启动过程完成后能够从操作系统挂起或崩溃中恢复很有用。
默认值:0 (disabled)
kernel_watchdog_partition
如果内核看门狗触发(具体来说,操作系统未能在超时时间内重置看门狗),此属性指定重置后要启动的分区号。这允许自动故障转移到恢复分区或备用分区。
您可以将其与表达式过滤器结合使用,以便在看门狗触发重启到特定分区时应用不同的设置或选择不同的启动流程。
另请参阅分区属性,以获取有关如何使用高分区号检测看门狗触发的更多信息。
默认值:0 (default partition)
eeprom_write_protect
配置 EEPROMwrite status register. This can be set either to mark the entire EEPROM as write-protected, or to clear write-protection.
此选项必须与 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.
请查看Winbond W25x40cl或Winbond W25Q16JV数据手册以获取更多详细信息。
eeprom_write_protect settings in config.txt for recovery.bin.
| 价值感 | 说明 |
|---|---|
1 |
配置写保护区域以覆盖整个 EEPROM。 |
0 |
清除写保护区域。 |
-1 |
不执行任何操作。 |
flashrom does not support clearing of the write-protect regions and will fail to update the EEPROM if write-protect regions are defined.
|
在 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.
默认值:-1
os_check
在 Raspberry Pi 5 上,固件在尝试从当前分区启动之前会自动检查兼容的 Device Tree 文件。否则,较旧的不兼容内核将被加载然后挂起。要禁用此检查(例如,对于裸机开发),请设置os_check=0 in config.txt
默认值:1
bootloader_update
您可以将此选项设置为 0,以在无需更新 EEPROM 配置的情况下阻止自更新。当通过网络启动更新多个 Raspberry Pi 设备时,这有时很有用,因为此选项可以按 Raspberry Pi 单独控制(例如,在config.txt).
默认值:1
Secure Boot 配置属性
MathLink 模板config.txt properties are used to program the secure-boot OTP settings. These changes are irreversible and can only be programmed by using 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.
有关启用以下内容的更多信息:secure-boot, see the following resources:
program_pubkey
如果此属性设置为1 then recovery.bin will write the hash of the public key in the EEPROM image to OTP. When set, the bootloader rejects EEPROM images signed with different RSA keys or unsigned images.
默认值:0
revoke_devkey
仅限 Raspberry Pi 4。
如果此属性设置为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.
此属性仅由recovery.bin release version 2025/05/16 and later if program_pubkey=1.
默认值:0
program_rpiboot_gpio
Raspberry Pi 4B 和 Raspberry Pi 400 自动设置。
Compute Module 4 和 4S 具有专用的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
OS 启动后,你可以将 GPIO 用作通用 I/O 引脚。但是,你应验证此 GPIO 配置不会与任何可能在启动期间将 GPIO 拉低的 HAT 冲突。
虽然“代码一小时”官网全年开放,但在每年的12月——计算机科学教育周之际,世界各地的人们都会……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.
为了安全,此 OTP 值可以仅通过使用以下方式编程: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.
默认值:
program_jtag_lock
如果此属性设置为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.
默认值:0
GPIO控制
gpio
该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).
设置的引脚号后跟一个= and one or more comma-separated attributes from this list:
-
ip– Input -
op– Output -
a0-a5– Alt0-Alt5 -
dh– Driving high (for outputs) -
dl– Driving low (for outputs) -
pu– Pull up -
pd– Pull down -
pn/np– No pull
gpio settings apply in order, so those appearing later override those appearing earlier.
例如:
# Select Alt2 for GPIO pins 0 to 27 (for DPI24)
gpio=0-27=a2
# Set GPIO12 to be an output set to 1
gpio=12=op,dh
# Change the pull on (input) pins 18 and 20
gpio=18,20=pu
# Make pins 17 to 21 inputs
gpio=17-21=ip
该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.
通过此机制进行的 GPIO 更改不会对 kernel 产生任何直接影响。它们不会导致 GPIO 引脚被导出到sysfs interface, and they can be overridden by pinctrl entries in the Device Tree as well as utilities like pinctrl.
另外请注意,从通电到更改生效之间会有几秒钟的延迟——如果通过网络启动或从 USB 大容量存储设备启动,延迟时间会更长。
enable_jtag_gpio
设置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.
| 引脚编号 | 函数 |
|---|---|
GPIO22 |
|
GPIO23 |
|
GPIO24 |
|
GPIO25 |
|
GPIO26 |
|
GPIO27 |
|
超频选项
kernel 包含一个CPUFreq驱动程序,默认启用 powersave governor,在安装raspi-config后于启动期间切换为 on-demand governor。使用 on-demand governor 时,CPU 频率将随处理器负载而变化。您可使用以下参数调整最低值*_min config options, or disable dynamic clocking by applying a static scaling governor (powersave or performance) or with force_turbo=1.
当 SoC 达到指定条件时,将在运行时自动禁用超频和过压。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.
| 有关更多信息请参阅频率管理与热控制部分. |
将任何超频参数设置为除raspi-config正常使用值之外的数值,可能会在 SoC 内部设置一个永久位。这使得能够检测到您的 Raspberry Pi 曾进行过超频操作。超频位会在以下情况被设置force_turbo is set to 1 and any of the over_voltage_* options are set to a value of more than 0. See the 关于 Turbo 模式的官方博客获取更多详细信息。 |
超频
| 选项 | 说明 |
|---|---|
|
Arm CPU 的频率(MHz)。 |
|
增加 |
|
设置 |
|
GPU processor core 频率(MHz)。影响 CPU performance,因为它驱动 L2 cache 和 memory bus;L2 cache 仅对 Raspberry Pi Zero/Raspberry Pi Zero W/Raspberry Pi 1 有优化作用;并且对 Raspberry Pi 2 和 Raspberry Pi 3 的 SDRAM 也有轻微益处。有关在 Raspberry Pi 4 上的用法,请参阅下文。 |
|
hardware video block 频率(MHz);独立覆盖的 |
|
image sensor pipeline block 频率(MHz);独立覆盖的 |
|
3D block 频率(MHz);独立覆盖的 |
|
High Efficiency Video Codec block 频率(MHz);独立覆盖的 |
|
SDRAM 频率(MHz)。不支持在 Raspberry Pi 4 或更新设备上超频 SDRAM。 |
|
CPU/GPU core upper voltage limit。该值应在范围 [-16,8] 内,对应 [0.95V,1.55V](Raspberry Pi 1 上为 [0.8,1.4V]),步长为 0.025V。换句话说,指定 -16 将以 0.95V(Raspberry Pi 1 上为 0.8V)作为最大 CPU/GPU core voltage,而指定 8 则允许最高达 1.55V(Raspberry Pi 1 上为 1.4V)。默认值请参见下表。大于 6 的值仅在以下条件满足时允许: |
|
设置 |
|
SDRAM controller voltage adjustment。[-16,8] 对应 [0.8V,1.4V],步长为 0.025V。不支持 Raspberry Pi 4 及后续设备。 |
|
SDRAM I/O voltage adjustment。[-16,8] 对应 [0.8V,1.4V],步长为 0.025V。不支持 Raspberry Pi 4 及后续设备。 |
|
SDRAM phy voltage adjustment。[-16,8] 对应 [0.8V,1.4V],步长为 0.025V。不支持 Raspberry Pi 4 及后续设备。 |
|
即使 Arm cores 未处于忙碌状态,也强制启用 turbo mode 频率。启用此选项若满足条件可能会设置 warranty bit: |
|
启用从启动时开始启用 turbo mode针对给定的以秒为单位的数值,或直到 * 已将默认值从...修改为 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
...的最小值 |
|
在 Raspberry Pi 4 和 Raspberry Pi 5 上,over_voltage_delta 参数会将给定的微伏偏移量添加到 DVFS algorithm 计算出的数值中。 |
|
Overheat protection。当 SoC 温度达到此摄氏度数值时,会将时钟和电压恢复为默认值。大于 85 的值将被钳位至 85。 |
|
仅适用于 3A+/3B+。CPU speed throttle control。此参数设置触发 CPU clock speed throttling system 的温度。在此温度下,clock speed 将从 1400 MHz 降至 1200 MHz。默认为 |
|
设置为 1 会禁用 core clock frequency 的 dynamic scaling,并确保任何使用 core clock 的 peripherals 保持恒定速度。固定的 clock speed 为该使用平台的较高/turbo frequency。建议优先使用此选项而不是设置特定的 core_clock frequencies,因为它能实现 config files 在不同平台间的可移植性。 |
下表列出了各种 Raspberry Pi models 各项 options 的默认值,所有 frequencies 均以 MHz 为单位。
| 选项 | 树莓派 Zero W | Pi 1 | Pi 2 | Pi 3 | Pi 3A+/Pi 3B+ | CM4 & Pi 4B ⇐ R1.3 | Pi 4B R1.4 | Pi 400 | Pi Zero 2 W | Pi 5/500/500+ |
|---|---|---|---|---|---|---|---|---|---|---|
|
1000 |
700 |
900 |
1200 |
1400 |
1500 |
1500 或 1800 如果 |
1800 |
1000 |
2400 |
|
400 |
250 |
250 |
400 |
400 |
500 |
500 |
500 |
400 |
910 |
|
300 |
250 |
250 |
400 |
400 |
500 |
500 |
500 |
300 |
不适用 |
|
300 |
250 |
250 |
400 |
400 |
500 |
500 |
500 |
300 |
910 |
|
300 |
250 |
250 |
400 |
400 |
500 |
500 |
500 |
300 |
960 |
|
不适用 |
不适用 |
不适用 |
不适用 |
不适用 |
500 |
500 |
500 |
不适用 |
910 |
|
450 |
400 |
450 |
450 |
500 |
3200 |
3200 |
3200 |
450 |
4267 |
|
700 |
700 |
600 |
600 |
600 |
600 |
600 |
600 |
600 |
1500 |
|
250 |
250 |
250 |
250 |
250 |
200 |
200 |
200 |
250 |
500 |
|
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
500 |
|
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
不适用 |
|
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
500 |
|
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
250 |
500 |
|
400 |
400 |
400 |
400 |
400 |
3200 |
3200 |
3200 |
400 |
4267 |
本表提供了跨所有型号相同的选项默认值。
| 选项 | 默认 |
|---|---|
|
0 (秒) |
|
85 (°C) |
|
0 (1.35V,在 Raspberry Pi 1 上为 1.2V) |
|
0 (1.2V) |
|
0 (1.2V) |
|
0 (1.2V) |
|
0 (1.2V) |
|
0 (1.2V) |
固件使用自适应电压缩放 (AVS) 来确定在指定范围内的 CPU/GPU 核心最佳电压。over_voltage and over_voltage_min.
仅适用于 Raspberry Pi 4、Raspberry Pi 400 和 CM4
系统空闲时的最低核心频率必须足够高,以支持显示器(忽略消隐期)的最高像素时钟。因此,core_freq will be boosted above 500 MHz if the display mode is 4Kp60.
| 显示选项 | Maxcore_freq |
|---|---|
默认 |
500 |
|
550 |
无需使用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.
|
-
超频需要最新的固件版本。
-
如果系统已超频,最新固件会自动提高电压。手动设置
over_voltagedisables automatic voltage scaling for overclocking. -
超频时建议使用独立的频率设置(
isp_freq,v3d_freqetc) rather thangpu_freq, because the maximum stable frequency will be different for ISP, V3D, HEVC etc. -
Raspberry Pi 4 或更高版本设备的 SDRAM 频率不可配置。
force_turbo
默认情况下(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.
时钟关系
树莓派 4
GPU 核心、CPU、SDRAM 和 GPU 各拥有独立的 PLL,且可运行于无关的频率。h264、v3d 和 ISP 模块共享一个 PLL。
要查看 Raspberry Pi 设备的当前频率(单位:KHz),请输入: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 请求频率,并且任何降频(如高温情况)可能导致 CPU 实际运行速度低于报告值。可使用 vcgencmd 获取实际 Arm CPU 频率的瞬时测量值。vcgencmd measure_clock arm. This is displayed in Hertz.
监控核心温度
要查看 Raspberry Pi 的温度,请运行以下命令:
$ cat /sys/class/thermal/thermal_zone0/temp
将结果除以 1000 以获取摄氏度的值。或者,您可以使用vcgencmd measure_temp to report the GPU temperature.
达到温度限制不会损坏 SoC,但会导致 CPU 降频。散热器有助于控制核心温度,从而维持性能。如果 Raspberry Pi 安装在机箱内,这一点尤其有用。流经散热器的气流可使散热更高效。
当核心温度在 80°C 到 85°C 之间时,Arm 核心将被降频。如果温度超过 85°C,Arm 核心和 GPU 将被降频。
对于 Raspberry Pi 3 Model B+,PCB 技术已更改以提供更好的散热性和增加热容量。此外,引入了软温度限制,目的是在达到 85°C 的硬限制之前,最大化设备“冲刺”的时间。达到软限制时,时钟频率会从 1.4 GHz 降至 1.2 GHz,工作电压也会略微降低。这会减缓温度上升的速度:我们用 1.4 GHz 下的一小段时间换取 1.2 GHz 下的一段更长时间。默认情况下,软限制为 60°C。这可以通过修改temp_soft_limit setting in config.txt.
监控电压
为了确保可靠运行,必须将供电电压保持在 4.8 V 以上。请注意,某些 USB 充电器/电源的输出电压可能会低至 4.2 V。这是因为它们通常是设计用于为 3.7 V LiPo 电池充电,而不是向计算机提供 5 V 电压。
要监控 Raspberry Pi 设备的 PSU 电压,您需要使用万用表测量 GPIO 上的 VCC 和 GND 引脚之间的电压。更多信息请参阅供电文档的相应部分。
如果电压降至 4.63 V(±5%)以下,Arm 核心和 GPU 将被降频,并且内核日志中将添加指示低电压状态的消息。
Raspberry Pi 5 的 PMIC 内置了 ADC,可用于测量供电电压。要查看当前供电电压,请运行以下命令:
$ vcgencmd pmic_read_adc EXT5V_V
超频问题
大多数超频问题会在设备无法启动时立即显现。如果因超频配置更改导致设备无法启动,请按以下步骤将设备恢复到可启动状态:
-
移除来自 的任意时钟频率覆盖设置
config.txt. -
使用 提升核心电压
over_voltage_delta. -
重新应用超频参数,并注意避免使用之前已知有问题的超频参数。
条件过滤器
当一张 SD card(或 card image)与一个 Raspberry Pi 和一台显示器一起使用时,很容易设置config.txt as required for that specific combination and keep it that way, amending it only when something changes.
然而,如果一个 Raspberry Pi 在不同显示器之间换用,或者如果 SD card(或 card image)在多块板之间换用,单组设置可能不再足够。条件过滤器允许你定义 config file 的某些部分仅在特定情况下使用,从而允许单个config.txt to create different configurations when read by different hardware.
该[all] filter
该[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).
型号过滤器
条件型号过滤器按下表适用。
| 过滤器 | 适用型号 |
|---|---|
|
1A、1B、1A+、1B+、Compute Module 1 |
|
2B(基于 BCM2836 或 BCM2837) |
|
3B、3B+、3A+、Compute Module 3、Compute Module 3+ |
|
3A+、3B+(也会看到 |
|
4B、400、Compute Module 4、Compute Module 4S |
|
5、500、500+、Compute Module 5 |
|
400(也会看到 |
|
500/500+(也会看到 |
|
Compute Module 0(也会看到 |
|
Compute Module 1(也会看到 |
|
Compute Module 3(也会看到 |
|
Compute Module 3+(也会看到 |
|
Compute Module 4(也会看到 |
|
Compute Module 4S(也会看到 |
|
Compute Module 5(也会看到 |
|
Zero、Zero W、Zero 2 W |
|
Zero W(也会看到 |
|
Zero 2 W(也会看到 |
|
按以下项筛选 |
这些对于定义不同的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]
记得使用[all] filter at the end, so that any subsequent settings aren’t limited to Raspberry Pi 2 hardware only.
|
某些 Raspberry Pi 型号(包括 Zero、Compute Module 和 Keyboard 型号)会从多个过滤器读取设置。要将设置仅应用于一个型号:
|
该[none] filter
该[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.
# 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
示例config.txt – (currently, Raspberry Pi 5 onwards)
# 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
……的原始值PM_RSTS register at bootup is available through /proc/device-tree/chosen/bootloader/rsts and the final partition number used for booting is available through /proc/device-tree/chosen/bootloader/partition. These are big-endian binary values.
表达式过滤器
表达式过滤器支持使用一组简单的运算符将无符号整数 “boot variables” 与常量进行比较。它旨在支持 OTA 更新机制、调试和测试。
-
“boot variables” 是
boot_arg1,cust_otpN,bootvar0,boot_count,boot_partitionandpartition. -
boot variables 始终为小写。
-
整数常量可以写成十进制或十六进制。
-
表达式条件过滤器没有副作用,例如没有赋值运算符。
-
与其他过滤器类型一样,表达式过滤器不能嵌套。
-
使用
[all]filter to reset expressions and all other conditional filter types.
语法:
# 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)
[ARG<VALUE] # selected if (ARG < VALUE)
[ARG>VALUE] # selected if (ARG > VALUE)
boot_arg1
仅限 Raspberry Pi 5 及更新设备。
该boot_arg1 variable is a 32-bit user defined value which is stored in a reset-safe register allowing parameters to be passed across a reboot.
设置boot_arg1 to 42 in config.txt:
set_reboot_arg1=42
该set_reboot_arg1 property sets the value for the next boot. It does not change the current value as seen by the config parser.
设置boot_arg1 to 42 by using vcmailbox`:
sudo vcmailbox 0x0003808c 8 8 1 42
读取boot_arg1 by using vcmailbox`:
sudo vcmailbox 0x0003008c 8 8 1 0
# Example output – boot_arg1 is 42
# 0x00000020 0x80000000 0x0003008c 0x00000008 0x80000008 0x00000001 0x0000002a 0x0000000
以下项的值boot_arg1 variable when the OS was started can be read from 设备树在/proc/device-tree/chosen/bootloader/arg1
cust_otpN
该cust_otpN boot variable, where N is in the range 0–7, corresponds to the eight customer OTP rows.
This enables you to select different configurations based on persistent values stored in customer OTP.
此示例config.txt snippet changes the cmdline file only when bit 0 of the customer OTP row 0 is set:
[cust_otp0&0x1]
cmdline=cmdline_product1.txt
有关编写客户 OTP 行的更多信息,请参阅写入和读取客户 OTP 值.
bootvar0
仅限 Raspberry Pi 4 及更新设备。
该bootvar0 variable is a 32-bit user-defined value that is set through rpi-eeprom-config, and then can be used as a conditional variable in config.txt.
例如,设置bootvar0 to 42 in rpi-eeprom-config:
BOOTVAR0=42
利用bootvar0 conditionally in config.txt:
[bootvar0=42]
arm_freq=1000
这允许使用一个通用镜像(即,具有相同的config.txt file) to support different configurations based on the persistent rpi-eeprom-config settings.
boot_count
仅限 Raspberry Pi 5 及更新设备。
该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.
要读取boot_count by using vcmailbox:
sudo vcmailbox 0x0003008d 4 4 0
# Example - boot count is 3
# 0x0000001c 0x80000000 0x0003008d 0x00000004 0x80000004 0x00000003 0x00000000
设置/清除boot_count by using vcmailbox:
# Clear boot_count by setting it to zero.
sudo vcmailbox 0x0003808d 4 4 0
以下项的值:boot_count when the OS was started can be read from 设备树在/proc/device-tree/chosen/bootloader/count
boot_partition
该boot_partition variable can be used to select alternate OS files (for example, cmdline.txt) to be loaded, depending on which partition config.txt was loaded from after processing autoboot.txt。这旨在与以下情况一起使用: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.
以下项的值boot_partition can be different to the requested partition variable if it was overridden by setting boot_partition in autoboot.txt或者如果指定分区不可启动,并且PARTITION_WALK已在 EEPROM 配置中启用。
示例config.txt – select the matching root filesystem for the A/B boot file-system:
# 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
以下项的值:boot_partition – the partition used to boot the OS – can be read from 设备树在/proc/device-tree/chosen/bootloader/partition
partition
该partition variable can be used to select alternate boot flows according to the requested partition number (sudo reboot N) or through direct usage of the PM_RSTS watchdog register.
该[tryboot] filter
如果满足以下条件,则此过滤器成功。tryboot reboot flag was set.
它旨在用于autoboot.txt选择不同的boot_partition in tryboot mode for fail-safe OS updates.
以下项的值:tryboot at the start of boot can be read from 设备树在/proc/device-tree/chosen/bootloader/tryboot
该[EDID=*] filter
当在 Raspberry Pi 中使用单张 SD 卡在多个显示器之间切换,并且空白配置不足以自动为每个显示器选择所需分辨率时,这允许根据显示器的 EDID 名称选择特定设置。
要查看所连接显示器的 EDID 名称,需要执行几个步骤。运行以下命令以查看 Raspberry Pi 上有哪些输出设备:
$ ls -1 /sys/class/drm/card?-HDMI-A-?/edid
在 Raspberry Pi 4 上,这将输出类似以下内容:
/sys/class/drm/card1-HDMI-A-1/edid /sys/class/drm/card1-HDMI-A-2/edid
然后需要运行edid-decode against each of these filenames, for example:
$ edid-decode /sys/class/drm/card1-HDMI-A-1/edid
如果该特定输出设备未连接显示器,它会告诉你 EDID 为空;否则它会为你提供而且关于显示器能力的信息。你需要查找指定以下内容的行:Manufacturer and the Display Product Name. The "EDID name" is then <Manufacturer>-<Display Product Name>, with any spaces in either string replaced by underscores. For example, if your edid-decode output included:
....
Vendor & Product Identification:
Manufacturer: DEL
....
Display Product Name: 'DELL U2422H'
....
此显示器的 EDID 名称将是DEL-DELL_U2422H.
然后,你可以将其用作 conditional-filter,以指定仅当此特定显示器连接时才应用的设置:
[EDID=DEL-DELL_U2422H]
cmdline=cmdline_U2422H.txt
[all]
这些设置仅在启动时应用。显示器必须在启动时连接,并且 Raspberry Pi 必须能够读取其 EDID 信息以找到正确的名称。启动后将不同显示器热插拔到 Raspberry Pi 不会选择不同的设置。
在 Raspberry Pi 4 上,如果两个 HDMI 端口都在使用,则会针对这两个端口检查 EDID 过滤器,并且将应用所有匹配条件过滤器的配置。
| 此设置在 Raspberry Pi 5 上不可用。 |
序列号过滤器
有时设置应只应用于某一台特定的 Raspberry Pi,即使你将 SD 卡换到另一台设备上也是如此。示例包括许可证密钥和超频设置(尽管许可证密钥已经以另一种方式支持 SD 卡更换)。你也可以用它来选择不同的显示设置,即使无法进行上述 EDID 识别,前提是你不在 Raspberry Pi 设备之间交换显示器。例如,如果你的显示器不提供可用的 EDID 名称,或者你使用的是复合输出(无法从中读取 EDID)。
要查看 Raspberry Pi 的序列号,请运行以下命令:
$ cat /proc/cpuinfo
输出底部附近会显示一个 16 位十六进制值。你的 Raspberry Pi 的序列号是最后八个十六进制数字。例如,如果你看到:
Serial : 0000000012345678
序列号是12345678.
在某些 Raspberry Pi 型号上,前 8 个十六进制数字包含的值不是0. Even in this case, only use the last eight hex-digits as the serial number.
|
你可以定义仅应用于此特定 Raspberry Pi 的设置:
[0x12345678]
# settings here apply only to the Raspberry Pi with this serial
[all]
# settings here apply to all hardware
GPIO 过滤器
你还可以根据 GPIO 的状态进行过滤。例如:
[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
组合条件过滤器
相同类型的过滤器会相互替换,因此[pi2] overrides [pi1], because it is not possible for both to be true at once.
不同类型的过滤器可以通过依次列出它们来组合,例如:
# 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
使用[all] filter to reset all previous filters and avoid unintentionally combining different filter types.
内存选项
total_mem
该参数可用于强制 Raspberry Pi 限制其内存容量:以兆字节为单位指定你希望 Raspberry Pi 使用的 RAM 总量。例如,要让 4 GB 的 Raspberry Pi 4B 表现得像 1 GB 型号一样,请使用以下内容:
total_mem=1024
该值将被钳制在最小 128 MB 与板载总内存最大值之间。
许可证密钥和编解码器选项
Raspberry Pi 3 及更早型号上其他编解码器的硬件解码可通过购买许可证来启用,该许可证绑定到你的 Raspberry Pi 的 CPU 序列号。
Raspberry Pi 4 已永久禁用 MPEG2 和 VC1 的硬件解码器。这些编解码器无法启用,因此不需要硬件编解码器许可证密钥。对于典型用例,MPEG2 和 VC1 文件的软件解码性能足够好。
Raspberry Pi 5 支持 H.265 (HEVC) 硬件解码。此解码默认启用,因此不需要硬件编解码器许可证密钥。
decode_MPG2
decode_MPG2 is a licence key to allow hardware MPEG-2 decoding, for example, decode_MPG2=0x12345678.
decode_WVC1
decode_WVC1 is a licence key to allow hardware VC-1 decoding, for example, decode_WVC1=0x12345678.
如果你有多台 Raspberry Pi 设备,并且已为每台设备购买了编解码器许可证,你可以在单个列表中最多列出八个许可证密钥config.txt, for example decode_MPG2=0x12345678,0xabcdabcd,0x87654321. This enables you to swap the same SD card between the different Raspberry Pi devices without having to edit config.txt each time.
视频选项
HDMI 模式
要控制 HDMI 设置,请遵循以下位置的说明:显示设置在……中配置页面。
4 系列设备的 HDMI 管线
为支持双显示器和最高 4Kp60 的模式,Raspberry Pi 4B、Compute Module 4、Compute Module 4S 和 Raspberry Pi 400 每个时钟周期生成两个输出像素。
每个 HDMI 模式都有一个时序列表,用于控制同步脉冲持续时间相关的所有参数。这些通常通过像素时钟定义,然后为水平和垂直方向分别定义有效像素数、前肩、同步脉冲和后肩。
以每个时钟周期 2 像素运行所有内容意味着 4 系列设备无法支持这样的时序,其中任何水平时序中有不能被 2 整除的项。固件和 Linux 内核会过滤掉任何不满足此条件的模式。
在 CEA 和 DMT 标准中只有一种不兼容模式:DMT 模式 81,1366x768 @ 60Hz。此模式的水平同步和后肩时序为奇数值,且宽度不能被 8 整除。
如果您的显示器具有此分辨率,4 系列设备会自动降级到显示器通告的下一个模式;通常是 1280x720。
5 系列设备的 HDMI 管线
Raspberry Pi 5 及更高版本、Raspberry Pi Compute Module 5 及更高版本和 Raspberry Pi 500 及更高版本也以每个时钟周期两个输出像素运行。这些型号对奇数时序有特殊处理,可以直接处理这些模式。
复合视频模式
每种 Raspberry Pi 计算机型号都有复合视频输出:
| 型号 | 复合输出 |
|---|---|
Raspberry Pi 1 A 和 B |
RCA 插孔 |
树莓派 Zero |
未焊接的 |
树莓派 Zero 2 W |
板底部的测试焊盘 |
树莓派 5 |
HDMI 插座旁边的 J7 焊盘 |
所有其他型号 |
3.5 mm AV 插孔 |
| Keyboard 型号不提供复合视频输出。 |
enable_tvout
设置为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.
| 模型 | 默认 |
|---|---|
自 Raspberry Pi 4B 起的旗舰型号、自 CM4 起的 Compute Modules、Keyboard 型号 |
0 |
所有其他型号 |
1 |
在受支持的型号上,必须禁用 HDMI 输出才能启用复合输出。当未检测到 HDMI 显示器时,HDMI 输出会被禁用。设置enable_tvout=0 to prevent composite being enabled when HDMI is disabled.
要启用复合输出,请追加,composite to the end of the dtoverlay=vc4-kms-v3d line in /boot/firmware/config.txt:
dtoverlay=vc4-kms-v3d,composite
默认情况下,这会输出复合 NTSC 视频。要选择不同的模式,请改为将以下内容追加到单行中:/boot/firmware/cmdline.txt:
vc4.tv_norm=<video_mode>
替换其中的<video_mode> placeholder with one of the following values:
-
NTSC -
NTSC-J -
NTSC-443 -
PAL -
PAL-M -
PAL-N -
PAL60 -
SECAM
LCD 显示器和触摸屏
ignore_lcd
默认情况下,当在 I2C 总线上检测到 Raspberry Pi Touch Displays 时,将使用它们。ignore_lcd=1 skips this detection phase. This prevents the LCD display from being used.
disable_touchscreen
启用和禁用触摸屏。
disable_touchscreen=1 disables the touchscreen component of the official Raspberry Pi Touch Displays.
通用显示选项
disable_fw_kms_setup
默认情况下,固件会解析任何已连接 HDMI 显示器的 EDID,选择合适的视频模式,然后通过使用内核命令行上的设置,将该模式的分辨率和帧率(以及过扫描参数)传递给 Linux 内核。在极少数情况下,固件可能选择 EDID 中不存在的模式,该模式可能与设备不兼容。使用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.
在 Raspberry Pi 5 上,此参数默认值为1.
|
相机设置
disable_camera_led
设置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
设置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 IR 滤光片已移除.