Lesson 4 : Setup switch ON/OFF button

You will discover in this lesson how simple it is to turn on and off the CM4 using the power button on the CM4 Maker Board. Instead of having to browse the start menu for a shutdown button or type "poweroff" into the terminal, use this approach instead. You can save time and energy by pressing the power button, especially if you want to use the CM4 Maker Board frequently. For everyone who wishes to use the board without having to navigate struggling menus or commands, this function also guarantees a smoother user experience.

 

Firstly, boot into the Raspberry Pi OS, launch the terminal and run the following command. You may SSH into your pi and run the command too.

curl -L tinyurl.com/setup-maker-cm4 | sudo bash

 

Reboot the CM4 when done.

 

To know more detail about what the script does can read more on the documentation. This script runs automatically after boot.

 

Follow these steps to flash the CM4 Bootloader from Windows:

 

1. Download and install the rpiboot tool.


2. Download the pre-configured bootloader image from GitHub and extract it. You should get a “recovery” folder.


3. On the CM4 Maker Board, slide the Boot Switch to BOOT, and connect the USB-C port to the PC.
 

Figure 1: Switch CM4 Maker Board to BOOT.

 

4. Open the command prompt (Press the Windows key and type "cmd") and go to the “recovery” folder you just extracted.

 

Figure 2: Open cmd on the recovery folder.

 

5. Run this command to start flashing the bootloader to the EEPROM of CM4.


"C:\Program Files (x86)\Raspberry Pi\rpiboot.exe" -d ./


6. The bootloader is flashed successfully if you see the following message. The ACT LED should be blinking continuously.
 

Figure 3: Success message on cmd.

 

You can unplug the USB cable connected to your computer and connect to a power supply to CM4 Maker Board. Make sure to switch the CM4 Maker Board to RUN mode.

Figure 4: Switch to RUN.

 

Now you can simply turn ON/OFF Raspberry Pi CM4 through a button. To avoid accidental pressing, both buttons at the Power must be pressed simultaneously because they are connected in series. The videos below demonstrate CM4 being turn ON and OFF when the power button is pressed on the CM4 Maker Board.

 

 

 

 

You can also use an external button by connecting the male header pin to the power button. Here is an example of using an external button through the jumper and breadboard. You can customize the button as you desire.

 

Figure 5: ON/OFF CM4 Maker Board using the external button.

 

 

Hardware Components