mirror of
https://github.com/dreemurrs-embedded/Jumpdrive.git
synced 2024-11-16 14:10:06 +00:00
Build multiple images and nice errors
This commit is contained in:
parent
7dfbc13bc2
commit
0257d43859
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,13 +1,12 @@
|
||||
/Image.gz
|
||||
/fat.img
|
||||
/jumpdrive.img
|
||||
/jumpdrive.img.xz
|
||||
/u-boot-sunxi-with-spl.bin
|
||||
/*.img
|
||||
/*.apk
|
||||
/initramfs.gz
|
||||
/initramfs.cpio
|
||||
/initramfs/bin/busybox
|
||||
/initramfs/splash.ppm.gz
|
||||
/initramfs-*
|
||||
/build
|
||||
/boot.scr
|
||||
/dtbs
|
||||
/*.scr
|
||||
/*.dtb
|
||||
/*.img.xz
|
||||
/*.gz
|
||||
/*.bin
|
||||
/splash/*.gz
|
||||
|
154
Makefile
154
Makefile
@ -1,74 +1,112 @@
|
||||
CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
|
||||
|
||||
all: jumpdrive.img.xz
|
||||
all: pine64-pinephone.img.xz pine64-pinetab.img.xz
|
||||
|
||||
jumpdrive.img.xz: jumpdrive.img
|
||||
xz -c jumpdrive.img > jumpdrive.img.xz
|
||||
|
||||
pine64-pinephone.img: fat-pine64-pinephone.img u-boot-sunxi-with-spl.bin
|
||||
rm -f $@
|
||||
truncate --size 50M $@
|
||||
parted -s $@ mktable msdos
|
||||
parted -s $@ mkpart primary fat32 2048s 100%
|
||||
parted -s $@ set 1 boot on
|
||||
dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1
|
||||
dd if=fat-$@ of=$@ seek=1024 bs=1k
|
||||
|
||||
fat-pine64-pinephone.img: initramfs-pine64-pinephone.gz kernel-sunxi.gz pine64-pinephone.scr dtbs/sunxi/sun50i-a64-pinephone.dtb
|
||||
@echo "MKFS $@"
|
||||
@rm -f $@
|
||||
@truncate --size 40M $@
|
||||
@mkfs.fat -F32 $@
|
||||
|
||||
@mcopy -i $@ kernel-sunxi.gz ::Image.gz
|
||||
@mcopy -i $@ dtbs/sunxi/sun50i-a64-pinephone.dtb ::sun50i-a64-pinephone.dtb
|
||||
@mcopy -i $@ initramfs-pine64-pinephone.gz ::initramfs.gz
|
||||
@mcopy -i $@ pine64-pinephone.scr ::boot.scr
|
||||
|
||||
pine64-pinetab.img: fat-pine64-pinetab.img u-boot-sunxi-with-spl.bin
|
||||
rm -f $@
|
||||
truncate --size 50M $@
|
||||
parted -s $@ mktable msdos
|
||||
parted -s $@ mkpart primary fat32 2048s 100%
|
||||
parted -s $@ set 1 boot on
|
||||
dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1
|
||||
dd if=fat-$@ of=$@ seek=1024 bs=1k
|
||||
|
||||
fat-pine64-pinetab.img: initramfs-pine64-pinetab.gz kernel-sunxi.gz pine64-pinetab.scr dtbs/sunxi/sun50i-a64-pinetab.dtb
|
||||
@echo "MKFS $@"
|
||||
@rm -f $@
|
||||
@truncate --size 40M $@
|
||||
@mkfs.fat -F32 $@
|
||||
|
||||
@mcopy -i $@ kernel-sunxi.gz ::Image.gz
|
||||
@mcopy -i $@ dtbs/sunxi/sun50i-a64-pinetab.dtb ::sun50i-a64-pinetab.dtb
|
||||
@mcopy -i $@ initramfs-pine64-pinetab.gz ::initramfs.gz
|
||||
@mcopy -i $@ pine64-pinetab.scr ::boot.scr
|
||||
|
||||
%.img.xz: %.img
|
||||
@echo "XZ $@"
|
||||
@xz -c $< > $@
|
||||
|
||||
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
|
||||
@echo "MAKE $@"
|
||||
@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
|
||||
splash/%.ppm.gz: splash/%.ppm
|
||||
@echo "GZ $@"
|
||||
@gzip < $< > $@
|
||||
|
||||
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-%.cpio: initramfs/bin/busybox initramfs/init initramfs/init_functions.sh splash/%.ppm.gz splash/%-error.ppm.gz
|
||||
@echo "CPIO $@"
|
||||
@rm -rf initramfs-$*
|
||||
@cp -r initramfs initramfs-$*
|
||||
@cp src/info-$*.sh initramfs-$*/info.sh
|
||||
@cp splash/$*.ppm.gz initramfs-$*/splash.ppm.gz
|
||||
@cp splash/$*-error.ppm.gz initramfs-$*/error.ppm.gz
|
||||
@cp src/info-$*.sh initramfs-$*/info.sh
|
||||
@cd initramfs-$*; find . | cpio -H newc -o > ../$@
|
||||
|
||||
initramfs.gz: initramfs.cpio
|
||||
gzip < initramfs.cpio > initramfs.gz
|
||||
initramfs-%.gz: initramfs-%.cpio
|
||||
@echo "GZ $@"
|
||||
@gzip < $< > $@
|
||||
|
||||
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
|
||||
kernel-sunxi.gz: src/linux_config
|
||||
@echo "MAKE $@"
|
||||
@mkdir -p build/linux-sunxi
|
||||
@mkdir -p dtbs/sunxi
|
||||
@cp src/linux_config build/linux-sunxi/.config
|
||||
@$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS) olddefconfig
|
||||
@$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS)
|
||||
@cp build/linux-sunxi/arch/arm64/boot/Image.gz $@
|
||||
@cp build/linux-sunxi/arch/arm64/boot/dts/allwinner/*.dtb dtbs/sunxi/
|
||||
|
||||
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
|
||||
%.scr: src/%.txt
|
||||
@echo "MKIMG $@"
|
||||
@mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $< $@
|
||||
|
||||
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
|
||||
@echo "WGET $@"
|
||||
@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
|
||||
.PHONY: clean cleanfast
|
||||
|
||||
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
|
||||
cleanfast:
|
||||
@rm -rvf build
|
||||
@rm -vf *.img
|
||||
@rm -vf *.img.xz
|
||||
@rm -vf *.apk
|
||||
@rm -vf *.bin
|
||||
@rm -vf *.cpio
|
||||
@rm -vf *.gz
|
||||
@rm -vf *.scr
|
||||
@rm -vf splash/*.gz
|
||||
|
||||
clean: cleanfast
|
||||
@rm -vf kernel*.gz
|
||||
@rm -vf initramfs/bin/busybox
|
||||
@rm -vrf dtbs
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
echo "Welcome to JumpDrive"
|
||||
|
||||
. /info.sh
|
||||
echo "Running on $PLATFORM"
|
||||
|
||||
. /init_functions.sh
|
||||
|
||||
# Environment variables that we want:
|
||||
@ -32,10 +35,10 @@ mount -t configfs -o nodev,noexec,nosuid configfs /config
|
||||
mkdir -p /dev/pts
|
||||
mount -t devpts devpts /dev/pts
|
||||
|
||||
# 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
|
||||
|
||||
# LED indicator for MMC r/w access
|
||||
if [ -n "$LED" ]; then
|
||||
echo $TRIGGER > /sys/class/leds/$LED/trigger
|
||||
fi
|
||||
|
||||
# Create device nodes
|
||||
echo "Creating device nodes..."
|
||||
|
@ -8,8 +8,7 @@ setup_usb_configfs() {
|
||||
CONFIGFS=/config/usb_gadget
|
||||
|
||||
if ! [ -e "$CONFIGFS" ]; then
|
||||
echo "$CONFIGFS does not exist, this is not good."
|
||||
crash_kernel
|
||||
fatal_error "$CONFIGFS does not exist"
|
||||
fi
|
||||
|
||||
# Default values for USB-related deviceinfo variables
|
||||
@ -21,7 +20,7 @@ setup_usb_configfs() {
|
||||
|
||||
echo "Setting up an USB gadget through configfs..."
|
||||
# Create an usb gadet configuration
|
||||
mkdir $CONFIGFS/g1 || ( echo "Couldn't create $CONFIGFS/g1" ; crash_kernel )
|
||||
mkdir $CONFIGFS/g1 || ( fatal_error "Couldn't create $CONFIGFS/g1" )
|
||||
echo "$usb_idVendor" > "$CONFIGFS/g1/idVendor"
|
||||
echo "$usb_idProduct" > "$CONFIGFS/g1/idProduct"
|
||||
|
||||
@ -48,14 +47,13 @@ setup_usb_configfs() {
|
||||
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 "/dev/mmcblk2 could not be opened, possible eMMC defect"
|
||||
crash_kernel
|
||||
# Make sure the node for the eMMC exists
|
||||
if [ -z "$(ls $EMMC)" ]; then
|
||||
fatal_error "$EMMC could not be opened, possible eMMC defect"
|
||||
fi
|
||||
|
||||
# Set up mass storage to internal EMMC
|
||||
echo /dev/mmcblk2 > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/file
|
||||
echo $EMMC > $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 \
|
||||
@ -65,12 +63,11 @@ setup_usb_configfs() {
|
||||
|
||||
# Check if there's an USB Device Controller
|
||||
if [ -z "$(ls /sys/class/udc)" ]; then
|
||||
echo "No USB Device Controller available"
|
||||
crash_kernel
|
||||
fatal_error "No USB Device Controller available"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2005
|
||||
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || ( echo "Couldn't write UDC." ; crash_kernel )
|
||||
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || ( fatal_error "Couldn't write to UDC" )
|
||||
}
|
||||
|
||||
setup_telnetd() {
|
||||
@ -124,11 +121,19 @@ start_udhcpd() {
|
||||
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
|
||||
fatal_error() {
|
||||
clear
|
||||
|
||||
# Move cursor into position for error message
|
||||
echo -e "\033[$ERRORLINES;0H"
|
||||
|
||||
gzip -c -d error.ppm.gz > /error.ppm
|
||||
fbsplash -s /error.ppm
|
||||
|
||||
# Print the error message over the error splash
|
||||
echo " $1"
|
||||
|
||||
loop_forever
|
||||
}
|
||||
|
||||
loop_forever() {
|
||||
|
BIN
splash/pine64-pinephone-error.ppm
Normal file
BIN
splash/pine64-pinephone-error.ppm
Normal file
Binary file not shown.
BIN
splash/pine64-pinetab-error.ppm
Normal file
BIN
splash/pine64-pinetab-error.ppm
Normal file
Binary file not shown.
BIN
splash/pine64-pinetab.ppm
Normal file
BIN
splash/pine64-pinetab.ppm
Normal file
Binary file not shown.
BIN
splash/pine64-pinetab.xcf
Normal file
BIN
splash/pine64-pinetab.xcf
Normal file
Binary file not shown.
5
src/info-pine64-pinephone.sh
Normal file
5
src/info-pine64-pinephone.sh
Normal file
@ -0,0 +1,5 @@
|
||||
PLATFORM=pine64-pinephone
|
||||
EMMC=/dev/mmcblk2
|
||||
LED=pinephone\:red\:user
|
||||
TRIGGER=mmc2
|
||||
ERRORLINES=80
|
2
src/info-pine64-pinetab.sh
Normal file
2
src/info-pine64-pinetab.sh
Normal file
@ -0,0 +1,2 @@
|
||||
PLATFORM=pine64-pinetab
|
||||
EMMC=/dev/mmcblk2
|
16
src/pine64-pinetab.txt
Normal file
16
src/pine64-pinetab.txt
Normal file
@ -0,0 +1,16 @@
|
||||
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-pinetab.dtb; 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};
|
||||
fi;
|
||||
fi;
|
||||
fi
|
Loading…
Reference in New Issue
Block a user