Skip to content

How-To SD Card

Description

The Pi-Tron CM4 has one micro SD card slot, which can be used as boot or as storage media. If Pi-Tron CM4 is fitted with a Compute Module 4 Lite, an SD card is needed to boot an operating system, like the popular Raspberry Pi OS, as there is no other storage media on the Pi itself. However, if the Pi-Tron CM4 is combined with a CM4 containing eMMC memory, the SD card cannot be used. In this case the Pi can only boot from and work with the on-board eMMC memory.

However, when the CM4 has eMMC memory, the Pi-Tron CM4 offers an option to use an SD card as data storage, but it must be activated via a software switch after the OS has loaded.


pi-tron-cm4-top-sd-card

Requirements

  • Development computer with Internet access for the Raspberry Pi Imager
  • For CM4 Lite models: SD card and card reader
  • For CM4 eMMC models: USB-A to Micro USB cable

How-To

Pi-Tron CM4 with CM4 Lite

By default this combination only allows the user to boot from an SD card. Of course extensions via USB are possible, but an SD card is required if the standard settings of the CM4 are kept.

It is recommended to use the Raspberry Pi Imager to create a bootable SD card for the Pi-Tron CM4. Also take a look at the Quickstart Guide.

Note: Newer versions of the Raspberry Pi OS (starting with Bullseye) require the user creating the initial SD card to choose a username and password when creating the SD card or the information has to be entered during the first boot of the system.

Pi-Tron CM4 with CM4 and on-board eMMC memory

If the CM4 in the Pi-Tron CM4 has eMMC memory on-board, the SD card cannot be used right away, but can be activated later on via a software switch and can then be used as regular data storage. The mechanism is comparable to plugging in an SD card into a card reader. Once the OS has detect the SD card, it can be mounted and used just like any other removable media.

The following steps show how to activate the SD card. If no OS is installed yet, have a look at the How-To Write eMMC page for more information.

Step 1 - Enable the MCP23017

The software switch for the SD card is connected to the MCP23017 GPIO expander on-board of the Pi-Tron CM4, which means this device must be activated.
For instructions on how to do this, look at the How-To Digital Input/Output (DIO) page. Then continue with this how-to.

Step 2 - Activate the SD card slot

The SD card software switch is connected to port GPB7 on the I/O expander, which corresponds to GPIO 15 when working with libgpiod.

To activate the switch enter in the command line or console:

gpioset 2 15=1

Assuming the I/O expander was registered as gpiochip2 device. The offset is 15 and set to equal 1. If the recommendations from the How-To Device Management page are used, replace the 2 with the full name of the new gpio device, e.g. pitroncm4gpio or /dev/pitroncm4gpio.

The activation of the SD card can be observed on the Pi-Tron CM4 board as well, as the green LED XY turns off and the blue LED XY turns on.

pi-tron-cm4-io-expander-schematic

Step 3 - Insert SD card

Now insert an SD card and the OS will load the appropriate drivers and create a new /dev/sdXY device, e.g. /dev/sda.

Looking at the Kernel log should confirm this.

pi@raspberrypi:~ $ dmesg

.......
[  123.108036] sd 0:0:0:0: [sda] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
[  123.109558] sda: detected capacity change from 0 to 31116288
[  123.114638]  sda: sda1 sda2

Many messages will be shown, but at the end of the log it should say that a new device was found. In the above case there are also 2 partitions on the SD card, noted by the last line sda: sda1 sda2.

From this point on, the SD card can be used the same way as any other removable media on the Pi. Delete or create partitions as needed and format them with a file system suitable for the intended application. For example, if the SD card is holding logging information, it might be a good idea to format the SD card with the FAT32 file system, which allows the SD card to be read by many operating systems like Windows, Linux and macOS.

Restrictions

  • No known Restrictions