First release, might be buggy!
Signed-off-by: Danct12 <danct12@disroot.org>
This commit is contained in:
commit
8ae62238c7
|
@ -0,0 +1,13 @@
|
||||||
|
[submodule "src/busybox"]
|
||||||
|
path = src/busybox
|
||||||
|
url = git://git.busybox.net/busybox
|
||||||
|
[submodule "src/linux"]
|
||||||
|
path = src/linux
|
||||||
|
url = https://gitlab.com/pine64-org/linux.git
|
||||||
|
branch = pine64-kernel-5.5.y
|
||||||
|
[submodule "src/u-boot"]
|
||||||
|
path = src/u-boot
|
||||||
|
url = https://github.com/u-boot/u-boot
|
||||||
|
[submodule "src/arm-trusted-firmware"]
|
||||||
|
path = src/arm-trusted-firmware
|
||||||
|
url = https://github.com/ARM-software/arm-trusted-firmware.git
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Rescue SD for PinePhone
|
||||||
|
|
||||||
|
This image is a swiss army knife solution for **PinePhone eMMC**.
|
||||||
|
|
||||||
|
You can use this to flash a image **directly to eMMC**, troubleshooting a broken system, and a lot more.
|
||||||
|
|
||||||
|
## This project is built on:
|
||||||
|
- [Busybox](https://busybox.net) - which is [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).
|
||||||
|
- [Pine64's kernel fork](https://gitlab.com/pine64-org/linux) - which is [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).
|
||||||
|
- [U-Boot](https://github.com/u-boot/u-boot) - which has [multiple licenses](https://github.com/u-boot/u-boot/tree/master/Licenses)
|
||||||
|
|
||||||
|
## Support
|
||||||
|
- Discord: https://discord.gg/AvtdRJ3
|
||||||
|
- Matrix: #danctnix-portingv2:matrix.org
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# EDIT THIS:
|
||||||
|
export ARCH=arm64
|
||||||
|
export CROSS_COMPILE=aarch64-linux-gnu-
|
||||||
|
IMAGE_NAME="pinephone-sdrescue.img"
|
||||||
|
|
||||||
|
# Cleanup first
|
||||||
|
rm -rf src/busybox/out
|
||||||
|
rm -rf src/linux/out
|
||||||
|
rm -rf usr
|
||||||
|
|
||||||
|
# Build Busybox
|
||||||
|
cd src/busybox
|
||||||
|
mkdir out
|
||||||
|
cp ../busybox_config out/.config
|
||||||
|
make O=out -j$(nproc --all)
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Build Linux Kernel
|
||||||
|
cd src/linux
|
||||||
|
mkdir out
|
||||||
|
patch -p1 -N < ../linux-disable_sysrq-msgs.diff || true
|
||||||
|
cp ../linux_config out/.config
|
||||||
|
make O=out -j$(nproc --all)
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Make initramfs
|
||||||
|
sudo cp -v src/busybox/out/busybox initramfs/bin/
|
||||||
|
cd initramfs
|
||||||
|
find . | cpio -H newc -o > ../initramfs.cpio
|
||||||
|
cd ..
|
||||||
|
cat initramfs.cpio | gzip > recovery.gz
|
||||||
|
|
||||||
|
# Create image
|
||||||
|
truncate --size 50M $IMAGE_NAME
|
||||||
|
|
||||||
|
cat << EOF | fdisk pinephone-sdrescue.img
|
||||||
|
o
|
||||||
|
n
|
||||||
|
p
|
||||||
|
1
|
||||||
|
2048
|
||||||
|
102399
|
||||||
|
w
|
||||||
|
EOF
|
||||||
|
|
||||||
|
LOOP_DEVICE=$(losetup -f)
|
||||||
|
sudo losetup -P $LOOP_DEVICE $IMAGE_NAME
|
||||||
|
sudo mkfs.fat -F32 ${LOOP_DEVICE}p1
|
||||||
|
mkdir mount
|
||||||
|
sudo mount ${LOOP_DEVICE}p1 mount
|
||||||
|
sudo cp -v src/linux/out/arch/arm64/boot/Image.gz mount
|
||||||
|
sudo cp -v src/linux/out/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtb mount
|
||||||
|
sudo cp -v recovery.gz mount
|
||||||
|
sudo mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d src/boot.txt mount/boot.scr
|
||||||
|
sudo umount mount
|
||||||
|
rm -rf mount
|
||||||
|
|
||||||
|
wget http://dl-cdn.alpinelinux.org/alpine/edge/main/aarch64/u-boot-pine64-2020.01-r0.apk
|
||||||
|
tar xvf u-boot-pine64-2020.01-r0.apk
|
||||||
|
sudo dd if=usr/share/u-boot/pine64-lts/u-boot-sunxi-with-spl.bin of=${LOOP_DEVICE} bs=8k seek=1
|
||||||
|
|
||||||
|
sudo losetup -d $LOOP_DEVICE
|
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Copyright (c) 2020 - Dreemurrs Embedded Labs #
|
||||||
|
################################################
|
||||||
|
|
||||||
|
. /init_functions.sh
|
||||||
|
|
||||||
|
# Environment variables that we want:
|
||||||
|
IP=172.16.42.1
|
||||||
|
|
||||||
|
# Mount things needed by this script
|
||||||
|
mount -t proc proc /proc
|
||||||
|
mount -t sysfs sysfs /sys
|
||||||
|
|
||||||
|
mkdir /config
|
||||||
|
mount -t configfs -o nodev,noexec,nosuid configfs /config
|
||||||
|
|
||||||
|
# /dev/pts (needed for telnet)
|
||||||
|
mkdir -p /dev/pts
|
||||||
|
mount -t devpts devpts /dev/pts
|
||||||
|
|
||||||
|
# LED indicator for MMC r/w access
|
||||||
|
echo mmc2 > /sys/class/leds/pinephone\:green\:user/trigger
|
||||||
|
|
||||||
|
# Create all the symlinks to /bin/busybox
|
||||||
|
echo "Installing Busybox..." && /bin/busybox --install -s
|
||||||
|
|
||||||
|
# Create device nodes
|
||||||
|
echo "Creating device nodes..."
|
||||||
|
mknod /dev/null c 1 3
|
||||||
|
mknod /dev/tty c 5 0
|
||||||
|
mdev -s
|
||||||
|
|
||||||
|
# Finishing rescue setup
|
||||||
|
setup_usb_configfs
|
||||||
|
start_udhcpd
|
||||||
|
setup_telnetd
|
||||||
|
|
||||||
|
# We'll just give some new lines cuz why not.
|
||||||
|
printf "\n\n"
|
||||||
|
|
||||||
|
echo "Rescue SD has initialized!"
|
||||||
|
echo "Please connect the device to your computer."
|
||||||
|
echo
|
||||||
|
echo "* Telnet: $IP (port 23)"
|
||||||
|
|
||||||
|
loop_forever
|
|
@ -0,0 +1,135 @@
|
||||||
|
setup_usb_configfs() {
|
||||||
|
# See: https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt
|
||||||
|
CONFIGFS=/config/usb_gadget
|
||||||
|
|
||||||
|
if ! [ -e "$CONFIGFS" ]; then
|
||||||
|
echo "$CONFIGFS does not exist, this is not good."
|
||||||
|
crash_kernel
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default values for USB-related deviceinfo variables
|
||||||
|
usb_idVendor="0x1F3A"
|
||||||
|
usb_idProduct="0xEFE8"
|
||||||
|
usb_serialnumber="Rescue SD Boot"
|
||||||
|
usb_rndis_function="rndis.usb0"
|
||||||
|
usb_mass_storage_function="mass_storage.0"
|
||||||
|
|
||||||
|
echo "Setting up an USB gadget through configfs..."
|
||||||
|
# Create an usb gadet configuration
|
||||||
|
mkdir $CONFIGFS/g1 || ( echo "Couldn't create $CONFIGFS/g1" ; crash_kernel )
|
||||||
|
echo "$usb_idVendor" > "$CONFIGFS/g1/idVendor"
|
||||||
|
echo "$usb_idProduct" > "$CONFIGFS/g1/idProduct"
|
||||||
|
|
||||||
|
# Create english (0x409) strings
|
||||||
|
mkdir $CONFIGFS/g1/strings/0x409 || echo " Couldn't create $CONFIGFS/g1/strings/0x409"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
echo "Pine64" > "$CONFIGFS/g1/strings/0x409/manufacturer"
|
||||||
|
echo "$usb_serialnumber" > "$CONFIGFS/g1/strings/0x409/serialnumber"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
echo "PinePhone" > "$CONFIGFS/g1/strings/0x409/product"
|
||||||
|
|
||||||
|
# Create rndis/mass_storage function
|
||||||
|
mkdir $CONFIGFS/g1/functions/"$usb_rndis_function" \
|
||||||
|
|| echo " Couldn't create $CONFIGFS/g1/functions/$usb_rndis_function"
|
||||||
|
mkdir $CONFIGFS/g1/functions/"$usb_mass_storage_function" \
|
||||||
|
|| echo " Couldn't create $CONFIGFS/g1/functions/$usb_mass_storage_function"
|
||||||
|
|
||||||
|
# Create configuration instance for the gadget
|
||||||
|
mkdir $CONFIGFS/g1/configs/c.1 \
|
||||||
|
|| echo " Couldn't create $CONFIGFS/g1/configs/c.1"
|
||||||
|
mkdir $CONFIGFS/g1/configs/c.1/strings/0x409 \
|
||||||
|
|| echo " Couldn't create $CONFIGFS/g1/configs/c.1/strings/0x409"
|
||||||
|
echo "rndis" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration \
|
||||||
|
|| echo " Couldn't write configration name"
|
||||||
|
|
||||||
|
# Make sure there is a mmcblk2 (eMMC)...
|
||||||
|
if [ -z "$(ls /dev/mmcblk2)" ]; then
|
||||||
|
echo "eMMC is not found, something is horribly wrong!!"
|
||||||
|
echo "It's probably better to make Huong Tram release a new music video."
|
||||||
|
crash_kernel
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set up mass storage to internal EMMC
|
||||||
|
echo /dev/mmcblk2 > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/file
|
||||||
|
|
||||||
|
# Link the rndis/mass_storage instance to the configuration
|
||||||
|
ln -s $CONFIGFS/g1/functions/"$usb_rndis_function" $CONFIGFS/g1/configs/c.1 \
|
||||||
|
|| echo " Couldn't symlink $usb_rndis_function"
|
||||||
|
ln -s $CONFIGFS/g1/functions/"$usb_mass_storage_function" $CONFIGFS/g1/configs/c.1 \
|
||||||
|
|| echo " Couldn't symlink $usb_mass_storage_function"
|
||||||
|
|
||||||
|
# Check if there's an USB Device Controller
|
||||||
|
if [ -z "$(ls /sys/class/udc)" ]; then
|
||||||
|
echo "No USB Device Controller available, something is horribly wrong!!"
|
||||||
|
echo "Please let Danct12 know this."
|
||||||
|
crash_kernel
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2005
|
||||||
|
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || ( echo "Couldn't write UDC." ; crash_kernel )
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_telnetd() {
|
||||||
|
echo "Starting telnet daemon..."
|
||||||
|
{
|
||||||
|
echo "#!/bin/sh"
|
||||||
|
echo "echo \"Welcome to Rescue SD Shell!\""
|
||||||
|
echo "sh"
|
||||||
|
} >/telnet_connect.sh
|
||||||
|
chmod +x /telnet_connect.sh
|
||||||
|
telnetd -b "${IP}:23" -l /telnet_connect.sh
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
start_udhcpd() {
|
||||||
|
# Only run once
|
||||||
|
[ -e /etc/udhcpd.conf ] && return
|
||||||
|
|
||||||
|
# Get usb interface
|
||||||
|
INTERFACE=""
|
||||||
|
ifconfig rndis0 "$IP" 2>/dev/null && INTERFACE=rndis0
|
||||||
|
if [ -z $INTERFACE ]; then
|
||||||
|
ifconfig usb0 "$IP" 2>/dev/null && INTERFACE=usb0
|
||||||
|
fi
|
||||||
|
if [ -z $INTERFACE ]; then
|
||||||
|
ifconfig eth0 "$IP" 2>/dev/null && INTERFACE=eth0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $INTERFACE ]; then
|
||||||
|
echo "Could not find an interface to run a DHCP server on, this is not good."
|
||||||
|
echo "Interfaces:"
|
||||||
|
ip link
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Network interface $INTERFACE is used"
|
||||||
|
|
||||||
|
# Create /etc/udhcpd.conf
|
||||||
|
{
|
||||||
|
echo "start 172.16.42.2"
|
||||||
|
echo "end 172.16.42.2"
|
||||||
|
echo "auto_time 0"
|
||||||
|
echo "decline_time 0"
|
||||||
|
echo "conflict_time 0"
|
||||||
|
echo "lease_file /var/udhcpd.leases"
|
||||||
|
echo "interface $INTERFACE"
|
||||||
|
echo "option subnet 255.255.255.0"
|
||||||
|
} >/etc/udhcpd.conf
|
||||||
|
|
||||||
|
echo "Started udhcpd daemon for rescue purposes"
|
||||||
|
udhcpd
|
||||||
|
}
|
||||||
|
|
||||||
|
crash_kernel() {
|
||||||
|
echo "panic: We're hanging here..."
|
||||||
|
# shellcheck disable=SC1001
|
||||||
|
echo panic > /sys/class/leds/pinephone\:red\:user/trigger
|
||||||
|
echo c > /proc/sysrq-trigger
|
||||||
|
}
|
||||||
|
|
||||||
|
loop_forever() {
|
||||||
|
while true; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit f9ea3a6291b45bddda0564e8ff654a615933b173
|
|
@ -0,0 +1,14 @@
|
||||||
|
setenv kernel_addr_z 0x44080000
|
||||||
|
|
||||||
|
setenv bootargs loglevel=0 silent console=tty0
|
||||||
|
|
||||||
|
if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_z} /Image.gz; then
|
||||||
|
unzip ${kernel_addr_z} ${kernel_addr_r}
|
||||||
|
if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} /sun50i-a64-pinephone.dtb; then
|
||||||
|
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /recovery.gz; then
|
||||||
|
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
|
||||||
|
else
|
||||||
|
booti ${kernel_addr_r} - ${fdt_addr_r};
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
fi
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 9aa751b08ab03d6396f86c3df77937a19687981b
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 51b5d93fce96448c0f93b98c1e28c85d6df3da78
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
|
||||||
|
index 573b20551..42b040d16 100644
|
||||||
|
--- a/drivers/tty/sysrq.c
|
||||||
|
+++ b/drivers/tty/sysrq.c
|
||||||
|
@@ -551,7 +551,6 @@ void __handle_sysrq(int key, bool check_mask)
|
||||||
|
* should not) and is the invoked operation enabled?
|
||||||
|
*/
|
||||||
|
if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
|
||||||
|
- pr_info("%s\n", op_p->action_msg);
|
||||||
|
console_loglevel = orig_log_level;
|
||||||
|
op_p->handler(key);
|
||||||
|
} else {
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit c00bd81ae0d6eb1f94e26b31be3a64cadaa05bcb
|
Loading…
Reference in New Issue