Freeplaytech Forum
Freeplay CM4 - 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 CM4 (/showthread.php?tid=5392)

Pages: 1 2 3 4 5 6 7


Freeplay CM4 - smoscar01 - 07-12-2022

tldr; It is possible to use a CM4 Lite (no eMMC) with an adapter board on the Freeplay CM3. The process involves using a fresh Retropie image and manually installing the changes required from the Freeplay-Support repo on top of it. The CM4 will not fit inside the GBA so a few mods to the case are also needed. Finally, the adapter board I used does not connect the pins required for the "L2R2 Dual Analog (4 ADC) Add-On Board" so individual wires must be rerouted in order for the analog joysticks and L2 and R2 to work. A low profile heatsink fits if it's carefully sanded off. 
         

The purpose of this post is to log my progress while I try to connect a CM4 Lite (no eMMC) to my Freeplay

So far I was able to make a fresh retropie image (buster) boot up on the Freeplay. There seems to be something missing that keeps sending current to the pi after holding the switch for 5 seconds.

I manually installed everything that's in the Full_Install.sh script that's in Freeplay-Support repo but it still won't stay on. And I found the script that does it when shutting it down but nothing similar for turning it on.

Any help would be greatly appreciated Smile


RE: Freeplay CM4 - Flavor - 07-13-2022

The part that keeps it running once the system boots up is in the config.txt file.

dtoverlay=gpio-poweroff,gpiopin=21,active_low

That's to use GPIO21 to hold the power on when the OS is running.

I'm attaching a photo of the "Gumstix" adapter we used.  We had to modify it to use the SD card (instead of eMMC), but maybe yours doesn't need that.

I found the one you have on AliExpress.  Parts of it look like a clone of the Gumstix board, but some seems different.  

What SD image are you using, by the way?  You would likely want to use one from us.

   


RE: Freeplay CM4 - smoscar01 - 07-13-2022

Thanks, Flavor! that worked!

I was also going to get the Gumstix but I found this board https://geekworm.com/products/cm4-to-cm3-adapter that would work with the CM4 lite without any modifications.

I couldn't find an image for the CM4 in the google drive, the ones shared for the CM3 wouldn't work so I started from scratch and downloaded a fresh image from retropie.org.uk/download/ (the one for the Pi4/400) and ran your script (Freeplay-Support/Full_Install.sh) on top of it.

I am now trying to figure out why the FBCP doesn't work. By using the default 'fbcpOld.service', I see errors in the daemon.log:

Code:
fbcpOld.service: Main process exited, code=exited, status=255/EXCEPTION
fbcpOld.service: Failed with result 'exit-code'.

I tried stopping the service and then running other options through ssh (fbcpFilled, fbcpCropped, etc) but all I got were lines like in the picture. (HDMI works fine though). Unsure if these should work with the CM4 or not.


RE: Freeplay CM4 - Flavor - 07-14-2022

I think that fbcp should work. There are 2 versions of it.

This one is unoptimized, but it should work just about anywhere.
https://github.com/TheFlav/rpi-fbcp
Take a look at the install script at https://github.com/TheFlav/rpi-fbcp/blob/master/install.sh and notice that it uses a .dtbo that needs to be copied in and added to config.txt
It also has a file called /boot/freeplayfbcp.cfg that it reads for configuration parameters.

You might want to look over https://github.com/TheFlav/Freeplay-Support/blob/master/config.txt and see the
dtoverlay=waveshare32b,speed=80000000,fps=60,rotate=270

The speed could be turned down if you're having problems. It's possible that the adapter board introduces noise/delays that might not play well with the speed setting.

You could also just grab the dtbo with this command.
sudo wget --output-document=/boot/overlays/waveshare32b.dtbo https://github.com/TheFlav/Freeplay-Support/raw/master/waveshare32b-fp.dtbo

In fact, you should take a look at https://docs.google.com/document/d/1jsMiFlVP3VeDBXceNmpgAKqP-99v2K9L3xj09K-zHSQ/edit# to get a better idea of what all goes into the Freeplay SD .img.

After having said all that, I would assume that the SD image you tried before didn't work because the base Raspbian (it was built on) didn't include CM4 support. I have released a newer SD image that MAY just work for you. Check
https://drive.google.com/drive/folders/0B3u1iTJauWTneXFTTnlPS2M4czg?resourcekey=0-VtDUv32Fl_Ftdwp_RqwzsQ for "Freeplay_CM3-and-Zero2_Test_22061501.img.gz" and see if that just works.

Oh, and, I said there were 2 FBCP versions.
The other (very optimized) version is at https://github.com/juj/fbcp-ili9341 and I would suggest reading/discussing things more there if you can't get it to work. They allow tuning the speed in different ways.

