Skip to content

Instantly share code, notes, and snippets.

@xerpi
Last active April 1, 2024 12:51
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save xerpi/5c60ce951caf263fcafffb48562fe50f to your computer and use it in GitHub Desktop.
Save xerpi/5c60ce951caf263fcafffb48562fe50f to your computer and use it in GitHub Desktop.
PSVita Linux build instructions

0) Optional: Solder UART0 pins

  1. Check here for the pinout. You will also need a 1.8V level shifter.

1) Install an ARMv7 cross-compiler

  1. Go to https://toolchains.bootlin.com
  2. Select arch: armv7-eabihf
  3. Select libc: glibc
  4. Download bleeding-edge
  5. Uncompress it (for example to /opt)
  6. Add the bin/directory of the toolchain to $PATH
    • In my case: export PATH=$PATH:/opt/armv7-eabihf--glibc--bleeding-edge-2023.08-1/bin

2) Build Buildroot

  1. git clone git://git.buildroot.net/buildroot && cd buildroot
  2. Download and copy this Buildroot .config to .config
  3. If using a toolchain path different than /opt/armv7-eabihf--glibc--bleeding-edge-2023.08-1:
    • make menuconfig
    • Navigate to Toolchain --->
    • Properly set the Toolchain path, save and exit
  4. Create a rootfs-overlay directory. Everything you put inside will be part of the rootfs.
  5. make -j
  6. This will generate output/images/rootfs.cpio.xz

3) Build Linux

  1. git clone https://github.com/xerpi/linux_vita.git
  2. cd linux_vita && cp ../buildroot/output/images/rootfs.cpio.xz ./
  3. make ARCH=arm vita_defconfig
  4. make ARCH=arm CROSS_COMPILE=arm-linux- -j
  5. make ARCH=arm CROSS_COMPILE=arm-linux- vita1000.dtb vita2000.dtb pstv.dtb
  6. This will generate arch/arm/boot/zImage and arch/arm/boot/dts/{vita1000.dtb,vita2000.dtb,pstv.dtb}

4) Install vitasdk

5) Build vita-baremetal-loader

  1. git clone https://github.com/xerpi/vita-baremetal-loader.git
  2. cd vita-baremetal-loader && make
  3. This will generate baremetal-loader.skprx

6) Install libbaremetal

  1. git clone https://github.com/xerpi/vita-libbaremetal.git
  2. cd vita-libbaremetal/libbaremetal && make install

7) Build vita-baremetal-linux-loader

  1. git clone https://github.com/xerpi/vita-baremetal-linux-loader.git
  2. cd vita-baremetal-linux-loader && make
  3. This will generate vita-baremetal-linux-loader.bin

8) Build and install the Plugin Loader VPK or vitacompanion

Two main methods: (a) a VPK that loads a kernel plugin, or (b) my fork of vitacompanion that has an custom command to load skprxes.

a. Plugin Loader VPK method:

  1. git clone https://bitbucket.org/xerpi/vita_plugin_loader.git
  2. cd vita_plugin_loader && mkdir build && cd build && cmake .. && make
  3. Install plugin_loader.vpk

b. vitacompanion method:

  1. Build and install vitacompanion
  2. To launch an skprx run:
    echo "load_skprx ux0:/myplugin.skprx" | nc $PSVITAIP 1338

9) Boot Linux

  1. Copy baremetal-loader.skprx to ux0:data/tai/kplugin.skprx
    • Configurable in vita_plugin_loader/main.c:13
  2. Copy vita-baremetal-linux-loader.bin to ux0:/baremetal/payload.bin
    • Configurable in vita-baremetal-loader/config.h
  3. Copy linux_vita/arch/arm/boot/zImage to ux0:/linux/zImage (uma0 if using sd2vita)
  4. Copy linux_vita/arch/arm/boot/dts/{vita1000.dtb,vita2000.dtb,pstv.dtb} to ux0:/linux/ (uma0 if using sd2vita)
  5. Launch the Plugin Loader VPK

More information

Deprecated steps

4) Build vita-linux-loader (DEPRECATED: use vita-baremetal-linux-loader instead)

  1. Install vitasdk
  2. git clone git@github.com:xerpi/vita-linux-loader.git
  3. cd vita-linux-loader && make
  4. This will generate linuxloader.skprx
@koko1ooo
Copy link

Has anyone got this working with SD2Vita? When I reboot into baremetal it tells me no memory card inserted and I can't continue to load the kernel image

Currently, the Linux loader loads from MSIF so only Memory Card are supported.
I think the old Linux loader could be used instead for now: https://github.com/xerpi/vita-linux-loader

Thanks, I recently switched to this loader and recompiled the plugin with the _stub includes, but I'm getting error 0x8002D003 while loading the plugin.. someone said it's relating to the linked includes missing the _stub versions so I'm trying to somehow see what is causing this

