A while ago, I’ve backed the M5Stack CardputerZero project which aimed at building a Cardputer-version with a Raspberry Pi CM0, i.e. a proper Linux-capable CPU.
The device has now arrived and it is a beauty!

The original firmware boots into a demo/test application to showcase all the various features. If you connect it to HDMI, it will also boot into a graphical environment. (Which takes unnecessary time when you don’t need it.)
My first task was to turn this into a simple Linux machine. Here’s what I did:
Preparations
For easier handling, I went through the onboarding and made sure the CPZ is connected to my WiFi and I can SSH into the thing.
Disable graphical mode
The default is to boot towards the graphical.target which includes launching the X11/Wayland environment. I very much prefer to boot into text mode. This can be configured by changing the default target like this:
sudo systemctl set-default multi-user.targetCode language: Bash (bash)
Subsequent reboots were much faster as it didn’t have to load the desktop environment anymore.
Don’t start APPLaunch
Next step was to disable the demo/test application that runs automatically on every boot.
sudo here.systemctl --user disable APPLaunch.serviceCode language: Bash (bash)
Don’t show splash screen
There’s a unit called fb_load that redraws the splash screen to the framebuffer during bootup. This had to go, too.
sudo systemctl disable fb_load.serviceCode language: Bash (bash)
Enable framebuffer output
The default kernel parameters disable framebuffer output using fbcon=map:off. Let’s change that.
Edit the file /boot/firmware/cmdline.txt, e.g. using vim (don’t forget sudo). Then find above option and change it to:
fbcon=map:0
fbcon=map:10 for it to first try fb1 (HDMI output) and then fb0 (internal display). However, since I have set hdmi_force_hotplug=1 in my config.txt (see below), this causes the output to generally go to the HDMI – whether a screen is connected or not. That’s why I’m using map:0 here.While here, I’ve also added consoleblank=0, changed the quiet to verbose and also added nosplash. Also, this might be a great opportunity to change the Wi-Fi RegDom to your country. In my case: cfg80211.ieee80211_regdom=GB.
Keyboard map
The proper keyboard map file is in /usr/share/keymaps/ but only loaded by the demo/test application, not the system. So, after booting with it disabled, you will notice that the blue special characters (to be used with the SYM key) don’t really work. E.g. a forward slash is now SYM+9 instead of SYM+N like it is printed on the device.
To fix this, we need to get the system to load the keymap. Edit the file /etc/default/keyboard and at the end add the line:
KMAP="/usr/share/keymaps/tca8418_keypad_m5stack_keymap.map"Code language: JavaScript (javascript)
Once done, run:
sudo setupcon --save
This will make sure to set this keymap as early in the boot process as possible. It should also apply the changes immediately.
Tweak config.txt
Finally, I’ve adjusted the Raspberry config in /boot/firmware/config.txt to my likings.
I’ve commented out the splash_screen= line so no graphics is displayed at first.
#splash_screen=CardputerZero_splash_custom.binCode language: PHP (php)
Also, I’ve lowered the GPU memory from the default 128 MB to only 32 MB:
gpu_mem=32
And I’ve also added HDMI forced hotplug so I can connect to HDMI at any time:
hdmi_force_hotplug=1
Further optimisations
This is now a great basis for a small pocket Linux machine. Depending on your use case, you might want to thin out the packages. E.g., I personally don’t need all those GUI tools that were installed by default. Instead, I like to manage the device using Midnight Commander (package mc) and Aptitude (package aptitude) instead of the normal apt.
Maybe I’ll try experimenting with different fonts. The smallest default font for the framebuffer is 8×8 which gives 40×21 characters. But there are fonts like Tamzen/Tamsyn, miniwi, or Spleentt that are even smaller. I might need a GameBoy Magnifier, though. Here’s a visual comparison:
Remove armhf architecture
The CPU is 64bit, i.e. what’s called the arm64 architecture. However, in the underlying Raspbian, there’s also support enabled for the 32-bit counterpart armhf. This causes lots of packages being displayed twice in aptitude and makes the initial start of that app very slow. To remove support for armhf, run this:
sudo dpkg --remove-architecture armhfCode language: Bash (bash)
(You can always add it back by using the --add-architecture option.)
Then remove already downloaded package lists for the armhf arch:
sudo rm -rf /var/lib/apt/lists/*-armhf*Code language: Bash (bash)
Get temperature and battery status
If you want to display e.g. the current CPU temperature and the battery charge in your system prompt, you’ll find these values at:
$ cat /sys/class/power_supply/bq27220-0/capacity
100
$ cat /sys/class/power_supply/bq27220-0/temp
358
$ cat /sys/class/thermal/thermal_zone1/temp
35800
$ cat /sys/class/thermal/thermal_zone0/temp
47774Code language: JavaScript (javascript)
Looks like thermal_zone1 is the same battery temperature reading. thermal_zone0 is the CPU temp.
Make framebuffer drivers available in initramfs
After removing the “boot beautifier” plymouth, the display didn’t show anything anymore. This seems to be due to missing kernel drivers for the framebuffer – since without a graphical boot screen thingy why would you need them?
To get it working again, you’ll need to add the kernel modules back into the initramfs. Edit the file /etc/initramfs-tools/modules and add the following lines at the end:
# Raspberry Pi framebuffer support
spi_bcm2835
drm
drm_kms_helper
drm_mipi_dbi
panel_mipi_dbi_m
vc4Code language: Bash (bash)
Once the changes are saved, you also have to make sure the display firmware is included in the initramfs. Create a hook file /etc/initramfs-tools/hooks/st7789-firmware with the following contents:
#!/bin/sh
if [ "$1" = "prereqs" ]; then exit 0; fi
. /usr/share/initramfs-tools/hook-functions
add_firmware "cardputerzero,st7789v_lcd.bin"Code language: PHP (php)
Make sure to make the file executable (sudo chmod a+x st7789-firmware) and then regenerate the initramfs:
sudo update-initramfs -uCode language: Bash (bash)
On the next reboot, the display should start working again.
Fix race condition with display going blank mid-boot
After re-enabling the M5Stack splash screen in config.txt, I had a phenomenon that I’d see the kernel start booting, but the moment console-setup should take over and apply its settings, the screen would turn blank.
After some fiddling, it appeared that the screen got blanked but the blank flag didn’t get updated with the new status. Thus, console-setup assumed everything was in order and didn’t try to unblank the screen. A simple fix is actually blanking the screen and then unblanking it after console-setup runs. To implement this, edit the console-setup.service:
sudo systemctl edit console-setup.serviceCode language: Bash (bash)
And in the “Anything between here and the comment below will become the contents…” block, paste this:
[Service]
ExecStartPost=/bin/sh -c 'echo 1 > /sys/class/graphics/fb0/blank && echo 0 > /sys/class/graphics/fb0/blank'Code language: JavaScript (javascript)
That fixed it for me.
@mbirth 50x magnification jeweler’s loupe sold separately.
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.
@mbirth What's the power management like? That Broadcom SoC doesn't support suspend to RAM, right? Is the power management simply "run" or "shutdown"?
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.
Pretty much, yes. The Raspbian kernel also doesn’t support hibernation, it seems. With a custom kernel you might get it working, though. Or get a semi-big 20 Ah power bank and you’ll have enough juice for a day.
@mbirth Thanks for letting me know. It's sad that after all this time RPI Ltd hasn't made any efforts to make their boards more battery friendly. I hope Qualcomm creates some CMx-compatible SOM boards with their battery-friendly SoCs.
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.
@mbirth
That is so cool.
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.