[OS] RetroArch - Debian OS image based on the minimal Debian (u-boot, kernel, and Debian from scratch) [v0.3]

I’ve just setup a new clean Ubuntu 20.04 VM to work out which packages are needed for a full build, and here’s what you need:

General:

sudo apt install git build-essential

For u-boot build:

sudo apt install gcc-arm-linux-gnueabihf \
    bison flex swig python3-distutils python3-dev

For Linux Kernel 5.7:

sudo apt install libssl-dev u-boot-tools

For generating Debian rootfs:

sudo apt install multistrap qemu-user-static

As an aside, I can’t seem to get the Gameshell to auto connect to Wifi even with the wpa_supplicant.conf configured correctly. Any idea?

2 Likes

Thanks a lot for your contribution! I’ll add it to the README.md :smiley:

Regarding wifi, I have some issues with the driver not being detected/loaded at boot time in some cases. This happens even with the official gameshell image, and It seems to be related to the power regulator. Sometimes I fix it with power off, waiting a few seconds, and powering on again. Since it is intermittent it is hard to find the real cause of this issue.

You can check if this is your problem by seeing if the wlan0 is available when you run ip a. So, try to run:

# ip a

and check if wlan0 is a valid connection. If wlan0 is present, your problem is just a configuration, if not the wifi module is not being detected (the problem I mentioned earlier) or the firmware is not being loaded at boot time.

If the problem is with driver/firmware try to check the kernel messages with:

# dmesg | grep brcm

and post here what you found.

Remember that our wifi module doesn’t work with 5 GHz network, so try to use the same network you had working with the official image.

Yeah I keep a 2.4Ghz Wifi network for such devices, and connected (somewhat intermittently!) to it with the Clockwork OS previously.

Here’s the output I’m seeing while ssh’d to the Gameshell over USB:

root@clockworkpi :~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 4a:50:d0:7c:ea:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.1/24 brd 192.168.11.255 scope global usb0
       valid_lft forever preferred_lft forever

root@clockworkpi :~# dmesg | grep brcm
[    2.894298] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    2.904695] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.bin failed with error -2
[    3.916917] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50

root@clockworkpi :~# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf 
Successfully initialized wpa_supplicant
Could not read interface wlan0 flags: No such device
nl80211: Driver does not support authentication/association or connect commands
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Could not read interface wlan0 flags: No such device
wlan0: Failed to initialize driver interface

Here’s another output from a subsequent boot:

root@clockworkpi :~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ea:a6:f2:89:58:9c brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.1/24 brd 192.168.11.255 scope global usb0
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 6c:21:a2:44:ae:0a brd ff:ff:ff:ff:ff:ff

root@clockworkpi :~# dmesg | grep brcm
[    2.848166] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    2.890745] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.clockwork,clockworkpi-cpi3.txt failed with error -2
[    3.016294] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    3.032725] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[    3.046520] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Nov 25 2016 15:06:56 version 7.46.57.5.apsta.r4.o12 (Station/Softap) FWID 01-64fb9fe8 es6.c5.n4.a3
[  304.243093] ieee80211 phy0: brcmf_cfg80211_add_iface: iface validation failed: err=-16

So yes, the firmware loading seems to be intermittent. With the latter example, though the interface exists and wpa_supplicant.conf is configured correctly, it doesn’t want to connect.

root@clockworkpi :~# ifdown wlan0
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/6c:21:a2:44:ae:0a
Sending on   LPF/wlan0/6c:21:a2:44:ae:0a
Sending on   Socket/fallback

root@clockworkpi :~# ifup wlan0
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/6c:21:a2:44:ae:0a
Sending on   LPF/wlan0/6c:21:a2:44:ae:0a
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 12
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

in arch kernel i was need put wifi driver as a module to made it work

@Joao_Manoel this is great! totally looking forward to giving this a try!

I’ve downloaded the OS link, and loaded with “balenaEtcher” to format my card, but getting the following error:

Is there a way around this? #lazy

Good to know that I’m not the only one having these issues with intermittent wifi. Let’s fix it.
Ok, so we have to understand why it cannot connect with your configuration.
Is it possible for you to use wpa_cli to help you to configure the network? Try to use it to scan your wifi signal, and configure it from there. I used to use connmanctl to configure wifi networks but in later versions, they removed the ability to scan wifi network…

That is good to know, I will try it. Maybe the kernel tries to configure the wifi before the power regulator stabilizes the voltage. Making it as a module will give some time before it tries to load the firmware. Thank you!

You probably need to extract the file before using BalenaEtcher. I think Winrar can extract it. I thought that in the last version they added support for .tar.gz files, are you using the last version?

Version 0.2

Changelog:

  1. This image is based on Debian Bullseye/Unstable built on 13-June-2020.
  2. Kernel is 5.7 with power optimization and suspend (freezing) enabled.
  3. 1.4 GHz max frequency, and governor is set to ondemand by default. You can change it in userspace.
  4. The image is smaller now. It can be written in a 1GB SD card, and the OS only uses 733MB of it. (Now you can use the 10 years old SD card you have in your drawer and still have space for a ton of roms!!!).
  5. Changed image compression to zip for better compatibility with Windows, and flash image writer like balenaEtcher.
  6. HDMI driver support added.
    • HDMI with hotplug detection.
    • The controller can read the screen information to use the best resolution available (up to 720p).
    • The HDMI is part of the kernel and can be manipulated with DRM.
  7. U-boot chooses the dtb file for HDMI at boot time. Just plug the HDMI cable before booting to have HDMI out.
  8. LED fixed and it is now in userspace.
    • The charging LED (orange) in the userspace at (/sys/class/leds/axp20x\:chgled/). You can control it manually (to use it for what you want like a normal led), or automatic (controlled by the charger).
    • Enabled status LED (green) to monitor CPU activity. You can change it in the userspace.
  9. wifi driver is a kernel module now. We had issues with intermittent firmware loading. I hope it is fixed now.

Issues:

  1. The HDMI sound output doesn’t work, the sound is routed to the Gameshell speaker.

There is no password for root!

Download:

https://github.com/wolfallein/clockworkpi-debian/releases/download/v0.2-alpha/clockworkpi-debian-v0.2.zip

4 Likes

Now fully automated process! Instead of using the physical SD card, I am using an image file to fully create the OS.

Can you try with the new release [v0.2]? I changed the download file to zip. BalenaEtcher should be able to handle it.

1 Like

Just updated to the new version - realised I should have checked that 1st.

Going to try v0.2 shortly :smiley:
Thanks @Joao_Manoel

@Joao_Manoel That worked, loaded the image perfectly!

1 Like

great, I’m on your 0.2 image and trying to:

  • Expanding storage to full of my 16GB sdcard
  • Compiling latest RetroArch following RetroArch Megathread

:face_with_head_bandage: i’m kinda noob but I really miss the battery indicator in retroarch menu

Have you heard about BatMon?

1 Like

Hi @i4s33u, thanks for trying.

Just yesterday I committed a new code for auto expand. I could have added to the version 0.2 but I missed the opportunity :frowning: This will be out when I have enough new things to explain a new version. Maybe in 2 weeks…

what you need first is to install fdisk. If you have the internet configured, you can use:

apt update
apt install fdisk

and then you can run (If you didn’t change the partitions, it should work):

echo -e "d\n2\nn\np\n2\n94208\n\nN\nw\n" | fdisk /dev/mmcblk0
resize2fs /dev/mmcblk0p2

and reboot with:

systemctl reboot

You need to install some dependencies tor that. Can you be more specific? Where the compiation is stopping?

I am working in a RetroArch Lakka version for the GameShell. It has battery monitoring, screen brightness, and other small things. If you are interested I can send it to you before making a proper release. It still need to polish some things and enable the wifi configuration.

To be honest, this minimal Debian is to be the base of small projects like the Lakka. Today, I’m probably the person who worked more on it. On the version 0.3 I will think more on the user experience, and ship the customized RetroArch I’m developing.

Here are some screenshots (not well focused :frowning: ):

You can see the battery information at the top right of the picture:



3 Likes

Hi @Petrakis,

very nice project! I saw that it needs Qt for running. This Debian version doesn’t have X11 installed, I don’t know if Qt can run without X…

thanks you, lakka build is very aprriciated :smiley:
I’ve just tried compiled RetroArch 1.8.8 myself but finally messed up with Lima driver, I guess :frowning:
It launched fine but whenever pressing Enter, screen got freezed with error:
lima 1c40000.gpu: gp error irq state=4 status=2b

1 Like

What does it have? wayland? Qt works on wayland too.

It can also work without X11 nor Wayland https://doc.qt.io/qt-5/embedded-linux.html

Oh my goodness this is amazing!! I am super keen on this. This is probably as close to an official Lakka pure gaming device experience as we’re going to get!
I am going to download this right away.
This is the kind of image that I’d be happy to hand to someone as a gift, as a person who purely wants to play games on their gameshell.
I’ve been a huge fan of your work. Can’t wait to see more updates to it! :smiley:

As for the auto expand, the one I’m currently using on my images is the one from @guu

There was also one that I got from @hpcodecraft that automatically downloads all the tools required to expand, expands, then removes the tools.

#!/bin/bash

GREEN='\033[1;32m'
NC='\033[0m'

printf "${GREEN}Installing dependencies...${NC}\n"

# Install growpart util
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -y install cloud-guest-utils

printf "${GREEN}Growing partition...${NC}\n"

# Grow root partition
sudo growpart /dev/mmcblk0 2

printf "${GREEN}Resizing file system...${NC}\n"

# Resize file system
sudo resize2fs /dev/mmcblk0p2

printf "${GREEN}Cleaning up...${NC}\n"

# Uninstall growpart package again
sudo apt-get -y remove cloud-guest-utils

printf "\n${GREEN}Done! Reload UI and Check Settings->Storage 😊 ${NC}\n\n"

Also, on another note, given the simplicity of the OS, this could work as a great base to use something like Emulation Station as a front end. It would be a lot more visually appealing, and about as close to having a RetroPie like experience in a handheld console. There was some talk of it here:

That would at least make using standalone emulators that don’t depend on Retroarch easy to access.

3 Likes

OMG, I re-compiled and it worked now.
First time I uninstalled retroarch before compiling
Now I just compile without remove RetroArch 1.7.3
:smiley:

1 Like

Nothing, jusk KMS. No window system or window manager. RetroArch can work without it and have direct access to the GPU. I find this a bit faster than using X11 protocol, consumes less memory, and load faster. Very good that Qt also doesn’t need. I’ll check it :slight_smile:

Very good :smiley: You probably removed some dependencies when you removed RetroArch.

Thanks a lot for your kind words, I’m very happy if I can contribute a bit :smiley: Maybe one day we can put your efforts on the DEOT image and transfer your work to this image.

The main reason for this image was to have a clean minimal setup that we all understand what was installed and how it was made from the ground so anybody can use it and build something on top *for gamming or developer). On the official image, we have a lot of binaries/libraries that a normal user doesn’t need. I understand that this was necessary when lima was getting support, but now we have everything from Debian working out of the box.

For the expand I like very much these 2 lines:

echo -e "d\n2\nn\np\n2\n94208\n\nN\nw\n" | fdisk /dev/mmcblk0
resize2fs /dev/mmcblk0p2

It deletes the partition and creates another one starting from the same start point than the older. Everything with a pipeline | to fdisk.

4 Likes

Hey @Joao_Manoel I will be very interested by your version with battery info and brightness control ! :slight_smile:

1 Like