1DESCRIPTION = "Commented config.txt file for the Raspberry Pi. \
2               The Raspberry Pi config.txt file is read by the GPU before \
3               the ARM core is initialised. It can be used to set various \
4               system configuration parameters."
5LICENSE = "MIT"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
7
8COMPATIBLE_MACHINE = "^rpi$"
9
10SRCREV = "648ffc470824c43eb0d16c485f4c24816b32cd6f"
11SRC_URI = "git://github.com/Evilpaul/RPi-config.git;protocol=git;branch=master \
12          "
13
14S = "${WORKDIR}/git"
15
16PR = "r5"
17
18INHIBIT_DEFAULT_DEPS = "1"
19
20PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}"
21PITFT22="${@bb.utils.contains("MACHINE_FEATURES", "pitft22", "1", "0", d)}"
22PITFT28r="${@bb.utils.contains("MACHINE_FEATURES", "pitft28r", "1", "0", d)}"
23PITFT35r="${@bb.utils.contains("MACHINE_FEATURES", "pitft35r", "1", "0", d)}"
24
25VC4GRAPHICS="${@bb.utils.contains("MACHINE_FEATURES", "vc4graphics", "1", "0", d)}"
26VC4DTBO ?= "vc4-kms-v3d"
27
28inherit deploy nopackages
29
30do_deploy() {
31    install -d ${DEPLOYDIR}/bcm2835-bootfiles
32
33    cp ${S}/config.txt ${DEPLOYDIR}/bcm2835-bootfiles/
34
35    if [ -n "${KEY_DECODE_MPG2}" ]; then
36        sed -i '/#decode_MPG2=/ c\decode_MPG2=${KEY_DECODE_MPG2}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
37    fi
38    if [ -n "${KEY_DECODE_WVC1}" ]; then
39        sed -i '/#decode_WVC1=/ c\decode_WVC1=${KEY_DECODE_WVC1}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
40    fi
41    if [ -n "${DISABLE_OVERSCAN}" ]; then
42        sed -i '/#disable_overscan=/ c\disable_overscan=${DISABLE_OVERSCAN}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
43    fi
44    if [ "${DISABLE_SPLASH}" = "1" ]; then
45        sed -i '/#disable_splash=/ c\disable_splash=${DISABLE_SPLASH}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
46    fi
47
48    # Set overclocking options
49    if [ -n "${ARM_FREQ}" ]; then
50        sed -i '/#arm_freq=/ c\arm_freq=${ARM_FREQ}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
51    fi
52    if [ -n "${GPU_FREQ}" ]; then
53        sed -i '/#gpu_freq=/ c\gpu_freq=${GPU_FREQ}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
54    fi
55    if [ -n "${CORE_FREQ}" ]; then
56        sed -i '/#core_freq=/ c\core_freq=${CORE_FREQ}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
57    fi
58    if [ -n "${SDRAM_FREQ}" ]; then
59        sed -i '/#sdram_freq=/ c\sdram_freq=${SDRAM_FREQ}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
60    fi
61    if [ -n "${OVER_VOLTAGE}" ]; then
62        sed -i '/#over_voltage=/ c\over_voltage=${OVER_VOLTAGE}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
63    fi
64
65    # GPU memory
66    if [ -n "${GPU_MEM}" ]; then
67        sed -i '/#gpu_mem=/ c\gpu_mem=${GPU_MEM}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
68    fi
69    if [ -n "${GPU_MEM_256}" ]; then
70        sed -i '/#gpu_mem_256=/ c\gpu_mem_256=${GPU_MEM_256}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
71    fi
72    if [ -n "${GPU_MEM_512}" ]; then
73        sed -i '/#gpu_mem_512=/ c\gpu_mem_512=${GPU_MEM_512}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
74    fi
75    if [ -n "${GPU_MEM_1024}" ]; then
76        sed -i '/#gpu_mem_1024=/ c\gpu_mem_1024=${GPU_MEM_1024}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
77    fi
78
79    # Set boot delay
80    if [ -n "${BOOT_DELAY}" ]; then
81        sed -i '/#boot_delay=/ c\boot_delay=${BOOT_DELAY}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
82    fi
83    if [ -n "${BOOT_DELAY_MS}" ]; then
84        sed -i '/#boot_delay_ms=/ c\boot_delay_ms=${BOOT_DELAY_MS}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
85    fi
86
87    # Set HDMI and composite video options
88    if [ -n "${HDMI_FORCE_HOTPLUG}" ]; then
89        sed -i '/#hdmi_force_hotplug=/ c\hdmi_force_hotplug=${HDMI_FORCE_HOTPLUG}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
90    fi
91    if [ -n "${HDMI_DRIVE}" ]; then
92        sed -i '/#hdmi_drive=/ c\hdmi_drive=${HDMI_DRIVE}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
93    fi
94    if [ -n "${HDMI_GROUP}" ]; then
95        sed -i '/#hdmi_group=/ c\hdmi_group=${HDMI_GROUP}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
96    fi
97    if [ -n "${HDMI_MODE}" ]; then
98        sed -i '/#hdmi_mode=/ c\hdmi_mode=${HDMI_MODE}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
99    fi
100    if [ -n "${CONFIG_HDMI_BOOST}" ]; then
101        sed -i '/#config_hdmi_boost=/ c\config_hdmi_boost=${CONFIG_HDMI_BOOST}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
102    fi
103    if [ -n "${SDTV_MODE}" ]; then
104        sed -i '/#sdtv_mode=/ c\sdtv_mode=${SDTV_MODE}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
105    fi
106    if [ -n "${SDTV_ASPECT}" ]; then
107        sed -i '/#sdtv_aspect=/ c\sdtv_aspect=${SDTV_ASPECT}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
108    fi
109    if [ -n "${DISPLAY_ROTATE}" ]; then
110        sed -i '/#display_rotate=/ c\display_rotate=${DISPLAY_ROTATE}' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
111    fi
112
113    # Video camera support
114    if [ "${VIDEO_CAMERA}" = "1" ]; then
115        echo "# Enable video camera" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
116        echo "start_x=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
117    fi
118
119    # Offline compositing support
120    if [ "${DISPMANX_OFFLINE}" = "1" ]; then
121        echo "# Enable offline compositing" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
122        echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
123    fi
124
125    # SPI bus support
126    if [ "${ENABLE_SPI_BUS}" = "1" ] || [ "${PITFT}" = "1" ]; then
127        echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
128        echo "dtparam=spi=on" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
129    fi
130
131    # I2C support
132    if [ "${ENABLE_I2C}" = "1" ] || [ "${PITFT}" = "1" ]; then
133        echo "# Enable I2C" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
134        echo "dtparam=i2c1=on" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
135        echo "dtparam=i2c_arm=on" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
136    fi
137
138    # PiTFT22 display support
139    if [ "${PITFT22}" = "1" ]; then
140        echo "# Enable PITFT22 display" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
141        echo "dtoverlay=pitft22,rotate=270,speed=32000000,txbuflen=32768" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
142    fi
143    if [ "${PITFT28r}" = "1" ]; then
144        echo "# Enable PITFT28r display" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
145        echo "dtoverlay=pitft28-resistive,rotate=90,speed=32000000,txbuflen=32768" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
146    fi
147    if [ "${PITFT35r}" = "1" ]; then
148        echo "# Enable PITFT35r display" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
149        echo "dtoverlay=pitft35-resistive,rotate=90,speed=42000000,fps=20" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
150    fi
151
152    # UART support
153    if [ "${ENABLE_UART}" = "1" ]; then
154        echo "# Enable UART" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
155        echo "enable_uart=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
156    fi
157
158    # VC4 Graphics support
159    if [ "${VC4GRAPHICS}" = "1" ]; then
160        echo "# Enable VC4 Graphics" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
161        echo "dtoverlay=${VC4DTBO}" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
162    fi
163
164    # Waveshare "C" 1024x600 7" Rev2.1 IPS capacitive touch (http://www.waveshare.com/7inch-HDMI-LCD-C.htm)
165    if [ "${WAVESHARE_1024X600_C_2_1}" = "1" ]; then
166        echo "# Waveshare \"C\" 1024x600 7\" Rev2.1 IPS capacitive touch screen" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
167        echo "max_usb_current=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
168        echo "hdmi_group=2" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
169        echo "hdmi_mode=87" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
170        echo "hdmi_cvt 1024 600 60 6 0 0 0" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
171        echo "hdmi_drive=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
172    fi
173
174    # DWC2 USB peripheral support
175    if [ "${ENABLE_DWC2_PERIPHERAL}" = "1" ]; then
176        echo "# Enable USB peripheral mode" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
177        echo "dtoverlay=dwc2,dr_mode=peripheral" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
178    fi
179
180    # AT86RF23X support
181    if [ "${ENABLE_AT86RF}" = "1" ]; then
182        echo "# Enable AT86RF23X" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
183        echo "dtoverlay=at86rf233,speed=3000000" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
184    fi
185
186    # ENABLE CAN
187    if [ "${ENABLE_CAN}" = "1" ]; then
188        echo "# Enable CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
189        echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
190    fi
191
192    # Append extra config if the user has provided any
193    printf "${RPI_EXTRA_CONFIG}\n" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
194
195    # Handle setup with armstub file
196    if [ "${@bb.utils.contains("MACHINE_FEATURES", "armstub", "1", "0", d)}" = "1" ]; then
197        echo "\n# ARM stub configuration" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
198        echo "armstub=${ARMSTUB}" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
199        case "${ARMSTUB}" in
200            *-gic.bin)
201                echo  "enable_gic=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
202                ;;
203        esac
204    fi
205}
206
207do_deploy_append_raspberrypi3-64() {
208    echo "# have a properly sized image" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
209    echo "disable_overscan=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
210
211    echo "# Enable audio (loads snd_bcm2835)" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
212    echo "dtparam=audio=on" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
213}
214
215addtask deploy before do_build after do_install
216do_deploy[dirs] += "${DEPLOYDIR}/bcm2835-bootfiles"
217
218PACKAGE_ARCH = "${MACHINE_ARCH}"
219