# Raspberry Pi OS for CM-Panel BASIC

<abstract>
This article explains how to create a microSD with Raspberry PI OS for the CM-Panel BASIC starting from an official image for Raspberry Pi.
</abstract>


Download and install on your PC the Raspberry Pi Imager from this url:

* <https://www.raspberrypi.com/software/>

then launch it.

<img src="./raspberry_pi_imager_1.jpg">

In this point, you can choose whether to use a ready-to-use image from those available on this page @article='download_cmpanel' or to modify the standard image downloaded from the Raspberry site. The ready-to-use images have nevertheless been derived from the standard distributions with some modifications to enable the TFT display and touch instead of the HDMI output.

<h3>Continue using the official Raspberry image</h3> 

If on your CM-Panel is mounted a Raspberry CM4S module press the <code>CHOOSE DEVICE</code> button and select <code>Raspberry Pi 4</code>

Press the <code>CHOOSE OS</code> button and select the Raspberry Pi OS you like. In this 
example we will use <code>Raspberry Pi OS (other)</code> -> <code>Raspberry Pi OS Lite (64-bit)</code> 

Insert in your PC the blank microSD and press the <code>CHOOSE STORAGE</code> button and select 
the microSD storage.

<img src="./raspberry_pi_imager_2.jpg">

Press the <code>NEXT</code> button.

<img src="./raspberry_pi_imager_3.jpg">

Press the <code>EDIT SETTINGS</code> button.

<img src="./raspberry_pi_imager_general.jpg">

In this form set the hostname of your CM Panel, the user and password. 
<br/>
If you are using a CM Panel BASIC WIFI insert the name of your WiFi (SSID) and the password to get the access.

Switch to the tab <code>SETTINGS</code> and enable the SSH access.

<img src="./raspberry_pi_imager_services.jpg">

Press the <code>SAVE</code> button the the <code>YES</code> button.

<img src="./raspberry_pi_imager_3.jpg">

The <code>YES</code> again.

<img src="./raspberry_pi_imager_confirm.jpg">

After the writing and verifying operation, remove the microSD card and insert it again to see the content of the first microSD partition
called <code>bootfs</code> the make these changes on the stardard files present on this partition.

### Changes on config.txt file

Open the file <code>config.txt</code> with a text editor and change its content with this:

	# For more options and information see
	# http://rptl.io/configtxt

	#Ignore the HDMI cable hotplug (to avoid the delay at startup)
	hdmi_ignore_hotplug=1

	# Set the debug port on GPIO32, GPIO33 pins
	force_turbo=1
	dtoverlay=uart1,txd1_pin=32,rxd1_pin=33

	# Automatically load initramfs files, if found
	auto_initramfs=1
	
	# Enable DRM VC4 V3D driver
	dtoverlay=vc4-kms-v3d
	dtoverlay=vc4-kms-dpi-generic
	max_framebuffers=2
	
	# Run in 64-bit mode
	arm_64bit=1
	
	# Disable compensation for displays with overscan
	disable_overscan=1
	
	# Run as fast as firmware / board allows
	arm_boost=1

	# Set I2C port on the pin wired to the touch controller
	dtoverlay=i2c1,pins_44_45
	dtoverlay=goodix-7-acme

	## Enable the DPI port to talk with the TFT display
	dtoverlay=dpi18
	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
	hdmi_timings=800 0 40 48 88 480 0 13 3 32 0 0 0 60 0 32000000 6

### Changes on cmdline.txt file

Open <code>cmdline.txt</code> and change this line:

	console=serial0,115200

in:

	console=serial1,115200

In this way the serial console messages will be transmitted on the DEBUG_TX and DEBUG_RX lines available 
on the EXP2 connector.

### Add goodix-7-acme.dtbo overlay blog file

Goodix is the brand of I2C chip mounted to the touchscreen. The file
<code>goodix-7-acme.dtbo</code> is used to enable the Goodix I2C Linux driver and use the rigth 
lines and I2C address.

Download and save <code>goodix-7-acme.dtbo</code> in the <code>overlays</code> directory:

* [overlays/goodix-7-acme.dtbo](./goodix-7-acme.dtbo)
 
If your like to check the device tree source used to generate this file click on this link:

* [overlays/goodix-7-acme.dts](./goodix-7-acme.dts)

To generate the <code>.dtbo</code> file from thr <code>.dts</code> source use this command:

	sudo dtc -@ -I dts -O dtb -o /boot/overlays/goodix-7-acme.dtbo /boot/overlays/goodix-7-acme.dts 

### Add the dt-blob.bin blog file

The file <code>dt-blob.bin</code> defines the lines used by the Raspberry camera for the I2C bus on the CM-Panel.

Download and save it in the boot directory:

* [dt-blob.bin](./dt-blob.bin)

of your prefere you can compile it from this source:

* [dt-blob.dts](./dt-blob.dts)

To compile it you need a Linux PC or a Raspberry Pi and a Device Tree Compiler:

	sudo dtc -I dts -O dtb -o /boot/dt-blob.bin /boot/dt-blob.dts

### Bootstrap 

Umount the microSD from your PC and boot it on your CM-Panel

## Links

* [dt-blob.dts](https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts)

<hr>

@include='adv_cmpanel'

