Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Steam Deck

Morberis
2022-03-09
2023-07-20
  • Morberis

    Morberis - 2022-03-09

    I was wondering... has anyone tried to run the Codesys IDE on a Steam Deck?

    I see that Ingo has a Codesys 4 Linux forge project that allows you to run it under WINE. The Steam Deck uses a modified version of Wine but also has an ARM cpu rather than an x86.

    The background is that I switched companies about a year back. It's a much bigger company and IT rules mean I can't install Codesys on company laptops. Everything here is Rockwell. But I would still like to use Codesys for my own purposes but I dont have time to program at home.

    Edit: I do have the use of external monitors when I would be coding. A Steam Deck has much better performance than similarly priced laptops and is much more repairable. So I'd need to shell out more money for a similar laptop.

     

    Last edit: Morberis 2022-03-09
  • vaughnvarma - 2023-07-19

    I thought for sure I was the only person on earth who wanted to put an industrial IDE onto a video game console, but here we are!

    tl;dr I did get it working, instructions further down

    Codesys-4-linux has given me a ton of issues, partially because of the different architecture, and partially because it references old or deprecated packages. Also, newer versions of Codesys require the webview2 runtime, which, I understand, is very difficult to get working via WINE, and breaks just about every time it is updated.

    On a tangent, Windows doesn't want you to use a fixed version of this runtime on your system, so they only provide an installer for a self-updating version. You can get a fixed version, but without an installer, and the official way to use this is to modify your program (codesys) to look for that instead of the system version. I imagine there's a way around this, by moving the fixed version files into the correct location, and then, crucially, modifying several keys in WINE's windows registry. I'm not sure which keys, or what values in those keys, codesys is looking for, but the installer simply will not run if it does not detect webview2 in your system. I, however, gave up before succeeding at this. If you want a newer version of codesys (I think >=SP18), I have a couple ideas how you could figure out what those keys are, and how you should set them, but if you are okay with SP16 (SP17 may work, I have not tried it yet), read on.

    I have gotten it working using the docker implementation, but I had to make changes to the build process to avoid unexpected race conditions during building, and I furthermore needed to make significant changes to the docker image after building to install some dependencies the build process missed, and to simplify the process of launching the IDE with a bash script. I did not go back and modify the dockerfile, but I did have to upload the modified image to Docker Hub when I ran into size limitations (see below), so it is now publicly available. rather than following the instructions on the codesys-4-linux page, I recommend the following:

    1. install docker (sudo pacman -S docker)
    2. create /etc/docker/daemon.json. Mine looks like this:
      {
      "data-root": "/run/media/mmcblk0p1/docker-root",
      "storage-driver":
      "devicemapper",
      "storage-opts":
      "dm.basesize=20G"

      }
      If your steam deck has enough internal storage space, you can leave off the "data-root" line; this line tells docker to put all its data into the /docker-root folder at the root of the SD card.
      The dm.basesize is important, as the default size, 10GB, is too small for codesys and related necessary components. you can make it bigger than 20 if you have the space. If you run into problems with running out of space, you can increase it and restart the docker daemon (see below), but you have to upload the image to a repository with push (like docker hub), delete the docker image and related containers, clear your docker environment with 'sudo docker system prune -a' and redownload (pull) the image to get it to match your new size setting.

    3. start the docker daemon with 'sudo systemctl start docker'. If you get a message that it's already running (I don't think you should, I did not on the same hardware as you), run 'sudo systemctl restart docker'

    4. pull the image with 'sudo docker pull vaughnvarma/codesys-steamdeck. This will take some time, it's big (over 10GB)
    5. rename the image with "sudo docker tag vaughnvarma/codesys-steamdeck codesys-ide". This is not strictly necessary, but if you don't, you'll have to modify the script below, and also will always have to refer to the docker image (e.g. if you want to go in and try to add support for something like the store, which currently doesn't work) as vaughnvarma/codesys-steamdeck.
    6. create this shell script codesys.sh (anywhere, it lives in my home directory):
    1
    2
    3
    4
    #!/bin/sh
    xhost local:root
    sudo docker run -it -u 1000 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw --net=host -v /run/media/mmcblk0p1/codesys-projects:/projects --entrypoint=/bin/bash codesys-ide  "/home/wineuser/codesys.sh"
    xhost -
    
    1. create folder codesys-projects somewhere on your steam deck (I have it in /run/media/mmcblk0p1/codesys-projects on the SD card), and change the corresponding portion of the script above to wherever you have this folder. This is also not strictly necessary, but ensures your projects get saved onto your steam deck, and don't vanish if something happens to your docker container. Specifically, this will give you access to that codesys-projects folder from codesys as Z:\projects, so I recommend saving projects here. If you'd rather have it somewhere else, like C:\projects or in your (wineuser's) documents, you will have to change the /projects in the script above to e.g. /home/wineuser/.wine.cds/drive_c/projects
    2. make sure you can run codesys.sh as an executable with 'chmod u+x codesys.sh'
    3. run ~/codesys.sh, enter your password, and you should be able to load codesys

    I don't think I missed anything, but let me know if you try this and run into trouble. Note that you will need the docker daemon running, so you may get an error your first time running it after booting up your steam deck; simply run 'sudo systemctl start docker' and then run the script.

    If you want to be dropped into a shell in this docker image to do your own poking around/modifications, you can take the 'sudo docker run' command above and run it without the quoted script at the end, i.e.

    xhost local:root
    sudo docker run -it -u 1000 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw --net=host -v /run/media/mmcblk0p1/codesys-projects:/projects --entrypoint=/bin/bash codesys-ide
    

    To run as root (for installing applications, change -u 1000 to -u 0. If you don't need a GUI, you can skip the xhost command, and simply enter the following into your terminal:

    sudo docker run -it -u 1000 -v /run/media/mmcblk0p1/codesys-projects:/projects --entrypoint=/bin/bash codesys-ide
    

    Some final notes: I will be continuing to work on this image to get some of those features working that have given me trouble so far, and to prevent random crashes that I cannot reliably reproduce at this time. I will update the image on docker hub as I make progress, but I do not plan on maintaining this image in any continuous capacity. If something doesn't work, you can feel free to try to fix it, and if you do, I would love to know about it, but don't ask me to fix it for you; I don't have that kind of time.
    Also, I am not a docker expert, and know that I have done some things which are not best-practice to put the image together. I wouldn't use this as an example for others, or for general deployment (I expect the above instructions may work on other archlinux systems, YMMV) but it does put codesys 3.5 SP16 on my steam deck, so I think it's fine for personal use.

     
  • vaughnvarma - 2023-07-20

    I have updated the image with firefox; the help files can now be opened from the IDE.

    I realized that I may not be able to actually use codesys for my use case, so I will be putting this down until further notice.

     

Log in to post a comment.