I just did a port to the 6.5 kernel. Including a self-built toolchain with crosstool-ng and the latest buildroot. I am now trying to install the WLAN driver.

Isn't the 0x8002D003 error that unsafe homebrews are not allowed? I could be wrong about that

@AGitVictim
Copy link

I just did a port to the 6.5 kernel. Including a self-built toolchain with crosstool-ng and the latest buildroot. I am now trying to install the WLAN driver.

Is it available?

@xerpi
Copy link
Author

xerpi commented Sep 27, 2023

I have updated https://github.com/xerpi/vita-baremetal-loader to also generate a skprx for FW ≥ 3.63 automatically.
I have also updated this guide to the latest bootlin toolchain and written about the vitacompanion method to load skprxes easily.

@xerpi
Copy link
Author

xerpi commented Sep 27, 2023

I have rebased the Vita port to the latest upstream Linux commit (6.6.0-rc3): https://github.com/xerpi/linux_vita/tree/rebase-6.6.0-rc3
When booting, sometimes it hangs at:

Uncompressing Linux... done, booting the kernel.

And sometimes it gets a bit further:

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 6.6.0-rc3-00045-g87e131f82459 (xerpi@xps15-linux) (arm-linux-gcc.br_real (Buildroot 2021.11-8547-g7e65a1a) 13.2.0, GNU ld (GNU Binutils) 2.41) #3 SMP Thu Sep 28 00:29:59 CEST 2023
CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5787d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: PlayStation Vita
OF: fdt: Ignoring memory range 0x40200000 - 0x41000000
printk: bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
BUG: not creating mapping for 0x00000000 at 0x7f000000 in user region

I suspect it's a problem related to the linux loader leaving stale data in the L2 data cache.

@GGLinnk
Copy link

GGLinnk commented Oct 13, 2023

There is a missing folder in buildroot (Chapter 2) : It's rootfs-overlay
make doesn't seems to make it. Creating it manually allows to get rid of the error I encountered with rsync.

I suggest adding the creation of this folder into the guide or find a fix. Maybe the configuration file is incorrect ?

The error :

>>>   Copying overlay rootfs-overlay
rsync: [sender] change_dir "/home/gglinnk/buildroot/rootfs-overlay" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7]
make[1]: *** [Makefile:749: target-finalize] Error 23
make: *** [Makefile:82: _all] Error 2

@xerpi
Copy link
Author

xerpi commented Oct 14, 2023

There is a missing folder in buildroot (Chapter 2) : It's rootfs-overlay make doesn't seems to make it. Creating it manually allows to get rid of the error I encountered with rsync.

I suggest adding the creation of this folder into the guide or find a fix. Maybe the configuration file is incorrect ?

The error :

>>>   Copying overlay rootfs-overlay
rsync: [sender] change_dir "/home/gglinnk/buildroot/rootfs-overlay" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7]
make[1]: *** [Makefile:749: target-finalize] Error 23
make: *** [Makefile:82: _all] Error 2

Thanks for pointing that out. I have updated the instructions.

@Cinder4198
Copy link

It took me far too long to realize that there is an entire comment thread under the guide.
Anyways what does it mean I boot up plugin loader, it shows this for a split second

Plugin Loader by xerpi
Module loaded with ID: 0x4002006D
Press Start to continue.

then reboots to a blank screen?

Using a slim on 3.65, and I made sure to use the 363 skprx file.

@DvaMishkiLapa
Copy link

It took me far too long to realize that there is an entire comment thread under the guide. Anyways what does it mean I boot up plugin loader, it shows this for a split second

@Cinder4198
It's funny, but I got here completely by accident. Looks like my experiments from a year ago will help you out. The comments from here confused me for a long time, until I got into the source code of the Xerpi toolkit and made it more intuitive.

I made a fork of my experiments where I also updated the README.md, it seems to be clearer. I have it running on 3.65, I've tried to cover all the subtleties I've seen, especially for the different PS Vita firmware.

I'll also give a link to my merge attempt with the newer kernel. Of course, I failed miserably, especially since I can't get debugging.
I have also placed the finished files in the plugin and loader repositories.

My failed kernel - https://github.com/DvaMishkiLapa/linux_vita
Original Xerpi kernel image - https://github.com/xerpi/linux_vita/releases/tag/5.9.0-rc5
Loader modification - https://github.com/DvaMishkiLapa/vita_plugin_linux_loader
Plugins - https://github.com/DvaMishkiLapa/vita-baremetal-loader

@DvaMishkiLapa
Copy link

@xerpi
Probably should have shown you this, there might be something useful in there. You seem to be doing about the same thing in vita-baremetal-loader as I am. I'd be glad if this helps you in any way or improves the important repository ^^.

@Ipertatos
Copy link

I am getting Error cant read zImage on 3.65. idk what i am doing wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment