Advertising (This ad goes away for registered users. You can Login or Register)

[Tutorial] Vita SDK & toolchain for Archlinux & Docker

Post here your guides, tips, how-to, etc...
Post Reply
BuLLeKeUp
Posts: 4
Joined: Mon Mar 19, 2012 10:55 am
Location: France
Contact:

[Tutorial] Vita SDK & toolchain for Archlinux & Docker

Post by BuLLeKeUp » Tue Aug 02, 2016 1:03 am

Hey guys !

Seems like everybody is (re)starting to look on the Vita since last friday and the HENkaku release (a huge thx to Molecule team for that), and that's more than cool :)

As some people have pointed out, it may be difficult to install the SDK and toolchain from the source, with errors depending on the distro you're using, the version of the tools (make 4.x caused me some trouble with libelf build for instance). If you want to go the easy way, you also have the solution of the pre-built toolchain. And I propose a third option :)

!! WARNING !! I have tested both methods and it worked for me, BUT this is still a first draft and it may have bugs. Obviously, no warranty provided. But you can ask questions, and I will try to answer as quick as possible (so not that quick ;) )

Archlinux Packages

As I prefer to go with packaged software as often as possible, I decided to package all the toolchain (host libs included) for Archlinux (cause that's the distro I use), and as I don't wanted to stop so early I also ported vitasdk's vita.patch to recent versions of binutils / gcc / libelf.

Note that my work is based on vitasdk's buildscripts

I separated the toolchain in two package groups:
  • vita-toolchain-hostlibs (needed to rebuilt the toolchain)
    vita-toolchain (the toolchain itself)
If you don't have plans on modifying the toolchain itself, go with vita-toolchain, no need to install extra libs.

Packages are available on my personal repo at https://repo.bullekeup.net/x86_64 (only for 64 bits installs, don't have time to build it for 32 bits sorry :? )
To use it, add this to your /etc/pacman.conf

Code: Select all

[bullekeup.net]
Server = https://repo.bullekeup.net/$arch
SigLevel = Never
Then install the toolchain

Code: Select all

$ pacman -Sy vita-toolchain
$ pacman -Sy vita-toolchain-hostlibs
Make sure you source /etc/profile in either your ~/.bashrc or ~/.zshrc or whatever term init file you use. This step is mandatory to have the toolchain in your $PATH. That's it you're ready to go ! See Testing below for more info on use.

PKGBUILDs

If you prefer rebuild the package yourself, or need to (32 bits install for example), the PKGBUILDS are on my github.

If you don't have Archlinux installed, don't worry, I've get you covered with a docker container.

Docker

If you don't know what docker is, that's more or less like a stripped down VM. Or a chroot on steroids, depends on your point of view, more here. I won't cover details of docker installation, as a lot of guys and girls already done it on the web. Refer to your distro install guide (or ask Google to find out ;) ).

So how it works ?

I made an Archlinux based docker image and simply installed the packages I've made into it.

First step: pull the image

Code: Select all

$ docker pull bullekeup/arch-vita-toolchain
Normally, the image has been downloaded and is ready to be launched

Second step: launch the image

You need to replace <your_workdir> with the path to your actual work directory on your computer to allow the container to find your code. Then you should see <your_workdir> content in /home/workspace in the container.

Code: Select all

$ docker run -ti -v <your_workdir>:/home/workspace --name=vita-tool bullekeup/arch-vita-toolchain:latest
That's all ! The toolchain is ready to work (only in the terminal connected to the docker container), and you can test the installation by compiling a sample of code if you want (see Testing below)

Tip: If you want to launch a second terminal, no need to spawn a new container, exec a new terminal in the running one with following command:

Code: Select all

$ docker exec -ti -u devuser vita-tool /usr/bin/zsh
!! WARNING !! All the code NOT in /home/workspace in the container will be lost after the next reboot

Testing

First, try printing arm-vita-eabi-gcc's version

Code: Select all

$ arm-vita-eabi-gcc --version
You should see

Code: Select all

arm-vita-eabi-gcc (GNU Tools for embedded ARM processor - PSVita toolchain build) 6.1.1 20160707
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
To test the installation, I've made a little script which compiles and send Xerpi's helloworld sample code to your Vita.

In either your Archlinux term or your Docker term, launch the script with

Code: Select all

$ vita-testsuite
It will wait for you to launch HENkaku's molecularShell (see VitaShell for reference) on your vita and launch the FTP Server. Then press enter to continue.

Vitahelloworld sample code will be copied into the current directory and compiled. Then the script will ask you the Vita's IP on your network to transfer vitahelloworld.vpk. After the transfer, just stop the FTP server on your console, select the VPK in molecularShell and press X two times to install. Go back to the LiveArea and try to launch vitahelloworld, it should work. Et voilà !

Note that vitahelloworld code is available as it was when package was built in

Code: Select all

/opt/vita-toolchain/arm-vita-eabi/usr/samples/src/vitahelloworld/
A VPK file compiled when package was built is available in

Code: Select all

/opt/vita-toolchain/arm-vita-eabi/usr/samples/vpk/vitahelloworld.vpk
And as I'm here, I would like to thank Yifan, Davee, Proxima, xyz, Wololo and globally all Vita hackers for their work, cause that's really really cool to be able to code natively and easily on the Vita and I can't wait to see all what will come next :D

Links

https://github.com/bullekeup
https://github.com/vitasdk
https://github.com/henkaku
https://github.com/xerpi
https://docker.com
Advertising

Post Reply

Return to “Tutorials”