Super Mario 64 Natively on Android

Found a post on XDA about building Super Mario 64 for Android using Termux, & figured I’d try it out for fun.
Source: XDA Developers: Super Mario 64 can be natively run on Android without a Nintendo 64 emulator

Their instructions worked fine, so below is really just a copy & paste from the XDA post:

➜  ~ pkg install git wget make python getconf zip apksigner clang
Checking availability of current mirror: ok
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apksigner is already the newest version (29.0.2-5).
clang is already the newest version (10.0.1-2).
getconf is already the newest version (0.5-1).
git is already the newest version (2.28.0).
make is already the newest version (4.3-1).
python is already the newest version (3.8.5).
wget is already the newest version (1.20.3-3).
zip is already the newest version (3.0-5).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
➜  ~ cd Development 
➜  Development git clone https://github.com/VDavid003/sm64-port-android
Cloning into 'sm64-port-android'...
remote: Enumerating objects: 15616, done.
remote: Total 15616 (delta 0), reused 0 (delta 0), pack-reused 15616
Receiving objects: 100% (15616/15616), 22.76 MiB | 5.71 MiB/s, done.
Resolving deltas: 100% (7567/7567), done.
➜  Development cd sm64-port-android 
➜  sm64-port-android git:(master) cp ~/storage/shared/Super\ Mario\ 64\ \(USA\).z64 baserom.us.z64
➜  sm64-port-android git:(master) sha256 baserom.us.z64 
The program openssl is not installed. Install it by executing:
 pkg install openssl-tool
➜  sm64-port-android git:(master) pkg install openssl-tool
Checking availability of current mirror: ok
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  openssl-tool
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 185 kB of archives.
After this operation, 643 kB of additional disk space will be used.
Get:1 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 openssl-tool aarch64 1.1.1g-4 [185 kB]
Fetched 185 kB in 0s (214 kB/s)    
Selecting previously unselected package openssl-tool.
(Reading database ... 14219 files and directories currently installed.)
Preparing to unpack .../openssl-tool_1.1.1g-4_aarch64.deb ...
Unpacking openssl-tool (1.1.1g-4) ...
Setting up openssl-tool (1.1.1g-4) ...
➜  sm64-port-android git:(master) sha256 baserom.us.z64   
SHA256(baserom.us.z64)= 17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91
➜  sm64-port-android git:(master) md5sum baserom.us.z64 
20b854b239203baf6c961b850a4a51a2  baserom.us.z64
➜  sm64-port-android git:(master) ./getSDL.sh
~/Development/sm64-port-android/SDL ~/Development/sm64-port-android
--2020-09-20 11:56:47--  https://www.libsdl.org/release/SDL2-2.0.12.zip
Resolving www.libsdl.org... 2604:a880:1:20::181:e001, 192.241.223.99
Connecting to www.libsdl.org|2604:a880:1:20::181:e001|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6784187 (6.5M) [application/zip]
Saving to: ‘SDL2-2.0.12.zip’

SDL2-2.0.12.zip                       100%[=======================================================================>]   6.47M  5.65MB/s    in 1.1s    

2020-09-20 11:56:49 (5.65 MB/s) - ‘SDL2-2.0.12.zip’ saved [6784187/6784187]

~/Development/sm64-port-android
➜  sm64-port-android git:(master) make --jobs 4
...
cp build/us_pc/sm64.us.f3dex2e.unsigned.apk build/us_pc/sm64.us.f3dex2e.apk
apksigner sign --cert certificate.pem --key key.pk8 build/us_pc/sm64.us.f3dex2e.apk
➜  sm64-port-android git:(master) ls
Android.mk   Makefile.split  assets           charmap.txt       enhancements       key.pk8        sm64.jp.sha1  text
CHANGES      README.md       assets.json      charmap_menu.txt  extract_assets.py  levels         sm64.ld       textures
Dockerfile   SDL             baserom.us.z64   data              first-diff.py      lib            sm64.sh.sha1  tools
Doxyfile     actors          bin              diff.py           format.sh          rename_sym.sh  sm64.us.sha1  undefined_syms.txt
Jenkinsfile  android         build            diff_settings.py  getSDL.sh          rsp            sound
Makefile     asm             certificate.pem  doxygen           include            sm64.eu.sha1   src
➜  sm64-port-android git:(master) ls build 
us_pc
➜  sm64-port-android git:(master) ls build/us_pc 
actors  bin   endian-and-bitwidth  level_rules.mk  lib         rsp                  sm64.us.f3dex2e.unsigned.apk  src   textures
assets  data  include              levels          libmain.so  sm64.us.f3dex2e.apk  sound                         text
➜  sm64-port-android git:(master)
Super Mario 64 running natively on my OnePlus 7 Pro.