The other place to investigate is https://github.com/Mootikins/FreeplayILI9341 which contains some pre-built binaries of the juj fbcp-ili9341 and some install scripts.

I hope that all helps. I'm betting that the new SD image works, but I dunno.


RE: Freeplay CM4 - smoscar01 - 07-14-2022

Thanks, Flavor! I feel like I'm getting closer

I started with my current retropie image (the one downloaded from retropie.org.uk/download/) and noticed that the dtoverlay for waveshare32b was only under the pi0, pi2 and pi3 filters. I copied it directly from the README.md file in the repo (the actual config.txt file has it correctly under the `all` filter) but unfortunately there's still no image, the program no longer crashes and I don't see issues in daemon.log but the screen is still white on any of the fbcp options. Perhaps there's a speed or a DMA channel that's not supported in Buster?

I then flashed the suggested image (Freeplay_CM3-and-Zero2_Test_22061501.img.gz) and I saw that FBCP works fine. There's an image on the screen and through HDMI. The resolution is too high for me to be able to read anything but I see things on the screen. Unfortunately, emulation station will fail to start with this image.

If I ssh into it and try to execute emulation station manually it throws the following error:

Code:
* failed to add service - already in use?

Should I try to use a different version of emulation station on top of this image or would it be better to try to make FBCP work on the retropie image where emulation station works fine? hehe


RE: Freeplay CM4 - Flavor - 07-14-2022

Here's what I would try (with HDMI plugged in):
Boot up Freeplay_CM3-and-Zero2_Test_22061501.img.gz (maybe make a video or photos of how it looks) Where does it leave off?
SSH in and run 'ps aux | grep emul' That should show if emulationstation is actually running in the background or something.
If it is already running, kill it.
Run 'emulationstation' on the ssh command line. What do you see on the SSH window, the LCD, and HDMI?

You said "emulation station will fail to start with this image." Sometimes it's hard to tell if emulationstation is failing or if fbcp crashes. When fbcp crashes, the LCD will just stay "stuck" at the last screen, so it can seem like emulationstation failed. If you have HDMI connected, then you can better tell what's going on.

Also, you said that the HDMI resolution is too high but you see things on the screen. I'm wondering what that looks like. I don't think I've seen that. If the resolution is too high, fbcp may be having problems, as it copies the HDMI output to the LCD. It should be forcing the HDMI output to 1024x768 (IIRC offhand). That shouldn't be "too high," so I'm wondering what's wrong here.


RE: Freeplay CM4 - smoscar01 - 07-15-2022

Oh my bad! here are more details:

When using the Pi4/400 image (where emulationstation starts correctly) I see the emulationstation process in ps but the following in dmesg for fbcp:


Code:
pi@retropie:~ $ dmesg | grep fb
[    1.103874] simple-framebuffer 3eb7c000.framebuffer: fb0: simplefb registered!
[    5.211647] fb0: switching to vc4drmfb from simple
[    5.463984] vc4-drm gpu: [drm] fb0: vc4drmfb frame buffer device
[    5.979534] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    5.983522] fb_ili9340: module is from the staging directory, the quality is unknown, you have been warned.
[    5.984365] fb_ili9340 spi0.0: fbtft_property_value: buswidth = 8
[    5.984394] fb_ili9340 spi0.0: fbtft_property_value: debug = 0
[    5.984416] fb_ili9340 spi0.0: fbtft_property_value: rotate = 270
[    5.984447] fb_ili9340 spi0.0: fbtft_property_value: fps = 60
[    5.984473] fb_ili9340 spi0.0: fbtft_property_value: txbuflen = 32768
[    6.305863] graphics fb1: fb_ili9340 frame buffer, 320x240, 150 KiB video memory, 32 KiB buffer memory, fps=100, spi0.0 at 80 MHz

When I'm using the CM3/Zero2 image, emulationstation fails to start both at boot up and when I run it manually either from ssh or if I plug in a keyboard to try to run it from the same user session (it throws the error mentioned above and goes back to the prompt). I don't see any process running for emulationstation and this is what I see in dmesg for fbcp:

Code:
pi@retropie:~ $ dmesg | grep fb
[    1.103198] simple-framebuffer 3eb7c000.framebuffer: fb0: simplefb registered!
[    4.937840] fb0: switching to vc4drmfb from simple
[    5.229719] vc4-drm gpu: [drm] fb0: vc4drmfb frame buffer device

Thanks again, Flavor


RE: Freeplay CM4 - Flavor - 07-15-2022

If I had to guess, the Pi4 image maybe uses
  dtoverlay=vc4-kms-v3d
and I think that does not use dispmanx which the fbcp relies on.  If you have that dtoverlay line in the config.txt, you may want to comment it out and use this instead
  dtoverlay=vc4-fkms-v3d

In fact, I think you may want to try to force a different HDMI resolution for testing purposes.

Try adding these lines to that Pi4 image's config.txt file (in addition to changing vc4-kms-v3d to vc4-fkms-v3d).


hdmi_group=2
hdmi_mode=87
hdmi_cvt=320 240 60 1 0 0 0
hdmi_force_hotplug=1


I would guess that MIGHT help the built-in LCD, but your HDMI will likely fail after that.  If so, try some different values for hdmi_cvt like
hdmi_cvt=640 480 60 1 0 0 0
hdmi_cvt=1024 768 60 1 0 0 0

OR switch to what we would use in the Zero/CM3 image.


Code:
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)



RE: Freeplay CM4 - smoscar01 - 07-15-2022

The DRM I see for the pi4 was already `vc4-fkms-v3d`

Using the hdmi mode and resolutions did not break hdmi just reduced the hdmi resolution, but still nothing was shown on the screen

This is the config.txt I have so far, perhaps you can spot an obvious mistake I made

Code:
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
dtoverlay=dwc2,dr_mode=host
dtoverlay=gpio-poweroff,gpiopin=21,active_low

[all]
#dtoverlay=vc4-fkms-v3d
overscan_scale=1

# BEGIN FREEPLAY MODS
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=waveshare32b,speed=80000000,fps=60,rotate=270
[pi0]
#Freeplay Zero
dtoverlay=audremap,swap_lr=off
dtoverlay=waveshare32b,speed=80000000,fps=60,rotate=270
[pi3]
#Freeplay CM3
dtoverlay=audremap,swap_lr=on
dtoverlay=waveshare32b,speed=99999999,fps=60,rotate=270
dtparam=i2c1_baudrate=400000 #makes a big speed difference
dtoverlay=i2c1-bcm2708,sda1_pin=44,scl1_pin=45,pin_func=6
[pi2]
#Sometimes we test with Pi2
dtoverlay=audremap,swap_lr=on
dtoverlay=waveshare32b,speed=80000000,fps=60,rotate=270
[all]
dtoverlay=gpio-poweroff,gpiopin=21,active_low
# Disable the ACT LED on the Pi Zero.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
audio_pwm_mode=2
dtparam=watchdog=on # Enabling watchdog.
# remove # from following 2 lines to turn wifi and bluetooth off (if not needed, can Speed Up Pi Zero W)
#dtoverlay=pi3-disable-wifi
#dtoverlay=pi3-disable-bt
# END FREEPLAY MODS

[pi3]
dtparam=i2c1_baudrate=400000 #makes a big speed difference
dtoverlay=i2c1-bcm2708,sda1_pin=44,scl1_pin=45,pin_func=6,combine=off
[all]



RE: Freeplay CM4 - smoscar01 - 07-15-2022

Weird update:

I tried manually running the different options I had in the FreeplayILI9341 directory and I noticed all of them would crash with a DMA colllision error except for the `fbcpZeroNoDMA` option. Even though this version wouldn't crash immediately, I still wouldn't see anything on the screen.

A while ago I compiled my own version to be able to play N64 games that randomly had DMA collisions as well (https://forum.freeplaytech.com/showthread.php?tid=5096). Using this version gave me an image on the screen but it was very buggy. It will show artifacts, invert colors and sometimes it just goes back to not showing anything on the screen.

This is what I saw in the prompt while running the custom version (until closing it with ctrl+c):
Code:
pi@retropie:~ $ sudo ./fbcpFilledN64
bcm_host_get_peripheral_address: 0xfe000000, bcm_host_get_peripheral_size: 25165824, bcm_host_get_sdram_address: 0xc0000000
BCM core speed: current: 266666666hz, max turbo: 500000000hz. SPI CDIV: 6, SPI max frequency: 83333333hz
Initializing display
Resetting display at reset GPIO pin 27
Creating SPI task thread
InitSPI done
Relevant source display area size with overscan cropped away: 1024x768.
Source GPU display is 1024x768. Output SPI display is 320x240 with a drawable area of 320x240. Applying scaling factor horiz=0.31x & vert=0.31x, xOffset: 0, yOffset: 0, scaledWidth: 320, scaledHeight: 240
Creating dispmanX resource of size 320x240 (aspect ratio=1.333333).
GPU grab rectangle is offset x=0,y=0, size w=320xh=240, aspect ratio=1.333333
All initialized, now running main loop...
^CSignal SIGINT(2) received, quitting
Quit.

Could this be something fixable by reducing the speed in the dtoverlay?

Can DMA be configured/disabled through freeplayfbcp.cfg? or would I need to recompile all of them?