config.txt is a startup configuration file unique to the Raspberry Pi system, located on the first (boot) partition of the SD card and read by the GPU before initializing the ARM CPU and Linux.
xxxxxxxxxx
Raspberry Pi OS config.txt path: /boot/config.txt
Use the following command to view the current option settings:
xxxxxxxxxx
Example: vcgencmd get_config arm_freq
xxxxxxxxxx
vcgencmd get_config int
xxxxxxxxxx
vcgencmd get_config str
File Format:
You can add a line of comments before each statement to explain the statement function. The length of each line is limited to 98 characters. The content exceeding the limit will be ignored.
x# Example:
# 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
When this setting is enabled, the firmware will automatically load overlays for CSI cameras it recognizes.
Set to disabled:
xxxxxxxxxx
camera_auto_detect=0
When this setting is enabled, the firmware will automatically load overlays for DSI displays it recognizes.
Set to disable:
xxxxxxxxxx
display_auto_detect=0
Used to load and configure device tree overlays. By configuring dtoverlay, users can add additional hardware support or features to the Raspberry Pi system.
Load an overlay that enables kernel graphics drivers:
xxxxxxxxxx
dtoverlaydtoverlay=vc4-kms-v3d
Set GPIO pins to specific modes and values at boot time without using custom files.
Each line sets pins with the same mode: can be a single pin, a pin range, or a comma-separated list of pins;
The pin settings are followed by one or more comma-separated properties.
Abbreviation | Full name | Meaning |
---|---|---|
ip | Input | |
op | Output | |
a0-a5 | Alt0-Alt5 | Multiplexing |
dh | Driving high (for outputs) | |
dl | Driving low (for outputs) | |
pu | Pull up | |
pd | Pull down | |
pn/np | No pull |
Example:
xxxxxxxxxx
# 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
Only some options are listed here, please visit the official website for more detailed information!
https://www.raspberrypi.com/documentation/