OnePlus 7 Pro: Update System Firmware on Custom ROM

Follow up to the OnePlus 7 Pro: LineageOS+MicroG post, where I mentioned I would have to update the Bluetooth & Modem firmware on my device. This fortunately went as smoothly as the LineageOS+MicroG install, so I’m very happy about that.

The first step was downloading the latest OxygenOS ZIP through this post: XDA Developers: [ROM][STOCK][FASTBOOT][OP7P] Stock Fastboot ROMs for OnePlus 7 Pro/ 7 Pro 5G by mauronofrio. The specific ZIP i pulled down from Android File Host was “10.0-GM21AA-OnePlus7ProOxygen_21.O.20_OTA_020_all_1909172051_db7a3f61-FASTBOOT.zip”. From there, it was just a simple matter of extracting that, images.zip, & flashing the bluetooth.img & modem.img files:

➜  Downloads cd 10.0-GM21AA-OnePlus7ProOxygen_21.O.20_OTA_020_all_1909172051_db7a3f61-FASTBOOT/images
➜  images file bluetooth.img
bluetooth.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSDOS5.0", Bytes/sector 4096, sectors/cluster 4, root entries 512, Media descriptor 0xf8, sectors/FAT 3, sectors/track 63, heads 255, sectors 16384 (volumes > 32 MB), serial number 0xbc614e, unlabeled, FAT (16 bit)
➜  images file modem.img
modem.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSDOS5.0", Bytes/sector 4096, sectors/cluster 4, root entries 512, Media descriptor 0xf8, sectors/FAT 10, sectors/track 63, heads 255, sectors 76800 (volumes > 32 MB), serial number 0xbc614e, unlabeled, FAT (16 bit)

➜  images adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
➜  images adb devices
List of devices attached
1234abcd        device
➜  images adb reboot bootloader
➜  images fastboot devices
1234abcd        fastboot
➜  images fastboot flash bluetooth_a bluetooth.img
Sending 'bluetooth_a' (828 KB)                     OKAY [  0.030s]
Writing 'bluetooth_a'                              OKAY [  0.005s]
Finished. Total time: 0.049s
➜  images fastboot flash bluetooth_b bluetooth.img
Sending 'bluetooth_b' (828 KB)                     OKAY [  0.032s]
Writing 'bluetooth_b'                              OKAY [  0.005s]
Finished. Total time: 0.050s
➜  images fastboot flash modem_a modem.img
Sending 'modem_a' (161700 KB)                      OKAY [  4.308s]
Writing 'modem_a'                                  OKAY [  0.633s]
Finished. Total time: 4.954s
➜  images fastboot flash modem_b modem.img
Sending 'modem_b' (161700 KB)                      OKAY [  3.769s]
Writing 'modem_b'                                  OKAY [  0.696s]
Finished. Total time: 4.480s
➜  images fastboot reboot
Rebooting                                          OKAY [  0.002s]
Finished. Total time: 0.002s
➜  images

OnePlus 7 Pro: LineageOS+MicroG

After a full weekend of originally getting CrDroid on my new OnePlus 7 Pro a few months back, I decided to switch to LineageOS+MicroG because I was never able to get location working on CrDroid. This was mostly due to the changes in Android 10, but when I was still unable to get it working with the new UnifiedNLP package, I just decided it was easier to switch & settled for reinstalling MicroG, which I had avoided on CrDroid because I wanted to avoid as many Google services as possible.

Since I had so many issues getting CrDroid setup in the first place (mainly due to me lack of experience with A\B partitions & not knowing I needed to flash OxygenOS first, then the ROM on top of it), I wanted to keep track of the exact steps I took to get LineageOS+MicroG so I could follow it the next time I decide I want to try a new ROM. Posting it here just makes it easier to come back to & maybe it will help out someone else.

First step was just backup & prep: Making sure I had backups of my messages, F-Droid repositories, 2FA tokens, as well as my list of installed apps.

One thing I was surprised at for the installation was that I wasn’t expected to flash an OxygenOS ROM first… Below are the two “guides” i followed:

This one specifically included when to flash Magisk:
XDA Developers: [ROM]-[10-04-2020]-[microG] Unofficial LineageOS 17 w/ microG support by gigatex

Flashing Recovery: I thought this was one place where I had issues, but that may have only been on the Essential Phone, where I couldn’t boot recovery. that did work on the OP7Pro:

➜ OP7Pro adb reboot fastboot
➜ OP7Pro fastboot devices
0810d6ea fastboot
➜ OP7Pro fastboot boot twrp-3.4.0-0-guacamole.img
Sending 'boot.img' (31704 KB) OKAY [ 0.742s]
Booting OKAY [ 0.106s]
Finished. Total time: 0.886s
➜ OP7Pro

Once I was booted into TWRP I formatted DATA & pushed the LineageOS+MicroG & TWRP installer ZIPs, then rebooted to recovery again (without flashing anything). I ended up having to push the two ZIPs again because they were not present on the “SD Card” after the reboot. After pushing the files again I flashed & rebooted the system to complete setup.

An issue I did run into with Magisk appeared to be due to the A\B slots again. The fix seemed to be flashing when getting into TWRP, then manually changing the A\B slot, rebooting to recovery, & flashing again. Just a simple “Reboot > Recovery” didn’t change the slots.

I did just attempt a system update yesterday, & it was successful, following the same process I took during CrDroid: Use the internal updater, but DO NOT REBOOT through the updater. You have to go into Magisk Manager > Magisk Install > Install > Install to Inactive Slot (After OTA). You can then reboot & will still be rooted with Magisk.

I will have another update shortly about updating firmware, since I just noticed this morning that Bluetooth will not stay enabled. While on CrDroid the fix seemed to be flashing Bluetooth & Modem firmware from an official OxygenOS update.

Custom ROM on Mi MIX 3

I recently picked up a Xiaomi Mi MIX 3 & was able to unlock the bootloader after the 72 hour waiting period. That wasn’t a problem, however getting TWRP up & running was where I had a problem.

For some reason, whenever I would flash TWRP, but device was stuck in a fastboot loop — could not reboot out of it, boot the TWRP image, or any other method of exiting fastboot. I finally got TWRP working properly after flashing perseus_global_images_9.5.17_20190517.0000.00_9.0 _global_134d3070e5.tgz. I tried flashing one of the China ROM’s, & that was of no help.

Since this was turning out to be nothing close to simple like other devices, I was then running into an issue flashing NanoDroid after my ROM. That one seemed to be related to the /system partition not being found. It looks like my partition was instead mounted as /system_root, but the NanoDroid install script was looking for /system. Managed to fix that as well:

Results of mount:


/dev/block/sde48 on /system_root type ext4 (rw,seclabel,relatime,block_validity,delalloc,barrier,user_xattr)

Remount /system_root as /system:

perseus:/ # mount -o bind /system_root/system /system

Taking a look at NanoDroid-20.8.91.20190525.zip\CommonInstaller: Lines 248-252:

if [ -f /system/init.rc ]; then
mkdir /system_root 2>/dev/null
mount –move /system /system_root
mount -o bind /system_root/system /system
fi

Once NanoDroid was working, I then needed to double check how to restore my backed up Signal messages: Signal: Backup & Restore Messages.

Protecting Linux Login with 2FA

This is definitely not the first time I’ve tried getting this working, but glad I was finally able to. Looks like if I had read a bit more, I never would have run into issues…

By the second or third time I ran into problems, I at least figured out why: with my home directory being encrypted, the “secret” 2FA files could not be accessed & verified.

Now for the fun part… It looks like Google had the instructions for encrypted home directories in the README the whole time.

Encrypted home directories
If your system encrypts home directories until after your users entered their password, you either have to re-arrange the entries in the PAM configuration file to decrypt the home directory prior to asking for the OTP code, or you have to store the secret file in a non-standard location:

auth required pam_google_authenticator.so secret=/var/unencrypted-home/${USER}/.google_authenticator

would be a possible choice. Make sure to set appropriate permissions. You also have to tell your users to manually move their .google_authenticator file to this location.

In addition to “${USER}”, the secret= option also recognizes both “~” and ${HOME} as short-hands for the user’s home directory.

When using the secret= option, you might want to also set the user= option. The latter forces the PAM module to switch to a dedicated hard-coded user id prior to doing any file operations. When using the user= option, you must not include “~” or “${HOME}” in the filename.

The user= option can also be useful if you want to authenticate users who do not have traditional UNIX accounts on your system.

So, after getting through that tedious “reading” thing, I followed their suggestion, & created the “unencrypted-home” directory, moved the ~/.google_authenticator file there, edited /etc/pam.d/common-auth & included the path to the file at the encrypted location. After that… Working as expected!

user@Hostname:~$ cat /etc/pam.d/common-auth | tail -n 1
auth required pam_google_authenticator.so secret=/var/unencrypted-home/${USER}/.google_authenticator

