Skip to content

Commit

Permalink
Merge pull request #1 from MartijnBraam/master
Browse files Browse the repository at this point in the history
Fix build, cleanup and nice branding
  • Loading branch information
asriel-danctnix authored Mar 16, 2020
2 parents 8ae6223 + 7c5b667 commit f6e34e5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 100 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/Image.gz
/fat.img
/jumpdrive.img
/jumpdrive.img.xz
/u-boot-sunxi-with-spl.bin
/*.apk
/initramfs.gz
/initramfs.cpio
/initramfs/bin/busybox
/initramfs/splash.ppm.gz
/build
/boot.scr
/*.dtb
74 changes: 74 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

all: jumpdrive.img.xz

jumpdrive.img.xz: jumpdrive.img
xz -c jumpdrive.img > jumpdrive.img.xz

initramfs/bin/busybox: src/busybox src/busybox_config
mkdir -p build/busybox
cp src/busybox_config build/busybox/.config
make -C src/busybox O=../../build/busybox $(CROSS_FLAGS)
cp build/busybox/busybox initramfs/bin/busybox

initramfs/splash.ppm.gz: splash/jumpdrive.ppm
gzip < splash/jumpdrive.ppm > initramfs/splash.ppm.gz

initramfs.cpio: initramfs/bin/busybox initramfs/init initramfs/init_functions.sh initramfs/splash.ppm.gz
cd initramfs; find . | cpio -H newc -o > ../initramfs.cpio

initramfs.gz: initramfs.cpio
gzip < initramfs.cpio > initramfs.gz

Image.gz: src/linux_config
mkdir -p build/linux
cp src/linux_config build/linux/.config
make -C src/linux O=../../build/linux $(CROSS_FLAGS) olddefconfig
make -C src/linux O=../../build/linux $(CROSS_FLAGS)
cp build/linux/arch/arm64/boot/Image.gz Image.gz
cp build/linux/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtb sun50i-a64-pinephone.dtb

jumpdrive.img: fat.img u-boot-sunxi-with-spl.bin
rm -f jumpdrive.img
truncate --size 50M jumpdrive.img
parted -s jumpdrive.img mktable msdos
parted -s jumpdrive.img mkpart primary fat32 2048s 100%
parted -s jumpdrive.img set 1 boot on
dd if=u-boot-sunxi-with-spl.bin of=jumpdrive.img bs=8k seek=1
dd if=fat.img of=jumpdrive.img seek=1024 bs=1k

boot.scr: src/boot.txt
mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d src/boot.txt boot.scr

u-boot-sunxi-with-spl.bin:
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 usr/share/u-boot/pine64-lts/u-boot-sunxi-with-spl.bin --strip-components 4


fat.img: initramfs.gz Image.gz boot.scr
rm -f fat.img
truncate --size 40M fat.img
mkfs.fat -F32 fat.img

mcopy -i fat.img Image.gz ::Image.gz
mcopy -i fat.img sun50i-a64-pinephone.dtb ::sun50i-a64-pinephone.dtb
mcopy -i fat.img initramfs.gz ::initramfs.gz
mcopy -i fat.img boot.scr ::boot.scr

.PHONY: clean

clean:
rm -rf build
rm -f initramfs/bin/busybox
rm -f fat.img
rm -f jumpdrive.img
rm -f jumpdrive.img.xz
rm -f *.dtb
rm -f u-boot-pine64-2020.01-r0.apk
rm -f u-boot-sunxi-with-spl.bin
rm -f initramfs/splash.ppm.gz
rm -f initramfs/bin/busybox
rm -f initramfs.cpio
rm -f initramfs.gz
rm -f Image.gz
rm -f boot.scr
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ You can use this to flash a image **directly to eMMC**, troubleshooting a broken

## This project is built on:
- [Busybox](https://busybox.net) - which is [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).
- [postmarketOS](https://postmarketos.org) scripts - 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
## Building

Run `make` inside this directory and it will build jumpdrive.img.xz that can be flashed to SD.

The dependencies are:

- aarch64-linux-gnu- toolchain
- u-boot tools
- mtools
64 changes: 0 additions & 64 deletions build.sh

This file was deleted.

30 changes: 17 additions & 13 deletions initramfs/init
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#!/bin/sh
## Init script for JumpDrive
## Copyright (C) 2020 - postmarketOS
## Copyright (C) 2020 - Danctl12 <danct12@disroot.org>

################################################
# Copyright (c) 2020 - Dreemurrs Embedded Labs #
################################################
echo "Welcome to JumpDrive"

. /init_functions.sh

# Environment variables that we want:
IP=172.16.42.1

# Create all the symlinks to /bin/busybox
mkdir -p /usr/bin
mkdir -p /sbin
mkdir -p /usr/sbin
echo "Installing Busybox..." && /bin/busybox --install -s

# Mount things needed by this script
mkdir /proc
mkdir /sys
mkdir /etc
mount -t proc proc /proc
mount -t sysfs sysfs /sys

Expand All @@ -20,11 +30,10 @@ mount -t configfs -o nodev,noexec,nosuid configfs /config
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts

# LED indicator for MMC r/w access
# Amber LED indicator for MMC r/w access
echo mmc2 > /sys/class/leds/pinephone\:green\:user/trigger
echo mmc2 > /sys/class/leds/pinephone\:red\:user/trigger

# Create all the symlinks to /bin/busybox
echo "Installing Busybox..." && /bin/busybox --install -s

# Create device nodes
echo "Creating device nodes..."
Expand All @@ -37,12 +46,7 @@ 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)"
gzip -c -d splash.ppm.gz > /splash.ppm
fbsplash -s /splash.ppm

loop_forever
12 changes: 5 additions & 7 deletions initramfs/init_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ setup_usb_configfs() {
fi

# Default values for USB-related deviceinfo variables
usb_idVendor="0x1F3A"
usb_idProduct="0xEFE8"
usb_serialnumber="Rescue SD Boot"
usb_idVendor="0x1209" # Generic
usb_idProduct="0x4201" # Random ID
usb_serialnumber="Jumpdrive"
usb_rndis_function="rndis.usb0"
usb_mass_storage_function="mass_storage.0"

Expand Down Expand Up @@ -45,8 +45,7 @@ setup_usb_configfs() {

# 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."
echo "/dev/mmcblk2 could not be opened, possible eMMC defect"
crash_kernel
fi

Expand All @@ -61,8 +60,7 @@ setup_usb_configfs() {

# 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."
echo "No USB Device Controller available"
crash_kernel
fi

Expand Down
Binary file added splash/jumpdrive.ppm
Binary file not shown.
Binary file added splash/jumpdrive.xcf
Binary file not shown.
4 changes: 3 additions & 1 deletion src/boot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ setenv kernel_addr_z 0x44080000

setenv bootargs loglevel=0 silent console=tty0

gpio set 114

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
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /initramfs.gz; then
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
booti ${kernel_addr_r} - ${fdt_addr_r};
Expand Down
12 changes: 0 additions & 12 deletions src/linux-disable_sysrq-msgs.diff

This file was deleted.

0 comments on commit f6e34e5

Please sign in to comment.