config.txt是树莓派系统特有的启动配置文件,位于SD卡的第一个(引导)分区上,在初始化 ARM CPU和Linux之前由GPU读取的。
Raspberry Pi OS的config.txt路径:/boot/config.txt
使用以下命令查看当前选项的设置:
显示特定的配置值:vcgencmd get_config 
xxxxxxxxxx示例:vcgencmd get_config arm_freq
列出所有已设置的整数配置选项(非零)
xxxxxxxxxxvcgencmd get_config int
列出所有已设置的字符串配置选项(非零)
xxxxxxxxxxvcgencmd get_config str
文件格式:
1、每行单个语句,内容是整数或字符串
2、注释:行开头添加#
每个语句前可添加一行注释来解释语句作用,每行长度限制为98个字符,超过限制的内容部分会被忽略。
x#示例:# Enable audio (loads snd_bcm2835)dtparam=audio=on# Automatically load overlays for detected camerascamera_auto_detect=1# Automatically load overlays for detected DSI displaysdisplay_auto_detect=1# Enable DRM VC4 V3D driverdtoverlay=vc4-kms-v3d
启用此设置后,固件将自动加载其识别的 CSI 摄像机的叠加层。
设置为禁用:
xxxxxxxxxxcamera_auto_detect=0
启用此设置后,固件将自动加载它识别的 DSI 显示器的叠加层。
设置为禁用:
xxxxxxxxxxdisplay_auto_detect=0
用于加载和配置设备树覆盖,通过配置dtoverlay,用户可以添加额外的硬件支持或功能到树莓派系统中。
加载启用内核图形驱动程序的覆盖层:
xxxxxxxxxxdtoverlaydtoverlay=vc4-kms-v3d
在启动时设置GPIO引脚为特定模式和数值,而不需要使用自定义文件。
每行设置相同模式的引脚:可以是单个引脚、引脚范围或逗号分隔的引脚列表;
引脚设置后面跟着一个或多个逗号分隔的属性。
| 缩写 | 全称 | 含义 | 
|---|---|---|
| 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 | 无上下拉 | 
示例:
xxxxxxxxxx# Select Alt2 for GPIO pins 0 to 27 (for DPI24)gpio=0-27=a2# Set GPIO12 to be an output set to 1gpio=12=op,dh# Change the pull on (input) pins 18 and 20gpio=18,20=pu# Make pins 17 to 21 inputsgpio=17-21=ip
这里只列举部分选项,更详细的资料请去官网查看!
xxxxxxxxxxhttps://www.raspberrypi.com/documentation/