0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2025-03-01 11:31:22 +00:00
GavinDarkglider 3cc9dbb9ca Switch: Tons of fixes, with poor commit history. lol. (#1839)
* Switch: Minor kernel config update

* fat32-boot: Attempt to fix umounting flash partition to prevent possible corruption on reboot

* Switch: Bootloader: Fix mistake in boot.txt that wasnt properly setting up dvfsb stuff

* Switch: Add user for retroarch to run as

* Busybox: Fix writing flash partition when using fat32-boot option to give all users write access

* Audio: Pulseaudio-configs: Minor updates for use when running apps as non root user

* Switch: Finalize changes so for running as non root user.

* Retroarch: Revert broken WAR in retroarch-config script

* Switch: Fix default retroarch config, to work out of box with new user

* Fix retroarch controller configs for switch, and add line to fix it to the update.sh file

* Add back missing lite gamepad config, which got lost in a rebase somewhere

* Retroarch: Start Reworking Switch Clocks

* Switch: Bump switch specific package versions, and add changes needed to make built in lakka clock speed menu work properly. Also hide gamemode.

* Retroarch: add patch to remove game mode from menu to all builds

* Switch: dont enable overclock by default

* sort

* Sort me.

* Switch: Drop old flycast from switch build in favor of newer core.

This has some issues with some games showing artifact bars using vulkan renderer,
but also fixes a lot of issues. As a work around to this issue, users can set opengl renderer, and the bars will not be there.

* More to sort

* Fix CEC stuff

* Fix dock audio switching with new user config

* WIP: GPU Clocks

* sort

* fix quotes

* Add working single joycon configs

* Update Switch Joycond to latest

* Switch: Retroarch: add bluetooth ertm disable, and add patch to fix l2cap kernel hang

* Switch: Update image stuff, so kernel reflects Lakka/Libreelec kernel makes in uimage header, and re-arange some things to make them global

* Switch: Linux: Enable Xpad Driver for wired xbox controllers

* Switch: More xpadneo stuff
This should at a minimum fix issues with Xbox One S controllers
8bitdo and GuliKit KingKong Controller families will probably need more
hid-core patching to redirect them to this driver for support.

Also, when 0.10 version of Xpadneo is released, It will stop building due to kernel not having this patch:
f07b3c1da9

When the time comes, this will need to be looked into.

* xpadneo: update package

* Switch: Update U-Boot to Switchroot 2023-NX03 version

* Switch: Update kernel to Switchroot 5.1.0

* Switch: Create Singular switch-bsp Package
This package consolodates the switch specific configs into one package,
as this feels cleaner, and easier to deal with later, if/when needed.
This package combines the switch-alsa-ucm and switch-bluetooth-dock stuff
into one package.

---------

Co-authored-by: Tomáš Kelemen (vudiq) <vudiq@vudiq.sk>
2023-06-10 03:17:06 +03:00

241 lines
8.7 KiB
Plaintext

# Set defaults env variables if they do not exist.
setenv boot_dir @DISTRO_PATH@
test -n ${id} || setenv id @DISTRO_ID@
test -n ${fbconsole} || setenv fbconsole 1
test -n ${uart_port} || setenv uart_port 0
test -n ${r2p_action} || setenv r2p_action self
test -n ${autoboot} || setenv autoboot 0
test -n ${autoboot_list} || setenv autoboot_list 0
test -n ${als_enable} || setenv als_enable 1
test -n ${usb3_enable} || setenv usb3_enable 0
test -n ${4k60_disable} || setenv 4k60_disable 0
test -n ${dvfsb} || setenv dvfsb 0
test -n ${dock_freq_switch_enabled} || setenv dock_freq_switch_enabled 0
# Set logging params for each serial type.
setenv uarta "no_console_suspend console=ttyS0,115200,8n1 loglevel=8"
setenv uartb "no_console_suspend console=ttyS1,115200,8n1 loglevel=8"
setenv uartc "no_console_suspend console=ttyS2,115200,8n1 loglevel=8"
setenv usblg "console=ttyGS0,115200,8n1 loglevel=8"
# Default read addresses.
# fdt_addr_r 0x8d000000
# scriptaddr 0x8fe00000
# ramdisk_addr_r 0x92000000
# Set important addresses.
setenv kernload 0xA0000000
setenv initaddr 0x92000000
setenv fdtrload 0xA8000000
setenv fdtraddr 0x8d000000
# Set temp addresses.
setenv fdtovaddr 0x8d200000
# Set SoC info.
if test ${t210b01} = 1; then setenv plat_info T210B01; else setenv plat_info T210; fi
# Set SKU info.
if test ${sku} = 0; then setenv sku_info ODIN; setenv sku_rev 0
elif test ${sku} = 1; then setenv sku_info ODIN; setenv sku_rev b01
elif test ${sku} = 2; then setenv sku_info VALI; setenv sku_rev 0
elif test ${sku} = 3; then setenv sku_info FRIG; setenv sku_rev 0
fi
# Print platform info.
echo PLAT: ${plat_info} SKU: ${sku_info}
echo Serial: ${device_serial}
echo BT MAC: ${device_bt_mac}
echo WF MAC: ${device_wifi_mac}
# Load Kernel.
if load mmc 1:1 ${kernload} ${boot_dir}/KERNEL; then echo Kernel loaded
else echoe Kernel read failed!; echoe Rebooting in 10s..; sleep 10; reset; fi
# Load DT img.
if load mmc 1:1 ${fdtrload} ${boot_dir}/nx-plat.dtimg; then echo Device Tree Image loaded
else echoe Device Tree Image read failed!; echoe Rebooting in 10s..; sleep 10; reset; fi
# Get DT from image. If failed, reset.
if dtimg load ${fdtrload} ${sku} ${fdtraddr} fdtrsize; then echo Device Tree for SKU ${sku_info} loaded
else echoe Device Tree load for SKU ${sku_info} failed!; echoe Rebooting in 10s..; sleep 10; reset; fi
# Set dtb address and size from above and resize it enough to fit any change.
fdt addr ${fdtraddr} ${fdtrsize}
fdt resize 16384
# Sanity checks for dtb info.
if test ${sku_info} != ${fdt_id_text} -o ${sku_rev} != ${fdt_rev}; then
echoe Device Tree loaded (SKU: ${fdt_id_text}, Rev: ${fdt_rev}) not correct!
echoe Expected SKU: ${sku_info}, Rev: ${sku_rev}
echoe Rebooting in 10s..; sleep 10; reset
fi
# Add additional bootargs for UART Logging.
if test ${uart_port} = 1; then
setenv bootargs_extra ${bootargs_extra} ${uarta}; echoe UART-A logging enabled
fdt set /serial@70006000 compatible nvidia,tegra20-uart
fdt set /serial@70006000 status okay
elif test ${uart_port} = 2; then
setenv bootargs_extra ${bootargs_extra} ${uartb}; echoe UART-B logging enabled
fdt set /serial@70006040 compatible nvidia,tegra20-uart
fdt set /serial@70006040/joyconr status disabled
elif test ${uart_port} = 3; then
setenv bootargs_extra ${bootargs_extra} ${uartc}; echoe UART-C logging enabled
fdt set /serial@70006200 compatible nvidia,tegra20-uart
fdt set /serial@70006200/joyconl status disabled
elif test ${uart_port} = 4; then
# Add additional bootargs for Serial USB.
setenv bootargs_extra ${usblg} ${bootargs_extra}; echoe USB Serial logging enabled
fi
# Enable ALS sensor.
if test ${als_enable} = 1; then
fdt set /i2c@7000c400/bh1730fvc@29 status okay
fi
# Get display panel handle.
if test ${display_id} = f20; then echo Display is INN 6.2; fdt get value DHANDLE /host1x/dsi/panel-i-720p-6-2 phandle
elif test ${display_id} = f30; then echo Display is AUO 6.2; fdt get value DHANDLE /host1x/dsi/panel-a-720p-6-2 phandle
elif test ${display_id} = 10; then echo Display is JDI 6.2; fdt get value DHANDLE /host1x/dsi/panel-j-720p-6-2 phandle
elif test ${display_id} = 1020; then echo Display is INN 5.5; fdt get value DHANDLE /host1x/dsi/panel-i-720p-5-5 phandle
elif test ${display_id} = 1030; then echo Display is AUO 5.5; fdt get value DHANDLE /host1x/dsi/panel-a-720p-5-5 phandle
elif test ${display_id} = 1040; then echo Display is SHP 5.5; fdt get value DHANDLE /host1x/dsi/panel-s-720p-5-5 phandle
elif test ${display_id} = 2050; then echo Display is SAM 7.0
else echoe Unknown Display ID: ${display_id}!; fi
# Set new active display panel handle.
if test -n ${DHANDLE} -a ${sku} != 3; then echo Setting Display panel; fdt set /host1x/dsi nvidia,active-panel <$DHANDLE>; fi
# Disable USB3.
if test ${usb3_enable} = 0; then
echo USB3 disabled
fdt get value DHANDLE_USB2 /xusb_padctl@7009f000/pads/usb2/lanes/usb2-0 phandle
fdt set /xusb@70090000 phys <$DHANDLE_USB2>
fdt set /xusb@70090000 phy-names usb2-0
fdt set /xudc@700d0000 phys <$DHANDLE_USB2>
fdt set /xudc@700d0000 phy-names usb2
fdt set /xusb_padctl@7009f000 usb3-no-mapping-war <0x1>
fdt set /xusb_padctl@7009f000/ports/usb2-0 nvidia,usb3-port-fake <0xffffffff>
fdt set /xusb_padctl@7009f000/ports/usb3-0 status disabled
else
echoe USB3 enabled
fi
# Disable 4 DP lanes on Frig.
if test ${sku} = 3 -a ${4k60_disable} = 1 -a ${usb3_enable} != 0; then
echoe 4K60 disabled
fdt set /i2c@7000c000/bm92t@18 rohm,dp-lanes <2>
fi
# Check if SD is initialized in 1-bit mode.
if test "${sd_1bit}" = 1; then
echoe SD Card is initialized in 1-bit mode!
fdt set /sdhci@700b0000 bus-width <0x1>
fdt set /sdhci@700b0000 uhs-mask <0x7F>
fi
# Set battery voltage limit via cell age for Vali.
if test ${sku} = 2 -a -n "${VLIM}"; then
echo VALI: voltage limits [${VLIM}, ${SOCLIM}]
fdt set /i2c@7000c000/battery-charger@6b/charger ti,charge-voltage-limit-millivolt <0x$VLIM>
fdt set /i2c@7000c000/battery-charger@6b/charger ti,charge-thermal-voltage-limit <0x$VLIM 0x$VLIM 0x$VLIM 0xFF0>
fdt set /i2c@7000c000/battery-gauge@36 maxim,kernel-maximum-soc <0x$SOCLIM>
fi
# Enable SLT DVFS.
# Enable SLT DVFS.
if test ${t210b01} = 1 -a ${dvfsb} = 1; then
echoe DVFS B-Side enabled
setenv bootargs_extra ${bootargs_extra} "speedo_tegra210.sku_id=0x83 speedo_tegra210.cspd_id=2 speedo_tegra210.sspd_id=2 speedo_tegra210.gspd_id=2"
if test ${sku} != 2; then
# 2397 MHz CPU and 1075 MHz GPU hard limit.
fdt set /cpufreq/cpu-scaling-data max-frequency <0x249348>
fdt set /dvfs nvidia,gpu-max-freq-khz <0x106800>
else
# 2091 MHz CPU and 844 MHz GPU hard limit. Vali.
fdt set /cpufreq/cpu-scaling-data max-frequency <0x1FE7F8>
fdt set /dvfs nvidia,gpu-max-freq-khz <0xCE400>
fi
fi
# Set serial number.
if test -n ${device_serial}; then fdt set / serial-number ${device_serial}; fi
# load mac address info file
if fatload mmc 1:1 0x90000000 switchroot/joycon_mac.bin; then
if itest.b *0x90000000 == 0x01; then
# left joy con is available
host_mac_addr=0x90000007
fi
if itest.b *0x9000001d == 0x02; then
# right joy con is available
host_mac_addr=0x90000024
fi
fi
if itest $host_mac_addr == 0xff; then
# no joy con is available
# write to a known good location
mw.q 0x90000000 ${serial#} 1
# write crc32 of value at offset 0x3
crc32 0x90000000 8 0x90000003
# write nintendo prefix
mw.b 0x90000000 0x98 1
mw.b 0x90000001 0xE8 1
mw.b 0x90000002 0xFA 1
# use this to generate mac
host_mac_addr=0x90000000
fi
bt_mac=""
sep=""
for i in 0 1 2 3 4 5 ; do
setexpr x $host_mac_addr + $i
setexpr.b b *$x
if itest $b <= f; then
# There is no way to have leading zeros, so do this hack
bt_mac="$bt_mac${sep}0$b"
else
bt_mac="$bt_mac$sep$b"
fi
sep=":"
done
# Set default bt mac. initramfs will/can change it.
if test -n ${bt_mac}; then fdt set /chosen nvidia,bluetooth-mac ${bt_mac}; fi
# Set default wifi mac. initramfs will/can change it.
if test -n ${device_wifi_mac}; then fdt set /chosen nvidia,wifi-mac ${device_wifi_mac}; fi
# Set kernel cdmline.
setenv bootargs ${bootargs_extra} "boot=/dev/mmcblk0p1 BOOT_IMAGE=@DISTRO_PATH@/KERNEL SYSTEM_IMAGE=@DISTRO_PATH@/SYSTEM nofsck fat32-boot \
firmware_class.path=/usr/lib/firmware \
pmc_r2p.enabled=1 pmc_r2p.action=${r2p_action} \
pmc_r2p.param1=${autoboot} pmc_r2p.param2=${autoboot_list} \
nvdec_enabled=0 tegra_fbmem=0x400000@0xf5a00000 access=m2 \
consoleblank=0 fbcon=map:${fbconsole} "
# Boot kernel.
echo Launching Kernel!
bootm ${kernload} - ${fdtraddr}
echoe Failed to launch Kernel!
echoe
echoe Rebooting in 10s..
sleep 10
reset