Vita Development environment

HijackedBrain, 23 September 2018

How to set QtCreator for Vita development

Ok so developing on Vita with vitasdk (no unity, no official sdk, etc) can be a pain in the ass to setup correctly.

Here’s a little tutorial for my future self (or anybody stumbling upon this blog entry) on how to get a working windows10, QtCreator, vitasdk setup working. With shortcuts and all the benefits (Just a little heads up, you’ll be using WSL’s QtCreator, not windows’s one)

  1. Windows Subsystem for Linux installation (WSL) :
    • install WSL https://docs.microsoft.com/en-us/windows/wsl/install-win10
    • Pick whatever distrib you like. (debian being obviously the best choice ;).
    • (pin WSL’s Bash on the taskbar) Install “Windows Subsystem for Linux” (WSL) . And Give up on MSYS2 because this thing corrupt itself for no reasons sometimes….
  2. Install VitaSDK (https://vitasdk.org/, we’ll do the global variables stuff later on) :
    apt-get install make git cmake tar mingw64/mingw-w64-x86_64-libwinpthread-git
    git clone https://github.com/vitasdk/vdpm
    cd vdpm
    ./bootstrap-vitasdk.sh
    ./install-all.sh
    
  3. Install QtCreator :
    apt-get install qtcreator
    
  4. Xming server (windows side) for graphical WSL graphical application :
  5. Set a WSL’s QtCreator shortcut
    • Create a WSLQtCreator.bat script and put this in it, it will automatically launch Xming’s server and qtcreator (and also kill Xming when you’ll close qtcreator)
      start Xming -multiwindow -clipboard -dpi 108
      timeout 1 > NUL
      bash --login -c "qtcreator"
      Taskkill /IM Xming.exe /F
      
    • ( Convert the .bat to a .exe and use some really professional grade icon file for the shortcut like this one)
  6. Setup VitaCompanion
  7. Setup global variables and vita tools
    • Put those lines in your /etc/profile
      export VITASDK=/usr/local/vitasdk
      export PATH=$VITASDK/bin:$PATH
      export DISPLAY=:0 #For Xming window server
      
    • Put those lines in your ~/.bashrc (or also in /etc/profile)
      function vitasendfile
      {
        /home/$USER/Tools/vitasendfile.sh $1 $2 $3
      }
      function vitareboot
      {
        /home/$USER/Tools/vitareboot.sh $1
      }
      function vitaexecute
      {
        /home/$USER/Tools/vitareexecute.sh
      }  
      
    • And put associated tools (download here) in /home/$USER/Tools/ folder. Those are just basic script encapsulating the vitacompanion command. This way we’ll be able to call them directly from QtCreator
  8. Setup QtCreator
    • Open QtCreator
    • ( Setting up the build directory : Tools -> Options -> Build & Run -> Default Build Directory -> remove the ../ at the beginning, so it will build in a subfolder instead of a folder next to the source code )
    • Setting up the Compilers : Tools -> Options -> Build & Run -> Kits -> Add -> GCC(C & C++). Add the gcc & g++ vita compilers located at /usr/local/vitasdk/bin/
    • Setting up the “kit” : Create a new kit and use the two newly added compilers, and use the following “CMake Configuration” : CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} QtCreator will cry about gdb’s ABI not corresponding to the compilers’s ones… Don’t mind this … There is no vita compatible gdb for now
    • Setting up the External Tools :
      • Create a Tools -> Options -> Environment -> External Tools:
      • Create a “Reboot” tool : Description : “Reboot Vita” ; Executable : “/home/aramir/Tools/vitareboot.sh” ; Arguments : “192.168.1.24” ; Working Directory : “”
      • Create a “SendVPK” tool : Description : “Send vpk file to Vita” ; Executable : “/home/aramir/Tools/vitasendfile.sh” ; Arguments : “%{CurrentProject:BuildPath}/%{CurrentProject:Name} 192.168.1.24 ux0:/tmp/” ; Working Directory : “%{CurrentProject:BuildPath}”
      • Create a “SendEboot” tool : Description : “Send Eboot.bin to Vita” ; Executable : “/home/aramir/Tools/vitasendfile.sh” ; Arguments : “%{CurrentProject:BuildPath}/%{CurrentProject:Name} 192.168.1.24 %{CurrentProject:Path}/CMakeLists.txt” ; Working Directory : “%{CurrentProject:BuildPath}”
      • Create a “Execute” tool : Description : “Execute program” ; Executable : “/home/aramir/Tools/vitaexecute.sh” ; Arguments : “%{CurrentProject:Path}/CMakeLists.txt 192.168.1.24” ; Working Directory : “%{CurrentProject:Path}”
      • For those tools, I assume that your Vita’s IP adress is 192.168.1.24 and determine your VITA_TITLEID by parsing the CMakeLists.txt
    • Setting up the commands, map the created External tools :
      • External.Reboot -> Ctrl+Alt+R
      • External.SendVPK -> Ctrl+Alt+V
      • External.SendEboot -> Ctrl+Alt+E
      • External.Execute -> Ctrl+Alt+X
  9. Test setup with HelloWorld project, you can use the one at /usr/local/vitasdk/share/gcc-arm-vita-eabi/samples/hello_cpp_world or donwload it somewhere else (eg : http://modconsoles.fr/saves/psvita/hello_world.zip )

  10. How to use ?
    • (Right click on the “hello world” in the Projects view -> Run CMake)
    • Simply build the program, hitting the usual “hammer logo” at the bottom left (or press Ctrl+Shift+B)
    • Press Ctrl+Alt+V to send the .vpk file to the Vita
    • Go to your vita, open VitaShell and install it from ux0:/tmp/xxx/.vpk
    • (Run it from the LiveArea screen)
    • Modify something in the code, press Ctrl+Alt+E to send ONLY the updated eboot.bin
    • Press Ctrl+Alt+X to run the Program
    • Keep in mind that the FTP server and PSP2Shell/VitaCompanion are “sensitive flowers”. So sometimes you might have to restart the vita
    • vitasendfile, vitareboot and vitaexecute are accessible directly from your bash thanks to the .bashrc
  11. More ? How to debug ?
    • Download and set everything for VitaParseCore
    • Write yourself a bash script (eg : vitaparsecoredump.sh) and set an alias for it in your .bashrc cause it’s way too long to call vita-parse-core by hand everytime.
    • Compile your program (using your QtCreator’s kit in debug mode) and crash your application
    • Get the .psp2dump from ux0:/data and open it by calling vitaparsecoredump this way “vitaparsecoredump.sh <.psp2dump> <.elf>”. Beware usual CMakeLists.txt out there will create a .elf for you but the “.elf” extension will be stripped because of the unorthodox way vitasdk work with Linux’s QtCreator. tldr ? “vitaparsecoredump ~/dumpsFolder/dummyDump.psp2dmp HelloWorld”
    • Here’s vitaparsecoredump.sh :
      #!/bin/bash
      if [ $# -eq 0 ]; then
      echo "Usage : vitaparsecoredump.sh <.psp2dump> <.elf>"
      exit 1
      fi
      python2 /home/aramir/Tools/vita-parse-core/main.py $1 $2
      

Useful links: