Freeplaytech Forum
Freeplay CM3 --> CM4S - Printable Version

+- Freeplaytech Forum (https://forum.freeplaytech.com)
+-- Forum: Freeplay Zero / Freeplay CM3 / Game Pie Advance (https://forum.freeplaytech.com/forumdisplay.php?fid=24)
+--- Forum: Freeplay Zero/CM3 (AKA GPA) Hardware (https://forum.freeplaytech.com/forumdisplay.php?fid=25)
+--- Thread: Freeplay CM3 --> CM4S (/showthread.php?tid=5479)



Freeplay CM3 --> CM4S - Lanium - 09-09-2024

This thread will record my adventure swapping out a raspberry pi CM3 with a CM4S that i found on my Freeplay CM3 device.

The benefits of moving from a 3 to a 4 seem to be pretty good:

https://www.reddit.com/r/RetroPie/comments/fmdx0t/pi_3_vs_pi_4_worth_it/

https://www.reddit.com/r/raspberry_pi/comments/14gtjx1/pi_3_vs_pi_4_emulation_performance/

I bought a CM4S that i found on ebay.

A straight swap from CM3 to CM4S didn't work. I got a small error about unable to load something. is it running?.  Avoiding the troubleshooting for now, i am imaging a new SD card and will start from a fresh image.


RE: Freeplay CM3 --> CM4S - Lanium - 09-09-2024

I would like to go with the most up to date version of Raspbian: Operating system images (https://www.raspberrypi.com/software/operating-systems/)

Raspberry Pi OS Lite
  • Release date: July 4th 2024
  • System: 64-bit
  • Kernel version: 6.6
  • Debian version: 12 (bookworm)


and manually install RetroPie using this: Manually Install RetroPie on Raspbian/Raspberry Pi OS (https://retropie.org.uk/docs/Manual-Installation/)

Then plan to customize using this: Manual Instructions - How To Add Freeplay Functionality To Raspbian


RE: Freeplay CM3 --> CM4S - Lanium - 09-09-2024

I used the Raspberry Pi Imager to image "retropie-buster-4.8-rpi4_400.img.gz" and edited the configuration in the Raspberry Pi Imager to apply a custom hostname, setup a user / password, configure WiFi, and enable SSH with keys.

added an ssh file to enable ssh and replaced the config.txt with this:

Code:
dtparam=i2c_arm=on
core_freq=400
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=256
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
dtoverlay=dwc2,dr_mode=host
overscan_scale=1
framebuffer_width=320
framebuffer_height=240
hdmi_force_hotplug=1  #these HDMI lines will try to set up 1024x768 (you can remove them if you have problems playing via HDMI)
HDMI_FORCE_MODE=1
hdmi_group=2
hdmi_mode=16
hdmi_drive=1          #Normal DVI mode (No sound) (2 for HDMI with sound)
dtparam=spi=on
dtparam=audio=on
dtoverlay=audremap,swap_lr=on
dtparam=i2c1_baudrate=400000 #makes a big speed difference
dtoverlay=i2c1,pins_44_45=1,combine=off
dtoverlay=disable-bt
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
dtoverlay=gpio-poweroff,gpiopin=21,active_low
dtoverlay=gpio-shutdown,gpio_pin=20,active_low=0,gpio_pull=off,debounce=4000

I removed most comments and the filters that can be applied as documented here:
https://www.raspberrypi.com/documentation/computers/config_txt.html#conditional-filters

mostly sourced from:
https://forum.freeplaytech.com/showthread.php?tid=5392&pid=10384#pid10384

added dtoverlay=dwc2,dr_mode=host to enable usb.

Observed results:
held CM3 freeplay switch closed and the green power indicator turned on (4 sec)
- white screen, and green power light turns off
held CM3 freeplay switch closed and the green power indicator turned on (4 sec)
- white screen on device, hdmi shows splashscreen and then console text showing process ending at a reboot state
pressed reset button to turn off
held CM3 freeplay switch closed and the green power indicator turned on (4 sec)
- white screen on device, hdmi shows splashscreen and then console text showing process ending at a prompt
- powered usb hub is working, usb keyboard plugged into hub is working, usb wifi dongle plugged into hub is working (wifi connected and IP address obtained)
- connecting via ssh works


RE: Freeplay CM3 --> CM4S - Lanium - 09-09-2024

From SSH, i first made a symbolic link from my home to a directory named /home/pi. This workaround allowed running all the scripts that are hard coded to use that directory without error.

Code:
sudo ln -s ~ /home/pi

I was able to download and compile the very optimized fbcp from here: https://github.com/juj/fbcp-ili9341

Code:
sudo apt-get install cmake
cd ~
git clone https://github.com/juj/fbcp-ili9341.git
cd fbcp-ili9341
mkdir build
cd build
cmake [options] ..
make -j
sudo ./fbcp-ili9341

After running the binary the screen changed from a white screen to duplicate the hdmi.

for the [options] i used the recommended ones except since the CM4S runs faster than the CM3/CM3+ i set the -DSPI_BUS_CLOCK_DIVISOR=8 from 6

Code:
-DARMV8A=ON -DFREEPLAYTECH_WAVESHARE32B=ON -DSPI_BUS_CLOCK_DIVISOR=8 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DUSE_DMA_TRANSFERS=ON -DBACKLIGHT_CONTROL=ON -DGPIO_TFT_BACKLIGHT=31 -DSTATISTICS=0

This allowed me to not underclock the cpu to 400, however the viewable area of the screen was restricted.

This comment pointed me towards the code to change: https://forum.freeplaytech.com/showthread.php?tid=4931&pid=8610#pid8610

Code:
In 'freeplaytech_waveshare32b.h': (also important as unmodified juj driver have not access to Freeplay screen config)
DISPLAY_NATIVE_COVERED_TOP_SIDE is left border of the screen
DISPLAY_NATIVE_COVERED_LEFT_SIDE is top border of the screen
DISPLAY_NATIVE_COVERED_RIGHT_SIDE is bottom border of the screen
DISPLAY_NATIVE_COVERED_BOTTOM_SIDE is right border of the screen



RE: Freeplay CM3 --> CM4S - Lanium - 09-09-2024

Ok, now i have a custom compiled https://github.com/juj/fbcp-ili9341 driver and the whole screen is now visible.

I have followed most of these instructions: https://docs.google.com/document/d/1jsMiFlVP3VeDBXceNmpgAKqP-99v2K9L3xj09K-zHSQ/edit?usp=sharing 

I installed these binaries using the git clone, then installCM3 script, however they were compiled for pi3/pi3+ and would only work with underclocking. I selected the fbcpFilled through the Freeplay menu and this installed the driver and setup a service. Then i overwrote the binary located in /usr/local/bin/fbcpFilled with my binary that i compiled. I then commented out the underclocking and have restarted the Freeplay CM3 device. to keep myself from accidentally picking a different driver i removed the menu by deleting the menu that was added /home/pi/RetroPie/retropiemenu/Freeplay\ Options/dispMenu.sh.

This has me auto booting into emulation station, my screen looks good, and i am not under clocking.


RE: Freeplay CM3 --> CM4S - Lanium - 11-13-2024

looks like the filter to use in the config.txt is [board-type=0x15] per https://forums.raspberrypi.com/viewtopic.php?t=338978

i noticed that the usb port wasn’t working with the cm4s plugged in. it might require a connection to a pin or a specific overlay.

“pulldown the pin USB_OTGID.”
https://raspberrypi.stackexchange.com/questions/147300/usb-not-working-for-cm4s#147379

“add
dtoverlay=dwc2,dr_mode=host
to the config.txt
Then reboot the Pi. Now you should be able to use the built-in USB 2.0 ports!”
https://www.jeffgeerling.com/blog/2020/usb-20-ports-not-working-on-compute-module-4-check-your-overlays

i also found a review of the cm4s compared to other cm versions:
https://www.tomshardware.com/raspberry-pi/raspberry-pi-compute-module-4s-review


RE: Freeplay CM3 --> CM4S - Lanium - 11-13-2024

i found this type of installation nice:
https://www.cytron.io/tutorial/installing-retropie-on-cm4-emmc-with-retroflag-gpi-case-2-swift-performance-actionclear-all-cache_wpnoncef3e213e2f7

instead of requiring a custom image, it just uses a retropie image and provides a patch to install in the boot partition for the custom changes. i am not sure if this would be possible to convert. i will investigate.