FINALLY Got my OpenVPN Server Setup on My DD-WRT Router

This took way longer than I would have liked, but at least it seems to be working right now.

After moving recently, I needed to purchase a new router, leaving my rooted Google WiFi AP’s behind. I decided to replace it with a D-LINK AC2600 EXO MU-MIMO Wi-Fi Router. After some more router related fun, I was able to get DD-WRT custom firmware running on the device. With that finally in place, my next project was to get the OpenVPN Server feature enabled. I had all the certificates & keys I needed, it was just a matter of getting the right config in the DD-WRT Admin GUI. Below is what I finally had in the “Additional Config” field that, that ended up working:

push “route 192.168.1.0 255.255.255.0”
push “dhcp-option DNS 192.168.2.1”
server 192.168.2.0 255.255.255.0
verb 5
dev tun0
proto udp4
keepalive 10 120
dh /tmp/openvpn/dh.pem
ca /tmp/openvpn/ca.crt
cert /tmp/openvpn/cert.pem
key /tmp/openvpn/key.pem
script-security 2
# Only use crl-verify if you are using the revoke list – otherwise leave it commented out
# crl-verify /tmp/openvpn/ca.crl
# management parameter allows DD-WRT’s OpenVPN Status web page to access the server’s management port
# port must be 5001 for scripts embedded in firmware to work
# management localhost 5001

Where 192.168.1.0 is my local subnet, & 192.168.2.0 is a subnet I’m assigning to VPN clients.

I haven’t started configuring clients yet, but don’t believe that will be anywhere near as difficult as getting the server running. For reference, below is a history of the commands I ran to get the certificates, keys, etc setup for the server:

v3ritas@Hostname:~/.openvpn/20190101$ history
2956 make-cadir 20190101
2957 cd 20190101/
2958 ls
2959 nano vars
2960 source vars
2961 cp openssl-1.0.0.cnf openssl.cnf
2962 source vars
2963 ./clean-all
2964 ./build-ca
2965 ./build-key-server OpenVPN-Server
2966 ./clean-all
2967 nano vars
2968 ./build-ca
2969 source vars
2970 ./build-ca
2971 ./build-key-server OpenVPN-Server
2972 ./build-dh
2973 ls keys
2974 openvpn –genkey –secret pfs.key
2975 ls keys
2976 cat keys/ca.crt
2977 cat OpenVPN-Server.crt
2978 cat keys/OpenVPN-Server.crt
2979 cat keys/OpenVPN-Server.key
2980 cat keys/dh4096.pem
2981 cat pfs.key
2982 md5 ~/Downloads/factory-to-ddwrt.bin
2983 md5 ~/Downloads/dlink-dir882-a1-webflash.bin
2984 ./build-key Client01
2985 ls keys
2986 cat keys/ca.crt
2987 cat keys/OpenVPN-Server.crt
2988 cat keys/OpenVPN-Server.key
2989 cat keys/dh4096.pem
2990 cat pfs.key

Just of dump of my command history.

New Nintendo Switch Payload: ArgonNX

Guillem96 has a new payload available on GitHub: argon-nx.

As he states in the description there, it’s meant to be used to choose which payload you’d actually like to launch; just use the ArgonNX payload, & then choose from any BIN you have located in the \argon\payloads\ directory. What’s nice about this is that you can choose the logos to go along with each BIN. Still have some work to do, but this is what my selection screen looks like right now:

Photo of the ArgonNX payload running.
Photo of the ArgonNX payload running.
ArgonNX logos.
Some quick logos I put together to be used with ArgonNX. Crappy screenshot because apparently WordPress \ Gutenberg views BMP files as a security risk… See screenshot below.
BMP files are a security risk?

Homebrewing ALL THE THINGS

Pretty accurate description of what I’ve been up to recently.

Since getting homebrew running on my Nintendo Switch, I’ve been booting up some old hardware & getting homebrew &\or custom firmware running there. The most recent three after the Switch have been my Nintendo Wii U, PlayStation Vita, & PlayStation 3. I’ve had CFW running on my Vita for a while, but also haven’t turned it on in ages. I came back to some interesting to features in the homebrew scene which was a nice surprise.

It took me a little while to get homebrew up on my Wii U, but was much easier than what I’ve been dealing with on the Switch. Same goes for the PlayStation 3. I’ve not yet gotten a chance to play around much with either system, but hopefully that will change in the upcoming weeks. I’ll be sure to post more information then, but in the meantime, here are some helpful sites I used in getting homebrew running on my Wii U & PS3: